Try the cache_digests gem for Tracks

cache_digests will be part of Rails 4
This commit is contained in:
Reinier Balt 2012-08-27 21:00:51 +02:00
parent 8b1fc99b72
commit 8a8dc47ab8
9 changed files with 134 additions and 105 deletions

View file

@ -16,6 +16,8 @@ gem "aasm"
gem "htmlentities" gem "htmlentities"
gem "swf_fu" gem "swf_fu"
gem "rails_autolink" gem "rails_autolink"
gem "cache_digests" #, :git => 'git://github.com/rails/cache_digests.git'
gem "rack-mini-profiler"
# Gems used only for assets and not required # Gems used only for assets and not required
# in production environments by default. # in production environments by default.
@ -44,6 +46,7 @@ group :development do
end end
gem "yard" gem "yard"
gem "tolk" gem "tolk"
gem "bullet"
end end
group :test do group :test do

View file

@ -41,6 +41,10 @@ GEM
bcrypt-ruby (3.0.1) bcrypt-ruby (3.0.1)
bluecloth (2.2.0) bluecloth (2.2.0)
builder (3.0.0) builder (3.0.0)
bullet (4.1.6)
uniform_notifier (~> 1.0.0)
cache_digests (0.1.0)
actionpack (>= 3.2)
capybara (1.1.2) capybara (1.1.2)
mime-types (>= 1.16) mime-types (>= 1.16)
nokogiri (>= 1.3.3) nokogiri (>= 1.3.3)
@ -111,6 +115,8 @@ GEM
rack (1.4.1) rack (1.4.1)
rack-cache (1.2) rack-cache (1.2)
rack (>= 0.4) rack (>= 0.4)
rack-mini-profiler (0.1.10)
rack (>= 1.1.3)
rack-ssl (1.3.2) rack-ssl (1.3.2)
rack rack
rack-test (0.6.1) rack-test (0.6.1)
@ -178,6 +184,7 @@ GEM
uglifier (1.2.7) uglifier (1.2.7)
execjs (>= 0.3.0) execjs (>= 0.3.0)
multi_json (~> 1.3) multi_json (~> 1.3)
uniform_notifier (1.0.2)
will_paginate (3.0.3) will_paginate (3.0.3)
xpath (0.1.4) xpath (0.1.4)
nokogiri (~> 1.3) nokogiri (~> 1.3)
@ -193,6 +200,8 @@ DEPENDENCIES
acts_as_list acts_as_list
aruba aruba
bcrypt-ruby bcrypt-ruby
bullet
cache_digests
capybara capybara
coffee-rails coffee-rails
cucumber-rails cucumber-rails
@ -203,6 +212,7 @@ DEPENDENCIES
jquery-rails jquery-rails
mongrel (>= 1.2.0.pre2) mongrel (>= 1.2.0.pre2)
mysql2 mysql2
rack-mini-profiler
rails rails
rails_autolink rails_autolink
sanitize sanitize

View file

@ -50,23 +50,20 @@ class ContextsController < ApplicationController
@pending = @context.todos.pending.includes(Todo::DEFAULT_INCLUDES) @pending = @context.todos.pending.includes(Todo::DEFAULT_INCLUDES)
@projects = current_user.projects @projects = current_user.projects
@contexts = current_user.contexts
@count = @not_done_todos.count + @deferred.count + @pending.count @count = @not_done_todos.count + @deferred.count + @pending.count
end
@contexts = current_user.contexts(true)
if @context.nil?
respond_to do |format|
format.html { render :text => 'Context not found', :status => 404 }
format.xml { render :xml => '<error>Context not found</error>', :status => 404 }
end
else
@page_title = "TRACKS::Context: #{@context.name}" @page_title = "TRACKS::Context: #{@context.name}"
respond_to do |format| respond_to do |format|
format.html format.html
format.m &render_context_mobile format.m &render_context_mobile
format.xml { render :xml => @context.to_xml( :except => :user_id ) } format.xml { render :xml => @context.to_xml( :except => :user_id ) }
end end
else
respond_to do |format|
format.html { render :text => 'Context not found', :status => 404 }
format.xml { render :xml => '<error>Context not found</error>', :status => 404 }
end
end end
end end

