diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 0caeafa..83b1bdf 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -1,5 +1,10 @@ class TagsController < ApplicationController def index - return render :json => Tag.active.all + @tags = Tag.all_with_story_counts_for(nil) + + respond_to do |format| + format.html { render :action => "index" } + format.json { render :json => @tags } + end end end diff --git a/app/views/tags/index.html.erb b/app/views/tags/index.html.erb new file mode 100644 index 0000000..1310c9c --- /dev/null +++ b/app/views/tags/index.html.erb @@ -0,0 +1,13 @@ +
+
+ Tags +
+ + <% max_size = @tags.map{|t| t.stories_count }.max %> + <% @tags.each do |tag| %> + <% mod = (max_size.to_f / tag.stories_count.to_f) %> + <%= link_to tag.tag, tag_path(tag), :class => tag.css_class, + :style => "text-decoration: none; vertical-align: middle; " << + "font-size: #{((52 / (mod + 1)) + 8).ceil}pt; line-height: 1.5em;" %> + <% end %> +
diff --git a/config/routes.rb b/config/routes.rb index 89a6b60..a97cb18 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -106,6 +106,7 @@ Lobsters::Application.routes.draw do get "/filters" => "filters#index" post "/filters" => "filters#update" + get "/tags" => "tags#index" get "/tags.json" => "tags#index", :format => "json" post "/invitations" => "invitations#create"