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
21297e78
Commit
21297e78
authored
9 years ago
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor blob helpers
parent
e07da598
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
39 deletions
+43
-39
app/helpers/blob_helper.rb
app/helpers/blob_helper.rb
+38
-0
app/helpers/projects_helper.rb
app/helpers/projects_helper.rb
+5
-1
app/helpers/tree_helper.rb
app/helpers/tree_helper.rb
+0
-38
No files found.
app/helpers/blob_helper.rb
View file @
21297e78
...
@@ -19,4 +19,42 @@ module BlobHelper
...
@@ -19,4 +19,42 @@ module BlobHelper
def
no_highlight_files
def
no_highlight_files
%w(credits changelog copying copyright license authors)
%w(credits changelog copying copyright license authors)
end
end
def
edit_blob_link
(
project
,
ref
,
path
,
options
=
{})
blob
=
begin
project
.
repository
.
blob_at
(
ref
,
path
)
rescue
nil
end
if
blob
&&
blob
.
text?
text
=
'Edit'
after
=
options
[
:after
]
||
''
from_mr
=
options
[
:from_merge_request_id
]
link_opts
=
{}
link_opts
[
:from_merge_request_id
]
=
from_mr
if
from_mr
cls
=
'btn btn-small'
if
allowed_tree_edit?
(
project
,
ref
)
link_to
text
,
project_edit_blob_path
(
project
,
tree_join
(
ref
,
path
),
link_opts
),
class:
cls
else
content_tag
:span
,
text
,
class:
cls
+
' disabled'
end
+
after
.
html_safe
else
''
end
end
def
leave_edit_message
"Leave edit mode?
\n
All unsaved changes will be lost."
end
def
editing_preview_title
(
filename
)
if
Gitlab
::
MarkdownHelper
.
previewable?
(
filename
)
'Preview'
else
'Preview changes'
end
end
end
end
This diff is collapsed.
Click to expand it.
app/helpers/projects_helper.rb
View file @
21297e78
...
@@ -187,7 +187,11 @@ module ProjectsHelper
...
@@ -187,7 +187,11 @@ module ProjectsHelper
"Issues - "
+
title
"Issues - "
+
title
end
end
elsif
current_controller?
(
:blob
)
elsif
current_controller?
(
:blob
)
"
#{
@project
.
path
}
\/
#{
@blob
.
path
}
at
#{
@ref
}
- "
+
title
if
current_action?
(
:new
)
||
current_action?
(
:create
)
"New file at
#{
@ref
}
"
elsif
@blob
"Edit file
#{
@blob
.
path
}
at
#{
@ref
}
"
end
elsif
current_controller?
(
:commits
)
elsif
current_controller?
(
:commits
)
"Commits at
#{
@ref
}
- "
+
title
"Commits at
#{
@ref
}
- "
+
title
elsif
current_controller?
(
:merge_requests
)
elsif
current_controller?
(
:merge_requests
)
...
...
This diff is collapsed.
Click to expand it.
app/helpers/tree_helper.rb
View file @
21297e78
...
@@ -64,32 +64,6 @@ module TreeHelper
...
@@ -64,32 +64,6 @@ module TreeHelper
::
Gitlab
::
GitAccess
.
can_push_to_branch?
(
current_user
,
project
,
ref
)
::
Gitlab
::
GitAccess
.
can_push_to_branch?
(
current_user
,
project
,
ref
)
end
end
def
edit_blob_link
(
project
,
ref
,
path
,
options
=
{})
blob
=
begin
project
.
repository
.
blob_at
(
ref
,
path
)
rescue
nil
end
if
blob
&&
blob
.
text?
text
=
'Edit'
after
=
options
[
:after
]
||
''
from_mr
=
options
[
:from_merge_request_id
]
link_opts
=
{}
link_opts
[
:from_merge_request_id
]
=
from_mr
if
from_mr
cls
=
'btn btn-small'
if
allowed_tree_edit?
(
project
,
ref
)
link_to
text
,
project_edit_tree_path
(
project
,
tree_join
(
ref
,
path
),
link_opts
),
class:
cls
else
content_tag
:span
,
text
,
class:
cls
+
' disabled'
end
+
after
.
html_safe
else
''
end
end
def
tree_breadcrumbs
(
tree
,
max_links
=
2
)
def
tree_breadcrumbs
(
tree
,
max_links
=
2
)
if
@path
.
present?
if
@path
.
present?
part_path
=
""
part_path
=
""
...
@@ -121,16 +95,4 @@ module TreeHelper
...
@@ -121,16 +95,4 @@ module TreeHelper
return
tree
.
name
return
tree
.
name
end
end
end
end
def
leave_edit_message
"Leave edit mode?
\n
All unsaved changes will be lost."
end
def
editing_preview_title
(
filename
)
if
Gitlab
::
MarkdownHelper
.
previewable?
(
filename
)
'Preview'
else
'Diff'
end
end
end
end
This diff is collapsed.
Click to expand it.
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