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
Boxiang Sun
gitlab-ce
Commits
3702c4ad
Commit
3702c4ad
authored
Feb 24, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Render go-import meta tag for private repos.
parent
d513ca58
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
7 deletions
+32
-7
app/controllers/projects_controller.rb
app/controllers/projects_controller.rb
+11
-0
app/views/layouts/_head.html.haml
app/views/layouts/_head.html.haml
+0
-7
app/views/projects/go_import.html.haml
app/views/projects/go_import.html.haml
+5
-0
spec/controllers/projects_controller_spec.rb
spec/controllers/projects_controller_spec.rb
+16
-0
No files found.
app/controllers/projects_controller.rb
View file @
3702c4ad
class
ProjectsController
<
ApplicationController
prepend_before_filter
:render_go_import
,
only:
[
:show
]
skip_before_filter
:authenticate_user!
,
only:
[
:show
]
before_filter
:project
,
except:
[
:new
,
:create
]
before_filter
:repository
,
except:
[
:new
,
:create
]
...
...
@@ -184,4 +185,14 @@ class ProjectsController < ApplicationController
end
end
end
def
render_go_import
return
unless
params
[
"go-get"
]
==
"1"
@namespace
=
params
[
:namespace_id
]
@id
=
params
[
:project_id
]
||
params
[
:id
]
@id
=
@id
.
gsub
(
/\.git\Z/
,
""
)
render
"go_import"
,
layout:
false
end
end
app/views/layouts/_head.html.haml
View file @
3702c4ad
%head
%meta
{
charset:
"utf-8"
}
-# Go repository retrieval support
-# Need to be the fist thing in the head
-# Since Go is using an XML parser to process HTML5
-# https://github.com/gitlabhq/gitlabhq/pull/5958#issuecomment-45397555
-
if
controller_name
==
'projects'
&&
action_name
==
'show'
%meta
{
name:
"go-import"
,
content:
"#{@project.web_url_without_protocol} git #{@project.web_url}.git"
}
%meta
{
content:
"GitLab Community Edition"
,
name:
"description"
}
%title
...
...
app/views/projects/go_import.html.haml
0 → 100644
View file @
3702c4ad
!!! 5
%html
%head
-
web_url
=
[
Gitlab
.
config
.
gitlab
.
url
,
@namespace
,
@id
].
join
(
'/'
)
%meta
{
name:
"go-import"
,
content:
"#{web_url.split('://')[1]} git #{web_url}.git"
}
spec/controllers/projects_controller_spec.rb
View file @
3702c4ad
...
...
@@ -7,6 +7,22 @@ describe ProjectsController do
let
(
:jpg
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/rails_sample.jpg'
,
'image/jpg'
)
}
let
(
:txt
)
{
fixture_file_upload
(
Rails
.
root
+
'spec/fixtures/doc_sample.txt'
,
'text/plain'
)
}
describe
"GET show"
do
context
"when requested by `go get`"
do
render_views
it
"renders the go-import meta tag"
do
get
:show
,
"go-get"
=>
"1"
,
namespace_id:
"bogus_namespace"
,
id:
"bogus_project"
expect
(
response
.
body
).
to
include
(
"name='go-import'"
)
content
=
"localhost/bogus_namespace/bogus_project git http://localhost/bogus_namespace/bogus_project.git"
expect
(
response
.
body
).
to
include
(
"content='
#{
content
}
'"
)
end
end
end
describe
"POST #toggle_star"
do
it
"toggles star if user is signed in"
do
sign_in
(
user
)
...
...
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