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
Léo-Paul Géneau
gitlab-ce
Commits
a3d879d4
Commit
a3d879d4
authored
Jan 26, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor web editor
parent
aac36b12
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
112 additions
and
72 deletions
+112
-72
app/assets/javascripts/blob/blob.js.coffee
app/assets/javascripts/blob/blob.js.coffee
+0
-0
app/assets/javascripts/blob/edit_blob.js.coffee
app/assets/javascripts/blob/edit_blob.js.coffee
+40
-0
app/assets/javascripts/blob/new_blob.js.coffee
app/assets/javascripts/blob/new_blob.js.coffee
+17
-0
app/assets/stylesheets/sections/editor.scss
app/assets/stylesheets/sections/editor.scss
+22
-0
app/views/projects/blob/_editor.html.haml
app/views/projects/blob/_editor.html.haml
+25
-0
app/views/projects/blob/edit.html.haml
app/views/projects/blob/edit.html.haml
+2
-40
app/views/projects/blob/new.html.haml
app/views/projects/blob/new.html.haml
+2
-28
lib/gitlab/satellite/files/new_file_action.rb
lib/gitlab/satellite/files/new_file_action.rb
+4
-4
No files found.
app/assets/javascripts/blob.js.coffee
→
app/assets/javascripts/blob
/blob
.js.coffee
View file @
a3d879d4
File moved
app/assets/javascripts/blob/edit_blob.js.coffee
0 → 100644
View file @
a3d879d4
class
@
EditBlob
constructor
:
(
assets_path
,
mode
)
->
ace
.
config
.
set
"modePath"
,
assets_path
+
'/ace'
ace
.
config
.
loadModule
"ace/ext/searchbox"
if
mode
ace_mode
=
mode
editor
=
ace
.
edit
(
"editor"
)
editor
.
focus
()
if
ace_mode
editor
.
getSession
().
setMode
"ace/mode/"
+
ace_mode
disableButtonIfEmptyField
"#commit_message"
,
".js-commit-button"
$
(
".js-commit-button"
).
click
->
$
(
"#file-content"
).
val
editor
.
getValue
()
$
(
".file-editor form"
).
submit
()
return
editModePanes
=
$
(
".js-edit-mode-pane"
)
editModeLinks
=
$
(
".js-edit-mode a"
)
editModeLinks
.
click
(
event
)
->
event
.
preventDefault
()
currentLink
=
$
(
this
)
paneId
=
currentLink
.
attr
(
"href"
)
currentPane
=
editModePanes
.
filter
(
paneId
)
editModeLinks
.
parent
().
removeClass
"active hover"
currentLink
.
parent
().
addClass
"active hover"
editModePanes
.
hide
()
if
paneId
is
"#preview"
currentPane
.
fadeIn
200
$
.
post
currentLink
.
data
(
"preview-url"
),
content
:
editor
.
getValue
()
,
(
response
)
->
currentPane
.
empty
().
append
response
return
else
currentPane
.
fadeIn
200
editor
.
focus
()
return
app/assets/javascripts/blob/new_blob.js.coffee
0 → 100644
View file @
a3d879d4
class
@
NewBlob
constructor
:
(
assets_path
,
mode
)
->
ace
.
config
.
set
"modePath"
,
assets_path
+
'/ace'
ace
.
config
.
loadModule
"ace/ext/searchbox"
if
mode
ace_mode
=
mode
editor
=
ace
.
edit
(
"editor"
)
editor
.
focus
()
if
ace_mode
editor
.
getSession
().
setMode
"ace/mode/"
+
ace_mode
disableButtonIfEmptyField
"#commit_message"
,
".js-commit-button"
$
(
".js-commit-button"
).
click
->
$
(
"#file-content"
).
val
editor
.
getValue
()
$
(
".file-editor form"
).
submit
()
return
app/assets/stylesheets/sections/editor.scss
View file @
a3d879d4
...
@@ -31,4 +31,26 @@
...
@@ -31,4 +31,26 @@
margin
:
5px
8px
0
8px
;
margin
:
5px
8px
0
8px
;
}
}
}
}
.file-title
{
@extend
.monospace
;
font-size
:
14px
;
}
.editor-ref
{
background
:
#fafafa
;
padding
:
18px
15px
;
padding-left
:
25px
;
border-right
:
1px
solid
#CCC
;
display
:
inline-block
;
margin
:
-10px
-15px
;
margin-right
:
10px
;
}
.editor-file-name
{
.new-file-name
{
display
:
inline-block
;
width
:
200px
;
}
}
}
}
app/views/projects/
_blob
_editor.html.haml
→
app/views/projects/
blob/
_editor.html.haml
View file @
a3d879d4
.file-holder.file
.file-holder.file
.file-title
.file-title
%i
.icon-file
.editor-ref
%span
.file_name
%i
.fa.fa-code-fork
%span
.monospace.light
#{
ref
}
=
ref
-
if
local_assigns
[
:path
]
%span
.editor-file-name
=
': '
+
local_assigns
[
:path
]
-
if
@path
%span
.monospace
=
@path
-
if
current_action?
(
:new
)
||
current_action?
(
:create
)
\/
=
text_field_tag
'file_name'
,
params
[
:file_name
],
placeholder:
"sample.rb"
,
required:
true
,
class:
'form-control new-file-name'
.pull-right
=
select_tag
:encoding
,
options_for_select
([
"base64"
,
"text"
],
"text"
),
class:
'form-control'
.file-content.code
.file-content.code
%pre
.js-edit-mode-pane
#editor
%pre
.js-edit-mode-pane
#editor
=
params
[
:content
]
||
local_assigns
[
:blob_data
]
=
params
[
:content
]
||
local_assigns
[
:blob_data
]
...
...
app/views/projects/blob/edit.html.haml
View file @
a3d879d4
...
@@ -11,7 +11,7 @@
...
@@ -11,7 +11,7 @@
=
editing_preview_title
(
@blob
.
name
)
=
editing_preview_title
(
@blob
.
name
)
=
form_tag
(
project_update_blob_path
(
@project
,
@id
),
method: :put
,
class:
"form-horizontal"
)
do
=
form_tag
(
project_update_blob_path
(
@project
,
@id
),
method: :put
,
class:
"form-horizontal"
)
do
=
render
'projects/blob
_
editor'
,
ref:
@ref
,
path:
@path
,
blob_data:
@blob
.
data
=
render
'projects/blob
/
editor'
,
ref:
@ref
,
path:
@path
,
blob_data:
@blob
.
data
=
render
'shared/commit_message_container'
,
params:
params
,
=
render
'shared/commit_message_container'
,
params:
params
,
placeholder:
"Update
#{
@blob
.
name
}
"
placeholder:
"Update
#{
@blob
.
name
}
"
=
hidden_field_tag
'last_commit'
,
@last_commit
=
hidden_field_tag
'last_commit'
,
@last_commit
...
@@ -21,42 +21,4 @@
...
@@ -21,42 +21,4 @@
cancel_path:
@after_edit_path
cancel_path:
@after_edit_path
:javascript
:javascript
ace
.
config
.
set
(
"
modePath
"
,
gon
.
relative_url_root
+
"
#{
Gitlab
::
Application
.
config
.
assets
.
prefix
}
/ace
"
)
new
EditBlob
(
gon
.
relative_url_root
+
"
#{
Gitlab
::
Application
.
config
.
assets
.
prefix
}
"
,
"
#{
@blob
.
language
.
try
(
:ace_mode
)
}
"
)
ace
.
config
.
loadModule
(
"
ace/ext/searchbox
"
);
var
ace_mode
=
"
#{
@blob
.
language
.
try
(
:ace_mode
)
}
"
;
var
editor
=
ace
.
edit
(
"
editor
"
);
if
(
ace_mode
)
{
editor
.
getSession
().
setMode
(
'
ace/mode/
'
+
ace_mode
);
}
disableButtonIfEmptyField
(
"
#commit_message
"
,
"
.js-commit-button
"
);
$
(
"
.js-commit-button
"
).
click
(
function
(){
$
(
"
#file-content
"
).
val
(
editor
.
getValue
());
$
(
"
.file-editor form
"
).
submit
();
});
var
editModePanes
=
$
(
'
.js-edit-mode-pane
'
),
editModeLinks
=
$
(
'
.js-edit-mode a
'
);
editModeLinks
.
click
(
function
(
event
)
{
event
.
preventDefault
();
var
currentLink
=
$
(
this
),
paneId
=
currentLink
.
attr
(
'
href
'
),
currentPane
=
editModePanes
.
filter
(
paneId
);
editModeLinks
.
parent
().
removeClass
(
'
active hover
'
);
currentLink
.
parent
().
addClass
(
'
active hover
'
);
editModePanes
.
hide
();
if
(
paneId
==
'
#preview
'
)
{
currentPane
.
fadeIn
(
200
);
$
.
post
(
currentLink
.
data
(
'
preview-url
'
),
{
content
:
editor
.
getValue
()
},
function
(
response
)
{
currentPane
.
empty
().
append
(
response
);
})
}
else
{
currentPane
.
fadeIn
(
200
);
editor
.
focus
()
}
})
app/views/projects/blob/new.html.haml
View file @
a3d879d4
%h3
.page-title
New file
%h3
.page-title
New file
%hr
.file-editor
.file-editor
=
form_tag
(
project_create_blob_path
(
@project
,
@id
),
method: :post
,
class:
'form-horizontal form-new-file'
)
do
=
form_tag
(
project_create_blob_path
(
@project
,
@id
),
method: :post
,
class:
'form-horizontal form-new-file'
)
do
.form-group.commit_message-group
=
render
'projects/blob/editor'
,
ref:
@ref
=
label_tag
'file_name'
,
class:
'control-label'
do
File name
.col-sm-10
.input-group
%span
.input-group-addon
=
@path
[
-
1
]
==
"/"
?
@path
:
@path
+
"/"
=
text_field_tag
'file_name'
,
params
[
:file_name
],
placeholder:
"sample.rb"
,
required:
true
,
class:
'form-control'
%span
.input-group-addon
on
%span
=
@ref
.form-group.commit_message-group
=
label_tag
:encoding
,
class:
"control-label"
do
Encoding
.col-sm-10
=
select_tag
:encoding
,
options_for_select
([
"base64"
,
"text"
],
"text"
),
class:
'form-control'
=
render
'projects/blob_editor'
,
ref:
@ref
=
render
'shared/commit_message_container'
,
params:
params
,
=
render
'shared/commit_message_container'
,
params:
params
,
placeholder:
'Add new file'
placeholder:
'Add new file'
=
hidden_field_tag
'content'
,
''
,
id:
'file-content'
=
hidden_field_tag
'content'
,
''
,
id:
'file-content'
...
@@ -27,12 +9,4 @@
...
@@ -27,12 +9,4 @@
cancel_path:
project_tree_path
(
@project
,
@id
)
cancel_path:
project_tree_path
(
@project
,
@id
)
:javascript
:javascript
ace
.
config
.
set
(
"
modePath
"
,
gon
.
relative_url_root
+
"
#{
Gitlab
::
Application
.
config
.
assets
.
prefix
}
/ace-src-noconflict
"
)
new
NewBlob
(
gon
.
relative_url_root
+
"
#{
Gitlab
::
Application
.
config
.
assets
.
prefix
}
"
,
null
)
var
editor
=
ace
.
edit
(
"
editor
"
);
disableButtonIfAnyEmptyField
(
$
(
'
.form-new-file
'
),
'
.form-control
'
,
'
.btn-create
'
)
$
(
"
.js-commit-button
"
).
click
(
function
(){
$
(
"
#file-content
"
).
val
(
editor
.
getValue
());
$
(
"
.file-editor form
"
).
submit
();
});
lib/gitlab/satellite/files/new_file_action.rb
View file @
a3d879d4
...
@@ -15,12 +15,12 @@ module Gitlab
...
@@ -15,12 +15,12 @@ module Gitlab
# create target branch in satellite at the corresponding commit from bare repo
# create target branch in satellite at the corresponding commit from bare repo
current_ref
=
current_ref
=
if
repo
.
commits
.
any?
if
@project
.
empty_repo?
repo
.
git
.
checkout
({
raise:
true
,
timeout:
true
,
b:
true
},
ref
,
"origin/
#{
ref
}
"
)
ref
else
# skip this step if we want to add first file to empty repo
# skip this step if we want to add first file to empty repo
Satellite
::
PARKING_BRANCH
Satellite
::
PARKING_BRANCH
else
repo
.
git
.
checkout
({
raise:
true
,
timeout:
true
,
b:
true
},
ref
,
"origin/
#{
ref
}
"
)
ref
end
end
file_path_in_satellite
=
File
.
join
(
repo
.
working_dir
,
file_path
)
file_path_in_satellite
=
File
.
join
(
repo
.
working_dir
,
file_path
)
...
...
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