From cf0fdcb4ba0a7d6aa835de12eb9fa89e35a6403c Mon Sep 17 00:00:00 2001 From: Russell Branca Date: Mon, 15 Feb 2010 13:35:16 -0800 Subject: [PATCH] Updating fragment caching and compartmentalizing partials. --- .gitignore | 2 + app/controllers/home_controller.rb | 12 +--- app/views/home/index.fbml.haml | 11 ++-- app/views/home/index.html.haml | 11 ++-- app/views/layouts/application.html.haml | 2 +- app/views/shared/_featured_items.fbml.haml | 59 ++++++++++--------- app/views/shared/_featured_items.html.haml | 59 ++++++++++--------- app/views/shared/_stories.fbml.haml | 57 +++++++++--------- app/views/shared/_stories.html.haml | 57 +++++++++--------- .../shared/sidebar/_active_users.fbml.haml | 11 ++-- .../shared/sidebar/_active_users.html.haml | 26 ++++---- .../shared/sidebar/_newest_users.fbml.haml | 24 ++++---- .../shared/sidebar/_newest_users.html.haml | 24 ++++---- .../sidebar/_top_discussed_stories.fbml.haml | 22 +++---- .../sidebar/_top_discussed_stories.html.haml | 22 +++---- .../shared/sidebar/_top_stories.fbml.haml | 22 +++---- .../shared/sidebar/_top_stories.html.haml | 22 +++---- app/views/shared/sidebar/_top_users.fbml.haml | 26 ++++---- app/views/shared/sidebar/_top_users.html.haml | 26 ++++---- config/application_settings.yml.sample | 3 + config/environments/development.rb | 1 + public/cache/.gitignore | 0 22 files changed, 264 insertions(+), 235 deletions(-) create mode 100644 public/cache/.gitignore diff --git a/.gitignore b/.gitignore index f6948a4f..a86d6641 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,7 @@ +!*.gitignore public/uploads public/cache/* +!public/cache/.gitignore tmp .DS_Store public/system diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 0b73c17b..45009293 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -2,20 +2,10 @@ class HomeController < ApplicationController caches_page :index, :google_ads before_filter :set_current_tab - before_filter :load_top_stories, :only => [:index, :app_tab] - before_filter :load_featured_items, :only => [:index, :app_tab] - before_filter :load_top_discussed_stories, :only => [:index, :app_tab] - before_filter :load_top_users, :only => [:index, :app_tab] - before_filter :load_newest_users, :only => [:index, :app_tab] def index - expires_in 1.minutes, :private => false, :public => true + #expires_in 1.minutes, :private => false, :public => true @no_paginate = true - @contents = Content.paginate :page => params[:page], :per_page => 10, :order => "created_at desc" - respond_to do |format| - format.html - format.fbml - end end def app_tab diff --git a/app/views/home/index.fbml.haml b/app/views/home/index.fbml.haml index 9f23f964..d81764be 100644 --- a/app/views/home/index.fbml.haml +++ b/app/views/home/index.fbml.haml @@ -1,11 +1,10 @@ #col_left - - if @featured_items.present? - = render :partial => 'shared/featured_items', :locals => { :featured_items => @featured_items } + = render :partial => 'shared/featured_items' = render :partial => 'shared/stories' #col_right - = render :partial => 'shared/sidebar/top_stories', :locals => { :top_stories => @top_stories } - = render :partial => 'shared/sidebar/top_discussed_stories', :locals => { :most_discussed_stories => @most_discussed_stories } - = render :partial => 'shared/sidebar/top_users', :locals => { :top_users => @top_users } - = render :partial => 'shared/sidebar/newest_users', :locals => { :newest_users => @newest_users } + = render :partial => 'shared/sidebar/top_stories' + = render :partial => 'shared/sidebar/top_discussed_stories' + = render :partial => 'shared/sidebar/top_users' + = render :partial => 'shared/sidebar/newest_users' = render :partial => 'shared/sidebar/active_users' diff --git a/app/views/home/index.html.haml b/app/views/home/index.html.haml index 9f23f964..d81764be 100644 --- a/app/views/home/index.html.haml +++ b/app/views/home/index.html.haml @@ -1,11 +1,10 @@ #col_left - - if @featured_items.present? - = render :partial => 'shared/featured_items', :locals => { :featured_items => @featured_items } + = render :partial => 'shared/featured_items' = render :partial => 'shared/stories' #col_right - = render :partial => 'shared/sidebar/top_stories', :locals => { :top_stories => @top_stories } - = render :partial => 'shared/sidebar/top_discussed_stories', :locals => { :most_discussed_stories => @most_discussed_stories } - = render :partial => 'shared/sidebar/top_users', :locals => { :top_users => @top_users } - = render :partial => 'shared/sidebar/newest_users', :locals => { :newest_users => @newest_users } + = render :partial => 'shared/sidebar/top_stories' + = render :partial => 'shared/sidebar/top_discussed_stories' + = render :partial => 'shared/sidebar/top_users' + = render :partial => 'shared/sidebar/newest_users' = render :partial => 'shared/sidebar/active_users' diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 8a095752..eba454e3 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -1,7 +1,7 @@ !!! %html{:xmlns => "http://www.w3.org/1999/xhtml", "xmlns:fb" => "http://www.facebook.com/2008/fbml"} %head - = stylesheet_link_tag 'default.css', 'formtastic.css', 'ui-lightness/jquery-ui-1.7.2.custom.css', 'jquery.jcarousel', 'jcarousel.skin', 'application', :cache => true + = stylesheet_link_tag 'default.css', 'formtastic.css', 'ui-lightness/jquery-ui-1.7.2.custom.css', 'jquery.jcarousel', 'jcarousel.skin', 'application' = javascript_include_tag 'jquery.min', 'jquery.ui.min', 'jquery.jcarousel.pack', 'jquery.application' = auto_discovery_link_tag(:atom, stories_path(:format => :atom)) %style diff --git a/app/views/shared/_featured_items.fbml.haml b/app/views/shared/_featured_items.fbml.haml index ae23bcbb..e9dd7c86 100644 --- a/app/views/shared/_featured_items.fbml.haml +++ b/app/views/shared/_featured_items.fbml.haml @@ -1,28 +1,31 @@ -#featurePanel.clearfix - .panelBar.clearfix - %h2 Featured Content - #featuredStories - - section1 = featured_items.children.first - - section2 = featured_items.children.second - - case featured_items.featured_type - - when 'template_1' - .featured_story.clearfix - - primary1 = section1.children.first.featurable - #story_1_image.thumb= link_to image_tag(primary1.featured_image_url), primary1.featured_url - .storyBlockWrap - %h1#story_1_title= link_to primary1.featured_title, primary1.featured_url - %p#story_1_caption= primary1.featured_blurb - - when 'template_2' - .featured_story.clearfix - - primary1 = section1.children.first.featurable - - secondary1 = section1.children.second.featurable - - secondary2 = section1.children.third.featurable - #story_1_image.thumb= link_to image_tag(primary1.featured_image_url), primary1.featured_url - .storyBlockWrap - %h1#story_1_title= link_to primary1.featured_title, primary1.featured_url - %p#story_1_caption= primary1.featured_blurb - .related_story - .bullet_list - %ul - %li= link_to secondary1.featured_title, secondary1.featured_url - %li= link_to secondary2.featured_title, secondary2.featured_url +- cache :featured_items do + - featured_items ||= FeaturedItem.find_root_by_item_name('featured_template') + - if featured_items.present? + #featurePanel.clearfix + .panelBar.clearfix + %h2 Featured Content + #featuredStories + - section1 = featured_items.children.first + - section2 = featured_items.children.second + - case featured_items.featured_type + - when 'template_1' + .featured_story.clearfix + - primary1 = section1.children.first.featurable + #story_1_image.thumb= link_to image_tag(primary1.featured_image_url), primary1.featured_url + .storyBlockWrap + %h1#story_1_title= link_to primary1.featured_title, primary1.featured_url + %p#story_1_caption= primary1.featured_blurb + - when 'template_2' + .featured_story.clearfix + - primary1 = section1.children.first.featurable + - secondary1 = section1.children.second.featurable + - secondary2 = section1.children.third.featurable + #story_1_image.thumb= link_to image_tag(primary1.featured_image_url), primary1.featured_url + .storyBlockWrap + %h1#story_1_title= link_to primary1.featured_title, primary1.featured_url + %p#story_1_caption= primary1.featured_blurb + .related_story + .bullet_list + %ul + %li= link_to secondary1.featured_title, secondary1.featured_url + %li= link_to secondary2.featured_title, secondary2.featured_url diff --git a/app/views/shared/_featured_items.html.haml b/app/views/shared/_featured_items.html.haml index ae23bcbb..e9dd7c86 100644 --- a/app/views/shared/_featured_items.html.haml +++ b/app/views/shared/_featured_items.html.haml @@ -1,28 +1,31 @@ -#featurePanel.clearfix - .panelBar.clearfix - %h2 Featured Content - #featuredStories - - section1 = featured_items.children.first - - section2 = featured_items.children.second - - case featured_items.featured_type - - when 'template_1' - .featured_story.clearfix - - primary1 = section1.children.first.featurable - #story_1_image.thumb= link_to image_tag(primary1.featured_image_url), primary1.featured_url - .storyBlockWrap - %h1#story_1_title= link_to primary1.featured_title, primary1.featured_url - %p#story_1_caption= primary1.featured_blurb - - when 'template_2' - .featured_story.clearfix - - primary1 = section1.children.first.featurable - - secondary1 = section1.children.second.featurable - - secondary2 = section1.children.third.featurable - #story_1_image.thumb= link_to image_tag(primary1.featured_image_url), primary1.featured_url - .storyBlockWrap - %h1#story_1_title= link_to primary1.featured_title, primary1.featured_url - %p#story_1_caption= primary1.featured_blurb - .related_story - .bullet_list - %ul - %li= link_to secondary1.featured_title, secondary1.featured_url - %li= link_to secondary2.featured_title, secondary2.featured_url +- cache :featured_items do + - featured_items ||= FeaturedItem.find_root_by_item_name('featured_template') + - if featured_items.present? + #featurePanel.clearfix + .panelBar.clearfix + %h2 Featured Content + #featuredStories + - section1 = featured_items.children.first + - section2 = featured_items.children.second + - case featured_items.featured_type + - when 'template_1' + .featured_story.clearfix + - primary1 = section1.children.first.featurable + #story_1_image.thumb= link_to image_tag(primary1.featured_image_url), primary1.featured_url + .storyBlockWrap + %h1#story_1_title= link_to primary1.featured_title, primary1.featured_url + %p#story_1_caption= primary1.featured_blurb + - when 'template_2' + .featured_story.clearfix + - primary1 = section1.children.first.featurable + - secondary1 = section1.children.second.featurable + - secondary2 = section1.children.third.featurable + #story_1_image.thumb= link_to image_tag(primary1.featured_image_url), primary1.featured_url + .storyBlockWrap + %h1#story_1_title= link_to primary1.featured_title, primary1.featured_url + %p#story_1_caption= primary1.featured_blurb + .related_story + .bullet_list + %ul + %li= link_to secondary1.featured_title, secondary1.featured_url + %li= link_to secondary2.featured_title, secondary2.featured_url diff --git a/app/views/shared/_stories.fbml.haml b/app/views/shared/_stories.fbml.haml index 870f3995..6d7e7098 100644 --- a/app/views/shared/_stories.fbml.haml +++ b/app/views/shared/_stories.fbml.haml @@ -1,27 +1,30 @@ -.panel_1 - .panelBar.clearfix - %h2= t('.stories_title') - .subtitle - %span= t('.stories_subtitle') - .storyList - .list_stories.clearfix - %ul - - @contents.each do |content| - %li - .thumb - - if content.content_image.present? - %img{:alt => "story image", :src => content.content_image.url} - .storyBlockWrap - %p.storyHead= link_to content.title, story_path(content) - %p.storyCaption= linked_story_caption content - .profilePic= local_linked_profile_pic content.user - .storyBlockMeta - %p= t('.stories_posted_by', :fb_name => local_linked_profile_name(content.user), :date => time_ago_in_words(content.created_at)) - %p - %span.btn_left== #{link_to t('.stories_like'), like_story_path(content.id), :class => "voteLink"} #{content.votes.size} - %span.btn_mid== #{link_to t('.stories_comments'), story_path(content, :anchor => "commentListTop")} #{content.comments_count} - %span.btn_right= t('.stories_share') - - unless @no_paginate - .clearfix - = will_paginate @contents - %br +- cache :stories_list do + - contents ||= Content.paginate :page => params[:page], :per_page => 10, :order => "created_at desc" + - no_paginate ||= false + .panel_1 + .panelBar.clearfix + %h2= t('.stories_title') + .subtitle + %span= t('.stories_subtitle') + .storyList + .list_stories.clearfix + %ul + - contents.each do |content| + %li + .thumb + - if content.content_image.present? + %img{:alt => "story image", :src => content.content_image.url} + .storyBlockWrap + %p.storyHead= link_to content.title, story_path(content) + %p.storyCaption= linked_story_caption content + .profilePic= local_linked_profile_pic content.user + .storyBlockMeta + %p= t('.stories_posted_by', :fb_name => local_linked_profile_name(content.user), :date => time_ago_in_words(content.created_at)) + %p + %span.btn_left== #{link_to t('.stories_like'), like_story_path(content.id), :class => "voteLink"} #{content.votes.size} + %span.btn_mid== #{link_to t('.stories_comments'), story_path(content, :anchor => "commentListTop")} #{content.comments_count} + %span.btn_right= t('.stories_share') + - unless no_paginate + .clearfix + = will_paginate contents + %br diff --git a/app/views/shared/_stories.html.haml b/app/views/shared/_stories.html.haml index 870f3995..6d7e7098 100644 --- a/app/views/shared/_stories.html.haml +++ b/app/views/shared/_stories.html.haml @@ -1,27 +1,30 @@ -.panel_1 - .panelBar.clearfix - %h2= t('.stories_title') - .subtitle - %span= t('.stories_subtitle') - .storyList - .list_stories.clearfix - %ul - - @contents.each do |content| - %li - .thumb - - if content.content_image.present? - %img{:alt => "story image", :src => content.content_image.url} - .storyBlockWrap - %p.storyHead= link_to content.title, story_path(content) - %p.storyCaption= linked_story_caption content - .profilePic= local_linked_profile_pic content.user - .storyBlockMeta - %p= t('.stories_posted_by', :fb_name => local_linked_profile_name(content.user), :date => time_ago_in_words(content.created_at)) - %p - %span.btn_left== #{link_to t('.stories_like'), like_story_path(content.id), :class => "voteLink"} #{content.votes.size} - %span.btn_mid== #{link_to t('.stories_comments'), story_path(content, :anchor => "commentListTop")} #{content.comments_count} - %span.btn_right= t('.stories_share') - - unless @no_paginate - .clearfix - = will_paginate @contents - %br +- cache :stories_list do + - contents ||= Content.paginate :page => params[:page], :per_page => 10, :order => "created_at desc" + - no_paginate ||= false + .panel_1 + .panelBar.clearfix + %h2= t('.stories_title') + .subtitle + %span= t('.stories_subtitle') + .storyList + .list_stories.clearfix + %ul + - contents.each do |content| + %li + .thumb + - if content.content_image.present? + %img{:alt => "story image", :src => content.content_image.url} + .storyBlockWrap + %p.storyHead= link_to content.title, story_path(content) + %p.storyCaption= linked_story_caption content + .profilePic= local_linked_profile_pic content.user + .storyBlockMeta + %p= t('.stories_posted_by', :fb_name => local_linked_profile_name(content.user), :date => time_ago_in_words(content.created_at)) + %p + %span.btn_left== #{link_to t('.stories_like'), like_story_path(content.id), :class => "voteLink"} #{content.votes.size} + %span.btn_mid== #{link_to t('.stories_comments'), story_path(content, :anchor => "commentListTop")} #{content.comments_count} + %span.btn_right= t('.stories_share') + - unless no_paginate + .clearfix + = will_paginate contents + %br diff --git a/app/views/shared/sidebar/_active_users.fbml.haml b/app/views/shared/sidebar/_active_users.fbml.haml index fc128dd9..396b996d 100644 --- a/app/views/shared/sidebar/_active_users.fbml.haml +++ b/app/views/shared/sidebar/_active_users.fbml.haml @@ -8,7 +8,10 @@ %br .list_stories.clearfix %ul - - active_users.each do |user| - %li - .profilePic= local_linked_profile_pic user - == #{link_to user.name, user_path(user)} active #{time_ago_in_words user.last_active} ago + - unless active_users.empty? + - active_users.each do |user| + %li + .profilePic= local_linked_profile_pic user + == #{link_to user.name, user_path(user)} active #{time_ago_in_words user.last_active} ago + - else + %p No currently active users. diff --git a/app/views/shared/sidebar/_active_users.html.haml b/app/views/shared/sidebar/_active_users.html.haml index fc128dd9..425b12d3 100644 --- a/app/views/shared/sidebar/_active_users.html.haml +++ b/app/views/shared/sidebar/_active_users.html.haml @@ -1,14 +1,18 @@ -# @expects: local 'active_users' -- active_users ||= User.last_active +- cache :active_users do + - active_users ||= User.last_active -.panel_2 - .panelBar.clearfix - %h2= t('.title') - %br - .list_stories.clearfix - %ul - - active_users.each do |user| - %li - .profilePic= local_linked_profile_pic user - == #{link_to user.name, user_path(user)} active #{time_ago_in_words user.last_active} ago + .panel_2 + .panelBar.clearfix + %h2= t('.title') + %br + .list_stories.clearfix + - unless active_users.empty? + %ul + - active_users.each do |user| + %li + .profilePic= local_linked_profile_pic user + == #{link_to user.name, user_path(user)} active #{time_ago_in_words user.last_active} ago + - else + %p No currently active users. diff --git a/app/views/shared/sidebar/_newest_users.fbml.haml b/app/views/shared/sidebar/_newest_users.fbml.haml index cbf73766..5adf980b 100644 --- a/app/views/shared/sidebar/_newest_users.fbml.haml +++ b/app/views/shared/sidebar/_newest_users.fbml.haml @@ -1,13 +1,15 @@ -# @expects: local 'newest_users' -- unless newest_users.empty? - .panel_2 - .panelBar.clearfix - %h2= t('.newest_users_title') - %br - .list_stories.clearfix - %ul - - newest_users.each do |user| - %li - .profilePic= local_linked_profile_pic user - == #{link_to user.name, user_path(user)} registered #{time_ago_in_words user.created_at} ago +- cache :newest_users do + - newest_users ||= User.newest + - unless newest_users.empty? + .panel_2 + .panelBar.clearfix + %h2= t('.newest_users_title') + %br + .list_stories.clearfix + %ul + - newest_users.each do |user| + %li + .profilePic= local_linked_profile_pic user + == #{link_to user.name, user_path(user)} registered #{time_ago_in_words user.created_at} ago diff --git a/app/views/shared/sidebar/_newest_users.html.haml b/app/views/shared/sidebar/_newest_users.html.haml index cbf73766..5adf980b 100644 --- a/app/views/shared/sidebar/_newest_users.html.haml +++ b/app/views/shared/sidebar/_newest_users.html.haml @@ -1,13 +1,15 @@ -# @expects: local 'newest_users' -- unless newest_users.empty? - .panel_2 - .panelBar.clearfix - %h2= t('.newest_users_title') - %br - .list_stories.clearfix - %ul - - newest_users.each do |user| - %li - .profilePic= local_linked_profile_pic user - == #{link_to user.name, user_path(user)} registered #{time_ago_in_words user.created_at} ago +- cache :newest_users do + - newest_users ||= User.newest + - unless newest_users.empty? + .panel_2 + .panelBar.clearfix + %h2= t('.newest_users_title') + %br + .list_stories.clearfix + %ul + - newest_users.each do |user| + %li + .profilePic= local_linked_profile_pic user + == #{link_to user.name, user_path(user)} registered #{time_ago_in_words user.created_at} ago diff --git a/app/views/shared/sidebar/_top_discussed_stories.fbml.haml b/app/views/shared/sidebar/_top_discussed_stories.fbml.haml index 5a5b48e9..327dfffd 100644 --- a/app/views/shared/sidebar/_top_discussed_stories.fbml.haml +++ b/app/views/shared/sidebar/_top_discussed_stories.fbml.haml @@ -1,12 +1,14 @@ -# @expects: local 'most_discussed_stories' -.panel_2 - .panelBar.clearfix - %h2= t('.top_discussed_title') - %br - .list_stories.clearfix - %ul - - most_discussed_stories.each do |story| - %li - .profilePic= local_linked_profile_pic story.user - = link_to story.title, story_path(story) +- cache :most_discussed_stories do + - most_discussed_stories ||= Content.find( :all, :limit => 5, :order => "comments_count desc") + .panel_2 + .panelBar.clearfix + %h2= t('.top_discussed_title') + %br + .list_stories.clearfix + %ul + - most_discussed_stories.each do |story| + %li + .profilePic= local_linked_profile_pic story.user + = link_to story.title, story_path(story) diff --git a/app/views/shared/sidebar/_top_discussed_stories.html.haml b/app/views/shared/sidebar/_top_discussed_stories.html.haml index 5a5b48e9..327dfffd 100644 --- a/app/views/shared/sidebar/_top_discussed_stories.html.haml +++ b/app/views/shared/sidebar/_top_discussed_stories.html.haml @@ -1,12 +1,14 @@ -# @expects: local 'most_discussed_stories' -.panel_2 - .panelBar.clearfix - %h2= t('.top_discussed_title') - %br - .list_stories.clearfix - %ul - - most_discussed_stories.each do |story| - %li - .profilePic= local_linked_profile_pic story.user - = link_to story.title, story_path(story) +- cache :most_discussed_stories do + - most_discussed_stories ||= Content.find( :all, :limit => 5, :order => "comments_count desc") + .panel_2 + .panelBar.clearfix + %h2= t('.top_discussed_title') + %br + .list_stories.clearfix + %ul + - most_discussed_stories.each do |story| + %li + .profilePic= local_linked_profile_pic story.user + = link_to story.title, story_path(story) diff --git a/app/views/shared/sidebar/_top_stories.fbml.haml b/app/views/shared/sidebar/_top_stories.fbml.haml index e55f40a2..fe5f0795 100644 --- a/app/views/shared/sidebar/_top_stories.fbml.haml +++ b/app/views/shared/sidebar/_top_stories.fbml.haml @@ -1,12 +1,14 @@ -# @expects: local 'story' -.panel_2 - .panelBar.clearfix - %h2= t('.top_stories_title') - %br - .list_stories.clearfix - %ul - - top_stories.each do |story| - %li - .profilePic= local_linked_profile_pic story.user - = link_to story.title, story_path(story) +- cache :top_stories do + - top_stories ||= Content.tally({ :at_least => 1, :limit => 5, :order => "votes.count desc" }) + .panel_2 + .panelBar.clearfix + %h2= t('.top_stories_title') + %br + .list_stories.clearfix + %ul + - top_stories.each do |story| + %li + .profilePic= local_linked_profile_pic story.user + = link_to story.title, story_path(story) diff --git a/app/views/shared/sidebar/_top_stories.html.haml b/app/views/shared/sidebar/_top_stories.html.haml index e55f40a2..a0c0ee88 100644 --- a/app/views/shared/sidebar/_top_stories.html.haml +++ b/app/views/shared/sidebar/_top_stories.html.haml @@ -1,12 +1,14 @@ -# @expects: local 'story' -.panel_2 - .panelBar.clearfix - %h2= t('.top_stories_title') - %br - .list_stories.clearfix - %ul - - top_stories.each do |story| - %li - .profilePic= local_linked_profile_pic story.user - = link_to story.title, story_path(story) +- cache :top_stories, :expires_in => 15.seconds do + - top_stories ||= Content.tally({ :at_least => 1, :limit => 5, :order => "votes.count desc" }) + .panel_2 + .panelBar.clearfix + %h2= t('.top_stories_title') + %br + .list_stories.clearfix + %ul + - top_stories.each do |story| + %li + .profilePic= local_linked_profile_pic story.user + = link_to story.title, story_path(story) diff --git a/app/views/shared/sidebar/_top_users.fbml.haml b/app/views/shared/sidebar/_top_users.fbml.haml index eb7df52d..21ec50e2 100644 --- a/app/views/shared/sidebar/_top_users.fbml.haml +++ b/app/views/shared/sidebar/_top_users.fbml.haml @@ -1,14 +1,16 @@ -# @expects: local 'top_users' -- unless top_users.empty? - .panel_2 - .panelBar.clearfix - %h2= t('.top_users_karma_title') - %br - .list_stories.clearfix - %ul - - top_users.each do |user| - %li - .profilePic= local_linked_profile_pic user - = link_to user.name, user_path(user) - %span.karma-score== (#{user.karma_score}) +- cache :top_users do + - top_users ||= User.top + - unless top_users.empty? + .panel_2 + .panelBar.clearfix + %h2= t('.top_users_karma_title') + %br + .list_stories.clearfix + %ul + - top_users.each do |user| + %li + .profilePic= local_linked_profile_pic user + = link_to user.name, user_path(user) + %span.karma-score== (#{user.karma_score}) diff --git a/app/views/shared/sidebar/_top_users.html.haml b/app/views/shared/sidebar/_top_users.html.haml index eb7df52d..21ec50e2 100644 --- a/app/views/shared/sidebar/_top_users.html.haml +++ b/app/views/shared/sidebar/_top_users.html.haml @@ -1,14 +1,16 @@ -# @expects: local 'top_users' -- unless top_users.empty? - .panel_2 - .panelBar.clearfix - %h2= t('.top_users_karma_title') - %br - .list_stories.clearfix - %ul - - top_users.each do |user| - %li - .profilePic= local_linked_profile_pic user - = link_to user.name, user_path(user) - %span.karma-score== (#{user.karma_score}) +- cache :top_users do + - top_users ||= User.top + - unless top_users.empty? + .panel_2 + .panelBar.clearfix + %h2= t('.top_users_karma_title') + %br + .list_stories.clearfix + %ul + - top_users.each do |user| + %li + .profilePic= local_linked_profile_pic user + = link_to user.name, user_path(user) + %span.karma-score== (#{user.karma_score}) diff --git a/config/application_settings.yml.sample b/config/application_settings.yml.sample index 34e1b0be..84728108 100644 --- a/config/application_settings.yml.sample +++ b/config/application_settings.yml.sample @@ -27,6 +27,9 @@ defaults: &defaults default_admin_user: 'admin' default_admin_password: 'n2adminpassword' + # Default image + default_image: 'images/default/watermark.jpg' + development: <<: *defaults fb_rss_url: "http://my.site.com/stories.atom" diff --git a/config/environments/development.rb b/config/environments/development.rb index 85c9a608..596452c9 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -12,6 +12,7 @@ config.action_controller.consider_all_requests_local = true config.action_view.debug_rjs = true config.action_controller.perform_caching = false +config.action_controller.cache_store = :file_store, RAILS_ROOT + "/public/cache" # Don't care if the mailer can't send config.action_mailer.raise_delivery_errors = false \ No newline at end of file diff --git a/public/cache/.gitignore b/public/cache/.gitignore new file mode 100644 index 00000000..e69de29b