Commit 6e08b5cc857b3b218df0b20745ad295e79abc722
1 parent
1e5aa0ef
Exists in
master
and in
4 other branches
create tags page and made tag filter for projects
Showing
10 changed files
with
62 additions
and
24 deletions
Show diff stats
app/assets/stylesheets/projects.css.scss
@@ -270,6 +270,20 @@ input.ssh_project_url { | @@ -270,6 +270,20 @@ input.ssh_project_url { | ||
270 | } | 270 | } |
271 | } | 271 | } |
272 | 272 | ||
273 | +#projects-list .small-tags a{ | ||
274 | + font-size: 9px; | ||
275 | + | ||
276 | + display: inline-block; | ||
277 | + padding: 2px 3px 1px 3px; | ||
278 | + margin: 0px 3px 0px 0px; | ||
279 | + border-radius: 2px; | ||
280 | + background-color: #3b6bce; | ||
281 | + color: #FFF; | ||
282 | + text-shadow: none; | ||
283 | + font-weight: bold; | ||
284 | +} | ||
285 | + | ||
286 | + | ||
273 | .clear { | 287 | .clear { |
274 | clear: both; | 288 | clear: both; |
275 | } | 289 | } |
@@ -0,0 +1,16 @@ | @@ -0,0 +1,16 @@ | ||
1 | +.tags-list { | ||
2 | + padding : 0px 10px 10px 10px; | ||
3 | + | ||
4 | +} | ||
5 | + | ||
6 | +.tags-list a { | ||
7 | + display: inline-block; | ||
8 | + padding: 8px 11px 8px 11px; | ||
9 | + margin: 1px 5px 0px 0px; | ||
10 | + border-radius: 4px; | ||
11 | + border: 1px solid #d0e1ff; | ||
12 | + background-color: #d0e1ff; | ||
13 | + color: #0f326d; | ||
14 | + font-weight: bold; | ||
15 | + font-size: 14px; | ||
16 | +} | ||
0 | \ No newline at end of file | 17 | \ No newline at end of file |
app/controllers/projects_controller.rb
@@ -10,7 +10,9 @@ class ProjectsController < ApplicationController | @@ -10,7 +10,9 @@ class ProjectsController < ApplicationController | ||
10 | before_filter :require_non_empty_project, :only => [:blob, :tree] | 10 | before_filter :require_non_empty_project, :only => [:blob, :tree] |
11 | 11 | ||
12 | def index | 12 | def index |
13 | - @projects = current_user.projects.all | 13 | + source = current_user.projects |
14 | + source = source.tagged_with(params[:tag]) unless params[:tag].blank? | ||
15 | + @projects = source.all | ||
14 | end | 16 | end |
15 | 17 | ||
16 | def new | 18 | def new |
app/controllers/tags_controller.rb
1 | class TagsController < ApplicationController | 1 | class TagsController < ApplicationController |
2 | def index | 2 | def index |
3 | - end | ||
4 | - | ||
5 | - def autocomplete | ||
6 | - tags = Project.tag_counts.limit 8 | ||
7 | - tags = tags.where('name like ?', "%#{params[:term]}%") unless params[:term].blank? | ||
8 | - tags = tags.map {|t| t.name} | 3 | + @tags = Project.tag_counts.order('count DESC') |
4 | + @tags = @tags.where('name like ?', "%#{params[:term]}%") unless params[:term].blank? | ||
9 | 5 | ||
10 | respond_to do |format| | 6 | respond_to do |format| |
11 | - format.json { render json: tags} | 7 | + format.html |
8 | + format.json { render json: @tags.limit(8).map {|t| t.name}} | ||
12 | end | 9 | end |
13 | end | 10 | end |
14 | - | ||
15 | end | 11 | end |
app/views/projects/_form.html.haml
@@ -57,11 +57,8 @@ | @@ -57,11 +57,8 @@ | ||
57 | $(function(){ | 57 | $(function(){ |
58 | var tag_field = $('#tag_field').tagify(); | 58 | var tag_field = $('#tag_field').tagify(); |
59 | 59 | ||
60 | - | ||
61 | tag_field.tagify('inputField').autocomplete({ | 60 | tag_field.tagify('inputField').autocomplete({ |
62 | - source: '/tags/autocomplete.json', | ||
63 | - position: { of: tag_field.tagify('containerDiv') }, | ||
64 | - close: function(event, ui) { tag_field.tagify('add'); }, | 61 | + source: '/tags.json' |
65 | }); | 62 | }); |
66 | 63 | ||
67 | 64 | ||
@@ -70,6 +67,4 @@ | @@ -70,6 +67,4 @@ | ||
70 | tag_field.val( tag_field.tagify('serialize') ); | 67 | tag_field.val( tag_field.tagify('serialize') ); |
71 | return true; | 68 | return true; |
72 | }); | 69 | }); |
73 | - | ||
74 | - | ||
75 | }) | 70 | }) |
app/views/projects/_list.html.haml
@@ -10,7 +10,12 @@ | @@ -10,7 +10,12 @@ | ||
10 | 10 | ||
11 | - @projects.each do |project| | 11 | - @projects.each do |project| |
12 | %tr{ :class => "project", :url => project_path(project) } | 12 | %tr{ :class => "project", :url => project_path(project) } |
13 | - %td= project.name | 13 | + %td |
14 | + = project.name | ||
15 | + .small-tags | ||
16 | + - project.tag_list.each do |tag| | ||
17 | + = link_to tag, "/tags/#{tag}" | ||
18 | + | ||
14 | %td= truncate project.url_to_repo | 19 | %td= truncate project.url_to_repo |
15 | %td= project.code | 20 | %td= project.code |
16 | %td= check_box_tag "read", 1, project.readers.include?(current_user), :disabled => :disabled | 21 | %td= check_box_tag "read", 1, project.readers.include?(current_user), :disabled => :disabled |
app/views/tags/autocomplete.html.haml
app/views/tags/index.html.haml
1 | -%h1 Tags#index | ||
2 | -%p Find me in app/views/tags/index.html.haml | ||
3 | \ No newline at end of file | 1 | \ No newline at end of file |
2 | +- content_for(:body_class, "projects-page") | ||
3 | +- content_for(:page_title) do | ||
4 | + .grid_4 | ||
5 | + %h2 | ||
6 | + Tags | ||
7 | + | ||
8 | + | ||
9 | + .tags-list | ||
10 | + - @tags.all.each do |tag| | ||
11 | + = link_to "#{tag.name}(#{tag.count})", "/tags/#{tag.name}" | ||
12 | + |
config/routes.rb
1 | Gitlab::Application.routes.draw do | 1 | Gitlab::Application.routes.draw do |
2 | - get "tags/index" | ||
3 | - get "tags/autocomplete" | 2 | + |
3 | + get 'tags'=> 'tags#index' | ||
4 | + get 'tags/:tag' => 'projects#index' | ||
5 | + | ||
4 | 6 | ||
5 | namespace :admin do | 7 | namespace :admin do |
6 | resources :users | 8 | resources :users |
@@ -23,6 +25,7 @@ Gitlab::Application.routes.draw do | @@ -23,6 +25,7 @@ Gitlab::Application.routes.draw do | ||
23 | 25 | ||
24 | resources :projects, :only => [:new, :create, :index] | 26 | resources :projects, :only => [:new, :create, :index] |
25 | resources :keys | 27 | resources :keys |
28 | + | ||
26 | devise_for :users | 29 | devise_for :users |
27 | 30 | ||
28 | resources :projects, :except => [:new, :create, :index], :path => "/" do | 31 | resources :projects, :except => [:new, :create, :index], :path => "/" do |
spec/requests/tags_spec.rb
@@ -11,13 +11,13 @@ describe "Tags" do | @@ -11,13 +11,13 @@ describe "Tags" do | ||
11 | # end | 11 | # end |
12 | 12 | ||
13 | 13 | ||
14 | - describe "GET '/tags/autocomplete'" do | 14 | + describe "GET '/tags.json'" do |
15 | before do | 15 | before do |
16 | @project = Factory :project | 16 | @project = Factory :project |
17 | @project.add_access(@user, :read) | 17 | @project.add_access(@user, :read) |
18 | @project.tag_list = 'demo1' | 18 | @project.tag_list = 'demo1' |
19 | @project.save | 19 | @project.save |
20 | - visit '/tags/autocomplete.json' | 20 | + visit '/tags.json' |
21 | end | 21 | end |
22 | 22 | ||
23 | 23 |