summaryrefslogtreecommitdiff
path: root/app/views/snippets
diff options
context:
space:
mode:
authorgitlabhq <m@gitlabhq.com>2011-10-17 00:07:10 +0300
committergitlabhq <m@gitlabhq.com>2011-10-17 00:07:10 +0300
commit9265de3d25715aeafd38a4ef41596dca058dc18c (patch)
treee755a2c4c0c0451c90a8bc0e75ffae1950a2f6fd /app/views/snippets
parent526ad466c86e69c3447c192d8cae8da653556058 (diff)
downloadgitlab-ce-9265de3d25715aeafd38a4ef41596dca058dc18c.tar.gz
snippets are ready
Diffstat (limited to 'app/views/snippets')
-rw-r--r--app/views/snippets/_form.html.haml22
-rw-r--r--app/views/snippets/_snippet.html.haml11
-rw-r--r--app/views/snippets/edit.html.haml1
-rw-r--r--app/views/snippets/index.html.haml14
-rw-r--r--app/views/snippets/new.html.haml1
-rw-r--r--app/views/snippets/show.html.haml22
6 files changed, 71 insertions, 0 deletions
diff --git a/app/views/snippets/_form.html.haml b/app/views/snippets/_form.html.haml
new file mode 100644
index 00000000000..571e2b063c1
--- /dev/null
+++ b/app/views/snippets/_form.html.haml
@@ -0,0 +1,22 @@
+%div
+ = form_for [@project, @snippet] do |f|
+ -if @snippet.errors.any?
+ %ul
+ - @snippet.errors.full_messages.each do |msg|
+ %li= msg
+
+ %table.round-borders
+ %tr
+ %td= f.label :title
+ %td= f.text_field :title, :placeholder => "Example Snippet"
+ %tr
+ %td= f.label :file_name
+ %td= f.text_field :file_name, :placeholder => "example.rb"
+ %tr
+ %td{:colspan => 2}
+ = f.label :content, "Code"
+ %br
+ = f.text_area :content, :style => "height:240px;width:932px;"
+
+ .actions.prepend-top
+ = f.submit 'Save', :class => "lbutton vm"
diff --git a/app/views/snippets/_snippet.html.haml b/app/views/snippets/_snippet.html.haml
new file mode 100644
index 00000000000..483ff42cbb6
--- /dev/null
+++ b/app/views/snippets/_snippet.html.haml
@@ -0,0 +1,11 @@
+%tr{ :id => dom_id(snippet), :class => "snippet", :url => project_snippet_path(@project, snippet) }
+ %td
+ = image_tag gravatar_icon(snippet.author.email), :class => "left", :width => 40, :style => "padding:0 5px;"
+ = truncate snippet.author.name, :lenght => 20
+ %td= html_escape snippet.title
+ %td= html_escape snippet.file_name
+ %td
+ - if can?(current_user, :admin_snippet, @project) || snippet.author == current_user
+ = link_to 'Edit', edit_project_snippet_path(@project, snippet), :class => "lbutton positive"
+ - if can?(current_user, :admin_snippet, @project) || snippet.author == current_user
+ = link_to 'Destroy', [@project, snippet], :confirm => 'Are you sure?', :method => :delete, :remote => true, :class => "lbutton delete-snippet negative", :id => "destroy_snippet_#{snippet.id}"
diff --git a/app/views/snippets/edit.html.haml b/app/views/snippets/edit.html.haml
new file mode 100644
index 00000000000..f81c0b8bc64
--- /dev/null
+++ b/app/views/snippets/edit.html.haml
@@ -0,0 +1 @@
+= render "snippets/form"
diff --git a/app/views/snippets/index.html.haml b/app/views/snippets/index.html.haml
new file mode 100644
index 00000000000..6e5dbde5bb1
--- /dev/null
+++ b/app/views/snippets/index.html.haml
@@ -0,0 +1,14 @@
+%div
+ - if can? current_user, :write_snippet, @project
+ .left= link_to 'New Snippet', new_project_snippet_path(@project), :class => "lbutton vm"
+
+ %table.round-borders#snippets-table
+ %tr
+ %th Author
+ %th Title
+ %th File name
+ %th
+ = render @snippets
+:javascript
+ $('.delete-snippet').live('ajax:success', function() {
+ $(this).closest('tr').fadeOut(); });
diff --git a/app/views/snippets/new.html.haml b/app/views/snippets/new.html.haml
new file mode 100644
index 00000000000..f81c0b8bc64
--- /dev/null
+++ b/app/views/snippets/new.html.haml
@@ -0,0 +1 @@
+= render "snippets/form"
diff --git a/app/views/snippets/show.html.haml b/app/views/snippets/show.html.haml
new file mode 100644
index 00000000000..d29e0f8c7ab
--- /dev/null
+++ b/app/views/snippets/show.html.haml
@@ -0,0 +1,22 @@
+%h2
+ = "Snippet ##{@snippet.id} - #{@snippet.title}"
+
+.view_file
+ .view_file_header
+ %strong
+ = @snippet.file_name
+ %br/
+ .view_file_content
+ - ft = handle_file_type(@snippet.file_name)
+ :erb
+ <%= raw Albino.colorize(@snippet.content, ft, :html, 'utf-8', "linenos=True") %>
+
+- if can?(current_user, :admin_snippet, @project) || @snippet.author == current_user
+ = link_to 'Edit', edit_project_snippet_path(@project, @snippet), :class => "lbutton positive"
+- if can?(current_user, :admin_snippet, @project) || @snippet.author == current_user
+ = link_to 'Destroy', [@project, @snippet], :confirm => 'Are you sure?', :method => :delete, :class => "lbutton delete-snippet negative", :id => "destroy_snippet_#{@snippet.id}"
+%br
+.snippet_notes= render "notes/notes"
+
+.clear
+