View file

@ -4,8 +4,8 @@ class Todo < ActiveRecord::Base
after_save :save_predecessors after_save :save_predecessors
# associations # associations
belongs_to :context belongs_to :context, :touch => true
belongs_to :project belongs_to :project, :touch => true
belongs_to :user belongs_to :user
belongs_to :recurring_todo belongs_to :recurring_todo

View file

@ -1,20 +1,24 @@
<% @not_done = @not_done_todos.select {|t| t.context_id == context.id } -%> <%
<div id="c<%= context.id %>" class="container context" style="display:<%= (collapsible && @not_done.empty?) ? "none" : "block" %>"> @not_done = @not_done_todos.select {|t| t.context_id == context.id }
<h2> cache context do
<% if collapsible -%> %>
<a href="#" class="container_toggle" id="toggle_c<%= context.id %>"><%= image_tag("collapse.png") %></a> <div id="c<%= context.id %>" class="container context" style="display:<%= (collapsible && @not_done.empty?) ? "none" : "block" %>">
<% end -%> <h2>
<% if source_view_is :context %> <% if collapsible -%>
<span id="context_name"><%= context.name %></span> <a href="#" class="container_toggle" id="toggle_c<%= context.id %>"><%= image_tag("collapse.png") %></a>
<% else %> <% end -%>
<%= link_to_context( context ) %> <% if source_view_is :context %>
<% end %> <span id="context_name"><%= context.name %></span>
</h2> <% else %>
<div id="c_<%=context.id%>_target" class="context_target drop_target"></div> <%= link_to_context( context ) %>
<div id="c<%= context.id %>items" class="items toggle_target"> <% end %>
<div id="c<%= context.id %>empty-nd" style="display:<%= @not_done.empty? ? 'block' : 'none'%>;"> </h2>
<div class="message"><p><%= t 'contexts.no_actions' %></p></div> <div id="c_<%=context.id%>_target" class="context_target drop_target"></div>
<div id="c<%= context.id %>items" class="items toggle_target">
<div id="c<%= context.id %>empty-nd" style="display:<%= @not_done.empty? ? 'block' : 'none'%>;">
<div class="message"><p><%= t 'contexts.no_actions' %></p></div>
</div>
<%= render :partial => "todos/todo", :collection => @not_done, :locals => { :parent_container_type => "context" } %>
</div> </div>
<%= render :partial => "todos/todo", :collection => @not_done, :locals => { :parent_container_type => "context" } %>
</div> </div>
</div> <% end %>

View file

@ -1,21 +1,23 @@
<div class="container"> <% cache project do %>
<h2 id="project_name_container"> <div class="container">
<% if collapsible -%> <h2 id="project_name_container">
<a href="#" class="container_toggle" id="toggle_p<%= project.id %>"><%= image_tag("collapse.png") %></a> <% if collapsible -%>
<% end -%> <a href="#" class="container_toggle" id="toggle_p<%= project.id %>"><%= image_tag("collapse.png") %></a>
<div id="project_name" style="width: 100%;"><%= project.name -%></div> <% end -%>
</h2> <div id="project_name" style="width: 100%;"><%= project.name -%></div>
<div id="<%= dom_id(project, "container")%>" class="list"> </h2>
<%= render :partial => "projects/project_settings", :object => project, :locals => { :collapsible => collapsible } %> <div id="<%= dom_id(project, "container")%>" class="list">
</div> <%= render :partial => "projects/project_settings", :object => project, :locals => { :collapsible => collapsible } %>
</div>
<div class="container">
<h2><%= t('projects.actions_in_project_title') %></h2>
<div id="p<%= project.id %>items" class="items toggle_target">
<div id="p<%= project.id %>empty-nd" style="display:<%= @not_done.empty? ? 'block' : 'none'%>;">
<div class="message"><p><%= t('projects.no_actions_in_project') %></p></div>
</div> </div>
<%= render :partial => "todos/todo", :collection => @not_done, :locals => { :parent_container_type => "project" } %>
</div> </div>
</div>
<div class="container">
<h2><%= t('projects.actions_in_project_title') %></h2>
<div id="p<%= project.id %>items" class="items toggle_target">
<div id="p<%= project.id %>empty-nd" style="display:<%= @not_done.empty? ? 'block' : 'none'%>;">
<div class="message"><p><%= t('projects.no_actions_in_project') %></p></div>
</div>
<%= render :partial => "todos/todo", :collection => @not_done, :locals => { :parent_container_type => "project" } %>
</div>
</div>
<% end %>

