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
21297e78
Commit
21297e78
authored
Jan 26, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor blob helpers
parent
e07da598
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
39 deletions
+43
-39
blob_helper.rb
app/helpers/blob_helper.rb
+38
-0
projects_helper.rb
app/helpers/projects_helper.rb
+5
-1
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
def
no_highlight_files
%w(credits changelog copying copyright license authors)
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
app/helpers/projects_helper.rb
View file @
21297e78
...
...
@@ -187,7 +187,11 @@ module ProjectsHelper
"Issues - "
+
title
end
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
)
"Commits at
#{
@ref
}
- "
+
title
elsif
current_controller?
(
:merge_requests
)
...
...
app/helpers/tree_helper.rb
View file @
21297e78
...
...
@@ -64,32 +64,6 @@ module TreeHelper
::
Gitlab
::
GitAccess
.
can_push_to_branch?
(
current_user
,
project
,
ref
)
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
)
if
@path
.
present?
part_path
=
""
...
...
@@ -121,16 +95,4 @@ module TreeHelper
return
tree
.
name
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
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