Commit 6e08b5cc authored by Aleksei Kvitinskii's avatar Aleksei Kvitinskii

create tags page and made tag filter for projects

parent 1e5aa0ef
...@@ -270,6 +270,20 @@ input.ssh_project_url { ...@@ -270,6 +270,20 @@ input.ssh_project_url {
} }
} }
#projects-list .small-tags a{
font-size: 9px;
display: inline-block;
padding: 2px 3px 1px 3px;
margin: 0px 3px 0px 0px;
border-radius: 2px;
background-color: #3b6bce;
color: #FFF;
text-shadow: none;
font-weight: bold;
}
.clear { .clear {
clear: both; clear: both;
} }
......
.tags-list {
padding : 0px 10px 10px 10px;
}
.tags-list a {
display: inline-block;
padding: 8px 11px 8px 11px;
margin: 1px 5px 0px 0px;
border-radius: 4px;
border: 1px solid #d0e1ff;
background-color: #d0e1ff;
color: #0f326d;
font-weight: bold;
font-size: 14px;
}
\ No newline at end of file
...@@ -10,7 +10,9 @@ class ProjectsController < ApplicationController ...@@ -10,7 +10,9 @@ class ProjectsController < ApplicationController
before_filter :require_non_empty_project, :only => [:blob, :tree] before_filter :require_non_empty_project, :only => [:blob, :tree]
def index def index
@projects = current_user.projects.all source = current_user.projects
source = source.tagged_with(params[:tag]) unless params[:tag].blank?
@projects = source.all
end end
def new def new
......
class TagsController < ApplicationController class TagsController < ApplicationController
def index def index
end @tags = Project.tag_counts.order('count DESC')
@tags = @tags.where('name like ?', "%#{params[:term]}%") unless params[:term].blank?
def autocomplete
tags = Project.tag_counts.limit 8
tags = tags.where('name like ?', "%#{params[:term]}%") unless params[:term].blank?
tags = tags.map {|t| t.name}
respond_to do |format| respond_to do |format|
format.json { render json: tags} format.html
format.json { render json: @tags.limit(8).map {|t| t.name}}
end end
end end
end end
...@@ -57,11 +57,8 @@ ...@@ -57,11 +57,8 @@
$(function(){ $(function(){
var tag_field = $('#tag_field').tagify(); var tag_field = $('#tag_field').tagify();
tag_field.tagify('inputField').autocomplete({ tag_field.tagify('inputField').autocomplete({
source: '/tags/autocomplete.json', source: '/tags.json'
position: { of: tag_field.tagify('containerDiv') },
close: function(event, ui) { tag_field.tagify('add'); },
}); });
...@@ -70,6 +67,4 @@ ...@@ -70,6 +67,4 @@
tag_field.val( tag_field.tagify('serialize') ); tag_field.val( tag_field.tagify('serialize') );
return true; return true;
}); });
}) })
...@@ -10,7 +10,12 @@ ...@@ -10,7 +10,12 @@
- @projects.each do |project| - @projects.each do |project|
%tr{ :class => "project", :url => project_path(project) } %tr{ :class => "project", :url => project_path(project) }
%td= project.name %td
= project.name
.small-tags
- project.tag_list.each do |tag|
= link_to tag, "/tags/#{tag}"
%td= truncate project.url_to_repo %td= truncate project.url_to_repo
%td= project.code %td= project.code
%td= check_box_tag "read", 1, project.readers.include?(current_user), :disabled => :disabled %td= check_box_tag "read", 1, project.readers.include?(current_user), :disabled => :disabled
......
%h1 Tags#autocomplete
%p Find me in app/views/tags/autocomplete.html.haml
\ No newline at end of file
%h1 Tags#index - content_for(:body_class, "projects-page")
%p Find me in app/views/tags/index.html.haml - content_for(:page_title) do
\ No newline at end of file .grid_4
%h2
Tags
.tags-list
- @tags.all.each do |tag|
= link_to "#{tag.name}(#{tag.count})", "/tags/#{tag.name}"
Gitlab::Application.routes.draw do Gitlab::Application.routes.draw do
get "tags/index"
get "tags/autocomplete" get 'tags'=> 'tags#index'
get 'tags/:tag' => 'projects#index'
namespace :admin do namespace :admin do
resources :users resources :users
...@@ -23,6 +25,7 @@ Gitlab::Application.routes.draw do ...@@ -23,6 +25,7 @@ Gitlab::Application.routes.draw do
resources :projects, :only => [:new, :create, :index] resources :projects, :only => [:new, :create, :index]
resources :keys resources :keys
devise_for :users devise_for :users
resources :projects, :except => [:new, :create, :index], :path => "/" do resources :projects, :except => [:new, :create, :index], :path => "/" do
......
...@@ -11,13 +11,13 @@ describe "Tags" do ...@@ -11,13 +11,13 @@ describe "Tags" do
# end # end
describe "GET '/tags/autocomplete'" do describe "GET '/tags.json'" do
before do before do
@project = Factory :project @project = Factory :project
@project.add_access(@user, :read) @project.add_access(@user, :read)
@project.tag_list = 'demo1' @project.tag_list = 'demo1'
@project.save @project.save
visit '/tags/autocomplete.json' visit '/tags.json'
end end
......
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