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
Kazuhiko Shiozaki
gitlab-ce
Commits
809aefb8
Commit
809aefb8
authored
Oct 15, 2012
by
randx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Minor improve to UI and code formatting of gitlab web editor
parent
47d9732a
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
37 additions
and
19 deletions
+37
-19
app/assets/stylesheets/sections/tree.scss
app/assets/stylesheets/sections/tree.scss
+8
-0
app/controllers/tree_controller.rb
app/controllers/tree_controller.rb
+6
-6
app/roles/repository.rb
app/roles/repository.rb
+4
-0
app/views/tree/_tree_file.html.haml
app/views/tree/_tree_file.html.haml
+5
-4
app/views/tree/edit.html.haml
app/views/tree/edit.html.haml
+4
-1
features/project/source/browse_files.feature
features/project/source/browse_files.feature
+1
-1
features/steps/project/project_browse_files.rb
features/steps/project/project_browse_files.rb
+2
-2
lib/gitlab/file_editor.rb
lib/gitlab/file_editor.rb
+7
-5
No files found.
app/assets/stylesheets/sections/tree.scss
View file @
809aefb8
...
...
@@ -59,3 +59,11 @@
}
}
}
.tree-btn-group
{
.btn
{
margin-right
:
-3px
;
padding
:
2px
10px
;
}
}
app/controllers/tree_controller.rb
View file @
809aefb8
...
...
@@ -21,23 +21,23 @@ class TreeController < ProjectResourceController
end
def
edit
@last_commit
=
@project
.
commits
(
@ref
,
@path
,
1
).
first
.
sha
@last_commit
=
@project
.
last_commit_for
(
@ref
,
@path
)
.
sha
end
def
update
file_editor
=
Gitlab
::
FileEditor
.
new
(
current_user
,
@project
,
@ref
)
update_status
=
file_editor
.
update
(
@path
,
params
[
:content
],
params
[
:commit_message
],
@path
,
params
[
:content
],
params
[
:commit_message
],
params
[
:last_commit
]
)
if
update_status
redirect_to
project_tree_path
(
@project
,
@id
),
:notice
=>
"File has been successfully changed"
else
flash
[
:notice
]
=
"You can't save file because it has been changed"
render
:edit
render
:edit
end
end
end
app/roles/repository.rb
View file @
809aefb8
...
...
@@ -32,6 +32,10 @@ module Repository
Commit
.
commits
(
repo
,
ref
,
path
,
limit
,
offset
)
end
def
last_commit_for
(
ref
,
path
=
nil
)
commits
(
ref
,
path
,
1
).
first
end
def
commits_between
(
from
,
to
)
Commit
.
commits_between
(
repo
,
from
,
to
)
end
...
...
app/views/tree/_tree_file.html.haml
View file @
809aefb8
...
...
@@ -5,10 +5,11 @@
=
tree_file
.
name
.
force_encoding
(
'utf-8'
)
%small
#{
tree_file
.
mode
}
%span
.options
=
link_to
"raw"
,
project_blob_path
(
@project
,
@id
),
class:
"btn very_small"
,
target:
"_blank"
=
link_to
"history"
,
project_commits_path
(
@project
,
@id
),
class:
"btn very_small"
=
link_to
"blame"
,
project_blame_path
(
@project
,
@id
),
class:
"btn very_small"
=
link_to
"Edit"
,
edit_project_tree_path
(
@project
,
@id
),
class:
"btn very_small"
.btn-group.tree-btn-group
=
link_to
"raw"
,
project_blob_path
(
@project
,
@id
),
class:
"btn very_small"
,
target:
"_blank"
=
link_to
"history"
,
project_commits_path
(
@project
,
@id
),
class:
"btn very_small"
=
link_to
"blame"
,
project_blame_path
(
@project
,
@id
),
class:
"btn very_small"
=
link_to
"edit"
,
edit_project_tree_path
(
@project
,
@id
),
class:
"btn very_small"
-
if
tree_file
.
text?
-
if
gitlab_markdown?
(
tree_file
.
name
)
.file_content.wiki
...
...
app/views/tree/edit.html.haml
View file @
809aefb8
...
...
@@ -3,7 +3,10 @@
.file_holder
.file_title
%i
.icon-file
=
@tree
.
path
.
force_encoding
(
'utf-8'
)
%span
.file_name
=
@tree
.
path
.
force_encoding
(
'utf-8'
)
%span
.options
=
link_to
"cancel editing"
,
project_tree_path
(
@project
,
@id
),
class:
"btn very_small"
.file_content.code
#editor
=
@tree
.
data
...
...
features/project/source/browse_files.feature
View file @
809aefb8
...
...
@@ -23,5 +23,5 @@ Feature: Project Browse files
@javascript
Scenario
:
I
can edit file
Given
I click on
"Gemfile"
file in repo
And
I click button
"
E
dit"
And
I click button
"
e
dit"
Then
I can edit code
features/steps/project/project_browse_files.rb
View file @
809aefb8
...
...
@@ -32,8 +32,8 @@ class ProjectBrowseFiles < Spinach::FeatureSteps
page
.
source
.
should
==
ValidCommit
::
BLOB_FILE
end
Given
'I click button "
E
dit"'
do
click_link
'
E
dit'
Given
'I click button "
e
dit"'
do
click_link
'
e
dit'
end
Then
'I can edit code'
do
...
...
lib/gitlab/file_editor.rb
View file @
809aefb8
module
Gitlab
# GitLab file editor
#
# It gives you ability to make changes to files
# & commit this changes from GitLab UI.
class
FileEditor
attr_accessor
:user
,
:project
,
:ref
def
initialize
(
user
,
project
,
ref
)
...
...
@@ -35,22 +38,21 @@ module Gitlab
r
.
git
.
sh
"git add ."
r
.
git
.
sh
"git commit -am '
#{
commit_message
}
'"
output
=
r
.
git
.
sh
"git push origin
#{
ref
}
"
if
output
=~
/reject/
return
false
end
end
end
end
true
end
protected
def
can_edit?
(
path
,
last_commit
)
current_last_commit
=
@project
.
commits
(
ref
,
path
,
1
).
first
.
sha
last_commit
==
current_last_commit
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