Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
iv
gitlab-ce
Commits
c1ccc3a5
Commit
c1ccc3a5
authored
Mar 28, 2014
by
Loic Nageleisen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added ability to serve files in wiki repository
From #6168.
parent
ab094e67
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
3 deletions
+44
-3
app/controllers/projects/wikis_controller.rb
app/controllers/projects/wikis_controller.rb
+1
-3
app/models/project_wiki.rb
app/models/project_wiki.rb
+9
-0
spec/models/project_wiki_spec.rb
spec/models/project_wiki_spec.rb
+34
-0
No files found.
app/controllers/projects/wikis_controller.rb
View file @
c1ccc3a5
...
@@ -12,12 +12,10 @@ class Projects::WikisController < Projects::ApplicationController
...
@@ -12,12 +12,10 @@ class Projects::WikisController < Projects::ApplicationController
def
show
def
show
@page
=
@project_wiki
.
find_page
(
params
[
:id
],
params
[
:version_id
])
@page
=
@project_wiki
.
find_page
(
params
[
:id
],
params
[
:version_id
])
gollum_wiki
=
@project_wiki
.
wiki
file
=
gollum_wiki
.
file
(
params
[
:id
],
gollum_wiki
.
ref
,
true
)
if
@page
if
@page
render
'show'
render
'show'
elsif
file
elsif
file
=
@project_wiki
.
find_file
(
params
[
:id
],
params
[
:version_id
])
if
file
.
on_disk?
if
file
.
on_disk?
send_file
file
.
on_disk_path
,
disposition:
'inline'
send_file
file
.
on_disk_path
,
disposition:
'inline'
else
else
...
...
app/models/project_wiki.rb
View file @
c1ccc3a5
...
@@ -72,6 +72,15 @@ class ProjectWiki
...
@@ -72,6 +72,15 @@ class ProjectWiki
end
end
end
end
def
find_file
(
name
,
version
=
nil
,
try_on_disk
=
true
)
version
=
wiki
.
ref
if
version
.
nil?
# Gollum::Wiki#file ?
if
wiki_file
=
wiki
.
file
(
name
,
version
,
try_on_disk
)
wiki_file
else
nil
end
end
def
create_page
(
title
,
content
,
format
=
:markdown
,
message
=
nil
)
def
create_page
(
title
,
content
,
format
=
:markdown
,
message
=
nil
)
commit
=
commit_details
(
:created
,
message
,
title
)
commit
=
commit_details
(
:created
,
message
,
title
)
...
...
spec/models/project_wiki_spec.rb
View file @
c1ccc3a5
...
@@ -149,6 +149,40 @@ describe ProjectWiki do
...
@@ -149,6 +149,40 @@ describe ProjectWiki do
end
end
end
end
describe
'#find_file'
do
before
do
file
=
Gollum
::
File
.
new
(
subject
.
wiki
)
Gollum
::
Wiki
.
any_instance
.
stub
(
:file
).
with
(
'image.jpg'
,
'master'
,
true
).
and_return
(
file
)
Gollum
::
File
.
any_instance
.
stub
(
:mime_type
).
and_return
(
'image/jpeg'
)
Gollum
::
Wiki
.
any_instance
.
stub
(
:file
).
with
(
'non-existant'
,
'master'
,
true
).
and_return
(
nil
)
end
after
do
Gollum
::
Wiki
.
any_instance
.
unstub
(
:file
)
Gollum
::
File
.
any_instance
.
unstub
(
:mime_type
)
end
it
'returns the latest version of the file if it exists'
do
file
=
subject
.
find_file
(
'image.jpg'
)
file
.
mime_type
.
should
==
'image/jpeg'
end
it
'returns nil if the page does not exist'
do
subject
.
find_file
(
'non-existant'
).
should
==
nil
end
it
'returns a Gollum::File instance'
do
file
=
subject
.
find_file
(
'image.jpg'
)
file
.
should
be_a
Gollum
::
File
end
end
describe
"#create_page"
do
describe
"#create_page"
do
after
do
after
do
destroy_page
(
subject
.
pages
.
first
.
page
)
destroy_page
(
subject
.
pages
.
first
.
page
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment