create tags page and made tag filter for projects

This commit is contained in:
Aleksei Kvitinskii 2011-11-05 21:00:05 +02:00
parent 1e5aa0efff
commit 6e08b5cc85
10 changed files with 62 additions and 24 deletions

View file

@ -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: both;
}

View file

@ -0,0 +1,16 @@
.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;
}

View file

@ -10,7 +10,9 @@ class ProjectsController < ApplicationController
before_filter :require_non_empty_project, :only => [:blob, :tree]
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
def new

View file

@ -1,15 +1,11 @@
class TagsController < ApplicationController
def index
end
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}
@tags = Project.tag_counts.order('count DESC')
@tags = @tags.where('name like ?', "%#{params[:term]}%") unless params[:term].blank?
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

View file

@ -57,11 +57,8 @@
$(function(){
var tag_field = $('#tag_field').tagify();
tag_field.tagify('inputField').autocomplete({
source: '/tags/autocomplete.json',
position: { of: tag_field.tagify('containerDiv') },
close: function(event, ui) { tag_field.tagify('add'); },
source: '/tags.json'
});
@ -70,6 +67,4 @@
tag_field.val( tag_field.tagify('serialize') );
return true;
});
})

View file

@ -10,7 +10,12 @@
- @projects.each do |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= project.code
%td= check_box_tag "read", 1, project.readers.include?(current_user), :disabled => :disabled

View file

@ -1,2 +0,0 @@
%h1 Tags#autocomplete
%p Find me in app/views/tags/autocomplete.html.haml

View file

@ -1,2 +1,11 @@
%h1 Tags#index
%p Find me in app/views/tags/index.html.haml
- content_for(:body_class, "projects-page")
- content_for(:page_title) do
.grid_4
%h2
Tags
.tags-list
- @tags.all.each do |tag|
= link_to "#{tag.name}(#{tag.count})", "/tags/#{tag.name}"

View file

@ -1,6 +1,8 @@
Gitlab::Application.routes.draw do
get "tags/index"
get "tags/autocomplete"
get 'tags'=> 'tags#index'
get 'tags/:tag' => 'projects#index'
namespace :admin do
resources :users
@ -23,6 +25,7 @@ Gitlab::Application.routes.draw do
resources :projects, :only => [:new, :create, :index]
resources :keys
devise_for :users
resources :projects, :except => [:new, :create, :index], :path => "/" do

View file

@ -11,13 +11,13 @@ describe "Tags" do
# end
describe "GET '/tags/autocomplete'" do
describe "GET '/tags.json'" do
before do
@project = Factory :project
@project.add_access(@user, :read)
@project.tag_list = 'demo1'
@project.save
visit '/tags/autocomplete.json'
visit '/tags.json'
end