View file

@ -6,30 +6,33 @@ parameters = "_source_view=#{@source_view}"
parameters += "&_tag_name=#{@tag_name}" if @source_view == 'tag' parameters += "&_tag_name=#{@tag_name}" if @source_view == 'tag'
@z_index_counter = @z_index_counter - 1 # for IE z-index bug @z_index_counter = @z_index_counter - 1 # for IE z-index bug
@rec_depth ||= 0 @rec_depth ||= 0
cache successor do
%> %>
<div id="<%= dom_id(successor, 'successor') %>" class="item-container"> <div id="<%= dom_id(successor, 'successor') %>" class="item-container">
<div id="<%= dom_id(successor, 'successor_line') %>"> <div id="<%= dom_id(successor, 'successor_line') %>">
<div class="description<%= staleness_class( successor ) %>" style="margin-left: 20px"> <div class="description<%= staleness_class( successor ) %>" style="margin-left: 20px">
<span class="todo.descr"><%= h sanitize(successor.description) %></span> <span class="todo.descr"><%= h sanitize(successor.description) %></span>
<%= remote_delete_dependency(successor, predecessor) %> <%= remote_delete_dependency(successor, predecessor) %>
<% unless successor.pending_successors.empty? <% unless successor.pending_successors.empty?
if @rec_depth < 8 if @rec_depth < 8
@rec_depth+=1 %> @rec_depth+=1 %>
<div class="todo_successors" id="<%= dom_id(successor, 'successors') %>"> <div class="todo_successors" id="<%= dom_id(successor, 'successors') %>">
<%= render :partial => "todos/successor", <%= render :partial => "todos/successor",
:collection => successor.pending_successors, :collection => successor.pending_successors,
:locals => { :todo => successor, :locals => { :todo => successor,
:parent_container_type => parent_container_type, :parent_container_type => parent_container_type,
:suppress_dependencies => true, :suppress_dependencies => true,
:predecessor => successor } :predecessor => successor }
%> %>
</div> </div>
<% else %> <% else %>
<a title="There are more dependencies that are not shown">[...]</a> <a title="There are more dependencies that are not shown">[...]</a>
<% end %>
<% end %> <% end %>
<% end %> </div>
</div> </div>
</div> </div>
</div> <% end %>

View file

@ -6,40 +6,43 @@ parameters = "_source_view=#{@source_view}"
parameters += "&_tag_name=#{@tag_name}" if @source_view == 'tag' parameters += "&_tag_name=#{@tag_name}" if @source_view == 'tag'
@z_index_counter = @z_index_counter - 1 # for IE z-index bug @z_index_counter = @z_index_counter - 1 # for IE z-index bug
@rec_depth=0 # to prevent stack overflow on large dependency trees, see _successor.html.erb @rec_depth=0 # to prevent stack overflow on large dependency trees, see _successor.html.erb
cache todo do
%> %>
<div id="<%= dom_id(todo) %>" class="item-container"> <div id="<%= dom_id(todo) %>" class="item-container">
<div id="<%= dom_id(todo, 'line') %>" class="item-show"> <div id="<%= dom_id(todo, 'line') %>" class="item-show">
<%= remote_star_icon(todo) %> <%= remote_star_icon(todo) %>
<%= remote_toggle_checkbox(todo) %> <%= remote_toggle_checkbox(todo) %>
<%= remote_edit_button(todo) unless suppress_edit_button %> <%= remote_edit_button(todo) unless suppress_edit_button %>
<ul class="sf-menu sf-item-menu"> <ul class="sf-menu sf-item-menu">
<li style="z-index:<%=@z_index_counter%>"><%= image_tag "downarrow.png", :class => "todo-submenu", :alt=> "" %> <li style="z-index:<%=@z_index_counter%>"><%= image_tag "downarrow.png", :class => "todo-submenu", :alt=> "" %>
<ul id="ul<%= dom_id(todo) %>" class="todo-submenu"> <ul id="ul<%= dom_id(todo) %>" class="todo-submenu">
<li><%= remote_delete_menu_item(todo) %></li> <li><%= remote_delete_menu_item(todo) %></li>
<% unless todo.completed? || todo.deferred? -%> <% unless todo.completed? || todo.deferred? -%>
<li><%= remote_defer_menu_item(1, todo) %></li> <li><%= remote_defer_menu_item(1, todo) %></li>
<li><%= remote_defer_menu_item(2, todo) %></li> <li><%= remote_defer_menu_item(2, todo) %></li>
<li><%= remote_defer_menu_item(3, todo) %></li> <li><%= remote_defer_menu_item(3, todo) %></li>
<li><%= remote_defer_menu_item(7, todo) %></li> <li><%= remote_defer_menu_item(7, todo) %></li>
<li><%= remote_promote_to_project_menu_item(todo) %></li> <li><%= remote_promote_to_project_menu_item(todo) %></li>
<% end -%> <% end -%>
</ul> </ul>
</li> </li>
</ul> </ul>
<%= grip_span(todo) %> <%= grip_span(todo) %>
<div class="description<%= staleness_class( todo ) %>"> <div class="description<%= staleness_class( todo ) %>">
<%= date_span(todo) -%> <%= date_span(todo) -%>
<span class="todo.descr"><%= h todo.description %></span> <span class="todo.descr"><%= h todo.description %></span>
<%= image_tag_for_recurring_todo(todo) if todo.from_recurring_todo? %> <%= image_tag_for_recurring_todo(todo) if todo.from_recurring_todo? %>
<%= tag_list(todo) %> <%= tag_list(todo) %>
<%= deferred_due_date(todo) %> <%= deferred_due_date(todo) %>
<%= project_and_context_links( todo, parent_container_type, :suppress_context => suppress_context, :suppress_project => suppress_project ) %> <%= project_and_context_links( todo, parent_container_type, :suppress_context => suppress_context, :suppress_project => suppress_project ) %>
<%= collapsed_notes_image(todo) unless todo.notes.blank? %> <%= collapsed_notes_image(todo) unless todo.notes.blank? %>
<%= collapsed_successors_image(todo) if todo.has_pending_successors %> <%= collapsed_successors_image(todo) if todo.has_pending_successors %>
</div>
</div>
<div id="<%= dom_id(todo, 'edit') %>" class="edit-form" style="display:none">
<% #note: edit form will load here remotely -%>
<div class="placeholder"> </div>
</div> </div>
</div> </div>
<div id="<%= dom_id(todo, 'edit') %>" class="edit-form" style="display:none"> <% end %>
<% #note: edit form will load here remotely -%>
<div class="placeholder"> </div>
</div>
</div>

View file

@ -0,0 +1,7 @@
# config for bullet gem
if defined? Bullet
Bullet.enable = false
Bullet.alert = false
Bullet.bullet_logger = true
end