myexperiment-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[myexperiment-hackers] [2029] branches/event_logging: Home page.


From: noreply
Subject: [myexperiment-hackers] [2029] branches/event_logging: Home page.
Date: Wed, 3 Dec 2008 08:22:42 -0500 (EST)

Revision
2029
Author
alekses6
Date
2008-12-03 08:22:41 -0500 (Wed, 03 Dec 2008)

Log Message

Home page. Re-styling as discussed:

1) New users / latest groups tabs removed;
2) New items tab added - related to this

Modified Paths

Added Paths

Removed Paths

Diff

Modified: branches/event_logging/.loadpath (2028 => 2029)


--- branches/event_logging/.loadpath	2008-12-03 11:04:12 UTC (rev 2028)
+++ branches/event_logging/.loadpath	2008-12-03 13:22:41 UTC (rev 2029)
@@ -4,8 +4,8 @@
 	<pathentry path="org.rubypeople.rdt.launching.RUBY_CONTAINER" type="con"/>
 	<pathentry path="GEM_LIB/activesupport-1.4.4/lib" type="var"/>
 	<pathentry path="GEM_LIB/actionpack-1.13.6/lib" type="var"/>
+	<pathentry path="GEM_LIB/actionmailer-1.3.6/lib" type="var"/>
 	<pathentry path="GEM_LIB/activerecord-1.15.6/lib" type="var"/>
-	<pathentry path="GEM_LIB/actionmailer-1.3.6/lib" type="var"/>
 	<pathentry path="GEM_LIB/rake-0.7.3/lib" type="var"/>
 	<pathentry path="GEM_LIB/rails-1.2.6/lib" type="var"/>
 	<pathentry path="GEM_LIB/actionwebservice-1.2.6/lib" type="var"/>

Modified: branches/event_logging/app/controllers/home_controller.rb (2028 => 2029)


--- branches/event_logging/app/controllers/home_controller.rb	2008-12-03 11:04:12 UTC (rev 2028)
+++ branches/event_logging/app/controllers/home_controller.rb	2008-12-03 13:22:41 UTC (rev 2029)
@@ -6,6 +6,7 @@
 class HomeController < ApplicationController
   
   before_filter :find_latest_public_group_announcements_rss, : [:group_announcements_rss]
+  before_filter :find_latest_public_items_rss, : [:new_items_rss]
   before_filter :find_latest_public_updated_items_rss, : [:updated_items_rss]
   before_filter :find_latest_comments_rss, : [:latest_comments_rss]
   before_filter :find_latest_reviews_rss, : [:latest_reviews_rss]
@@ -33,6 +34,14 @@
     end
   end
   
+  def new_items_rss
+    respond_to do |format|
+      format.rss do 
+        render :action ="" 'new_items.rxml', :layout => false
+      end
+    end
+  end
+  
   def updated_items_rss
     respond_to do |format|
       format.rss do 
@@ -67,6 +76,20 @@
     end
   end
 
+  def find_latest_public_items_rss
+    # Only carry out if request is for RSS
+    if params[:format] and params[:format].downcase == 'rss'
+      @new_items_rss = []
+      items = Contribution.latest(LATEST_ITEMS_RSS_ENTRY_COUNT)
+      items.each do |item|
+        # should be authorized for anonymous users to view
+        # (feed partials require contributables, not contributions to display details)
+        c_utable = item.contributable
+        @new_items_rss << c_utable if c_utable.authorized?("show", nil)
+      end
+    end
+  end
+
   def find_latest_public_updated_items_rss
     # Only carry out if request is for RSS
     if params[:format] and params[:format].downcase == 'rss'

Modified: branches/event_logging/app/helpers/application_helper.rb (2028 => 2029)


