summaryrefslogtreecommitdiff
path: root/app/views/snippets
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-06-14 12:36:46 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-06-14 12:36:46 +0300
commit9be5425a887d96aaf603dd537d36f410eb663e4f (patch)
treecf881f310c6732b9092e0c0e375a66a6567217e5 /app/views/snippets
parent600f4c68940160556b0a4c6ecf18c40dd6ad94d5 (diff)
downloadgitlab-ce-9be5425a887d96aaf603dd537d36f410eb663e4f.tar.gz
Refactor snippets views
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/views/snippets')
-rw-r--r--app/views/snippets/_blob.html.haml13
-rw-r--r--app/views/snippets/_blob_content.html.haml14
-rw-r--r--app/views/snippets/_form.html.haml58
-rw-r--r--app/views/snippets/edit.html.haml5
-rw-r--r--app/views/snippets/new.html.haml5
-rw-r--r--app/views/snippets/show.html.haml14
6 files changed, 21 insertions, 88 deletions
diff --git a/app/views/snippets/_blob.html.haml b/app/views/snippets/_blob.html.haml
deleted file mode 100644
index 4a907011ad1..00000000000
--- a/app/views/snippets/_blob.html.haml
+++ /dev/null
@@ -1,13 +0,0 @@
-.file-holder
- .file-title
- %i.icon-file
- %span.file_name
- = @snippet.file_name
- .options
- .btn-group
- - if can?(current_user, :modify_personal_snippet, @snippet)
- = link_to "edit", edit_snippet_path(@snippet), class: "btn btn-small", title: 'Edit Snippet'
- = link_to "raw", raw_snippet_path(@snippet), class: "btn btn-small", target: "_blank"
- - if can?(current_user, :admin_personal_snippet, @snippet)
- = link_to "remove", snippet_path(@snippet), method: :delete, data: { confirm: "Are you sure?" }, class: "btn btn-small btn-remove", title: 'Delete Snippet'
- = render 'snippets/blob_content'
diff --git a/app/views/snippets/_blob_content.html.haml b/app/views/snippets/_blob_content.html.haml
deleted file mode 100644
index 8cec6168ab8..00000000000
--- a/app/views/snippets/_blob_content.html.haml
+++ /dev/null
@@ -1,14 +0,0 @@
-- unless @snippet.content.empty?
- - if gitlab_markdown?(@snippet.file_name)
- .file-content.wiki
- = preserve do
- = markdown(@snippet.data)
- - elsif markup?(@snippet.file_name)
- .file-content.wiki
- = render_markup(@snippet.file_name, @snippet.data)
- - else
- .file-content.code
- = render 'shared/file_hljs', blob: @snippet
-- else
- .file-content.code
- .nothing-here-block Empty file
diff --git a/app/views/snippets/_form.html.haml b/app/views/snippets/_form.html.haml
deleted file mode 100644
index d466dc1af14..00000000000
--- a/app/views/snippets/_form.html.haml
+++ /dev/null
@@ -1,58 +0,0 @@
-%h3.page-title
- = @snippet.new_record? ? "New Snippet" : "Edit Snippet ##{@snippet.id}"
-%hr
-.snippet-form-holder
- = form_for @snippet, as: :personal_snippet, url: url, html: { class: "form-horizontal snippet-form" } do |f|
- -if @snippet.errors.any?
- .alert.alert-danger
- %ul
- - @snippet.errors.full_messages.each do |msg|
- %li= msg
-
- .form-group
- = f.label :title, class: 'control-label'
- .col-sm-10= f.text_field :title, placeholder: "Example Snippet", class: 'form-control', required: true
- .form-group
- = f.label "Access", class: 'control-label'
- .col-sm-10
- = f.label :private_true, class: 'radio-label' do
- = f.radio_button :private, true
- %span
- %strong Private
- (only you can see this snippet)
- %br
- = f.label :private_false, class: 'radio-label' do
- = f.radio_button :private, false
- %span
- %strong Public
- (GitLab users can see this snippet)
-
- .form-group
- .file-editor
- = f.label :file_name, "File", class: 'control-label'
- .col-sm-10
- .file-holder.snippet
- .file-title
- = f.text_field :file_name, placeholder: "example.rb", class: 'form-control snippet-file-name', required: true
- .file-content.code
- %pre#editor= @snippet.content
- = f.hidden_field :content, class: 'snippet-file-content'
-
- .form-actions
- - if @snippet.new_record?
- = f.submit 'Create snippet', class: "btn-create btn"
- - else
- = f.submit 'Save', class: "btn-save btn"
-
- - unless @snippet.new_record?
- .pull-right.prepend-left-20
- = link_to 'Remove', snippet_path(@snippet), data: { confirm: 'Removed snippet cannot be restored! Are you sure?'}, method: :delete, class: "btn btn-remove delete-snippet", id: "destroy_snippet_#{@snippet.id}"
- = link_to "Cancel", snippets_path(@project), class: "btn btn-cancel"
-
-
-:javascript
- var editor = ace.edit("editor");
- $(".snippet-form-holder form").submit(function(){
- $(".snippet-file-content").val(editor.getValue());
- });
-
diff --git a/app/views/snippets/edit.html.haml b/app/views/snippets/edit.html.haml
index 1b88a85faf1..7042d07d5e8 100644
--- a/app/views/snippets/edit.html.haml
+++ b/app/views/snippets/edit.html.haml
@@ -1 +1,4 @@
-= render "snippets/form", url: snippet_path(@snippet)
+%h3.page-title
+ Edit snippet
+%hr
+= render "shared/snippets/form", url: snippet_path(@snippet)
diff --git a/app/views/snippets/new.html.haml b/app/views/snippets/new.html.haml
index 90e0a1f79da..694d7058317 100644
--- a/app/views/snippets/new.html.haml
+++ b/app/views/snippets/new.html.haml
@@ -1 +1,4 @@
-= render "snippets/form", url: snippets_path(@snippet)
+%h3.page-title
+ New snippet
+%hr
+= render "shared/snippets/form", url: snippets_path(@snippet)
diff --git a/app/views/snippets/show.html.haml b/app/views/snippets/show.html.haml
index 655ff947d20..1d2e3d5ae4a 100644
--- a/app/views/snippets/show.html.haml
+++ b/app/views/snippets/show.html.haml
@@ -28,4 +28,16 @@
= link_to snippets_path do
&larr; discover snippets
-%div= render 'blob'
+.file-holder
+ .file-title
+ %i.icon-file
+ %span.file_name
+ = @snippet.file_name
+ .options
+ .btn-group
+ - if can?(current_user, :modify_personal_snippet, @snippet)
+ = link_to "edit", edit_snippet_path(@snippet), class: "btn btn-small", title: 'Edit Snippet'
+ = link_to "raw", raw_snippet_path(@snippet), class: "btn btn-small", target: "_blank"
+ - if can?(current_user, :admin_personal_snippet, @snippet)
+ = link_to "remove", snippet_path(@snippet), method: :delete, data: { confirm: "Are you sure?" }, class: "btn btn-small btn-remove", title: 'Delete Snippet'
+ = render 'shared/snippets/blob'