myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [1958] branches/event_logging: Subscriptions.


From: noreply
Subject: [myexperiment-hackers] [1958] branches/event_logging: Subscriptions.
Date: Thu, 13 Nov 2008 06:01:09 -0500 (EST)

Revision
1958
Author
alekses6
Date
2008-11-13 06:01:09 -0500 (Thu, 13 Nov 2008)

Log Message

Subscriptions. Added RSS feed for latest comments.

Modified Paths

Added Paths

Diff

Modified: branches/event_logging/app/controllers/home_controller.rb (1957 => 1958)


--- branches/event_logging/app/controllers/home_controller.rb	2008-11-13 10:35:40 UTC (rev 1957)
+++ branches/event_logging/app/controllers/home_controller.rb	2008-11-13 11:01:09 UTC (rev 1958)
@@ -7,6 +7,7 @@
   
   before_filter :find_latest_public_updated_items_rss, : [:updated_items_rss]
   before_filter :find_latest_tags_rss, : [:latest_tags_rss]
+  before_filter :find_latest_comments_rss, : [:latest_comments_rss]
   
   # GET /home
   def index
@@ -47,7 +48,15 @@
     end
   end
   
+  def latest_comments_rss
+    respond_to do |format|
+      format.rss do 
+        render :action ="" 'latest_comments.rxml', :layout => false
+      end
+    end
+  end
   
+  
 protected
 
   def find_latest_public_updated_items_rss
@@ -76,4 +85,16 @@
     end
   end
   
+  def find_latest_comments_rss
+    # Only carry out if request is for RSS
+    if params[:format] and params[:format].downcase == 'rss'
+      @latest_comments_rss = {}
+      comments = Comment.latest(DEFAULT_RSS_ENTRY_COUNT)
+      comments.each do |c|
+        # commented item should be authorized for anonymous users to view
+        @latest_comments_rss[c] = c.commentable if c.commentable.authorized?("show", nil)
+      end
+    end
+  end
+  
 end

Modified: branches/event_logging/app/views/home/_latest_comments.rhtml (1957 => 1958)


--- branches/event_logging/app/views/home/_latest_comments.rhtml	2008-11-13 10:35:40 UTC (rev 1957)
+++ branches/event_logging/app/views/home/_latest_comments.rhtml	2008-11-13 11:01:09 UTC (rev 1958)
@@ -3,7 +3,7 @@
 <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">
-		Latest Comments
+		<%= feed_icon_tag("Latest Comments on myExperiment", home_latest_comments_rss_url) -%>&nbsp;Latest Comments
 	</div>
 	<div class="content">
 		<% unless (comments = Comment.latest).empty? %>

Added: branches/event_logging/app/views/home/latest_comments.rxml (0 => 1958)


--- branches/event_logging/app/views/home/latest_comments.rxml	                        (rev 0)
+++ branches/event_logging/app/views/home/latest_comments.rxml	2008-11-13 11:01:09 UTC (rev 1958)
@@ -0,0 +1,12 @@
+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
+    # this RSS feed will show ALL shared items for this group that are visible to anonymous users
+    xml.title "myExperiment.org - Latest Comments"
+    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 "RSS feed listing the most recently added comments on myExperiment.org"
+    render(:partial => "layouts/comment", :collection => @latest_comments_rss, :locals => { :xm => xml })
+  end
+end
\ No newline at end of file

Added: branches/event_logging/app/views/layouts/_comment.rxml (0 => 1958)


--- branches/event_logging/app/views/layouts/_comment.rxml	                        (rev 0)
+++ branches/event_logging/app/views/layouts/_comment.rxml	2008-11-13 11:01:09 UTC (rev 1958)
@@ -0,0 +1,20 @@
+xm.item do
+  comment_instance = comment[0]
+  comment_maker = comment_instance.user
+  
+  commented_item = comment[1]
+  item_name = contributable_name_from_instance(commented_item)
+  item_type = visible_name(commented_item)
+  item_icon = image_tag(method_to_icon_filename(commented_item.class.to_s.downcase), :style => "vertical-align: middle;", :alt => item_type) 
+
+  xm.title "#{h(comment_maker.name)} commented on \"#{h(item_name)}\" #{item_type}"
+  
+  comment_desc = "#{name(comment_maker, nil, false)} commented on #{item_icon}#{link_to item_name, contributable_url(comment_instance.commentable_id, comment_instance.commentable_type)} #{item_type}:"
+  comment_body = "<blockquote style='border: 1px dotted #999999; padding: 0.5em 0.8em; width: 600px;'>" + comment_instance.comment + "</blockquote>"
+  xm.description white_list(comment_desc + comment_body)
+  
+  xm.pubDate comment_instance.created_at.rfc822
+  xm.guid [request.host_with_port, "comment", comment_instance.id.to_s].join(":"), "isPermaLink" => "false"
+  xm.author h(comment_maker.name)
+  xm.link eval("#{item_type.downcase}_url(#{commented_item.id})") + "#comment_" + comment_instance.id.to_s
+end
\ No newline at end of file

Modified: branches/event_logging/app/views/layouts/_tagging.rxml (1957 => 1958)


--- branches/event_logging/app/views/layouts/_tagging.rxml	2008-11-13 10:35:40 UTC (rev 1957)
+++ branches/event_logging/app/views/layouts/_tagging.rxml	2008-11-13 11:01:09 UTC (rev 1958)
@@ -10,7 +10,7 @@
   item_icon = image_tag(method_to_icon_filename(tagged_item.class.to_s.downcase), :style => "vertical-align: middle;", :alt => item_type) 
 
   xm.title "\"#{h(tag_instance.name)}\" on \"#{h(item_name)}\" #{item_type} by #{h(tag_maker.name)}"
-  xm.description white_list("#{processed_tag_link} on #{item_icon}#{link_to item_name, contributable_url(tagging_instance.taggable_id, tagging_instance.taggable_type)} by #{name(tag_maker, nil, false)}")
+  xm.description white_list("#{processed_tag_link} on #{item_icon}#{link_to item_name, contributable_url(tagging_instance.taggable_id, tagging_instance.taggable_type)} #{item_type} by #{name(tag_maker, nil, false)}")
   
   # next line should be enabled when files become versioned
   # xm.version blob.current_version

Modified: branches/event_logging/config/routes.rb (1957 => 1958)


--- branches/event_logging/config/routes.rb	2008-11-13 10:35:40 UTC (rev 1957)
+++ branches/event_logging/config/routes.rb	2008-11-13 11:01:09 UTC (rev 1958)
@@ -239,6 +239,7 @@
   map.home_updated_items_rss 'home/updated_items.rss', :controller => 'home', :action ="" 'updated_items_rss', :format => 'rss'
   map.home_latest_groups_rss 'home/latest_groups.rss', :controller => 'home', :action ="" 'latest_groups_rss', :format => 'rss'
   map.home_latest_tags_rss 'home/latest_tags.rss', :controller => 'home', :action ="" 'latest_tags_rss', :format => 'rss'
+  map.home_latest_comments_rss 'home/latest_comments.rss', :controller => 'home', :action ="" 'latest_comments_rss', :format => 'rss'
 
   # Install the default route as the lowest priority.
   map.connect ':controller/:action/:id'

reply via email to

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