--- branches/event_logging/app/helpers/application_helper.rb	2008-12-03 11:04:12 UTC (rev 2028)
+++ branches/event_logging/app/helpers/application_helper.rb	2008-12-03 13:22:41 UTC (rev 2029)
@@ -1176,6 +1176,7 @@
           feed_links << "<link href="" rel=\"alternate\" type=\"application/rss+xml\" title=\"myExperiment.org - Site Announcements\" />"
           feed_links << "<link href="" rel=\"alternate\" type=\"application/rss+xml\" title=\"myExperiment.org - Group Announcements\" />"
           feed_links << "<link href="" rel=\"alternate\" type=\"application/rss+xml\" title=\"myExperiment.org - Latest Groups\" />"
+          feed_links << "<link href="" rel=\"alternate\" type=\"application/rss+xml\" title=\"myExperiment.org - New Items\" />"
           feed_links << "<link href="" rel=\"alternate\" type=\"application/rss+xml\" title=\"myExperiment.org - Updated Items\" />"
           feed_links << "<link href="" rel=\"alternate\" type=\"application/rss+xml\" title=\"myExperiment.org - Latest Tags\" />"
           feed_links << "<link href="" rel=\"alternate\" type=\"application/rss+xml\" title=\"myExperiment.org - Latest Comments\" />"

Modified: branches/event_logging/app/models/blob_sweeper.rb (2028 => 2029)


--- branches/event_logging/app/models/blob_sweeper.rb	2008-12-03 11:04:12 UTC (rev 2028)
+++ branches/event_logging/app/models/blob_sweeper.rb	2008-12-03 13:22:41 UTC (rev 2029)
@@ -31,6 +31,7 @@
   private
 
   def expire_home_cache
+    expire_home_cache_new_items
     expire_home_cache_updated_items
     expire_home_cache_latest_comments
     expire_home_cache_latest_tags

Modified: branches/event_logging/app/models/contribution.rb (2028 => 2029)


--- branches/event_logging/app/models/contribution.rb	2008-12-03 11:04:12 UTC (rev 2028)
+++ branches/event_logging/app/models/contribution.rb	2008-12-03 13:22:41 UTC (rev 2029)
@@ -53,10 +53,26 @@
               :include => [ { :policy => :permissions } ])
   end
   
+  # returns the 'latest' Contributions
+  # the maximum number of results is set by #limit#
+  def self.latest(limit=10, klass=nil)
+    conditions = ["contributable_type = ?", klass] if klass
+    self.find(:all,
+              :conditions => conditions,
+              :order => "contributions.created_at DESC",
+              :limit => limit,
+              :include => [ { :policy => :permissions } ])
+  end
+  
   # returns the 'last updated' Contributions
   # the maximum number of results is set by #limit#
   def self.last_updated(limit=10, klass=nil)
