Commit 2c191ab06c61b839c3addf6b2f7e5660675908a2
Exists in
master
and in
4 other branches
Merge branch 'improve/snippets' of /home/git/repositories/gitlab/gitlabhq
Showing
13 changed files
with
81 additions
and
51 deletions
Show diff stats
app/assets/stylesheets/gitlab_bootstrap/lists.scss
app/assets/stylesheets/sections/snippets.scss
app/views/projects/snippets/_snippet.html.haml
1 | 1 | %li |
2 | - .snippet-title | |
3 | - - if snippet.private? | |
4 | - %i.icon-lock.cgreen | |
5 | - - else | |
6 | - %i.icon-globe.cblue | |
2 | + %h4.snippet-title | |
7 | 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 | + %span.cgray.monospace.tiny.pull-right | |
11 | 6 | = snippet.file_name |
12 | 7 | |
13 | 8 | %small.pull-right.cgray |
... | ... | @@ -17,9 +12,10 @@ |
17 | 12 | - else |
18 | 13 | Never |
19 | 14 | |
20 | - .snippet-info.prepend-left-20 | |
15 | + .snippet-info | |
21 | 16 | = "##{snippet.id}" |
22 | - %span.light | |
17 | + %span | |
23 | 18 | by |
24 | 19 | = image_tag gravatar_icon(snippet.author_email), class: "avatar avatar-inline s16" |
25 | 20 | = snippet.author_name |
21 | + %span.light #{time_ago_in_words(snippet.created_at)} ago | ... | ... |
app/views/projects/snippets/show.html.haml
app/views/snippets/_form.html.haml
... | ... | @@ -16,9 +16,6 @@ |
16 | 16 | = f.label "Private?" |
17 | 17 | .input= f.check_box :private, {class: ''} |
18 | 18 | .clearfix |
19 | - = f.label "Lifetime" | |
20 | - .input= f.select :expires_at, lifetime_select_options, {}, {class: 'chosen span2'} | |
21 | - .clearfix | |
22 | 19 | .file-editor |
23 | 20 | = f.label :file_name, "File" |
24 | 21 | .input |
... | ... | @@ -30,7 +27,11 @@ |
30 | 27 | = f.hidden_field :content, class: 'snippet-file-content' |
31 | 28 | |
32 | 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 | 35 | = link_to "Cancel", snippets_path(@project), class: " btn" |
35 | 36 | - unless @snippet.new_record? |
36 | 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 | 1 | %li |
2 | - .snippet-title | |
3 | - - if snippet.private? | |
4 | - = private_icon | |
5 | - - else | |
6 | - = public_icon | |
2 | + %h4.snippet-title | |
7 | 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 | 10 | = snippet.file_name |
12 | 11 | |
13 | 12 | %small.pull-right.cgray |
14 | 13 | - if snippet.project_id? |
15 | 14 | = link_to snippet.project.name_with_namespace, project_path(snippet.project) |
16 | - %span | |
17 | - \| | |
18 | - Expires: | |
19 | - - if snippet.expires_at | |
20 | - = snippet.expires_at.to_date.to_s(:short) | |
21 | - - else | |
22 | - Never | |
23 | 15 | |
24 | - .snippet-info.prepend-left-20 | |
16 | + .snippet-info | |
25 | 17 | = "##{snippet.id}" |
26 | - %span.light | |
18 | + %span | |
27 | 19 | by |
28 | - = image_tag gravatar_icon(snippet.author_email), class: "avatar avatar-inline s16", alt: '' | |
29 | - = snippet.author_name | |
30 | - | |
20 | + = link_to user_snippets_path(snippet.author) do | |
21 | + = image_tag gravatar_icon(snippet.author_email), class: "avatar avatar-inline s16", alt: '' | |
22 | + = snippet.author_name | |
23 | + %span.light #{time_ago_in_words(snippet.created_at)} ago | ... | ... |
app/views/snippets/_snippets.html.haml
app/views/snippets/current_user_index.html.haml
app/views/snippets/index.html.haml
app/views/snippets/show.html.haml
1 | 1 | %h3.page-title |
2 | + = @snippet.title | |
3 | + | |
2 | 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 | 16 | = "##{@snippet.id}" |
11 | 17 | %span.light |
12 | 18 | by |
13 | - = image_tag gravatar_icon(@snippet.author_email), class: "avatar avatar-inline s16" | |
14 | - = @snippet.author_name | |
19 | + = link_to user_snippets_path(@snippet.author) do | |
20 | + = image_tag gravatar_icon(@snippet.author_email), class: "avatar avatar-inline s16" | |
21 | + = @snippet.author_name | |
22 | + | |
23 | + .back-link | |
24 | + - if @snippet.author == current_user | |
25 | + = link_to user_snippets_path(current_user) do | |
26 | + ← my snippets | |
27 | + - else | |
28 | + = link_to snippets_path do | |
29 | + ← discover snippets | |
30 | + | |
15 | 31 | %div= render 'blob' | ... | ... |
app/views/snippets/user_index.html.haml
... | ... | @@ -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(3), | |
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 | 24 | |
25 | 25 | And 'I submit new snippet "Personal snippet three"' do |
26 | 26 | fill_in "personal_snippet_title", :with => "Personal snippet three" |
27 | - select "forever", :from => "personal_snippet_expires_at" | |
28 | 27 | fill_in "personal_snippet_file_name", :with => "my_snippet.rb" |
29 | 28 | within('.file-editor') do |
30 | 29 | find(:xpath, "//input[@id='personal_snippet_content']").set 'Content of snippet three' |
31 | 30 | end |
32 | - click_button "Save" | |
31 | + click_button "Create snippet" | |
33 | 32 | end |
34 | 33 | |
35 | 34 | Then 'I should see snippet "Personal snippet three"' do | ... | ... |