add a tag cloud thingy

closes #236
This commit is contained in:
joshua stein 2015-11-09 09:52:32 -06:00
parent 4fb0e7deb5
commit 09fd14dd93
3 changed files with 20 additions and 1 deletions

View file

@ -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

View file

@ -0,0 +1,13 @@
<div class="box wide">
<div class="legend">
Tags
</div>
<% 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 %>
</div>

View file

@ -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"