Permalink
Browse files

fixed top users, refactored articles, stories and answers

  • Loading branch information...
1 parent 390117b commit 9cfce231680f13762f21f1c4e62398e03c4fcbbe @newscloud committed Jul 25, 2010
@@ -88,7 +88,7 @@ def load_top_stories
end
def load_top_users
- @top_users ||= User.top
+ @top_users ||= User.top.members
end
def load_contents
View
@@ -13,6 +13,7 @@ class User < ActiveRecord::Base
named_scope :last_active, lambda { { :conditions => ["last_active > ?", 5.minutes.ago], :order => ["last_active desc"] } }
named_scope :admins, { :conditions => ["is_admin is true"] }
named_scope :moderators, { :conditions => ["is_moderator is true"] }
+ named_scope :members, { :conditions => ["is_moderator is false and is_admin is false and is_editor is false and is_host is false"] }
validates_presence_of :login, :unless => :facebook_connect_user?
validates_length_of :login, :within => 3..40, :unless => :facebook_connect_user?
@@ -1,16 +1,2 @@
-# expects answer
-
-.answer
- %blockquote
- .quotes= answer.answer
- .itemBlock
- .profilePic= local_linked_profile_pic answer.user
- .itemMeta
- %h3= t('answered_by', :fb_name => local_linked_profile_name(answer.user), :date => time_ago_in_words(answer.created_at))
- %span.btnComment.btn_left== #{like_link answer} #{answer.votes.size}
- %span.btnComment.btn_mid= link_to answer_comments_translate(answer.comments.size), '#', :class => 'answer_comments_link'
-
- %br
- .clearfix
- = render :partial => 'shared/comments', :locals => { :comments => answer.comments }
- = render :partial => 'shared/comment_form', :locals => { :commentable => answer }
+= render :partial => 'shared/items/answer', :locals => { :answer => answer , :show_comments => true }
@@ -17,21 +17,7 @@
- contents.each do |article|
- content = article.is_a?(Article) ? article.content : article
%li{'data-id' => content.cache_key}
- .article
- .thumb
- - if content.images.present?
- = image_tag content.images.first.url(:thumb)
- - else
- = image_tag ('default/watermark.jpg', :width => "100%")
- .itemBlock
- %h2= link_to content.title, story_path(content)
- %p= linked_story_caption content
- .profilePic= local_linked_profile_pic content.user
- .itemMeta
- %h3= t('.stories_posted_by', :fb_name => local_linked_profile_name(content.user), :date => time_ago_in_words(content.created_at))
- %span.btnComment== #{like_link content} #{content.votes_tally}
- %span.btnComment== #{link_to t('comments'), story_path(content, :anchor => "commentListTop")} #{content.comments_count}
-
+ = render :partial => 'shared/items/article', :locals => { :article => article}
- if paginate
.clearfix
= will_paginate contents
@@ -2,17 +2,4 @@
%ul
- stories.each do |content|
%li{'data-id' => content.cache_key}
- .article
- .thumb
- - if content.images.present?
- = image_tag content.images.first.url(:thumb)
- - else
- = image_tag ('default/watermark.jpg', :width => "100%")
- .itemBlock
- %h2= link_to content.title, story_path(content, :format => 'html')
- %p= linked_story_caption content, 150, false, :format => 'html'
- .profilePic= local_linked_profile_pic content.user, :format => 'html'
- .itemMeta
- %h3= t('.stories_posted_by', :fb_name => local_linked_profile_name(content.user, :format => 'html'), :date => time_ago_in_words(content.created_at))
- %span.btnComment== #{like_link content, :format => 'html'} #{content.votes_tally}
- %span.btnComment== #{link_to t('.stories_comments'), story_path(content, :anchor => "commentListTop", :format => 'html')} #{content.comments_count}
+ = render :partial => 'shared/items/article', :locals => { :article => article}
@@ -1,6 +1,5 @@
- page ||= ""
- cache_if page.present?, "stories_list_#{page}html" do
- -# contents ||= Content.active.paginate :page => params[:page], :per_page => 10, :order => "created_at desc"
- contents ||= Content.top_items.paginate :page => params[:page], :per_page => 10, :order => "created_at desc"
- paginate ||= false
.panel_1
@@ -18,27 +17,15 @@
-# todo hack to fix drafts appearing until we can switch articles out of this widget
- unless content.article.present? and content.article.is_draft?
%li{'data-id' => content.cache_key}
- .article
- .thumb
- - if content.images.present?
- = image_tag content.images.first.url(:thumb)
- -else
- = image_tag ('default/watermark.jpg')
- .itemBlock
- %h2= link_to content.title, story_path(content)
- %p= linked_story_caption content
-
- .profilePic= local_linked_profile_pic content.user
- .itemMeta
- %h3= t('.stories_posted_by', :fb_name => local_linked_profile_name(content.user), :date => time_ago_in_words(content.created_at))
- %span.btnComment== #{like_link content} #{content.votes_tally}
- %span.btnComment== #{link_to t('.stories_comments'), story_path(content, :anchor => "commentListTop")} #{content.comments_count}
-
+ - if content.article.present?
+ = render :partial => 'shared/items/article', :locals => { :article => content}
+ -else
+ = render :partial => 'shared/items/content', :locals => { :content => content}
- if paginate
.clearfix
= will_paginate contents
%br
- else
.clearfix
%p= link_to t('read_more'), stories_path, :class => "float_right"
- %br
+ %br
@@ -4,17 +4,7 @@
-# todo hack to fix drafts appearing until we can swithc articles out of this widget
- unless content.article.present? and content.article.is_draft?
%li{'data-id' => content.cache_key}
- .thumb
- - if content.images.present?
- = image_tag content.images.first.url(:thumb)
- - else
- = image_tag ('default/watermark.jpg', :width => "100%")
- .itemBlock
- %h2= link_to content.title, story_path(content, :format => 'html')
- %p= linked_story_caption content, 150, false, :format => 'html'
- .profilePic= local_linked_profile_pic content.user, :format => 'html'
- .itemMeta
- %h3= t('.stories_posted_by', :fb_name => local_linked_profile_name(content.user, :format => 'html'), :date => time_ago_in_words(content.created_at))
- %span.btnComment== #{like_link content, :format => 'html'} #{content.votes_tally}
- %span.btnComment== #{link_to t('.stories_comments'), story_path(content, :anchor => "commentListTop", :format => 'html')} #{content.comments_count}
-
+ - if content.article.present?
+ = render :partial => 'shared/items/article', :locals => { :article => content}
+ -else
+ = render :partial => 'shared/items/content', :locals => { :content => content}
@@ -7,3 +7,9 @@
%h3= t('answered_by', :fb_name => local_linked_profile_name(answer.user), :date => time_ago_in_words(answer.created_at))
%span.btnComment.btn_left== #{like_link answer} #{answer.votes.size}
%span.btnComment.btn_mid= link_to answer_comments_translate(answer.comments.size), '#', :class => 'answer_comments_link'
+ - if show_comments.present?
+ %br
+ .clearfix
+ = render :partial => 'shared/comments', :locals => { :comments => answer.comments }
+ = render :partial => 'shared/comment_form', :locals => { :commentable => answer }
+
@@ -1,7 +1,7 @@
-# @expects: local 'top_users'
- cache :top_users_html do
- - top_users ||= User.top
+ - top_users ||= User.top.members
- unless top_users.empty?
%div{:class => "panel_2 #{defined?(widget_page) ? widget_page.css_class : ''}"}
.panelBar

0 comments on commit 9cfce23

Please sign in to comment.