BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
121c5f66
Commit
121c5f66
authored
Apr 13, 2017
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add JSON endpoint to get simple blob viewer
parent
ee17c659
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
renders_blob.rb
app/controllers/concerns/renders_blob.rb
+17
-0
blob_controller.rb
app/controllers/projects/blob_controller.rb
+11
-0
No files found.
app/controllers/concerns/renders_blob.rb
0 → 100644
View file @
121c5f66
module
RendersBlob
extend
ActiveSupport
::
Concern
def
render_blob_json
(
blob
)
viewer
=
if
params
[
:viewer
]
==
'rich'
blob
.
rich_viewer
else
blob
.
simple_viewer
end
return
render_404
unless
viewer
render
json:
{
html:
view_to_html_string
(
"projects/blob/_viewer"
,
viewer:
viewer
)
}
end
end
app/controllers/projects/blob_controller.rb
View file @
121c5f66
...
...
@@ -2,6 +2,7 @@
class
Projects
::
BlobController
<
Projects
::
ApplicationController
include
ExtractsPath
include
CreatesCommit
include
RendersBlob
include
ActionView
::
Helpers
::
SanitizeHelper
# Raised when given an invalid file path
...
...
@@ -34,8 +35,18 @@ class Projects::BlobController < Projects::ApplicationController
end
def
show
respond_to
do
|
format
|
format
.
html
do
environment_params
=
@repository
.
branch_exists?
(
@ref
)
?
{
ref:
@ref
}
:
{
commit:
@commit
}
@environment
=
EnvironmentsFinder
.
new
(
@project
,
current_user
,
environment_params
).
execute
.
last
render
'show'
end
format
.
json
do
render_blob_json
(
@blob
)
end
end
end
def
edit
...
...
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