-    conditions = ["contributable_type = ?", klass] if klass
+    if klass
+      conditions = ["contributable_type = ? AND contributions.updated_at > contributions.created_at", klass]
+    else
+      conditions = ["contributions.updated_at > contributions.created_at"]
+    end
+  
     self.find(:all,
               :conditions => conditions,
               :order => "contributions.updated_at DESC",

Modified: branches/event_logging/app/models/pack_sweeper.rb (2028 => 2029)


--- branches/event_logging/app/models/pack_sweeper.rb	2008-12-03 11:04:12 UTC (rev 2028)
+++ branches/event_logging/app/models/pack_sweeper.rb	2008-12-03 13:22:41 UTC (rev 2029)
@@ -31,6 +31,7 @@
   private
 
   def expire_home_cache
+    expire_home_cache_new_items
     expire_home_cache_updated_items
     expire_home_cache_latest_comments
     expire_home_cache_latest_tags

Modified: branches/event_logging/app/models/workflow_sweeper.rb (2028 => 2029)


--- branches/event_logging/app/models/workflow_sweeper.rb	2008-12-03 11:04:12 UTC (rev 2028)
+++ branches/event_logging/app/models/workflow_sweeper.rb	2008-12-03 13:22:41 UTC (rev 2029)
@@ -31,6 +31,7 @@
   private
 
   def expire_home_cache
+    expire_home_cache_new_items
     expire_home_cache_updated_items
     expire_home_cache_latest_reviews
     expire_home_cache_latest_comments

Copied: branches/event_logging/app/views/home/_new_or_updated_items.rhtml (from rev 2020, branches/event_logging/app/views/home/_updated_items.rhtml) (0 => 2029)


--- branches/event_logging/app/views/home/_new_or_updated_items.rhtml	                        (rev 0)
+++ branches/event_logging/app/views/home/_new_or_updated_items.rhtml	2008-12-03 13:22:41 UTC (rev 2029)
@@ -0,0 +1,36 @@
+<% items_box_style ||= "" -%>
+
+<!-- New or Updated Items -->
+<% cache_action = (show_new_items ? "new_items" : "updated_items") -%>
+<% cache(:controller => 'home_cache', :action ="" cache_action, :id => (logged_in? ? current_user.id : 0)) do -%> 
+	<div class="box" style="<%= items_box_style -%>">
+		<b class="xtop"><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b></b>
+		<div class="box_title">
+			<% if show_new_items -%>
+			  <%= feed_icon_tag("Latest items on myExperiment", home_new_items_rss_url) -%>&nbsp;New Items
+		  <% else -%>
+			  <%= feed_icon_tag("Latest updated items on myExperiment", home_updated_items_rss_url) -%>&nbsp;Updated Items
+			<% end -%>
+		</div>
+		<div class="content">
+			<% contributions = (show_new_items ? Contribution.latest(25) : Contribution.last_updated(25)) -%>
+			<% unless contributions.empty? %>
+				<ul class="list">
+					<% contributions.each do |c| %>
+						<% if thing_authorized?('show', c) %>
+							<li>
+								<b><%= c_type = visible_name(c.contributable_type); icon(c.contributable_type.to_s, nil, nil, c_type, c_type) %>:</b>
+								<%= c.contributable_type == 'Network' ? title(c.contributable_id) : contributable(c.contributable_id, c.contributable_type) %>
+								by <b><%= contributor(c.contributor_id, c.contributor_type) %></b>
+								(<%= timeago_fuzzy (show_new_items ? c.created_at : c.updated_at) %>)
+							</li>
+						<% end %>
+					<% end %>
+				</ul>
+			<% else %>
+				<p class="none_text">None</p>
+			<% end %>
+		</div>
+		<b class="xbottom"><b class="xb5"></b><b class="xb6"></b><b class="xb7"></b><b class="xb1"></b></b>
+	</div>
+<% end -%>

Property changes: branches/event_logging/app/views/home/_new_or_updated_items.rhtml


Added: svn:mergeinfo

Modified: branches/event_logging/app/views/home/_summary.rhtml (2028 => 2029)


--- branches/event_logging/app/views/home/_summary.rhtml	2008-12-03 11:04:12 UTC (rev 2028)
+++ branches/event_logging/app/views/home/_summary.rhtml	2008-12-03 13:22:41 UTC (rev 2029)
@@ -66,7 +66,7 @@
 					<% end -%>
 			  </ul>
 				<p style="text-align: right; font-weight: bold; padding-top: 0; margin: 0 0 0.5em 0;">
-				  <a href=""  2+tab_id_correction -%>)">more...</a>
+				  <a href="" users_url -%>">more...</a>
 				</p>
 			<% else %>
 				<p class="none_text">None</p>
@@ -85,13 +85,38 @@
 					<% end -%>
 			  </ul>		
 				<p style="text-align: right; font-weight: bold; padding-top: 0; margin: 0 0 0.5em 0;">
-				  <a href=""  3+tab_id_correction -%>)">more...</a>
+				  <a href="" groups_url -%>">more...</a>
 				</p>
 			<% else %>
 				<p class="none_text">None</p>
 			<% end %>
 			
 			<p class="quick_summary_section_title">
