Skip to content

Commit

Permalink
Added tagcloud to homepage. Updated associated styles and specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
igal committed Oct 30, 2010
1 parent 217079d commit da5e50d
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 4 deletions.
1 change: 1 addition & 0 deletions app/controllers/site_controller.rb
Expand Up @@ -11,6 +11,7 @@ def hello

def index
@times_to_events_deferred = lambda { Event.select_for_overview }
@tagcloud_items_deferred = lambda { Tag.for_tagcloud }
end

# Displays the about page.
Expand Down
19 changes: 17 additions & 2 deletions app/views/site/index.html.erb
Expand Up @@ -2,8 +2,23 @@
<% cache(CacheObserver.daily_key_for("site_index", request)) do %>
<% @times_to_events ||= @times_to_events_deferred.call %>
<div id="project_description">
<%= render :partial => "description" %>
<div id="homepage_sidebar">
<div id="project_description">
<%= render :partial => "description" %>
</div>

<div id="tagcloud">
<h2>Popular tags</h2>
<%- @tagcloud_items_deferred.call.tap do |items| -%>
<%- items.each_with_index do |item, i| -%>
<%# Clicking a tag does a tag-specific search: %>
<%= tag_link(:event, item[:tag], "tagcloud_level_#{item[:level]}") -%>
<%# Or clicking a tag does a normal search that happens to rank tags highly, but may return fuzzy matches: %>
<%#= link_to(item[:tag].name, search_events_path(:query => item[:tag].name), :class => "tagcloud_level_#{item[:level]}") %>
<%- unless i == items.length-1 -%><span class="spacer">&middot;</span><%- end -%>
<%- end -%>
<%- end -%>
</div>
</div>

<div id="whats_happening">
Expand Down
14 changes: 14 additions & 0 deletions spec/views/site/index_spec.rb
Expand Up @@ -14,12 +14,26 @@
:later => [@day_after_tomorrow],
}

@tagcloud_items = [
{:tag => Tag.create(:name => "foo"), :level => 1},
{:tag => Tag.create(:name => "bar"), :level => 2},
{:tag => Tag.create(:name => "baz"), :level => 3},
]

assigns[:times_to_events_deferred] = lambda { @times_to_events }
assigns[:tagcloud_items_deferred] = lambda { @tagcloud_items }
end

it "should render valid XHTML" do
render "/site/index"
response.should be_valid_xhtml_fragment

response.should have_tag("#coming_events a[href=#{event_url(@codesprint)}]", @codesprint.title)
response.should have_tag("#coming_events a[href=#{@codesprint.url}]")

response.should have_tag('#tagcloud')
response.should have_tag('#tagcloud a', 3)
response.should have_tag('#tagcloud a[href="/events/search?tag=baz"][class="tagcloud_level_3"]')
end

end
Expand Down
16 changes: 15 additions & 1 deletion themes/default/stylesheets/layout.css
Expand Up @@ -390,7 +390,6 @@ fieldset .help {
padding: 1em;
width: 20em;
margin: 0 2em 0 -1em;
float: left;
}

#project_description a {
Expand All @@ -402,6 +401,21 @@ fieldset .help {
margin-bottom: .5em;
}

#tagcloud {
padding: 1em;
width: 20em;
margin: 0 2em 0 -1em;
}

#tagcloud h2 {
font-weight: bold;
margin-bottom: .5em;
}

#homepage_sidebar {
float: left;
}


/* @end */

Expand Down
10 changes: 9 additions & 1 deletion themes/default/stylesheets/typography.css
Expand Up @@ -206,4 +206,12 @@ a.external.upcoming { background-image: url("/images/external_sites/upcoming.p
a.external.yelp { background-image: url("/images/external_sites/yelp.png"); }
a.external.shizzow { background-image: url("/images/external_sites/shizzow.png"); }
a.external.foursquare { background-image: url("/images/external_sites/foursquare.png"); }
a.external.gowalla { background-image: url("/images/external_sites/gowalla.png"); }
a.external.gowalla { background-image: url("/images/external_sites/gowalla.png"); }

#tagcloud .tagcloud_level_1 { font-size: 75%; }
#tagcloud .tagcloud_level_2 { font-size: 100%; }
#tagcloud .tagcloud_level_3 { font-size: 125%; }
#tagcloud .tagcloud_level_4 { font-size: 150%; }
#tagcloud .tagcloud_level_5 { font-size: 200%; }

#tagcloud .spacer { color: gray }

0 comments on commit da5e50d

Please sign in to comment.