myexperiment-hackers
[Top][All Lists]
Advanced

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

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


From: noreply
Subject: [myexperiment-hackers] [1949] branches/event_logging: Subscriptions.
Date: Wed, 12 Nov 2008 14:18:13 -0500 (EST)

Revision
1949
Author
alekses6
Date
2008-11-12 14:18:13 -0500 (Wed, 12 Nov 2008)

Log Message

Subscriptions. Shared items for group RSS feed added. Icons for file / workflow / pack added to descriptions of items (these will get displayed on individual RSS feeds for each type, too).

Modified Paths

Added Paths

Diff

Modified: branches/event_logging/app/controllers/networks_controller.rb (1948 => 1949)


--- branches/event_logging/app/controllers/networks_controller.rb	2008-11-12 17:45:34 UTC (rev 1948)
+++ branches/event_logging/app/controllers/networks_controller.rb	2008-11-12 19:18:13 UTC (rev 1949)
@@ -4,10 +4,11 @@
 # See license.txt for details.
 
 class NetworksController < ApplicationController
-  before_filter :login_required, :except => [:index, :show, :search, :all, :news]
+  before_filter :login_required, :except => [:index, :show, :search, :all, :news, :shared_items]
   
   before_filter :find_networks, : [:all]
-  before_filter :find_network, : [:membership_request, :show, :comment, :comment_delete, :tag, :news]
+  before_filter :find_network, : [:membership_request, :show, :comment, :comment_delete, :tag, :news, :shared_items]
+  before_filter :find_network_shared_items, : [:shared_items]
   before_filter :find_network_auth, : [:invite, :membership_invite, :membership_invite_external, :edit, :update, :destroy]
   
   # declare sweepers and which actions should invoke them
@@ -200,6 +201,16 @@
                 :network_id => @network.id
   end
   
+  # GET /group/1/shared_items.rss
+  def shared_items
+    respond_to do |format|
+      format.html { redirect_to group_path(params[:id]) }
+      format.rss do
+        render :action ="" 'shared_items.rxml', :layout => false
+      end
+    end
+  end
+  
   # GET /groups/1/news.rss
   def news
     respond_to do |format|
@@ -359,6 +370,18 @@
     end
   end
   
+  def find_network_shared_items
+    # only called for preparing item collection shown in RSS feed;
+    # on 'show' page "contributions/table" partial takes care of authorization of each item
+    @shared_items = []
+    shared_items = @network.shared_contributables
+    
+    shared_items.each do |item|
+      # should be authorized for anonymous users
+      @shared_items << item if item.authorized?("show", nil)
+    end
+  end
+  
 private
 
   def error(notice, message)

Modified: branches/event_logging/app/views/layouts/_blob.rxml (1948 => 1949)


--- branches/event_logging/app/views/layouts/_blob.rxml	2008-11-12 17:45:34 UTC (rev 1948)
+++ branches/event_logging/app/views/layouts/_blob.rxml	2008-11-12 19:18:13 UTC (rev 1949)
@@ -1,6 +1,13 @@
 xm.item do
   xm.title "#{h(contributable_name_from_instance(blob))} (#{h(blob.contribution.contributor.name || blob.contribution.contributor.title)}) [#{blob.content_type.strip}]"
-  xm.description white_list(blob.body_html)
+  
+  # all "body_html" fields start with <p> tag - need to put
+  # an icon inside, so do a bit of string parsing:
+  img = image_tag(method_to_icon_filename("blob"), :style => "vertical-align: middle;", :alt => "File")
+  desc = ((blob.body_html.nil? || blob.body_html.blank?) ? "<i>No description</i>" : blob.body_html.gsub(/^<p>/, ""))
+  full_desc = "<p>" + img + desc
+  xm.description white_list(full_desc)
+  
   # next line should be enabled when files become versioned
   # xm.version blob.current_version
   xm.pubDate blob.contribution.updated_at.rfc822

Modified: branches/event_logging/app/views/layouts/_pack.rxml (1948 => 1949)


--- branches/event_logging/app/views/layouts/_pack.rxml	2008-11-12 17:45:34 UTC (rev 1948)
+++ branches/event_logging/app/views/layouts/_pack.rxml	2008-11-12 19:18:13 UTC (rev 1949)
@@ -1,6 +1,13 @@
 xm.item do
   xm.title "#{h(pack.title)} (#{h(pack.contribution.contributor.name || pack.contribution.contributor.title)})"
-  xm.description white_list(pack.description_html)
+  
+  # all "description_html" fields start with <p> tag - need to put
+  # an icon inside, so do a bit of string parsing:
+  img = image_tag(method_to_icon_filename("pack"), :style => "vertical-align: middle;", :alt => "Pack")
+  desc = ((pack.description_html.nil? || pack.description_html.blank?) ? "<i>No description</i>" : pack.description_html.gsub(/^<p>/, ""))
+  full_desc = "<p>" + img + desc
+  xm.description white_list(full_desc)
+  
   xm.pubDate pack.contribution.updated_at.rfc822
   xm.guid [request.host_with_port, "pack", pack.id.to_s].join(":"), "isPermaLink" => "false"
   xm.author h(pack.contribution.contributor.name || pack.contribution.contributor.title)

