snippets are ready
This commit is contained in:
parent
526ad466c8
commit
9265de3d25
28 changed files with 366 additions and 8 deletions
|
@ -1,8 +1,6 @@
|
|||
= form_for(@project, :remote => true) do |f|
|
||||
%div.form_content
|
||||
- if @project.new_record?
|
||||
%h1 New Project
|
||||
- else
|
||||
- unless @project.new_record?
|
||||
%h1 Edit Project
|
||||
- if @project.errors.any?
|
||||
#error_explanation
|
||||
|
|
|
@ -18,6 +18,11 @@
|
|||
Wall
|
||||
- if @project.common_notes.count > 0
|
||||
%span{ :class => "top_menu_count" }= @project.common_notes.count
|
||||
%span
|
||||
= link_to project_snippets_path(@project), :class => (controller.controller_name == "snippets") ? "current" : nil do
|
||||
Snippets
|
||||
- if @project.snippets.count > 0
|
||||
%span{ :class => "top_menu_count" }= @project.snippets.count
|
||||
|
||||
- if @commit
|
||||
%span= link_to truncate(commit_name(@project,@commit), :length => 15), project_commit_path(@project, :id => @commit.id), :class => current_page?(:controller => "commits", :action => "show", :project_id => @project, :id => @commit.id) ? "current" : nil
|
||||
|
|
22
app/views/snippets/_form.html.haml
Normal file
22
app/views/snippets/_form.html.haml
Normal file
|
@ -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"
|
11
app/views/snippets/_snippet.html.haml
Normal file
11
app/views/snippets/_snippet.html.haml
Normal file
|
@ -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}"
|
1
app/views/snippets/edit.html.haml
Normal file
1
app/views/snippets/edit.html.haml
Normal file
|
@ -0,0 +1 @@
|
|||
= render "snippets/form"
|
14
app/views/snippets/index.html.haml
Normal file
14
app/views/snippets/index.html.haml
Normal file
|
@ -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(); });
|
1
app/views/snippets/new.html.haml
Normal file
1
app/views/snippets/new.html.haml
Normal file
|
@ -0,0 +1 @@
|
|||
= render "snippets/form"
|
22
app/views/snippets/show.html.haml
Normal file
22
app/views/snippets/show.html.haml
Normal file
|
@ -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
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue