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
iv
gitlab-ce
Commits
bd2ca33d
Commit
bd2ca33d
authored
Nov 12, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'relative' of /home/git/repositories/gitlab/gitlabhq
parents
99334d4b
4e9284a0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
4 deletions
+21
-4
app/helpers/gitlab_markdown_helper.rb
app/helpers/gitlab_markdown_helper.rb
+10
-3
lib/redcarpet/render/gitlab_html.rb
lib/redcarpet/render/gitlab_html.rb
+1
-1
spec/factories.rb
spec/factories.rb
+1
-0
spec/support/test_env.rb
spec/support/test_env.rb
+9
-0
No files found.
app/helpers/gitlab_markdown_helper.rb
View file @
bd2ca33d
...
...
@@ -64,7 +64,9 @@ module GitlabMarkdownHelper
# ref - name of the branch or reference, eg. stable
# requested_path - path of request, eg. doc/api/README.md, used in special case when path is pointing to the .md file were the original request is coming from
# wiki - whether the markdown is from wiki or not
def
create_relative_links
(
text
,
project_path_with_namespace
,
ref
,
requested_path
,
wiki
=
false
)
def
create_relative_links
(
text
,
project
,
ref
,
requested_path
,
wiki
=
false
)
@path_to_satellite
=
project
.
satellite
.
path
project_path_with_namespace
=
project
.
path_with_namespace
paths
=
extract_paths
(
text
)
paths
.
each
do
|
file_path
|
new_path
=
rebuild_path
(
project_path_with_namespace
,
file_path
,
requested_path
,
ref
)
...
...
@@ -145,13 +147,18 @@ module GitlabMarkdownHelper
def
file_exists?
(
path
)
return
false
if
path
.
nil?
||
path
.
empty?
File
.
exists?
(
Rails
.
root
.
join
(
path
))
File
.
exists?
(
path_on_fs
(
path
))
end
# Check if the path is pointing to a directory(tree) or a file(blob)
# eg. doc/api is directory and doc/README.md is file
def
local_path
(
path
)
File
.
directory?
(
Rails
.
root
.
join
(
path
))
?
"tree"
:
"blob"
File
.
directory?
(
path_on_fs
(
path
))
?
"tree"
:
"blob"
end
# Path to the file in the satellites repository on the filesystem
def
path_on_fs
(
path
)
[
@path_to_satellite
,
path
].
join
(
"/"
)
end
# We will assume that if no ref exists we can point to master
...
...
lib/redcarpet/render/gitlab_html.rb
View file @
bd2ca33d
...
...
@@ -36,7 +36,7 @@ class Redcarpet::Render::GitlabHTML < Redcarpet::Render::HTML
def
preprocess
(
full_document
)
if
@project
h
.
create_relative_links
(
full_document
,
@project
.
path_with_namespace
,
@ref
,
@request_path
,
is_wiki?
)
h
.
create_relative_links
(
full_document
,
@project
,
@ref
,
@request_path
,
is_wiki?
)
else
full_document
end
...
...
spec/factories.rb
View file @
bd2ca33d
...
...
@@ -66,6 +66,7 @@ FactoryGirl.define do
after
:create
do
|
project
|
TestEnv
.
clear_repo_dir
(
project
.
namespace
,
project
.
path
)
TestEnv
.
reset_satellite_dir
TestEnv
.
create_repo
(
project
.
namespace
,
project
.
path
)
end
end
...
...
spec/support/test_env.rb
View file @
bd2ca33d
...
...
@@ -97,6 +97,15 @@ module TestEnv
FileUtils
.
rm_rf
File
.
join
(
testing_path
(),
"
#{
name
}
.wiki.git"
)
end
def
reset_satellite_dir
setup_stubs
FileUtils
.
cd
(
seed_satellite_path
)
do
`git reset --hard --quiet`
`git clean -fx`
`git checkout --quiet origin/master`
end
end
# Create a repo and it's satellite
def
create_repo
(
namespace
,
name
)
setup_stubs
...
...
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