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
Tatuya Kamada
gitlab-ce
Commits
22055e10
Commit
22055e10
authored
Apr 01, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix a few edited references from WikiLinkFilter and specs
parent
61fe0a23
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
6 deletions
+12
-6
lib/banzai/filter/wiki_link_filter.rb
lib/banzai/filter/wiki_link_filter.rb
+6
-2
spec/features/markdown_spec.rb
spec/features/markdown_spec.rb
+1
-0
spec/support/matchers/markdown_matchers.rb
spec/support/matchers/markdown_matchers.rb
+5
-4
No files found.
lib/banzai/filter/wiki_link_filter.rb
View file @
22055e10
...
@@ -25,10 +25,10 @@ module Banzai
...
@@ -25,10 +25,10 @@ module Banzai
end
end
def
process_link_attr
(
html_attr
)
def
process_link_attr
(
html_attr
)
return
if
html_attr
.
blank?
return
if
html_attr
.
blank?
||
file_reference?
(
html_attr
)
uri
=
URI
(
html_attr
.
value
)
uri
=
URI
(
html_attr
.
value
)
if
uri
.
relative?
&&
uri
.
path
.
present?
&&
uri
.
path
if
uri
.
relative?
&&
uri
.
path
.
present?
html_attr
.
value
=
rebuild_wiki_uri
(
uri
).
to_s
html_attr
.
value
=
rebuild_wiki_uri
(
uri
).
to_s
end
end
rescue
URI
::
Error
rescue
URI
::
Error
...
@@ -40,6 +40,10 @@ module Banzai
...
@@ -40,6 +40,10 @@ module Banzai
uri
uri
end
end
def
file_reference?
(
html_attr
)
!
File
.
extname
(
html_attr
.
value
).
blank?
end
def
project_wiki
def
project_wiki
context
[
:project_wiki
]
context
[
:project_wiki
]
end
end
...
...
spec/features/markdown_spec.rb
View file @
22055e10
...
@@ -230,6 +230,7 @@ describe 'GitLab Markdown', feature: true do
...
@@ -230,6 +230,7 @@ describe 'GitLab Markdown', feature: true do
file
=
Gollum
::
File
.
new
(
@project_wiki
.
wiki
)
file
=
Gollum
::
File
.
new
(
@project_wiki
.
wiki
)
expect
(
file
).
to
receive
(
:path
).
and_return
(
'images/example.jpg'
)
expect
(
file
).
to
receive
(
:path
).
and_return
(
'images/example.jpg'
)
expect
(
@project_wiki
).
to
receive
(
:find_file
).
with
(
'images/example.jpg'
).
and_return
(
file
)
expect
(
@project_wiki
).
to
receive
(
:find_file
).
with
(
'images/example.jpg'
).
and_return
(
file
)
allow
(
@project_wiki
).
to
receive
(
:wiki_base_path
)
{
'/namespace1/gitlabhq/wikis'
}
@html
=
markdown
(
@feat
.
raw_markdown
,
{
pipeline: :wiki
,
project_wiki:
@project_wiki
})
@html
=
markdown
(
@feat
.
raw_markdown
,
{
pipeline: :wiki
,
project_wiki:
@project_wiki
})
end
end
...
...
spec/support/matchers/markdown_matchers.rb
View file @
22055e10
...
@@ -13,7 +13,7 @@ module MarkdownMatchers
...
@@ -13,7 +13,7 @@ module MarkdownMatchers
set_default_markdown_messages
set_default_markdown_messages
match
do
|
actual
|
match
do
|
actual
|
link
=
actual
.
at_css
(
'a:contains("Relative Link")'
)
link
=
actual
.
at_css
(
'a:contains("Relative Link")'
)
image
=
actual
.
at_css
(
'img[alt="Relative Image"]'
)
image
=
actual
.
at_css
(
'img[alt="Relative Image"]'
)
expect
(
link
[
'href'
]).
to
end_with
(
'master/doc/README.md'
)
expect
(
link
[
'href'
]).
to
end_with
(
'master/doc/README.md'
)
...
@@ -72,14 +72,15 @@ module MarkdownMatchers
...
@@ -72,14 +72,15 @@ module MarkdownMatchers
have_css
(
"img[src$='
#{
src
}
']"
)
have_css
(
"img[src$='
#{
src
}
']"
)
end
end
prefix
=
'/namespace1/gitlabhq/wikis'
set_default_markdown_messages
set_default_markdown_messages
match
do
|
actual
|
match
do
|
actual
|
expect
(
actual
).
to
have_link
(
'linked-resource'
,
href:
'linked-resource'
)
expect
(
actual
).
to
have_link
(
'linked-resource'
,
href:
"
#{
prefix
}
/linked-resource"
)
expect
(
actual
).
to
have_link
(
'link-text'
,
href:
'linked-resource'
)
expect
(
actual
).
to
have_link
(
'link-text'
,
href:
"
#{
prefix
}
/linked-resource"
)
expect
(
actual
).
to
have_link
(
'http://example.com'
,
href:
'http://example.com'
)
expect
(
actual
).
to
have_link
(
'http://example.com'
,
href:
'http://example.com'
)
expect
(
actual
).
to
have_link
(
'link-text'
,
href:
'http://example.com/pdfs/gollum.pdf'
)
expect
(
actual
).
to
have_link
(
'link-text'
,
href:
'http://example.com/pdfs/gollum.pdf'
)
expect
(
actual
).
to
have_image
(
'/gitlabhq/wikis/images/example.jpg'
)
expect
(
actual
).
to
have_image
(
"
#{
prefix
}
/images/example.jpg"
)
expect
(
actual
).
to
have_image
(
'http://example.com/images/example.jpg'
)
expect
(
actual
).
to
have_image
(
'http://example.com/images/example.jpg'
)
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