Commit 2c191ab0 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'improve/snippets' of /home/git/repositories/gitlab/gitlabhq

parents 98e1597f 33347efa
...@@ -75,7 +75,6 @@ ul.bordered-list { ...@@ -75,7 +75,6 @@ ul.bordered-list {
display: block; display: block;
margin: 0px; margin: 0px;
&:last-child { border:none } &:last-child { border:none }
&.active { &.active {
background: #f9f9f9; background: #f9f9f9;
a { font-weight: bold; } a { font-weight: bold; }
......
...@@ -7,3 +7,9 @@ ...@@ -7,3 +7,9 @@
} }
} }
} }
.my-snippets li:first-child {
h4 { margin-top: 0; }
padding-top: 0;
}
%li %li
.snippet-title %h4.snippet-title
- if snippet.private?
%i.icon-lock.cgreen
- else
%i.icon-globe.cblue
= link_to reliable_snippet_path(snippet) do = link_to reliable_snippet_path(snippet) do
%h5.inline = truncate(snippet.title, length: 60)
= truncate(snippet.title, length: 60) %span.cgray.monospace.tiny.pull-right
%span.cgray
= snippet.file_name = snippet.file_name
%small.pull-right.cgray %small.pull-right.cgray
...@@ -17,9 +12,10 @@ ...@@ -17,9 +12,10 @@
- else - else
Never Never
.snippet-info.prepend-left-20 .snippet-info
= "##{snippet.id}" = "##{snippet.id}"
%span.light %span
by by
= image_tag gravatar_icon(snippet.author_email), class: "avatar avatar-inline s16" = image_tag gravatar_icon(snippet.author_email), class: "avatar avatar-inline s16"
= snippet.author_name = snippet.author_name
%span.light #{time_ago_in_words(snippet.created_at)} ago
%h3.page-title %h3.page-title
%i.icon-lock.cgreen
= @snippet.title = @snippet.title
%small.pull-right %small.pull-right
......
...@@ -15,9 +15,6 @@ ...@@ -15,9 +15,6 @@
.clearfix .clearfix
= f.label "Private?" = f.label "Private?"
.input= f.check_box :private, {class: ''} .input= f.check_box :private, {class: ''}
.clearfix
= f.label "Lifetime"
.input= f.select :expires_at, lifetime_select_options, {}, {class: 'chosen span2'}
.clearfix .clearfix
.file-editor .file-editor
= f.label :file_name, "File" = f.label :file_name, "File"
...@@ -30,7 +27,11 @@ ...@@ -30,7 +27,11 @@
= f.hidden_field :content, class: 'snippet-file-content' = f.hidden_field :content, class: 'snippet-file-content'
.form-actions .form-actions
= f.submit 'Save', class: "btn-save btn" - if @snippet.new_record?
= f.submit 'Create snippet', class: "btn-create btn"
- else
= f.submit 'Save', class: "btn-save btn"
= link_to "Cancel", snippets_path(@project), class: " btn" = link_to "Cancel", snippets_path(@project), class: " btn"
- unless @snippet.new_record? - unless @snippet.new_record?
.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}" .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}"
......
%li %li
.snippet-title %h4.snippet-title
- if snippet.private?
= private_icon
- else
= public_icon
= link_to reliable_snippet_path(snippet) do = link_to reliable_snippet_path(snippet) do
%h5.inline = truncate(snippet.title, length: 60)
= truncate(snippet.title, length: 60) - if snippet.private?
%span.cgray %span.label.label-success
%i.icon-lock
private
%span.cgray.monospace.tiny.pull-right
= snippet.file_name = snippet.file_name
%small.pull-right.cgray %small.pull-right.cgray
- if snippet.project_id? - if snippet.project_id?
= link_to snippet.project.name_with_namespace, project_path(snippet.project) = link_to snippet.project.name_with_namespace, project_path(snippet.project)
%span
\|
Expires:
- if snippet.expires_at
= snippet.expires_at.to_date.to_s(:short)
- else
Never
.snippet-info.prepend-left-20 .snippet-info
= "##{snippet.id}" = "##{snippet.id}"
%span.light %span
by by
= image_tag gravatar_icon(snippet.author_email), class: "avatar avatar-inline s16", alt: '' = link_to user_snippets_path(snippet.author) do
= snippet.author_name = image_tag gravatar_icon(snippet.author_email), class: "avatar avatar-inline s16", alt: ''
= snippet.author_name
%span.light #{time_ago_in_words(snippet.created_at)} ago
...@@ -4,4 +4,4 @@ ...@@ -4,4 +4,4 @@
%li %li
%h3.nothing_here_message Nothing here. %h3.nothing_here_message Nothing here.
= paginate @snippets = paginate @snippets, theme: 'gitlab'
...@@ -19,6 +19,6 @@ ...@@ -19,6 +19,6 @@
= nav_tab :scope, 'public' do = nav_tab :scope, 'public' do
= link_to "Public", user_snippets_path(@user, scope: 'public') = link_to "Public", user_snippets_path(@user, scope: 'public')
.span9 .span9.my-snippets
= render 'snippets' = render 'snippets'
...@@ -9,7 +9,5 @@ ...@@ -9,7 +9,5 @@
My snippets My snippets
%hr %hr
.row = render 'snippets'
.span12
= render 'snippets'
%h3.page-title %h3.page-title
= @snippet.title
- if @snippet.private? - if @snippet.private?
%i{:class => "icon-lock cgreen has_bottom_tooltip", "data-original-title" => "Private snippet"} %span.label.label-success
- else %i.icon-lock
%i{:class => "icon-globe cblue has_bottom_tooltip", "data-original-title" => "Public snippet"} private
= @snippet.title .pull-right
= link_to new_snippet_path, class: "btn btn-small add_new grouped btn-primary", title: "New Snippet" do
Add new snippet
%small.pull-right
.append-bottom-20
.pull-right
= "##{@snippet.id}" = "##{@snippet.id}"
%span.light %span.light
by by
= image_tag gravatar_icon(@snippet.author_email), class: "avatar avatar-inline s16" = link_to user_snippets_path(@snippet.author) do
= @snippet.author_name = image_tag gravatar_icon(@snippet.author_email), class: "avatar avatar-inline s16"
= @snippet.author_name
.back-link
- if @snippet.author == current_user
= link_to user_snippets_path(current_user) do
← my snippets
- else
= link_to snippets_path do
← discover snippets
%div= render 'blob' %div= render 'blob'
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
%span %span
\/ \/
Snippets Snippets
%small share code pastes with others out of git repository
= link_to new_snippet_path, class: "btn btn-small add_new pull-right", title: "New Snippet" do = link_to new_snippet_path, class: "btn btn-small add_new pull-right", title: "New Snippet" do
Add new snippet Add new snippet
......
ActiveRecord::Base.observers.disable :all
Gitlab::Seeder.quiet do
contents = [
`curl https://gist.github.com/randx/4275756/raw/da2f262920c96d1a970d48bf2e99147954b1f4bd/glus1204.sh`,
`curl https://gist.github.com/randx/3754594/raw/11026a295e6ef3a151c635707a3e1e8e15fc4725/gitlab_setup.sh `,
`curl https://gist.github.com/randx/3065552/raw/29fbd09f4605a5ea22a5a9095e35fd1938dea4d6/gistfile1.sh`,
]
(1..50).each do |i|
user = User.all.sample
PersonalSnippet.seed(:id, [{
id: i,
author_id: user.id,
title: Faker::Lorem.sentence(3),
file_name: Faker::Internet.domain_word + '.sh',
private: [true, false].sample,
content: contents.sample,
}])
print('.')
end
end
...@@ -24,12 +24,11 @@ class SnippetsFeature < Spinach::FeatureSteps ...@@ -24,12 +24,11 @@ class SnippetsFeature < Spinach::FeatureSteps
And 'I submit new snippet "Personal snippet three"' do And 'I submit new snippet "Personal snippet three"' do
fill_in "personal_snippet_title", :with => "Personal snippet three" fill_in "personal_snippet_title", :with => "Personal snippet three"
select "forever", :from => "personal_snippet_expires_at"
fill_in "personal_snippet_file_name", :with => "my_snippet.rb" fill_in "personal_snippet_file_name", :with => "my_snippet.rb"
within('.file-editor') do within('.file-editor') do
find(:xpath, "//input[@id='personal_snippet_content']").set 'Content of snippet three' find(:xpath, "//input[@id='personal_snippet_content']").set 'Content of snippet three'
end end
click_button "Save" click_button "Create snippet"
end end
Then 'I should see snippet "Personal snippet three"' do Then 'I should see snippet "Personal snippet three"' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment