Commit 9710e42d798556ecaf0ffeaf4806a117c1b3530c
1 parent
b3dc4fb7
Exists in
master
and in
4 other branches
Layuot and templates for personal snippets added
Showing
9 changed files
with
75 additions
and
26 deletions
Show diff stats
app/views/snippets/_blob.html.haml
| ... | ... | @@ -3,7 +3,7 @@ |
| 3 | 3 | %i.icon-file |
| 4 | 4 | %strong= @snippet.file_name |
| 5 | 5 | %span.options |
| 6 | - = link_to "raw", raw_project_snippet_path(@project, @snippet), class: "btn btn-tiny", target: "_blank" | |
| 6 | + = link_to "raw", raw_snippet_path(@snippet), class: "btn btn-tiny", target: "_blank" | |
| 7 | 7 | .file_content.code |
| 8 | 8 | - unless @snippet.content.empty? |
| 9 | 9 | %div{class: user_color_scheme_class} | ... | ... |
app/views/snippets/_form.html.haml
| ... | ... | @@ -2,7 +2,7 @@ |
| 2 | 2 | = @snippet.new_record? ? "New Snippet" : "Edit Snippet ##{@snippet.id}" |
| 3 | 3 | %hr |
| 4 | 4 | .snippet-form-holder |
| 5 | - = form_for [@project, @snippet] do |f| | |
| 5 | + = form_for @snippet, as: :personal_snippet, url: url do |f| | |
| 6 | 6 | -if @snippet.errors.any? |
| 7 | 7 | .alert.alert-error |
| 8 | 8 | %ul |
| ... | ... | @@ -13,6 +13,9 @@ |
| 13 | 13 | = f.label :title |
| 14 | 14 | .input= f.text_field :title, placeholder: "Example Snippet", class: 'input-xlarge', required: true |
| 15 | 15 | .clearfix |
| 16 | + = f.label "Private?" | |
| 17 | + .input= f.check_box :private, {class: ''} | |
| 18 | + .clearfix | |
| 16 | 19 | = f.label "Lifetime" |
| 17 | 20 | .input= f.select :expires_at, lifetime_select_options, {}, {class: 'chosen span2'} |
| 18 | 21 | .clearfix |
| ... | ... | @@ -28,9 +31,9 @@ |
| 28 | 31 | |
| 29 | 32 | .form-actions |
| 30 | 33 | = f.submit 'Save', class: "btn-save btn" |
| 31 | - = link_to "Cancel", project_snippets_path(@project), class: " btn" | |
| 34 | + = link_to "Cancel", snippets_path(@project), class: " btn" | |
| 32 | 35 | - unless @snippet.new_record? |
| 33 | - .pull-right= link_to 'Destroy', [@project, @snippet], confirm: 'Are you sure?', method: :delete, class: "btn pull-right danger delete-snippet", id: "destroy_snippet_#{@snippet.id}" | |
| 36 | + .pull-right= link_to 'Destroy', snippet_path(@snippet), confirm: 'Are you sure?', method: :delete, class: "btn pull-right danger delete-snippet", id: "destroy_snippet_#{@snippet.id}" | |
| 34 | 37 | |
| 35 | 38 | |
| 36 | 39 | :javascript | ... | ... |
app/views/snippets/_snippet.html.haml
| 1 | 1 | %tr |
| 2 | 2 | %td |
| 3 | + - if snippet.private? | |
| 4 | + %i.icon-lock | |
| 5 | + - else | |
| 6 | + %i.icon-globe | |
| 3 | 7 | = image_tag gravatar_icon(snippet.author_email), class: "avatar s24" |
| 4 | - %a{href: project_snippet_path(snippet.project, snippet)} | |
| 5 | - %strong= truncate(snippet.title, length: 60) | |
| 8 | + - if snippet.project_id? | |
| 9 | + %a{href: project_snippet_path(snippet.project, snippet)} | |
| 10 | + %strong= truncate(snippet.title, length: 60) | |
| 11 | + - else | |
| 12 | + %a{href: snippet_path(snippet)} | |
| 13 | + %strong= truncate(snippet.title, length: 60) | |
| 6 | 14 | %td |
| 7 | 15 | = snippet.file_name |
| 8 | 16 | %td |
| ... | ... | @@ -11,3 +19,6 @@ |
| 11 | 19 | = snippet.expires_at.to_date.to_s(:short) |
| 12 | 20 | - else |
| 13 | 21 | Never |
| 22 | + %td | |
| 23 | + - if snippet.project_id? | |
| 24 | + = link_to snippet.project.name, project_path(snippet.project) | ... | ... |
app/views/snippets/edit.html.haml
app/views/snippets/index.html.haml
| 1 | 1 | %h3.page_title |
| 2 | 2 | Snippets |
| 3 | 3 | %small share code pastes with others out of git repository |
| 4 | + = link_to new_snippet_path, class: "btn btn-small add_new pull-right", title: "New Snippet" do | |
| 5 | + Add new snippet | |
| 4 | 6 | |
| 5 | - - if can? current_user, :write_snippet, @project | |
| 6 | - = link_to new_project_snippet_path(@project), class: "btn btn-small add_new pull-right", title: "New Snippet" do | |
| 7 | - Add new snippet | |
| 8 | -%br | |
| 9 | -%table | |
| 10 | - %thead | |
| 11 | - %tr | |
| 12 | - %th Title | |
| 13 | - %th File Name | |
| 14 | - %th Expires At | |
| 15 | - = render @snippets | |
| 16 | - - if @snippets.empty? | |
| 17 | - %tr | |
| 18 | - %td{colspan: 3} | |
| 19 | - %h3.nothing_here_message Nothing here. | |
| 7 | +%hr | |
| 8 | +.row | |
| 9 | + .span3 | |
| 10 | + %ul.nav.nav-pills.nav-stacked | |
| 11 | + = nav_tab :scope, nil do | |
| 12 | + = link_to "All", snippets_path | |
| 13 | + = nav_tab :scope, 'projects' do | |
| 14 | + = link_to "Projects", snippets_path(scope: 'projects') | |
| 15 | + | |
| 16 | + .span9 | |
| 17 | + = render 'snippets' | ... | ... |
app/views/snippets/new.html.haml
app/views/snippets/show.html.haml
| 1 | 1 | %h3.page_title |
| 2 | + - if @snippet.private? | |
| 3 | + %i.icon-lock | |
| 4 | + - else | |
| 5 | + %i.icon-globe | |
| 6 | + | |
| 2 | 7 | = @snippet.title |
| 3 | 8 | %small= @snippet.file_name |
| 4 | - - if can?(current_user, :admin_snippet, @project) || @snippet.author == current_user | |
| 5 | - = link_to "Edit", edit_project_snippet_path(@project, @snippet), class: "btn btn-small pull-right", title: 'Edit Snippet' | |
| 9 | + - if @snippet.author == current_user | |
| 10 | + = link_to "Edit", edit_snippet_path(@snippet), class: "btn btn-small pull-right", title: 'Edit Snippet' | |
| 6 | 11 | |
| 7 | 12 | %br |
| 8 | 13 | %div= render 'blob' |
| 9 | -%div#notes= render "notes/notes_with_form" | ... | ... |
| ... | ... | @@ -0,0 +1,20 @@ |
| 1 | +%h3.page_title | |
| 2 | + Snippets by | |
| 3 | + = @user.name | |
| 4 | + %small share code pastes with others out of git repository | |
| 5 | + = link_to new_snippet_path, class: "btn btn-small add_new pull-right", title: "New Snippet" do | |
| 6 | + Add new snippet | |
| 7 | + | |
| 8 | +%hr | |
| 9 | +.row | |
| 10 | + .span3 | |
| 11 | + %ul.nav.nav-pills.nav-stacked | |
| 12 | + = nav_tab :scope, nil do | |
| 13 | + = link_to "All", user_snippets_path(@user) | |
| 14 | + = nav_tab :scope, 'private' do | |
| 15 | + = link_to "Private", user_snippets_path(@user, scope: 'private') | |
| 16 | + = nav_tab :scope, 'public' do | |
| 17 | + = link_to "Public", user_snippets_path(@user, scope: 'public') | |
| 18 | + | |
| 19 | + .span9 | |
| 20 | + = render 'snippets' | ... | ... |