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
Jérome Perrin
gitlab-ce
Commits
7635afd0
Commit
7635afd0
authored
Jan 16, 2013
by
Riyad Preukschas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use Urls for references in GFM
parent
640d51f4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
7 deletions
+11
-7
lib/gitlab/markdown.rb
lib/gitlab/markdown.rb
+5
-5
spec/helpers/gitlab_markdown_helper_spec.rb
spec/helpers/gitlab_markdown_helper_spec.rb
+6
-2
No files found.
lib/gitlab/markdown.rb
View file @
7635afd0
...
@@ -147,31 +147,31 @@ module Gitlab
...
@@ -147,31 +147,31 @@ module Gitlab
def
reference_user
(
identifier
)
def
reference_user
(
identifier
)
if
member
=
@project
.
users_projects
.
joins
(
:user
).
where
(
users:
{
username:
identifier
}).
first
if
member
=
@project
.
users_projects
.
joins
(
:user
).
where
(
users:
{
username:
identifier
}).
first
link_to
(
"@
#{
identifier
}
"
,
project_team_member_
path
(
@project
,
member
),
html_options
.
merge
(
class:
"gfm gfm-team_member
#{
html_options
[
:class
]
}
"
))
if
member
link_to
(
"@
#{
identifier
}
"
,
project_team_member_
url
(
@project
,
member
),
html_options
.
merge
(
class:
"gfm gfm-team_member
#{
html_options
[
:class
]
}
"
))
if
member
end
end
end
end
def
reference_issue
(
identifier
)
def
reference_issue
(
identifier
)
if
issue
=
@project
.
issues
.
where
(
id:
identifier
).
first
if
issue
=
@project
.
issues
.
where
(
id:
identifier
).
first
link_to
(
"#
#{
identifier
}
"
,
project_issue_
path
(
@project
,
issue
),
html_options
.
merge
(
title:
"Issue:
#{
issue
.
title
}
"
,
class:
"gfm gfm-issue
#{
html_options
[
:class
]
}
"
))
link_to
(
"#
#{
identifier
}
"
,
project_issue_
url
(
@project
,
issue
),
html_options
.
merge
(
title:
"Issue:
#{
issue
.
title
}
"
,
class:
"gfm gfm-issue
#{
html_options
[
:class
]
}
"
))
end
end
end
end
def
reference_merge_request
(
identifier
)
def
reference_merge_request
(
identifier
)
if
merge_request
=
@project
.
merge_requests
.
where
(
id:
identifier
).
first
if
merge_request
=
@project
.
merge_requests
.
where
(
id:
identifier
).
first
link_to
(
"!
#{
identifier
}
"
,
project_merge_request_
path
(
@project
,
merge_request
),
html_options
.
merge
(
title:
"Merge Request:
#{
merge_request
.
title
}
"
,
class:
"gfm gfm-merge_request
#{
html_options
[
:class
]
}
"
))
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
]
}
"
))
end
end
end
end
def
reference_snippet
(
identifier
)
def
reference_snippet
(
identifier
)
if
snippet
=
@project
.
snippets
.
where
(
id:
identifier
).
first
if
snippet
=
@project
.
snippets
.
where
(
id:
identifier
).
first
link_to
(
"$
#{
identifier
}
"
,
project_snippet_
path
(
@project
,
snippet
),
html_options
.
merge
(
title:
"Snippet:
#{
snippet
.
title
}
"
,
class:
"gfm gfm-snippet
#{
html_options
[
:class
]
}
"
))
link_to
(
"$
#{
identifier
}
"
,
project_snippet_
url
(
@project
,
snippet
),
html_options
.
merge
(
title:
"Snippet:
#{
snippet
.
title
}
"
,
class:
"gfm gfm-snippet
#{
html_options
[
:class
]
}
"
))
end
end
end
end
def
reference_commit
(
identifier
)
def
reference_commit
(
identifier
)
if
@project
.
valid_repo?
&&
commit
=
@project
.
repository
.
commit
(
identifier
)
if
@project
.
valid_repo?
&&
commit
=
@project
.
repository
.
commit
(
identifier
)
link_to
(
identifier
,
project_commit_
path
(
@project
,
commit
),
html_options
.
merge
(
title:
CommitDecorator
.
new
(
commit
).
link_title
,
class:
"gfm gfm-commit
#{
html_options
[
:class
]
}
"
))
link_to
(
identifier
,
project_commit_
url
(
@project
,
commit
),
html_options
.
merge
(
title:
CommitDecorator
.
new
(
commit
).
link_title
,
class:
"gfm gfm-commit
#{
html_options
[
:class
]
}
"
))
end
end
end
end
end
end
...
...
spec/helpers/gitlab_markdown_helper_spec.rb
View file @
7635afd0
...
@@ -272,7 +272,7 @@ describe GitlabMarkdownHelper do
...
@@ -272,7 +272,7 @@ describe GitlabMarkdownHelper do
groups
[
0
].
should
match
(
/This should finally fix $/
)
groups
[
0
].
should
match
(
/This should finally fix $/
)
# First issue link
# First issue link
groups
[
1
].
should
match
(
/href="
#{
project_issue_
path
(
project
,
issues
[
0
])
}
"/
)
groups
[
1
].
should
match
(
/href="
#{
project_issue_
url
(
project
,
issues
[
0
])
}
"/
)
groups
[
1
].
should
match
(
/#
#{
issues
[
0
].
id
}
$/
)
groups
[
1
].
should
match
(
/#
#{
issues
[
0
].
id
}
$/
)
# Internal commit link
# Internal commit link
...
@@ -280,7 +280,7 @@ describe GitlabMarkdownHelper do
...
@@ -280,7 +280,7 @@ describe GitlabMarkdownHelper do
groups
[
2
].
should
match
(
/ and /
)
groups
[
2
].
should
match
(
/ and /
)
# Second issue link
# Second issue link
groups
[
3
].
should
match
(
/href="
#{
project_issue_
path
(
project
,
issues
[
1
])
}
"/
)
groups
[
3
].
should
match
(
/href="
#{
project_issue_
url
(
project
,
issues
[
1
])
}
"/
)
groups
[
3
].
should
match
(
/#
#{
issues
[
1
].
id
}
$/
)
groups
[
3
].
should
match
(
/#
#{
issues
[
1
].
id
}
$/
)
# Trailing commit link
# Trailing commit link
...
@@ -339,5 +339,9 @@ describe GitlabMarkdownHelper do
...
@@ -339,5 +339,9 @@ describe GitlabMarkdownHelper do
it
"should leave inline code untouched"
do
it
"should leave inline code untouched"
do
markdown
(
"
\n
Don't use `$
#{
snippet
.
id
}
` here.
\n
"
).
should
==
"<p>Don't use <code>$
#{
snippet
.
id
}
</code> here.</p>
\n
"
markdown
(
"
\n
Don't use `$
#{
snippet
.
id
}
` here.
\n
"
).
should
==
"<p>Don't use <code>$
#{
snippet
.
id
}
</code> here.</p>
\n
"
end
end
it
"should generate absolute urls for refs"
do
markdown
(
"#
#{
issue
.
id
}
"
).
should
include
(
project_issue_url
(
project
,
issue
))
end
end
end
end
end
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