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
5117bf6f
Commit
5117bf6f
authored
Jun 11, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:gitlabhq/gitlabhq
parents
44730133
f881e436
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
117 additions
and
85 deletions
+117
-85
project_users_select.js.coffee
app/assets/javascripts/project_users_select.js.coffee
+1
-1
users_select.js.coffee
app/assets/javascripts/users_select.js.coffee
+1
-1
application_helper.rb
app/helpers/application_helper.rb
+1
-1
gitlab_markdown_helper.rb
app/helpers/gitlab_markdown_helper.rb
+1
-1
issues_helper.rb
app/helpers/issues_helper.rb
+43
-39
_commit.html.haml
app/views/events/_commit.html.haml
+1
-1
_show.html.haml
app/views/projects/merge_requests/_show.html.haml
+2
-2
markdown.rb
lib/gitlab/markdown.rb
+62
-35
reference_extractor.rb
lib/gitlab/reference_extractor.rb
+1
-1
application_helper_spec.rb
spec/helpers/application_helper_spec.rb
+2
-2
gitlab_markdown_helper_spec.rb
spec/helpers/gitlab_markdown_helper_spec.rb
+2
-1
No files found.
app/assets/javascripts/project_users_select.js.coffee
View file @
5117bf6f
...
...
@@ -43,7 +43,7 @@
avatar
=
avatar
.
replace
(
'%{hash}'
,
md5
(
user
.
email
))
avatar
=
avatar
.
replace
(
'%{size}'
,
'24'
)
else
avatar
=
gon
.
relative_url_root
+
"
/assets/no_avatar.png
"
avatar
=
gon
.
relative_url_root
+
"
#{
image_path
(
'no_avatar.png'
)
}
"
if
user
.
id
==
''
avatarMarkup
=
''
...
...
app/assets/javascripts/users_select.js.coffee
View file @
5117bf6f
...
...
@@ -7,7 +7,7 @@ $ ->
avatar
=
avatar
.
replace
(
'%{hash}'
,
md5
(
user
.
email
))
avatar
=
avatar
.
replace
(
'%{size}'
,
'24'
)
else
avatar
=
gon
.
relative_url_root
+
"
/assets/no_avatar.png
"
avatar
=
gon
.
relative_url_root
+
"
#{
image_path
(
'no_avatar.png'
)
}
"
"<div class='user-result'>
<div class='user-image'><img class='avatar s24' src='
#{
avatar
}
'></div>
...
...
app/helpers/application_helper.rb
View file @
5117bf6f
...
...
@@ -71,7 +71,7 @@ module ApplicationHelper
size
=
40
if
size
.
nil?
||
size
<=
0
if
!
Gitlab
.
config
.
gravatar
.
enabled
||
user_email
.
blank?
'/assets/no_avatar.png'
image_path
(
'no_avatar.png'
)
else
gravatar_url
=
request
.
ssl?
||
gitlab_config
.
https
?
Gitlab
.
config
.
gravatar
.
ssl_url
:
Gitlab
.
config
.
gravatar
.
plain_url
user_email
.
strip!
...
...
app/helpers/gitlab_markdown_helper.rb
View file @
5117bf6f
...
...
@@ -19,7 +19,7 @@ module GitlabMarkdownHelper
escape_once
(
body
)
end
gfm_body
=
gfm
(
escaped_body
,
html_options
)
gfm_body
=
gfm
(
escaped_body
,
@project
,
html_options
)
gfm_body
.
gsub!
(
%r{<a.*?>.*?</a>}m
)
do
|
match
|
"</a>
#{
match
}#{
link_to
(
""
,
url
,
html_options
)[
0
..-
5
]
}
"
# "</a>".length +1
...
...
app/helpers/issues_helper.rb
View file @
5117bf6f
...
...
@@ -13,76 +13,80 @@ module IssuesHelper
OpenStruct
.
new
(
id:
0
,
title:
'None (backlog)'
,
name:
'Unassigned'
)
end
def
url_for_project_issues
return
""
if
@
project
.
nil?
def
url_for_project_issues
(
project
=
@project
)
return
''
if
project
.
nil?
if
@
project
.
used_default_issues_tracker?
||
!
external_issues_tracker_enabled?
project_issues_path
(
@
project
)
if
project
.
used_default_issues_tracker?
||
!
external_issues_tracker_enabled?
project_issues_path
(
project
)
else
url
=
Gitlab
.
config
.
issues_tracker
[
@project
.
issues_tracker
][
"project_url"
]
url
.
gsub
(
':project_id'
,
@project
.
id
.
to_s
)
.
gsub
(
':issues_tracker_id'
,
@
project
.
issues_tracker_id
.
to_s
)
url
=
Gitlab
.
config
.
issues_tracker
[
project
.
issues_tracker
][
'project_url'
]
url
.
gsub
(
':project_id'
,
project
.
id
.
to_s
).
gsub
(
':issues_tracker_id'
,
project
.
issues_tracker_id
.
to_s
)
end
end
def
url_for_new_issue
return
""
if
@
project
.
nil?
def
url_for_new_issue
(
project
=
@project
)
return
''
if
project
.
nil?
if
@
project
.
used_default_issues_tracker?
||
!
external_issues_tracker_enabled?
url
=
new_project_issue_path
project_id:
@
project
if
project
.
used_default_issues_tracker?
||
!
external_issues_tracker_enabled?
url
=
new_project_issue_path
project_id:
project
else
url
=
Gitlab
.
config
.
issues_tracker
[
@project
.
issues_tracker
][
"new_issue_url"
]
url
.
gsub
(
':project_id'
,
@project
.
id
.
to_s
)
.
gsub
(
':issues_tracker_id'
,
@project
.
issues_tracker_id
.
to_s
)
issues_tracker
=
Gitlab
.
config
.
issues_tracker
[
project
.
issues_tracker
]
url
=
issues_tracker
[
'new_issue_url'
]
url
.
gsub
(
':project_id'
,
project
.
id
.
to_s
).
gsub
(
':issues_tracker_id'
,
project
.
issues_tracker_id
.
to_s
)
end
end
def
url_for_issue
(
issue_iid
)
return
""
if
@
project
.
nil?
def
url_for_issue
(
issue_iid
,
project
=
@project
)
return
''
if
project
.
nil?
if
@
project
.
used_default_issues_tracker?
||
!
external_issues_tracker_enabled?
url
=
project_issue_url
project_id:
@
project
,
id:
issue_iid
if
project
.
used_default_issues_tracker?
||
!
external_issues_tracker_enabled?
url
=
project_issue_url
project_id:
project
,
id:
issue_iid
else
url
=
Gitlab
.
config
.
issues_tracker
[
@project
.
issues_tracker
][
"issues_url"
]
url
.
gsub
(
':id'
,
issue_iid
.
to_s
)
.
gsub
(
':project_id'
,
@project
.
id
.
to_s
)
.
gsub
(
':issues_tracker_id'
,
@
project
.
issues_tracker_id
.
to_s
)
url
=
Gitlab
.
config
.
issues_tracker
[
project
.
issues_tracker
][
'issues_url'
]
url
.
gsub
(
':id'
,
issue_iid
.
to_s
)
.
gsub
(
':project_id'
,
project
.
id
.
to_s
).
gsub
(
':issues_tracker_id'
,
project
.
issues_tracker_id
.
to_s
)
end
end
def
title_for_issue
(
issue_iid
)
return
""
if
@
project
.
nil?
def
title_for_issue
(
issue_iid
,
project
=
@project
)
return
''
if
project
.
nil?
if
@project
.
used_default_issues_tracker?
&&
issue
=
@project
.
issues
.
where
(
iid:
issue_iid
).
first
issue
.
title
else
""
if
project
.
used_default_issues_tracker?
issue
=
project
.
issues
.
where
(
iid:
issue_iid
).
first
return
issue
.
title
if
issue
end
''
end
# Checks if issues_tracker setting exists in gitlab.yml
def
external_issues_tracker_enabled?
if
Gitlab
.
config
.
issues_tracker
&&
Gitlab
.
config
.
issues_tracker
.
values
.
any?
true
else
false
end
Gitlab
.
config
.
issues_tracker
&&
Gitlab
.
config
.
issues_tracker
.
values
.
any?
end
def
bulk_update_milestone_options
options_for_select
([
"None (backlog)"
])
+
options_from_collection_for_select
(
project_active_milestones
,
"id"
,
"title"
,
params
[
:milestone_id
])
options_for_select
([
'None (backlog)'
])
+
options_from_collection_for_select
(
project_active_milestones
,
'id'
,
'title'
,
params
[
:milestone_id
])
end
def
bulk_update_assignee_options
options_for_select
([
"None (unassigned)"
])
+
options_from_collection_for_select
(
@project
.
team
.
members
,
"id"
,
"name"
,
params
[
:assignee_id
])
def
bulk_update_assignee_options
(
project
=
@project
)
options_for_select
([
'None (unassigned)'
])
+
options_from_collection_for_select
(
project
.
team
.
members
,
'id'
,
'name'
,
params
[
:assignee_id
])
end
def
assignee_options
object
options_from_collection_for_select
(
@project
.
team
.
members
.
sort_by
(
&
:name
),
'id'
,
'name'
,
object
.
assignee_id
)
def
assignee_options
(
object
,
project
=
@project
)
options_from_collection_for_select
(
project
.
team
.
members
.
sort_by
(
&
:name
),
'id'
,
'name'
,
object
.
assignee_id
)
end
def
milestone_options
object
options_from_collection_for_select
(
object
.
project
.
milestones
.
active
,
'id'
,
'title'
,
object
.
milestone_id
)
options_from_collection_for_select
(
object
.
project
.
milestones
.
active
,
'id'
,
'title'
,
object
.
milestone_id
)
end
def
issue_box_class
(
item
)
...
...
app/views/events/_commit.html.haml
View file @
5117bf6f
...
...
@@ -2,4 +2,4 @@
.commit-row-title
=
link_to
commit
[
:id
][
0
..
8
],
project_commit_path
(
project
,
commit
[
:id
]),
class:
"commit_short_id"
,
alt:
''
=
gfm
event_commit_title
(
commit
[
:message
])
=
gfm
event_commit_title
(
commit
[
:message
])
,
project
app/views/projects/merge_requests/_show.html.haml
View file @
5117bf6f
...
...
@@ -26,11 +26,11 @@
-
if
@merge_request
.
closed?
=
link_to
'Reopen'
,
project_merge_request_path
(
@project
,
@merge_request
,
merge_request:
{
state_event: :reopen
}),
method: :put
,
class:
"btn btn-grouped btn-reopen reopen-mr-link"
,
title:
"Close merge request"
.notes.tab-content.voting_notes
#notes
{
class:
(
controller
.
action_name
==
'show'
)
?
""
:
"hide"
}
=
render
"projects/notes/notes_with_form"
.diffs.tab-content
-
if
current_page?
(
action:
'diffs'
)
=
render
"projects/merge_requests/show/diffs"
.notes.tab-content.voting_notes
#notes
{
class:
(
controller
.
action_name
==
'show'
)
?
""
:
"hide"
}
=
render
"projects/notes/notes_with_form"
.status
:javascript
...
...
lib/gitlab/markdown.rb
View file @
5117bf6f
...
...
@@ -33,10 +33,9 @@ module Gitlab
# Public: Parse the provided text with GitLab-Flavored Markdown
#
# text - the source text
# project - extra options for the reference links as given to link_to
# html_options - extra options for the reference links as given to link_to
#
# Note: reference links will only be generated if @project is set
def
gfm
(
text
,
html_options
=
{})
def
gfm
(
text
,
project
=
@project
,
html_options
=
{})
return
text
if
text
.
nil?
# Duplicate the string so we don't alter the original, then call to_str
...
...
@@ -56,14 +55,19 @@ module Gitlab
# TODO: add popups with additional information
text
=
parse
(
text
)
text
=
parse
(
text
,
project
)
# Insert pre block extractions
text
.
gsub!
(
/\{gfm-extraction-(\h{32})\}/
)
do
insert_piece
(
$1
)
end
sanitize
text
.
html_safe
,
attributes:
ActionView
::
Base
.
sanitized_allowed_attributes
+
%w(id class)
,
tags:
ActionView
::
Base
.
sanitized_allowed_tags
+
%w(table tr td th)
allowed_attributes
=
ActionView
::
Base
.
sanitized_allowed_attributes
allowed_tags
=
ActionView
::
Base
.
sanitized_allowed_tags
sanitize
text
.
html_safe
,
attributes:
allowed_attributes
+
%w(id class)
,
tags:
allowed_tags
+
%w(table tr td th)
end
private
...
...
@@ -84,11 +88,9 @@ module Gitlab
#
# text - Text to parse
#
# Note: reference links will only be generated if @project is set
#
# Returns parsed text
def
parse
(
text
)
parse_references
(
text
)
if
@
project
def
parse
(
text
,
project
=
@project
)
parse_references
(
text
,
project
)
if
project
parse_emoji
(
text
)
text
...
...
@@ -110,7 +112,7 @@ module Gitlab
TYPES
=
[
:user
,
:issue
,
:merge_request
,
:snippet
,
:commit
].
freeze
def
parse_references
(
text
)
def
parse_references
(
text
,
project
=
@project
)
# parse reference links
text
.
gsub!
(
REFERENCE_PATTERN
)
do
|
match
|
prefix
=
$~
[
:prefix
]
...
...
@@ -123,7 +125,7 @@ module Gitlab
# Avoid HTML entities
if
prefix
&&
suffix
&&
prefix
[
0
]
==
'&'
&&
suffix
[
-
1
]
==
';'
match
elsif
ref_link
=
reference_link
(
type
,
identifier
)
elsif
ref_link
=
reference_link
(
type
,
identifier
,
project
)
"
#{
prefix
}#{
ref_link
}#{
suffix
}
"
else
match
...
...
@@ -153,7 +155,7 @@ module Gitlab
#
# Returns boolean
def
valid_emoji?
(
emoji
)
Emoji
.
find_by_name
emoji
Emoji
.
find_by_name
(
emoji
)
end
# Private: Dispatches to a dedicated processing method based on reference
...
...
@@ -162,52 +164,77 @@ module Gitlab
# identifier - Object identifier (Issue ID, SHA hash, etc.)
#
# Returns string rendered by the processing method
def
reference_link
(
type
,
identifier
)
send
(
"reference_
#{
type
}
"
,
identifier
)
def
reference_link
(
type
,
identifier
,
project
=
@project
)
send
(
"reference_
#{
type
}
"
,
identifier
,
project
)
end
def
reference_user
(
identifier
)
if
user
=
User
.
find_by_username
(
identifier
)
link_to
(
"@
#{
identifier
}
"
,
user_url
(
identifier
),
html_options
.
merge
(
class:
"gfm gfm-team_member
#{
html_options
[
:class
]
}
"
))
def
reference_user
(
identifier
,
project
=
@project
)
if
user
=
User
.
find_by
(
username:
identifier
)
options
=
html_options
.
merge
(
class:
"gfm gfm-team_member
#{
html_options
[
:class
]
}
"
)
link_to
(
"@
#{
identifier
}
"
,
user_url
(
identifier
),
options
)
end
end
def
reference_issue
(
identifier
)
if
@
project
.
used_default_issues_tracker?
||
!
external_issues_tracker_enabled?
if
@
project
.
issue_exists?
identifier
url
=
url_for_issue
(
identifier
)
def
reference_issue
(
identifier
,
project
=
@project
)
if
project
.
used_default_issues_tracker?
||
!
external_issues_tracker_enabled?
if
project
.
issue_exists?
identifier
url
=
url_for_issue
(
identifier
,
project
)
title
=
title_for_issue
(
identifier
)
options
=
html_options
.
merge
(
title:
"Issue:
#{
title
}
"
,
class:
"gfm gfm-issue
#{
html_options
[
:class
]
}
"
)
link_to
(
"#
#{
identifier
}
"
,
url
,
html_options
.
merge
(
title:
"Issue:
#{
title
}
"
,
class:
"gfm gfm-issue
#{
html_options
[
:class
]
}
"
)
)
link_to
(
"#
#{
identifier
}
"
,
url
,
options
)
end
els
e
reference_jira_issue
(
identifier
)
if
@project
.
issues_tracker
==
"jira"
els
if
project
.
issues_tracker
==
'jira'
reference_jira_issue
(
identifier
,
project
)
end
end
def
reference_merge_request
(
identifier
)
if
merge_request
=
@project
.
merge_requests
.
where
(
iid:
identifier
).
first
link_to
(
"!
#{
identifier
}
"
,
project_merge_request_url
(
@project
,
merge_request
),
html_options
.
merge
(
title:
"Merge Request:
#{
merge_request
.
title
}
"
,
class:
"gfm gfm-merge_request
#{
html_options
[
:class
]
}
"
))
def
reference_merge_request
(
identifier
,
project
=
@project
)
if
merge_request
=
project
.
merge_requests
.
find_by
(
iid:
identifier
)
options
=
html_options
.
merge
(
title:
"Merge Request:
#{
merge_request
.
title
}
"
,
class:
"gfm gfm-merge_request
#{
html_options
[
:class
]
}
"
)
url
=
project_merge_request_url
(
project
,
merge_request
)
link_to
(
"!
#{
identifier
}
"
,
url
,
options
)
end
end
def
reference_snippet
(
identifier
)
if
snippet
=
@project
.
snippets
.
where
(
id:
identifier
).
first
link_to
(
"$
#{
identifier
}
"
,
project_snippet_url
(
@project
,
snippet
),
html_options
.
merge
(
title:
"Snippet:
#{
snippet
.
title
}
"
,
class:
"gfm gfm-snippet
#{
html_options
[
:class
]
}
"
))
def
reference_snippet
(
identifier
,
project
=
@project
)
if
snippet
=
project
.
snippets
.
find_by
(
id:
identifier
)
options
=
html_options
.
merge
(
title:
"Snippet:
#{
snippet
.
title
}
"
,
class:
"gfm gfm-snippet
#{
html_options
[
:class
]
}
"
)
link_to
(
"$
#{
identifier
}
"
,
project_snippet_url
(
project
,
snippet
),
options
)
end
end
def
reference_commit
(
identifier
)
if
@project
.
valid_repo?
&&
commit
=
@project
.
repository
.
commit
(
identifier
)
link_to
(
identifier
,
project_commit_url
(
@project
,
commit
),
html_options
.
merge
(
title:
commit
.
link_title
,
class:
"gfm gfm-commit
#{
html_options
[
:class
]
}
"
))
def
reference_commit
(
identifier
,
project
=
@project
)
if
project
.
valid_repo?
&&
commit
=
project
.
repository
.
commit
(
identifier
)
options
=
html_options
.
merge
(
title:
commit
.
link_title
,
class:
"gfm gfm-commit
#{
html_options
[
:class
]
}
"
)
link_to
(
identifier
,
project_commit_url
(
project
,
commit
),
options
)
end
end
def
reference_jira_issue
(
identifier
)
def
reference_jira_issue
(
identifier
,
project
=
@project
)
url
=
url_for_issue
(
identifier
)
title
=
Gitlab
.
config
.
issues_tracker
[
@project
.
issues_tracker
][
"title"
]
link_to
(
"
#{
identifier
}
"
,
url
,
html_options
.
merge
(
title:
"Issue in
#{
title
}
"
,
class:
"gfm gfm-issue
#{
html_options
[
:class
]
}
"
))
options
=
html_options
.
merge
(
title:
"Issue in
#{
title
}
"
,
class:
"gfm gfm-issue
#{
html_options
[
:class
]
}
"
)
link_to
(
"
#{
identifier
}
"
,
url
,
options
)
end
end
end
lib/gitlab/reference_extractor.rb
View file @
5117bf6f
...
...
@@ -51,7 +51,7 @@ module Gitlab
private
def
reference_link
type
,
identifier
def
reference_link
(
type
,
identifier
,
project
)
# Append identifier to the appropriate collection.
send
(
"
#{
type
}
s"
)
<<
identifier
end
...
...
spec/helpers/application_helper_spec.rb
View file @
5117bf6f
...
...
@@ -79,11 +79,11 @@ describe ApplicationHelper do
it
"should return a generic avatar path when Gravatar is disabled"
do
Gitlab
.
config
.
gravatar
.
stub
(
:enabled
).
and_return
(
false
)
gravatar_icon
(
user_email
).
should
==
'/assets/no_avatar.png'
gravatar_icon
(
user_email
).
should
match
(
'no_avatar.png'
)
end
it
"should return a generic avatar path when email is blank"
do
gravatar_icon
(
''
).
should
==
'/assets/no_avatar.png'
gravatar_icon
(
''
).
should
match
(
'no_avatar.png'
)
end
it
"should return default gravatar url"
do
...
...
spec/helpers/gitlab_markdown_helper_spec.rb
View file @
5117bf6f
...
...
@@ -41,7 +41,8 @@ describe GitlabMarkdownHelper do
end
it
"should forward HTML options to links"
do
gfm
(
"Fixed in
#{
commit
.
id
}
"
,
class:
"foo"
).
should
have_selector
(
"a.gfm.foo"
)
gfm
(
"Fixed in
#{
commit
.
id
}
"
,
@project
,
class:
'foo'
).
should
have_selector
(
'a.gfm.foo'
)
end
describe
"referencing a commit"
do
...
...
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