summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-07-18 11:12:01 +0000
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2013-07-18 11:12:01 +0000
commit2c191ab06c61b839c3addf6b2f7e5660675908a2 (patch)
tree66b9a7d1c556917a41ee5c35b87e0a55e02767ab
parent98e1597f8c4a3c55018a8d1f29a8462d2404dadf (diff)
parent33347efa26857243c9e61d4c89d1c4631244c5be (diff)
downloadgitlab-ce-2c191ab06c61b839c3addf6b2f7e5660675908a2.tar.gz
Merge branch 'improve/snippets' of /home/git/repositories/gitlab/gitlabhq
-rw-r--r--app/assets/stylesheets/gitlab_bootstrap/lists.scss1
-rw-r--r--app/assets/stylesheets/sections/snippets.scss6
-rw-r--r--app/views/projects/snippets/_snippet.html.haml16
-rw-r--r--app/views/projects/snippets/show.html.haml1
-rw-r--r--app/views/snippets/_form.html.haml9
-rw-r--r--app/views/snippets/_snippet.html.haml33
-rw-r--r--app/views/snippets/_snippets.html.haml2
-rw-r--r--app/views/snippets/current_user_index.html.haml2
-rw-r--r--app/views/snippets/index.html.haml4
-rw-r--r--app/views/snippets/show.html.haml30
-rw-r--r--app/views/snippets/user_index.html.haml1
-rw-r--r--db/fixtures/development/12_snippets.rb24
-rw-r--r--features/steps/snippets/snippets.rb3
13 files changed, 81 insertions, 51 deletions
diff --git a/app/assets/stylesheets/gitlab_bootstrap/lists.scss b/app/assets/stylesheets/gitlab_bootstrap/lists.scss
index 0fa4da44de5..cc7084d27d5 100644
--- a/app/assets/stylesheets/gitlab_bootstrap/lists.scss
+++ b/app/assets/stylesheets/gitlab_bootstrap/lists.scss
@@ -75,7 +75,6 @@ ul.bordered-list {
display: block;
margin: 0px;
&:last-child { border:none }
-
&.active {
background: #f9f9f9;
a { font-weight: bold; }
diff --git a/app/assets/stylesheets/sections/snippets.scss b/app/assets/stylesheets/sections/snippets.scss
index feeca655cb1..7dab0bfe014 100644
--- a/app/assets/stylesheets/sections/snippets.scss
+++ b/app/assets/stylesheets/sections/snippets.scss
@@ -7,3 +7,9 @@
}
}
}
+
+.my-snippets li:first-child {
+ h4 { margin-top: 0; }
+ padding-top: 0;
+}
+
diff --git a/app/views/projects/snippets/_snippet.html.haml b/app/views/projects/snippets/_snippet.html.haml
index 72865bf2872..fc1c0893b08 100644
--- a/app/views/projects/snippets/_snippet.html.haml
+++ b/app/views/projects/snippets/_snippet.html.haml
@@ -1,13 +1,8 @@
%li
- .snippet-title
- - if snippet.private?
- %i.icon-lock.cgreen
- - else
- %i.icon-globe.cblue
+ %h4.snippet-title
= link_to reliable_snippet_path(snippet) do
- %h5.inline
- = truncate(snippet.title, length: 60)
- %span.cgray
+ = truncate(snippet.title, length: 60)
+ %span.cgray.monospace.tiny.pull-right
= snippet.file_name
%small.pull-right.cgray
@@ -17,9 +12,10 @@
- else
Never
- .snippet-info.prepend-left-20
+ .snippet-info
= "##{snippet.id}"
- %span.light
+ %span
by
= image_tag gravatar_icon(snippet.author_email), class: "avatar avatar-inline s16"
= snippet.author_name
+ %span.light #{time_ago_in_words(snippet.created_at)} ago
diff --git a/app/views/projects/snippets/show.html.haml b/app/views/projects/snippets/show.html.haml
index 564c2e8b72c..4a07ebf7fd9 100644
--- a/app/views/projects/snippets/show.html.haml
+++ b/app/views/projects/snippets/show.html.haml
@@ -1,5 +1,4 @@
%h3.page-title
- %i.icon-lock.cgreen
= @snippet.title
%small.pull-right
diff --git a/app/views/snippets/_form.html.haml b/app/views/snippets/_form.html.haml
index 05502503bee..e5c63afe980 100644
--- a/app/views/snippets/_form.html.haml
+++ b/app/views/snippets/_form.html.haml
@@ -16,9 +16,6 @@
= f.label "Private?"
.input= f.check_box :private, {class: ''}
.clearfix
- = f.label "Lifetime"
- .input= f.select :expires_at, lifetime_select_options, {}, {class: 'chosen span2'}
- .clearfix
.file-editor
= f.label :file_name, "File"
.input
@@ -30,7 +27,11 @@
= f.hidden_field :content, class: 'snippet-file-content'
.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"
- 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}"
diff --git a/app/views/snippets/_snippet.html.haml b/app/views/snippets/_snippet.html.haml
index a013cdfe16a..9689c9c4d38 100644
--- a/app/views/snippets/_snippet.html.haml
+++ b/app/views/snippets/_snippet.html.haml
@@ -1,30 +1,23 @@
%li
- .snippet-title
- - if snippet.private?
- = private_icon
- - else
- = public_icon
+ %h4.snippet-title
= link_to reliable_snippet_path(snippet) do
- %h5.inline
- = truncate(snippet.title, length: 60)
- %span.cgray
+ = truncate(snippet.title, length: 60)
+ - if snippet.private?
+ %span.label.label-success
+ %i.icon-lock
+ private
+ %span.cgray.monospace.tiny.pull-right
= snippet.file_name
%small.pull-right.cgray
- if snippet.project_id?
= 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}"
- %span.light
+ %span
by
- = image_tag gravatar_icon(snippet.author_email), class: "avatar avatar-inline s16", alt: ''
- = snippet.author_name
-
+ = link_to user_snippets_path(snippet.author) do
+ = 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
diff --git a/app/views/snippets/_snippets.html.haml b/app/views/snippets/_snippets.html.haml
index 636bf37f6d9..05365dd8b88 100644
--- a/app/views/snippets/_snippets.html.haml
+++ b/app/views/snippets/_snippets.html.haml
@@ -4,4 +4,4 @@
%li
%h3.nothing_here_message Nothing here.
-= paginate @snippets
+= paginate @snippets, theme: 'gitlab'
diff --git a/app/views/snippets/current_user_index.html.haml b/app/views/snippets/current_user_index.html.haml
index 1d9b60f7331..b60026f4584 100644
--- a/app/views/snippets/current_user_index.html.haml
+++ b/app/views/snippets/current_user_index.html.haml
@@ -19,6 +19,6 @@
= nav_tab :scope, 'public' do
= link_to "Public", user_snippets_path(@user, scope: 'public')
- .span9
+ .span9.my-snippets
= render 'snippets'
diff --git a/app/views/snippets/index.html.haml b/app/views/snippets/index.html.haml
index 1502a6698fe..c65ed4fb9df 100644
--- a/app/views/snippets/index.html.haml
+++ b/app/views/snippets/index.html.haml
@@ -9,7 +9,5 @@
My snippets
%hr
-.row
- .span12
- = render 'snippets'
+= render 'snippets'
diff --git a/app/views/snippets/show.html.haml b/app/views/snippets/show.html.haml
index b112511a880..5cf1fefe5f0 100644
--- a/app/views/snippets/show.html.haml
+++ b/app/views/snippets/show.html.haml
@@ -1,15 +1,31 @@
%h3.page-title
+ = @snippet.title
+
- if @snippet.private?
- %i{:class => "icon-lock cgreen has_bottom_tooltip", "data-original-title" => "Private snippet"}
- - else
- %i{:class => "icon-globe cblue has_bottom_tooltip", "data-original-title" => "Public snippet"}
+ %span.label.label-success
+ %i.icon-lock
+ 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}"
%span.light
by
- = image_tag gravatar_icon(@snippet.author_email), class: "avatar avatar-inline s16"
- = @snippet.author_name
+ = link_to user_snippets_path(@snippet.author) do
+ = 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
+ &larr; my snippets
+ - else
+ = link_to snippets_path do
+ &larr; discover snippets
+
%div= render 'blob'
diff --git a/app/views/snippets/user_index.html.haml b/app/views/snippets/user_index.html.haml
index a9563b75e79..49636c3f5f0 100644
--- a/app/views/snippets/user_index.html.haml
+++ b/app/views/snippets/user_index.html.haml
@@ -4,7 +4,6 @@
%span
\/
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
Add new snippet
diff --git a/db/fixtures/development/12_snippets.rb b/db/fixtures/development/12_snippets.rb
new file mode 100644
index 00000000000..4ca8afe294e
--- /dev/null
+++ b/db/fixtures/development/12_snippets.rb
@@ -0,0 +1,24 @@
+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
+
diff --git a/features/steps/snippets/snippets.rb b/features/steps/snippets/snippets.rb
index d21ce9334e7..bbdf5b97c84 100644
--- a/features/steps/snippets/snippets.rb
+++ b/features/steps/snippets/snippets.rb
@@ -24,12 +24,11 @@ class SnippetsFeature < Spinach::FeatureSteps
And 'I submit new snippet "Personal snippet three"' do
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"
within('.file-editor') do
find(:xpath, "//input[@id='personal_snippet_content']").set 'Content of snippet three'
end
- click_button "Save"
+ click_button "Create snippet"
end
Then 'I should see snippet "Personal snippet three"' do