+				New Items
+			</p>
+			<% unless (contributions = Contribution.latest(10)).empty? %>
+				<ul class="quick_summary_list">
+					<% counter = 0 -%>
+					<% contributions.each do |c| %>
+					  <% break if counter >= 3 -%>
+						<% if c.authorized?('show', nil) %>
+							<li>
+								<%= c_type = visible_name(c.contributable_type); icon(c.contributable_type, nil, c_type, nil, "&nbsp;") %>
+								<% c_id = c.contributable.id; c_name = contributable_name_from_instance(c.contributable) -%>
+								<%= link_to truncate(c_name, summary_box_max_length), contributable_url(c_id, c.contributable_type), :alt => c_name, :title => tooltip_title_attrib(c_type + ": " + c_name) -%>
+							</li>
+							<% counter += 1 -%>
+						<% end %>
+					<% end %>
+				</ul>
+				<p style="text-align: right; font-weight: bold; padding-top: 0; margin: 0 0 0.5em 0;">
+				  <a href=""  2+tab_id_correction -%>)">more...</a>
+				</p>
+			<% else %>
+				<p class="none_text">None</p>
+			<% end %>
+			
+			<p class="quick_summary_section_title">
 				Updated Items
 			</p>
 			<% unless (contributions = Contribution.last_updated(10)).empty? %>
@@ -110,7 +135,7 @@
 					<% end %>
 				</ul>
 				<p style="text-align: right; font-weight: bold; padding-top: 0; margin: 0 0 0.5em 0;">
-				  <a href=""  4+tab_id_correction -%>)">more...</a>
+				  <a href=""  3+tab_id_correction -%>)">more...</a>
 				</p>
 			<% else %>
 				<p class="none_text">None</p>
@@ -140,7 +165,7 @@
 					<% end %>
 				</ul>
 				<p style="text-align: right; font-weight: bold; padding-top: 0; margin: 0 0 0.5em 0;">
-				  <a href=""  4+tab_id_correction -%>)">more...</a>
+				  <a href=""  2+tab_id_correction -%>)">more...</a>
 				</p>
 			<% else %>
 				<p class="none_text">None</p>
@@ -171,7 +196,7 @@
 					<% end %>
 				</ul>
 				<p style="text-align: right; font-weight: bold; padding-top: 0; margin: 0 0 0.5em 0;">
-				  <a href=""  5+tab_id_correction -%>)">more...</a>
+				  <a href=""  4+tab_id_correction -%>)">more...</a>
 				</p>
 			<% else %>
 				<p class="none_text">None</p>
@@ -203,7 +228,7 @@
 					<% end %>
 				</ul>
 				<p style="text-align: right; font-weight: bold; padding-top: 0; margin: 0 0 0.5em 0;">
-				  <a href=""  5+tab_id_correction -%>)">more...</a>
+				  <a href=""  4+tab_id_correction -%>)">more...</a>
 				</p>
 			<% else %>
 				<p class="none_text">None</p>

Deleted: branches/event_logging/app/views/home/_updated_items.rhtml (2028 => 2029)


--- branches/event_logging/app/views/home/_updated_items.rhtml	2008-12-03 11:04:12 UTC (rev 2028)
+++ branches/event_logging/app/views/home/_updated_items.rhtml	2008-12-03 13:22:41 UTC (rev 2029)
@@ -1,28 +0,0 @@
-<!-- Updated Items -->
-<% cache(:controller => 'home_cache', :action ="" 'updated_items', :id => (logged_in? ? current_user.id : 0)) do -%> 
-	<div class="box">
-		<b class="xtop"><b class="xb1"></b><b class="xb2"></b><b class="xb3"></b><b class="xb4"></b></b>
-		<div class="box_title">
-			<%= feed_icon_tag("Latest updated items on myExperiment", home_updated_items_rss_url) -%>&nbsp;Updated Items
-		</div>
-		<div class="content">
-			<% unless (contributions = Contribution.last_updated(25)).empty? %>
-				<ul class="list">
-					<% contributions.each do |c| %>
-						<% if thing_authorized?('show', c) %>
-							<li>
-								<b><%= c_type = visible_name(c.contributable_type); icon(c.contributable_type.to_s, nil, nil, c_type, c_type) %>:</b>
-								<%= c.contributable_type == 'Network' ? title(c.contributable_id) : contributable(c.contributable_id, c.contributable_type) %>
-								by <b><%= contributor(c.contributor_id, c.contributor_type) %></b>
-								(<%= timeago_fuzzy c.updated_at %>)
-							</li>
-						<% end %>
-					<% end %>
-				</ul>
-			<% else %>
-				<p class="none_text">None</p>
-			<% end %>
-		</div>
-		<b class="xbottom"><b class="xb5"></b><b class="xb6"></b><b class="xb7"></b><b class="xb1"></b></b>
-	</div>
-<% end -%>

