Commit 9710e42d798556ecaf0ffeaf4806a117c1b3530c

Authored by Andrew8xx8
1 parent b3dc4fb7

Layuot and templates for personal snippets added

app/views/snippets/_blob.html.haml
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 %i.icon-file 3 %i.icon-file
4 %strong= @snippet.file_name 4 %strong= @snippet.file_name
5 %span.options 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 .file_content.code 7 .file_content.code
8 - unless @snippet.content.empty? 8 - unless @snippet.content.empty?
9 %div{class: user_color_scheme_class} 9 %div{class: user_color_scheme_class}
app/views/snippets/_form.html.haml
@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 = @snippet.new_record? ? "New Snippet" : "Edit Snippet ##{@snippet.id}" 2 = @snippet.new_record? ? "New Snippet" : "Edit Snippet ##{@snippet.id}"
3 %hr 3 %hr
4 .snippet-form-holder 4 .snippet-form-holder
5 - = form_for [@project, @snippet] do |f| 5 + = form_for @snippet, as: :personal_snippet, url: url do |f|
6 -if @snippet.errors.any? 6 -if @snippet.errors.any?
7 .alert.alert-error 7 .alert.alert-error
8 %ul 8 %ul
@@ -13,6 +13,9 @@ @@ -13,6 +13,9 @@
13 = f.label :title 13 = f.label :title
14 .input= f.text_field :title, placeholder: "Example Snippet", class: 'input-xlarge', required: true 14 .input= f.text_field :title, placeholder: "Example Snippet", class: 'input-xlarge', required: true
15 .clearfix 15 .clearfix
  16 + = f.label "Private?"
  17 + .input= f.check_box :private, {class: ''}
  18 + .clearfix
16 = f.label "Lifetime" 19 = f.label "Lifetime"
17 .input= f.select :expires_at, lifetime_select_options, {}, {class: 'chosen span2'} 20 .input= f.select :expires_at, lifetime_select_options, {}, {class: 'chosen span2'}
18 .clearfix 21 .clearfix
@@ -28,9 +31,9 @@ @@ -28,9 +31,9 @@
28 31
29 .form-actions 32 .form-actions
30 = f.submit 'Save', class: "btn-save btn" 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 - unless @snippet.new_record? 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 :javascript 39 :javascript
app/views/snippets/_snippet.html.haml
1 %tr 1 %tr
2 %td 2 %td
  3 + - if snippet.private?
  4 + %i.icon-lock
  5 + - else
  6 + %i.icon-globe
3 = image_tag gravatar_icon(snippet.author_email), class: "avatar s24" 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 %td 14 %td
7 = snippet.file_name 15 = snippet.file_name
8 %td 16 %td
@@ -11,3 +19,6 @@ @@ -11,3 +19,6 @@
11 = snippet.expires_at.to_date.to_s(:short) 19 = snippet.expires_at.to_date.to_s(:short)
12 - else 20 - else
13 Never 21 Never
  22 + %td
  23 + - if snippet.project_id?
  24 + = link_to snippet.project.name, project_path(snippet.project)
app/views/snippets/_snippets.html.haml 0 → 100644
@@ -0,0 +1,13 @@ @@ -0,0 +1,13 @@
  1 +%table
  2 + %thead
  3 + %tr
  4 + %th Title
  5 + %th File Name
  6 + %th Expires At
  7 + %th Project
  8 +
  9 + = render partial: 'snippet', collection: @snippets
  10 + - if @snippets.empty?
  11 + %tr
  12 + %td{colspan: 4}
  13 + %h3.nothing_here_message Nothing here.
app/views/snippets/edit.html.haml
1 -= render "snippets/form" 1 += render "snippets/form", url: snippet_path(@snippet)
app/views/snippets/index.html.haml
1 %h3.page_title 1 %h3.page_title
2 Snippets 2 Snippets
3 %small share code pastes with others out of git repository 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
1 -= render "snippets/form" 1 += render "snippets/form", url: snippets_path(@snippet)
app/views/snippets/show.html.haml
1 %h3.page_title 1 %h3.page_title
  2 + - if @snippet.private?
  3 + %i.icon-lock
  4 + - else
  5 + %i.icon-globe
  6 +
2 = @snippet.title 7 = @snippet.title
3 %small= @snippet.file_name 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 %br 12 %br
8 %div= render 'blob' 13 %div= render 'blob'
9 -%div#notes= render "notes/notes_with_form"  
app/views/snippets/user_index.html.haml 0 → 100644
@@ -0,0 +1,20 @@ @@ -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'