Commit bbb06e504e387762bb5a073d1f0debdc05e03f98
1 parent
02e39563
Exists in
master
and in
4 other branches
Add seeds and improve ui. Remove snippet expires_at
Showing
6 changed files
with
61 additions
and
28 deletions
Show diff stats
app/views/snippets/_form.html.haml
@@ -16,9 +16,6 @@ | @@ -16,9 +16,6 @@ | ||
16 | = f.label "Private?" | 16 | = f.label "Private?" |
17 | .input= f.check_box :private, {class: ''} | 17 | .input= f.check_box :private, {class: ''} |
18 | .clearfix | 18 | .clearfix |
19 | - = f.label "Lifetime" | ||
20 | - .input= f.select :expires_at, lifetime_select_options, {}, {class: 'chosen span2'} | ||
21 | - .clearfix | ||
22 | .file-editor | 19 | .file-editor |
23 | = f.label :file_name, "File" | 20 | = f.label :file_name, "File" |
24 | .input | 21 | .input |
@@ -30,7 +27,11 @@ | @@ -30,7 +27,11 @@ | ||
30 | = f.hidden_field :content, class: 'snippet-file-content' | 27 | = f.hidden_field :content, class: 'snippet-file-content' |
31 | 28 | ||
32 | .form-actions | 29 | .form-actions |
33 | - = f.submit 'Save', class: "btn-save btn" | 30 | + - if @snippet.new_record? |
31 | + = f.submit 'Create snippet', class: "btn-create btn" | ||
32 | + - else | ||
33 | + = f.submit 'Save', class: "btn-save btn" | ||
34 | + | ||
34 | = link_to "Cancel", snippets_path(@project), class: " btn" | 35 | = link_to "Cancel", snippets_path(@project), class: " btn" |
35 | - unless @snippet.new_record? | 36 | - unless @snippet.new_record? |
36 | .pull-right= link_to 'Destroy', snippet_path(@snippet), confirm: 'Removed snippet cannot be restored! Are you sure?', method: :delete, class: "btn pull-right danger delete-snippet", id: "destroy_snippet_#{@snippet.id}" | 37 | .pull-right= link_to 'Destroy', snippet_path(@snippet), confirm: 'Removed snippet cannot be restored! Are you sure?', method: :delete, class: "btn pull-right danger delete-snippet", id: "destroy_snippet_#{@snippet.id}" |
app/views/snippets/_snippet.html.haml
1 | %li | 1 | %li |
2 | - .snippet-title | ||
3 | - - if snippet.private? | ||
4 | - = private_icon | ||
5 | - - else | ||
6 | - = public_icon | 2 | + %h4.snippet-title |
7 | = link_to reliable_snippet_path(snippet) do | 3 | = link_to reliable_snippet_path(snippet) do |
8 | - %h5.inline | ||
9 | - = truncate(snippet.title, length: 60) | ||
10 | - %span.cgray | 4 | + = truncate(snippet.title, length: 60) |
5 | + - if snippet.private? | ||
6 | + %span.label.label-success | ||
7 | + %i.icon-lock | ||
8 | + private | ||
9 | + %span.cgray.monospace.tiny.pull-right | ||
11 | = snippet.file_name | 10 | = snippet.file_name |
12 | 11 | ||
13 | %small.pull-right.cgray | 12 | %small.pull-right.cgray |
@@ -15,16 +14,11 @@ | @@ -15,16 +14,11 @@ | ||
15 | = link_to snippet.project.name_with_namespace, project_path(snippet.project) | 14 | = link_to snippet.project.name_with_namespace, project_path(snippet.project) |
16 | %span | 15 | %span |
17 | \| | 16 | \| |
18 | - Expires: | ||
19 | - - if snippet.expires_at | ||
20 | - = snippet.expires_at.to_date.to_s(:short) | ||
21 | - - else | ||
22 | - Never | ||
23 | 17 | ||
24 | - .snippet-info.prepend-left-20 | 18 | + .snippet-info |
25 | = "##{snippet.id}" | 19 | = "##{snippet.id}" |
26 | - %span.light | 20 | + %span |
27 | by | 21 | by |
28 | = image_tag gravatar_icon(snippet.author_email), class: "avatar avatar-inline s16", alt: '' | 22 | = image_tag gravatar_icon(snippet.author_email), class: "avatar avatar-inline s16", alt: '' |
29 | = snippet.author_name | 23 | = snippet.author_name |
30 | - | 24 | + %span.light #{time_ago_in_words(snippet.created_at)} ago |
app/views/snippets/_snippets.html.haml
app/views/snippets/show.html.haml
1 | %h3.page-title | 1 | %h3.page-title |
2 | + = @snippet.title | ||
3 | + | ||
2 | - if @snippet.private? | 4 | - if @snippet.private? |
3 | - %i{:class => "icon-lock cgreen has_bottom_tooltip", "data-original-title" => "Private snippet"} | ||
4 | - - else | ||
5 | - %i{:class => "icon-globe cblue has_bottom_tooltip", "data-original-title" => "Public snippet"} | 5 | + %span.label.label-success |
6 | + %i.icon-lock | ||
7 | + private | ||
6 | 8 | ||
7 | - = @snippet.title | 9 | + .pull-right |
10 | + = link_to new_snippet_path, class: "btn btn-small add_new grouped btn-primary", title: "New Snippet" do | ||
11 | + Add new snippet | ||
8 | 12 | ||
9 | - %small.pull-right | 13 | + |
14 | +.append-bottom-20 | ||
15 | + .pull-right | ||
10 | = "##{@snippet.id}" | 16 | = "##{@snippet.id}" |
11 | %span.light | 17 | %span.light |
12 | by | 18 | by |
13 | = image_tag gravatar_icon(@snippet.author_email), class: "avatar avatar-inline s16" | 19 | = image_tag gravatar_icon(@snippet.author_email), class: "avatar avatar-inline s16" |
14 | = @snippet.author_name | 20 | = @snippet.author_name |
21 | + | ||
22 | + .back-link | ||
23 | + - if @snippet.author == current_user | ||
24 | + = link_to user_snippets_path(current_user) do | ||
25 | + ← my snippets | ||
26 | + - else | ||
27 | + = link_to snippets_path do | ||
28 | + ← discover snippets | ||
29 | + | ||
15 | %div= render 'blob' | 30 | %div= render 'blob' |
@@ -0,0 +1,24 @@ | @@ -0,0 +1,24 @@ | ||
1 | +ActiveRecord::Base.observers.disable :all | ||
2 | + | ||
3 | +Gitlab::Seeder.quiet do | ||
4 | + contents = [ | ||
5 | + `curl https://gist.github.com/randx/4275756/raw/da2f262920c96d1a970d48bf2e99147954b1f4bd/glus1204.sh`, | ||
6 | + `curl https://gist.github.com/randx/3754594/raw/11026a295e6ef3a151c635707a3e1e8e15fc4725/gitlab_setup.sh `, | ||
7 | + `curl https://gist.github.com/randx/3065552/raw/29fbd09f4605a5ea22a5a9095e35fd1938dea4d6/gistfile1.sh`, | ||
8 | + ] | ||
9 | + | ||
10 | + (1..50).each do |i| | ||
11 | + user = User.all.sample | ||
12 | + | ||
13 | + PersonalSnippet.seed(:id, [{ | ||
14 | + id: i, | ||
15 | + author_id: user.id, | ||
16 | + title: Faker::Lorem.sentence(6), | ||
17 | + file_name: Faker::Internet.domain_word + '.sh', | ||
18 | + private: [true, false].sample, | ||
19 | + content: contents.sample, | ||
20 | + }]) | ||
21 | + print('.') | ||
22 | + end | ||
23 | +end | ||
24 | + |
features/steps/snippets/snippets.rb
@@ -24,12 +24,11 @@ class SnippetsFeature < Spinach::FeatureSteps | @@ -24,12 +24,11 @@ class SnippetsFeature < Spinach::FeatureSteps | ||
24 | 24 | ||
25 | And 'I submit new snippet "Personal snippet three"' do | 25 | And 'I submit new snippet "Personal snippet three"' do |
26 | fill_in "personal_snippet_title", :with => "Personal snippet three" | 26 | fill_in "personal_snippet_title", :with => "Personal snippet three" |
27 | - select "forever", :from => "personal_snippet_expires_at" | ||
28 | fill_in "personal_snippet_file_name", :with => "my_snippet.rb" | 27 | fill_in "personal_snippet_file_name", :with => "my_snippet.rb" |
29 | within('.file-editor') do | 28 | within('.file-editor') do |
30 | find(:xpath, "//input[@id='personal_snippet_content']").set 'Content of snippet three' | 29 | find(:xpath, "//input[@id='personal_snippet_content']").set 'Content of snippet three' |
31 | end | 30 | end |
32 | - click_button "Save" | 31 | + click_button "Create snippet" |
33 | end | 32 | end |
34 | 33 | ||
35 | Then 'I should see snippet "Personal snippet three"' do | 34 | Then 'I should see snippet "Personal snippet three"' do |