Modified: branches/event_logging/app/views/home/index.rhtml (2028 => 2029)


--- branches/event_logging/app/views/home/index.rhtml	2008-12-03 11:04:12 UTC (rev 2028)
+++ branches/event_logging/app/views/home/index.rhtml	2008-12-03 13:22:41 UTC (rev 2029)
@@ -62,35 +62,29 @@
 		</div>
 	</div>
 	
-	<a name="new_users"></a>
+	<a name="new_items"></a>
+	<a name="latest_tags"></a>
 	<div class="tabContainer">
-		<div class="tabTitle"><b>New Users</b></div>
+		<div class="tabTitle"><b>New Items</b></div>
 		<div class="tabContent">
-			<%= render :partial => "new_users" %>
+		  <div class="left">
+			  <%= render :partial => "latest_tags" %>
+		  </div>
+			<div class="right">
+				<%= render :partial => "new_or_updated_items", :locals => { :show_new_items => true } %>
+			</div>
 			<div class="clearer">&nbsp;</div>
 		</div>
 	</div>
 	
-	<a name="latest_groups"></a>
-	<div class="tabContainer">
-		<div class="tabTitle"><b>Latest Groups</b></div>
-		<div class="tabContent">
-		  <%= render :partial => "latest_groups" %>
-			<div class="clearer">&nbsp;</div>
-		</div>
-	</div>
-	
 	<a name="updated_items"></a>
-	<a name="latest_tags"></a>
 	<div class="tabContainer">
 		<div class="tabTitle"><b>Updated Items</b></div>
 		<div class="tabContent">
-			<div class="left">
-			  <%= render :partial => "latest_tags" %>
-		  </div>
-			<div class="right">
-				<%= render :partial => "updated_items" %>
-			</div>
+			<center>
+			  <%= render :partial => "new_or_updated_items", :locals => { :show_new_items => false,
+                                                                    :items_box_style => "width: 550px; text-align: left;" } %>
+			</center>
 			<div class="clearer">&nbsp;</div>
 		</div>
 	</div>

Added: branches/event_logging/app/views/home/new_items.rxml (0 => 2029)


--- branches/event_logging/app/views/home/new_items.rxml	                        (rev 0)
+++ branches/event_logging/app/views/home/new_items.rxml	2008-12-03 13:22:41 UTC (rev 2029)
@@ -0,0 +1,17 @@
+xml.rss "version" => "2.0", 'xmlns:opensearch' => "http://a9.com/-/spec/opensearch/1.1/", 'xmlns:atom' => "http://www.w3.org/2005/Atom" do
+  xml.channel do
+    xml.title "myExperiment.org - Latest Items"
+    xml.link url_for(:controller => 'home', :action ="" 'index')
+    xml.language "en-us"
+    xml.ttl "60"
+    xml.tag! "atom:link", :rel => 'search', :type => 'application/opensearchdescription+xml', :href ="" "http://#{request.host_with_port}/open_search.xml"
+    xml.description "Most recent items on myExperiment.org"
+    # iterate through the collection manually, as it contains items of different types
+    @new_items_rss.each do |item|
+      item_class = item.class.to_s.downcase
+      unless ["blog", "forum"].include? item_class
+        render(:partial => "layouts/#{item_class}", :object => item, :locals => { :xm => xml })
+      end
+    end
+  end
+end
\ No newline at end of file