Modified: branches/event_logging/app/views/layouts/_workflow.rxml (1948 => 1949)


--- branches/event_logging/app/views/layouts/_workflow.rxml	2008-11-12 17:45:34 UTC (rev 1948)
+++ branches/event_logging/app/views/layouts/_workflow.rxml	2008-11-12 19:18:13 UTC (rev 1949)
@@ -1,6 +1,13 @@
 xm.item do
   xm.title "#{h(workflow.title)} (#{h(workflow.contribution.contributor.name || workflow.contribution.contributor.title)}) [#{h(workflow.type_display_name)} Workflow]"
-  xm.description white_list(workflow.body_html)
+  
+  # all "body_html" fields start with <p> tag - need to put
+  # an icon inside, so do a bit of string parsing:
+  img = image_tag(method_to_icon_filename("workflow"), :style => "vertical-align: middle;", :alt => "Workflow")
+  desc = ((workflow.body_html.nil? || workflow.body_html.blank?) ? "<i>No description</i>" : workflow.body_html.gsub(/^<p>/, ""))
+  full_desc = "<p>" + img + desc
+  xm.description white_list(full_desc)
+
   xm.version workflow.current_version
   xm.pubDate workflow.contribution.updated_at.rfc822
   xm.guid [request.host_with_port, "workflow", workflow.id.to_s].join(":"), "isPermaLink" => "false"

Modified: branches/event_logging/app/views/networks/news.rxml (1948 => 1949)


--- branches/event_logging/app/views/networks/news.rxml	2008-11-12 17:45:34 UTC (rev 1948)
+++ branches/event_logging/app/views/networks/news.rxml	2008-11-12 19:18:13 UTC (rev 1949)
@@ -1,12 +1,11 @@
 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 - Public News for \"address@hidden" Group"
-    xml.link group_path(@network)
+    xml.link group_url(@network)
     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 public group news for address@hidden Group on myExperiment.org"
-    # for the feeds always display only the public announcements
     render(:partial => "layouts/group_news_entry", :collection => news_from_log_for_contributor(@network, Time.now, Time.now-DEFAULT_PUBLIC_NEWS_RSS_TIMEFRAME, true, false, DEFAULT_PUBLIC_NEWS_RSS_COUNT, nil), :locals => { :xm => xml, :group => @network })
   end
 end
\ No newline at end of file

Added: branches/event_logging/app/views/networks/shared_items.rxml (0 => 1949)


--- branches/event_logging/app/views/networks/shared_items.rxml	                        (rev 0)
+++ branches/event_logging/app/views/networks/shared_items.rxml	2008-11-12 19:18:13 UTC (rev 1949)
@@ -0,0 +1,15 @@
+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 - Shared Items of \"address@hidden" Group"
+    xml.link group_path(@network)
+    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 all items shared with address@hidden Group on myExperiment.org"
+    # iterate through the collection manually, as it contains items of different types
+    @shared_items.each do |item|
+      render(:partial => "layouts/#{item.class.to_s.downcase}", :object => item, :locals => { :xm => xml })
+    end
+  end
+end
\ No newline at end of file

Modified: branches/event_logging/app/views/networks/show.rhtml (1948 => 1949)


--- branches/event_logging/app/views/networks/show.rhtml	2008-11-12 17:45:34 UTC (rev 1948)
+++ branches/event_logging/app/views/networks/show.rhtml	2008-11-12 19:18:13 UTC (rev 1949)
@@ -160,7 +160,7 @@
 
 <a name="shared_items"></a>
 <div class="tabContainer">
-  <div class="tabTitle">Shared Items (<%= @shared_items.length -%>)</div>
+  <div class="tabTitle"><%= feed_icon_tag("\"address@hidden" Group shared items", formatted_shared_items_group_path(@network, :rss)) -%> Shared Items (<%= @shared_items.length -%>)</div>
   <div class="tabContent">
 		<% unless @shared_items.empty? %>
   		<%= view_privileges_notice %>

Modified: branches/event_logging/config/routes.rb (1948 => 1949)


--- branches/event_logging/config/routes.rb	2008-11-12 17:45:34 UTC (rev 1948)
+++ branches/event_logging/config/routes.rb	2008-11-12 19:18:13 UTC (rev 1949)
@@ -189,6 +189,7 @@
                  :comment_delete => :delete, 
                  :rate => :post, 
                  :tag => :post,
+                 :shared_items => :get,
                  :news => :get } do |group|
     # relationships 'accepted by' group (relation --> relationship --> group)
     group.resources :relationships, :member => { :accept => :get }

reply via email to

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