Diff
Modified: branches/event_logging/app/controllers/blobs_controller.rb (1962 => 1963)
--- branches/event_logging/app/controllers/blobs_controller.rb 2008-11-13 14:00:13 UTC (rev 1962)
+++ branches/event_logging/app/controllers/blobs_controller.rb 2008-11-13 14:24:44 UTC (rev 1963)
@@ -4,7 +4,7 @@
# See license.txt for details.
class BlobsController < ApplicationController
- before_filter :login_required, :except => [:index, :show, :download, :named_download, :search, :all]
+ before_filter :login_required, :except => [:index, :show, :download, :named_download, :search, :all, :news]
before_filter :find_blobs, : [:all]
before_filter :find_blobs_rss, : [:index]
@@ -82,6 +82,16 @@
end
end
+ # GET /files/1/news.rss
+ def news
+ respond_to do |format|
+ format.html { redirect_to file_path(params[:id]) }
+ format.rss do
+ render :action ="" 'news.rxml', :layout => false
+ end
+ end
+ end
+
# GET /files/new
def new
end
Modified: branches/event_logging/app/helpers/application_helper.rb (1962 => 1963)
--- branches/event_logging/app/helpers/application_helper.rb 2008-11-13 14:00:13 UTC (rev 1962)
+++ branches/event_logging/app/helpers/application_helper.rb 2008-11-13 14:24:44 UTC (rev 1963)
@@ -586,8 +586,9 @@
#
# Parameters:
# (default parameters defined in environment_private.rb)
- # 1) contributor - instance of a User or Network, for which the news are generated
- # (NIL to generate public news for "home" page)
+ # 1) news_for - instance of a contributor (User/Network) OR contributable (Workflow/File/Pack)
+ # for which the news are generated;
+ # (NIL to generate public news for "home" page)
# 2) restrict_contributor - when set to "true" will generate news only for the current contributor;
# when set to "false" will pick up also all related contributors;
# 3-4) before, after - Time objects; the news will be generated in a time slice [after..before]
@@ -595,18 +596,23 @@
# (NIL to process all events within ["after".."before"] timeframe)
# 6) current_viewer - User instance, which requests to generate the news
# (zero or NIL value indicates not logged in viewer; also a setting for RSS feeds, etc - only public events will be shown)
- def news(contributor, restrict_contributor=true, before=Time.now, after=Time.now-DEFAULT_NEWS_TIMEFRAME, limit=DEFAULT_NEWS_COUNT, current_viewer=nil)
+ def news(news_for, restrict_contributor=true, before=Time.now, after=Time.now-DEFAULT_NEWS_TIMEFRAME, limit=DEFAULT_NEWS_COUNT, current_viewer=nil)
hash = {}
# if event logging is switched off in "environment_private.rb" - no news can be generated
return hash unless USE_EVENT_LOG
# collect all activity log events and interpret them as news entries;
- # choose to display "my news" page for logged in users or a general one for anonymous viewers:
- if contributor.nil?
+ # choose to display news feed type:
+ # * public news for anonymous viewers;
+ # * "my news" page for logged in users; user / group profile page
+ # * news for a contributable item
+ if news_for.nil?
news_array = news_from_log_public(before, after, limit, current_viewer)
- else
- news_array = news_from_log_for_contributor(contributor, before, after, restrict_contributor, false, limit, current_viewer)
+ elsif ["User", "Network"].include? (news_for.class.to_s)
+ news_array = news_from_log_for_contributor(news_for, before, after, restrict_contributor, false, limit, current_viewer)
+ elsif ["Workflow", "Blob", "Pack"].include? (news_for.class.to_s)
+ news_array = news_from_log_for_contributable(news_for, before, after, limit, current_viewer)
end
news_array.sort! { |a, b|
@@ -1584,6 +1590,28 @@
end
+ # Produces an array of news items in a form of [timestamp, description string] from ActivityLog table.
+ #
+ # These are the news about certain contributable, not a contributor(user/group)
+ # ("contributor" for which these news are generated is treated as NIL in this case)
+ def news_from_log_for_contributable(contributable, before, after, limit, current_viewer)
+ events = []
+ obj_type = contributable.class.to_s
+ obj_id = contributable.id
+
+ # get all events from activity log in the required timeframe for the desired contributable
+ # (NB! the contributable can't be "culprit" of the action)
+ events = ActivityLog.find(:all, :conditions => ["((activity_loggable_type = ? AND activity_loggable_id = ?) OR (referenced_type = ? AND referenced_id = ?)) AND created_at > ? AND created_at < ?", obj_type, obj_id, obj_type, obj_id, after, before])
+
+ # interpret activity log entries into news entries
+ # (contributor set to NIL to indicate that non-contributor page is viewed - "show" page for
+ # a contributable in this case)
+ rtn = news_entries_from_log_entries(events, limit, current_viewer, nil, false)
+
+ return rtn
+ end
+
+
# Helper method that interprets an array of activity log entries into an array of news entries
# (works in a generic way for anonymous home page, user home page, user/group profile pages)
def news_entries_from_log_entries(events, limit, current_viewer, contributor, contributor_news_only)
Modified: branches/event_logging/app/models/policy.rb (1962 => 1963)
--- branches/event_logging/app/models/policy.rb 2008-11-13 14:00:13 UTC (rev 1962)
+++ branches/event_logging/app/models/policy.rb 2008-11-13 14:24:44 UTC (rev 1963)
@@ -342,6 +342,7 @@
"rate",
"tag",
"view",
+ "news",
"comments_timeline",
"comments",
"items"],
Added: branches/event_logging/app/views/blobs/news.rxml (0 => 1963)
--- branches/event_logging/app/views/blobs/news.rxml (rev 0)
+++ branches/event_logging/app/views/blobs/news.rxml 2008-11-13 14:24:44 UTC (rev 1963)
@@ -0,0 +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 - News and Status Updates for \"#{contributable_name_from_instance(@blob)}\" File"
+ xml.link file_url(@blob)
+ 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 status updates for #{contributable_name_from_instance(@blob)} File on myExperiment.org"
+ render(:partial => "layouts/news_entry", :collection => news_from_log_for_contributable(@blob, Time.now, Time.now-DEFAULT_CONTRIBUTABLE_NEWS_TIMEFRAME, DEFAULT_RSS_ENTRY_COUNT, nil), :locals => { :xm => xml })
+ end
+end
\ No newline at end of file
Modified: branches/event_logging/app/views/blobs/show.rhtml (1962 => 1963)
--- branches/event_logging/app/views/blobs/show.rhtml 2008-11-13 14:00:13 UTC (rev 1962)
+++ branches/event_logging/app/views/blobs/show.rhtml 2008-11-13 14:24:44 UTC (rev 1963)
@@ -31,11 +31,13 @@
|
<%= link_to "Favourited By (address@hidden)", "#favourited_by" %>
|
+ <br/>
+ |
+ <a href=""
+ |
<% if logged_in? and @blob.owner?(current_user) %>
- <br/>
- |
<!-- NB! Index of the 'sharing' tab might change! -->
- <a href=""
+ <a href=""
|
<% end %>
<%= link_to "Comments (address@hidden)", "#comments" %>
@@ -134,6 +136,19 @@
<br/>
<div id="tabsContainer" class="tabsContainer"></div>
+
+ <a name="news"></a>
+ <div class="tabContainer">
+ <div class="tabTitle"><%= feed_icon_tag("\"#{contributable_name_from_instance(@blob)}\" File news", formatted_news_file_path(@blob, :rss)) -%> News</div>
+ <div class="tabContent">
+ <% benchmark "File page news feed" do %>
+ <% viewer_id = (logged_in? ? current_user.id : "public") -%>
+ <% cache_timeout({ :controller => 'news', :action ="" 'file', :id => @blob.id, :viewer => viewer_id } , NEWS_CACHE_TIMEOUT.seconds.from_now ) do -%>
+ <%= render :partial => "layouts/news", :locals => { :collection => news(@blob, true, Time.now, Time.now-DEFAULT_CONTRIBUTABLE_NEWS_TIMEFRAME, DEFAULT_CONTRIBUTABLE_NEWS_COUNT, current_user) } %>
+ <% end -%>
+ <% end %>
+ </div>
+ </div>
<% if logged_in? and @blob.owner? current_user %>
Modified: branches/event_logging/config/environment_private.rb.pre (1962 => 1963)
--- branches/event_logging/config/environment_private.rb.pre 2008-11-13 14:00:13 UTC (rev 1962)
+++ branches/event_logging/config/environment_private.rb.pre 2008-11-13 14:24:44 UTC (rev 1963)
@@ -94,28 +94,32 @@
# [this means that only events after (Time.now - DEFAULT_<>_TIMEFRAME) will be fetched from event log]
DEFAULT_NEWS_TIMEFRAME = 1.week
DEFAULT_ANONYMOUS_HOME_PAGE_NEWS_TIMEFRAME = DEFAULT_NEWS_TIMEFRAME
-DEFAULT_PUBLIC_NEWS_RSS_TIMEFRAME = DEFAULT_NEWS_TIMEFRAME
DEFAULT_USER_HOME_PAGE_NEWS_TIMEFRAME = DEFAULT_NEWS_TIMEFRAME
DEFAULT_USER_NEWS_TIMEFRAME = DEFAULT_NEWS_TIMEFRAME
DEFAULT_GROUP_NEWS_TIMEFRAME = 2.weeks
+DEFAULT_CONTRIBUTABLE_NEWS_TIMEFRAME = 2.weeks
# Default news entry counts
DEFAULT_NEWS_COUNT = 30
DEFAULT_ANONYMOUS_HOME_PAGE_NEWS_COUNT = 50
-DEFAULT_PUBLIC_NEWS_RSS_COUNT = 50
DEFAULT_USER_HOME_PAGE_NEWS_COUNT = DEFAULT_NEWS_COUNT
DEFAULT_USER_NEWS_COUNT = DEFAULT_NEWS_COUNT
DEFAULT_GROUP_NEWS_COUNT = DEFAULT_NEWS_COUNT
+DEFAULT_CONTRIBUTABLE_NEWS_COUNT = DEFAULT_NEWS_COUNT
# =========== Settings for RSS feeds ===========
-# currently used for "latest tags|comments|reviews"
-DEFAULT_RSS_ENTRY_COUNT = 20
+# public news RSS feed on "home" page
+DEFAULT_PUBLIC_NEWS_RSS_TIMEFRAME = DEFAULT_NEWS_TIMEFRAME
+DEFAULT_PUBLIC_NEWS_RSS_COUNT = 50
# number of entries to show in "latest workflows|files|packs" feeds
+# (latest contributables - /workflows, /files, /packs respectively; latest groups - /groups)
LATEST_CONTRIBUTABLES_RSS_ENTRY_COUNT = 30
+LATEST_GROUPS_RSS_ENTRY_COUNT = 10
# various feeds on "home" page
-LATEST_UPDATED_ITEMS_RSS_ENTRY_COUNT = 25
-LATEST_GROUPS_RSS_ENTRY_COUNT = 10
\ No newline at end of file
+# (DEFAULT_RSS_ENTRY_COUNT is currently used for "latest tags|comments|reviews"; RSS news feed for Files)
+DEFAULT_RSS_ENTRY_COUNT = 20
+LATEST_UPDATED_ITEMS_RSS_ENTRY_COUNT = 25
\ No newline at end of file
Modified: branches/event_logging/config/routes.rb (1962 => 1963)
--- branches/event_logging/config/routes.rb 2008-11-13 14:00:13 UTC (rev 1962)
+++ branches/event_logging/config/routes.rb 2008-11-13 14:24:44 UTC (rev 1963)
@@ -97,7 +97,8 @@
:comment => :post,
:comment_delete => :delete,
:rate => :post,
- :tag => :post } do |file|
+ :tag => :post,
+ :news => :get } do |file|
# Due to restrictions in the version of Rails used (v1.2.3),
# we cannot have reviews as nested resources in more than one top level resource.
# ie: we cannot have polymorphic nested resources.