Skip to content

Commit 40da8e6

Browse files
author
Rahoul Baruah
committed
switcched off page caching, uses fragment caching on the home page
1 parent 1c86466 commit 40da8e6

File tree

6 files changed

+46
-52
lines changed

6 files changed

+46
-52
lines changed

app/controllers/code_and_comment_sweeper.rb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ def after_destroy code_or_comment
1111

1212
private
1313
def expire code_or_comment
14-
slug = code_or_comment.slug_name
15-
`rm #{RAILS_ROOT}/public/cache/index.html`
16-
`rm #{RAILS_ROOT}/public/cache/#{slug}.html`
14+
expire_fragment :controller => 'home', :action => 'show'
1715
end
1816
end

app/controllers/codes_controller.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
class CodesController < ApplicationController
2-
caches_page :show
3-
42
def index
3+
@page_title = "Community-powered gem compatibility for ruby 1.9"
54
if params[:s].blank?
65
@codes = Code.paginate(:per_page => 30, :page => params[:page], :include => [:working_comments, :failure_comments], :order => 'name')
76
else
@@ -13,7 +12,8 @@ def index
1312
end
1413

1514
def show
16-
@code = Code.find_by_slug_name!(params[:slug_name])
15+
@code = Code.find_by_slug_name!(params[:slug_name], :include => :comments)
16+
@page_title = "#{@code.name} gem ruby 1.9 compatibility"
1717
@comment = Comment.new
1818

1919
rescue ActiveRecord::RecordNotFound

app/controllers/home_controller.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
class HomeController < ApplicationController
2-
caches_page :show
3-
42
def show
5-
@latest_feedback = Comment.latest.all(:limit => 5)
6-
@popular = Code.popular.all(:limit => 15)
7-
@unpopular = Code.unpopular.all(:limit => 5)
3+
@page_title = 'Community-powered gem compatibility for ruby 1.9'
4+
unless read_fragment :controller => 'home', :action => 'show'
5+
@latest_feedback = Comment.latest.all(:limit => 5)
6+
@popular = Code.popular.all(:limit => 15)
7+
@unpopular = Code.unpopular.all(:limit => 5)
8+
end
89
end
910
end

app/views/codes/index.html.erb

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
<% @page_title = "Community-powered gem compatibility for ruby 1.9" %>
2-
31
<%= will_paginate @codes, :separator => '&bull;' %>
42
<% if @codes %>
53
<% if @codes.empty? %>
@@ -11,5 +9,5 @@
119
<% end %>
1210
<% end %>
1311

14-
<%= will_paginate @codes %>
12+
<%= will_paginate @codes, :separator => '&bull;' %>
1513

app/views/codes/show.html.erb

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
<% @page_title = @code.name+" gem ruby 1.9 compatibility" %>
2-
3-
41
<h1 class="code_title"><%= @code.name %></h1>
52

63
<dl>
7-
<dt>URL</dt>
8-
<dd><%= homepage_link_for @code %> </dd>
9-
<dt>Author(s)</dt>
10-
<dd><%= h @code.author_names %></dd>
11-
<dt>Summary</dt>
12-
<dd><%= @code.description_or_summary %></dd>
4+
<dt>URL</dt>
5+
<dd><%= homepage_link_for @code %> </dd>
6+
<dt>Author(s)</dt>
7+
<dd><%= h @code.author_names %></dd>
8+
<dt>Summary</dt>
9+
<dd><%= @code.description_or_summary %></dd>
1310
</dl>
1411

1512
<p><a href="#newcomment">Add your comment &darr;</a></p>
1613

17-
1814
<h2>Comments</h2>
1915
<%= render :partial => 'comments/comment', :collection => @code.comments, :locals => { :show_quote => true } %>
2016

app/views/home/show.html.erb

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
1-
<% @page_title = 'Community-powered gem compatibility for ruby 1.9' %>
1+
<% cache do %>
2+
<div id="left" class="column">
3+
<h2>Latest Feedback</h2>
4+
<%= render :partial => 'comments/comment', :collection => @latest_feedback %>
5+
</div>
26

3-
<div id="left" class="column">
4-
<h2>Latest Feedback</h2>
5-
<%= render :partial => 'comments/comment', :collection => @latest_feedback %>
6-
</div>
7-
8-
<div id="middle" class="column">
9-
<h2>Popular gems <span class="lighterblue">(most comments)</span></h2>
10-
<ul>
11-
<%= render :partial => 'codes/code', :collection => @popular %>
12-
</ul>
13-
14-
</div>
15-
16-
<div id="right" class="column">
17-
<h2>Get involved!</h2>
18-
<p class="lighterblue">The Ruby community needs your help. <a href="http://www.ruby-lang.org">Install Ruby 1.9.1</a> then try out your favourite gems and provide feedback here.</p>
19-
<p class="lighterblue">We can then track the general "supported-ness" of gems in Ruby 1.9</p>
20-
21-
<h2>Don't know where to start?</h2>
22-
<p class="lighterblue">Try one of these...</p>
23-
<ul>
24-
<%= render :partial => 'codes/code', :collection => @unpopular %>
25-
</ul>
26-
27-
</div>
28-
29-
<br style="clear:both" />
7+
<div id="middle" class="column">
8+
<h2>Popular gems <span class="lighterblue">(most comments)</span></h2>
9+
<ul>
10+
<%= render :partial => 'codes/code', :collection => @popular %>
11+
</ul>
12+
13+
</div>
14+
15+
<div id="right" class="column">
16+
<h2>Get involved!</h2>
17+
<p class="lighterblue">The Ruby community needs your help. <a href="http://www.ruby-lang.org">Install Ruby 1.9.1</a> then try out your favourite gems and provide feedback here.</p>
18+
<p class="lighterblue">We can then track the general "supported-ness" of gems in Ruby 1.9</p>
19+
20+
<h2>Don't know where to start?</h2>
21+
<p class="lighterblue">Try one of these...</p>
22+
<ul>
23+
<%= render :partial => 'codes/code', :collection => @unpopular %>
24+
</ul>
25+
26+
</div>
27+
28+
<br style="clear:both" />
29+
30+
<% end %>

0 commit comments

Comments
 (0)