Modified: branches/event_logging/app/views/home/updated_items.rxml (2028 => 2029)


--- branches/event_logging/app/views/home/updated_items.rxml	2008-12-03 11:04:12 UTC (rev 2028)
+++ branches/event_logging/app/views/home/updated_items.rxml	2008-12-03 13:22:41 UTC (rev 2029)
@@ -8,7 +8,10 @@
     xml.description "Most recently updated items on myExperiment.org"
     # iterate through the collection manually, as it contains items of different types
     @updated_items_rss.each do |item|
-      render(:partial => "layouts/#{item.class.to_s.downcase}", :object => item, :locals => { :xm => xml })
+      item_class = item.class.to_s.downcase
+      unless ["blog", "forum"].include? item_class
+        render(:partial => "layouts/#{item_class}", :object => item, :locals => { :xm => xml })
+      end
     end
   end
 end
\ No newline at end of file

Modified: branches/event_logging/config/environment_private.rb.pre (2028 => 2029)


--- branches/event_logging/config/environment_private.rb.pre	2008-12-03 11:04:12 UTC (rev 2028)
+++ branches/event_logging/config/environment_private.rb.pre	2008-12-03 13:22:41 UTC (rev 2029)
@@ -124,4 +124,5 @@
 #  also, RSS news feeds for Files, Workflows, Packs;
 #  also, RSS feed and listing on the "home" page for "latest public group announcements")
 DEFAULT_RSS_ENTRY_COUNT = 20
+LATEST_ITEMS_RSS_ENTRY_COUNT = 25
 LATEST_UPDATED_ITEMS_RSS_ENTRY_COUNT = 25
\ No newline at end of file

Modified: branches/event_logging/config/routes.rb (2028 => 2029)


--- branches/event_logging/config/routes.rb	2008-12-03 11:04:12 UTC (rev 2028)
+++ branches/event_logging/config/routes.rb	2008-12-03 13:22:41 UTC (rev 2029)
@@ -241,6 +241,7 @@
   
   map.home_public_news_rss 'home/public_news.rss', :controller => 'home', :action ="" 'public_news_rss', :format => 'rss'
   map.home_latest_public_group_announcements_rss 'home/group_announcements.rss', :controller => 'home', :action ="" 'group_announcements_rss', :format => 'rss'
+  map.home_new_items_rss 'home/new_items.rss', :controller => 'home', :action ="" 'new_items_rss', :format => 'rss'
   map.home_updated_items_rss 'home/updated_items.rss', :controller => 'home', :action ="" 'updated_items_rss', :format => 'rss'
   map.home_latest_comments_rss 'home/latest_comments.rss', :controller => 'home', :action ="" 'latest_comments_rss', :format => 'rss'
   map.home_latest_reviews_rss 'home/latest_reviews.rss', :controller => 'home', :action ="" 'latest_reviews_rss', :format => 'rss'

Modified: branches/event_logging/lib/caching_helper.rb (2028 => 2029)


--- branches/event_logging/lib/caching_helper.rb	2008-12-03 11:04:12 UTC (rev 2028)
+++ branches/event_logging/lib/caching_helper.rb	2008-12-03 13:22:41 UTC (rev 2029)
@@ -7,6 +7,10 @@
   
   # Methods to expire caches for the home page
   
+  def expire_home_cache_new_items
+    expire_fragment(%r{home_cache/new_items/[0-9]+})
+  end
+  
   def expire_home_cache_updated_items
     expire_fragment(%r{home_cache/updated_items/[0-9]+})
   end

reply via email to

[Prev in Thread] Current Thread [Next in Thread]