Modified: branches/event_logging/app/helpers/application_helper.rb (1997 => 1998)
--- branches/event_logging/app/helpers/application_helper.rb 2008-11-20 16:32:21 UTC (rev 1997)
+++ branches/event_logging/app/helpers/application_helper.rb 2008-11-21 12:00:51 UTC (rev 1998)
@@ -625,9 +625,9 @@
time = news_item[0].strftime("%H:%M")
if hash.has_key? nearest_day
- hash[nearest_day] << ["#{time}", "#{news_item[1]}"]
+ hash[nearest_day] << ["#{time}", "#{news_item[1]}", "#{news_item[2]}"]
else
- hash[nearest_day] = [["#{time}", "#{news_item[1]}"]]
+ hash[nearest_day] = [["#{time}", "#{news_item[1]}", "#{news_item[2]}"]]
end
end
@@ -1681,7 +1681,7 @@
end
- # Produces an array of news items in a form of [timestamp, description string] from ActivityLog table.
+ # Produces an array of news items in a form of [timestamp, description string, news_category_string] from ActivityLog table.
# (this is a worker method, usually called from news() - therefore, the caller method has default
# parameter values declared; the worker method needs to get all the parameters)
#
@@ -1701,7 +1701,7 @@
end
- # Produces an array of news items in a form of [timestamp, description string] from ActivityLog table.
+ # Produces an array of news items in a form of [timestamp, description string, news_category_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)
@@ -1773,7 +1773,7 @@
# helper method that interprets an event log entry from ActivityLog table
- # into a news entry in a format of [timestamp, news_entry_string];
+ # into a news entry in a format of [timestamp, news_entry_string, news_category_string];
#
# NIL is returned when the user viewing the news is not authorized to see
# current news entry OR entry in the event log is no longer valid because of
@@ -1835,13 +1835,13 @@
if authorized
if action == "create" && wf_version.version == 1
# new workflow created
- rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>created</span> the #{link_to workflow_visible_name, workflow_path} #{wf_type} Workflow."]
+ rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>created</span> the #{link_to workflow_visible_name, workflow_path} #{wf_type} Workflow.", "New Workflows"]
elsif action == "create"
# added new version for existing workflow
- rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>added</span> version #{wf_version_number} of the #{link_to workflow_visible_name, workflow_path} #{wf_type} Workflow."]
+ rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>added</span> version #{wf_version_number} of the #{link_to workflow_visible_name, workflow_path} #{wf_type} Workflow.", "New Workflow Versions"]
elsif action == "update"
# updated an existing version
- rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>updated</span> version #{wf_version_number} of the #{link_to workflow_visible_name, workflow_path} #{wf_type} Workflow."]
+ rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>updated</span> version #{wf_version_number} of the #{link_to workflow_visible_name, workflow_path} #{wf_type} Workflow.", "Edited Workflow Versions"]
end
end
rescue ActiveRecord::RecordNotFound
@@ -1856,10 +1856,12 @@
# check if contributable can still be found
object, object_path = evaluate_object_instance_and_path(log_entry.activity_loggable_type, log_entry.activity_loggable_id)
object_visible_name = contributable_name_from_instance(object)
+ object_visible_type = model_visible_name(loggable_type.to_s)
# need to check that current viewer allowed to see news entry about the current contributable
if my_event || object.authorized?("view", current_viewer)
- rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>#{action}d</span> the #{link_to object_visible_name, object_path} #{model_visible_name(loggable_type.to_s)}."]
+ news_category = ((action == "create") ? "New" : "Edited" ) + " " + object_visible_type.pluralize
+ rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>#{action}d</span> the #{link_to object_visible_name, object_path} #{object_visible_type}.", news_category]
end
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing contributable item
@@ -1881,6 +1883,7 @@
# eliminate further processing if not authorized to view the pack anyway
authorized = false unless my_event || pack.authorized?("view", current_viewer)
return nil unless authorized
+ news_category = "New Pack Items"
if loggable_type == "PackContributableEntry"
# ..and check if local entry (and the item it points to) can still be found
@@ -1897,7 +1900,7 @@
authorized = false unless my_event || object.authorized?("view", current_viewer)
if authorized
- rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>added</span> #{link_to object_visible_name, object_path} #{model_visible_name(object.class.to_s, true, object)} to #{pack_link} Pack."]
+ rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>added</span> #{link_to object_visible_name, object_path} #{model_visible_name(object.class.to_s, true, object)} to #{pack_link} Pack.", news_category]
end
else
# ..and check if external link can still be found
@@ -1906,7 +1909,7 @@
# if allowed to see the pack, no further checks required as anyone can see external items
if authorized
- rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>added</span> an external link to #{pack_link} Pack: #{link_to remote_entry.title, remote_entry.uri, :title => tooltip_title_attrib(h(remote_entry.uri))}."]
+ rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>added</span> an external link to #{pack_link} Pack: #{link_to remote_entry.title, remote_entry.uri, :title => tooltip_title_attrib(h(remote_entry.uri))}.", news_category]
end
end
rescue ActiveRecord::RecordNotFound
@@ -1949,29 +1952,30 @@
# if no exception at this point, can generate the news item:
# (name() and title() will accept instance instead of ID of the object - to save an extra DB access)
if authorized
+ news_category = "Memberships"
case action
when "invite"
- rtn << [timestamp, "#{name(network_admin, nil, false)} <span class='news_feed_action'>invited</span> #{name(user, nil, false)} to join the #{title(network)} Group."]
+ rtn << [timestamp, "#{name(network_admin, nil, false)} <span class='news_feed_action'>invited</span> #{name(user, nil, false)} to join the #{title(network)} Group.", news_category]
when "request"
- rtn << [timestamp, "#{name(user, nil, false)} <span class='news_feed_action'>requested</span> to join the #{title(network)} Group."]
+ rtn << [timestamp, "#{name(user, nil, false)} <span class='news_feed_action'>requested</span> to join the #{title(network)} Group.", news_category]
when "accept"
# even though it can be the admin who accepted the membership request,
# news item says that the "user" has joined the group - so it's not
# acceptable to show this event on the group admin's profile page
return nil if (contributor_news_only && contributor.id == network_admin.id)
- rtn << [timestamp, "#{name(user, nil, false)} <span class='news_feed_action'>joined</span> the #{title(network)} Group."]
+ rtn << [timestamp, "#{name(user, nil, false)} <span class='news_feed_action'>joined</span> the #{title(network)} Group.", news_category]
when "reject"
if log_entry.culprit_type == "User"
- rtn << [timestamp, "#{name(user, nil, false)} <span class='news_feed_action'>rejected</span> invitation to join the #{title(network)} Group."]
+ rtn << [timestamp, "#{name(user, nil, false)} <span class='news_feed_action'>rejected</span> invitation to join the #{title(network)} Group.", news_category]
else
- rtn << [timestamp, "#{name(network_admin, nil, false)} <span class='news_feed_action'>rejected</span> #{name(user, nil, false)}'s request to join the #{title(network)} Group."]
+ rtn << [timestamp, "#{name(network_admin, nil, false)} <span class='news_feed_action'>rejected</span> #{name(user, nil, false)}'s request to join the #{title(network)} Group.", news_category]
end
when "destroy"
if log_entry.culprit_type == "User"
- rtn << [timestamp, "#{name(user, nil, false)} has <span class='news_feed_action'>left</span> the #{title(network)} Group."]
+ rtn << [timestamp, "#{name(user, nil, false)} has <span class='news_feed_action'>left</span> the #{title(network)} Group.", news_category]
else
- rtn << [timestamp, "#{name(network_admin, nil, false)} <span class='news_feed_action'>removed</span> #{name(user, nil, false)} from the list of members of the #{title(network)} Group."]
+ rtn << [timestamp, "#{name(network_admin, nil, false)} <span class='news_feed_action'>removed</span> #{name(user, nil, false)} from the list of members of the #{title(network)} Group.", news_category]
end
end
else
@@ -2002,15 +2006,16 @@
# seems to be existent, as no exception thrown;
# name() will accept instance of the User to save an extra DB access
if authorized
+ news_category = "Friendships"
case action
when "create"
- rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>requested</span> friendship with #{name(referenced_user, nil, false)}."]
+ rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>requested</span> friendship with #{name(referenced_user, nil, false)}.", news_category]
when "accept"
rtn << [timestamp, "#{culprit_link} and #{name(referenced_user, nil, false)} <span class='news_feed_action'>became friends</span>."]
when "reject"
- rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>rejected</span> a friendship request from #{name(referenced_user, nil, false)}."]
+ rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>rejected</span> a friendship request from #{name(referenced_user, nil, false)}.", news_category]
when "destroy"
- rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>removed</span> #{name(referenced_user, nil, false)} from their friends list."]
+ rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>removed</span> #{name(referenced_user, nil, false)} from their friends list.", news_category]
end
else
return nil
@@ -2022,7 +2027,7 @@
network = Network.find(log_entry.activity_loggable_id)
# anyone is allowed to see new groups
- rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>created</span> the #{title(network)} Group."]
+ rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>created</span> the #{title(network)} Group.", "New Groups"]
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing group
end
@@ -2039,7 +2044,7 @@
if authorized
# title can't be blank for group announcements, so it's safe to assume it's going to be present;
- rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>made</span> an announcement \"#{link_to ann.title, group_announcement_path(log_entry.referenced_id, ann.id)}\" for group #{title(group)}."]
+ rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>made</span> an announcement \"#{link_to ann.title, group_announcement_path(log_entry.referenced_id, ann.id)}\" for group #{title(group)}.", "New Group Announcements"]
end
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing group announcement / group
@@ -2105,7 +2110,7 @@
end
if authorized
- rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>shared</span> #{access_rights} #{shared_what_links_arr.join(", ")} with #{shared_with}."]
+ rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>shared</span> #{access_rights} #{shared_what_links_arr.join(", ")} with #{shared_with}.", "Shared Items"]
end
end
rescue ActiveRecord::RecordNotFound
@@ -2125,7 +2130,7 @@
authorized = ( my_event || object.authorized?("view", current_viewer) )
if authorized
- rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>rated</span> #{link_to object_visible_name, object_path} #{model_visible_name(log_entry.referenced_type.to_s, true, object)} #{rating.rating} out of 5."]
+ rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>rated</span> #{link_to object_visible_name, object_path} #{model_visible_name(log_entry.referenced_type.to_s, true, object)} #{rating.rating} out of 5.", "Ratings"]
end
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing rating / object
@@ -2148,7 +2153,7 @@
authorized = ( my_event || object.authorized?("view", current_viewer) )
if authorized
- rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>added</span> #{link_to object_visible_name, object_path} #{model_visible_name(log_entry.referenced_type.to_s, true, object)} to their #{link_to "favourites", user_path(log_entry.culprit_id) + "/favourites"}."]
+ rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>added</span> #{link_to object_visible_name, object_path} #{model_visible_name(log_entry.referenced_type.to_s, true, object)} to their #{link_to "favourites", user_path(log_entry.culprit_id) + "/favourites"}.", "Favourites"]
end
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing bookmark / object
@@ -2167,7 +2172,7 @@
authorized = ( my_event || object.authorized?("view", current_viewer) )
if authorized
- rtn << [timestamp, "#{culprit_link} #{link_to "commented", object_path + "#comment_" + comment.id.to_s} on #{link_to object_visible_name, object_path} #{model_visible_name(log_entry.referenced_type.to_s, true, object)}."]
+ rtn << [timestamp, "#{culprit_link} #{link_to "commented", object_path + "#comment_" + comment.id.to_s} on #{link_to object_visible_name, object_path} #{model_visible_name(log_entry.referenced_type.to_s, true, object)}.", "Comments"]
end
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing comment / object
@@ -2195,7 +2200,7 @@
authorized = ( my_event || object.authorized?("view", current_viewer) )
if authorized
- rtn << [timestamp, "#{culprit_link} #{link_to_unless reviewed_link.nil?, (reviewed_link.nil? ? "<span class='news_feed_action'>reviewed</span>" : "reviewed"), reviewed_link} #{link_to object_visible_name, object_path} #{model_visible_name(log_entry.referenced_type.to_s, true, object)}#{review_title_link}."]
+ rtn << [timestamp, "#{culprit_link} #{link_to_unless reviewed_link.nil?, (reviewed_link.nil? ? "<span class='news_feed_action'>reviewed</span>" : "reviewed"), reviewed_link} #{link_to object_visible_name, object_path} #{model_visible_name(log_entry.referenced_type.to_s, true, object)}#{review_title_link}.", "Reviews"]
end
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing review / object
@@ -2231,7 +2236,7 @@
end
if authorized
- rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>credited</span> #{credited_whom} for #{link_to object_visible_name, object_path} #{model_visible_name(object.class.to_s, true, object)}."]
+ rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>credited</span> #{credited_whom} for #{link_to object_visible_name, object_path} #{model_visible_name(object.class.to_s, true, object)}.", "Creditations"]
end
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing creditation / object
@@ -2256,7 +2261,7 @@
authorized = ( my_event || attributed_to.authorized?("view", current_viewer) )
if authorized
- rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>attributed</span> #{link_to attributed_what_visible_name, attributed_what_path} #{model_visible_name(attributed_what.class.to_s, true, attributed_what)} to #{link_to attributed_to_visible_name, attributed_to_path} #{model_visible_name(attributed_to.class.to_s, true, attributed_to)}."]
+ rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>attributed</span> #{link_to attributed_what_visible_name, attributed_what_path} #{model_visible_name(attributed_what.class.to_s, true, attributed_what)} to #{link_to attributed_to_visible_name, attributed_to_path} #{model_visible_name(attributed_to.class.to_s, true, attributed_to)}.", "Attributions"]
end
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing creditation / object
@@ -2275,7 +2280,7 @@
authorized = ( my_event || object.authorized?("view", current_viewer) )
if authorized
- rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>tagged</span> #{link_to object_visible_name, object_path} #{model_visible_name(log_entry.referenced_type.to_s, true, object)} with \"#{link_to tag.name, tag_path(tag.id)}\"."]
+ rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>tagged</span> #{link_to object_visible_name, object_path} #{model_visible_name(log_entry.referenced_type.to_s, true, object)} with \"#{link_to tag.name, tag_path(tag.id)}\".", "Tags"]
end
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing tagging / tag / object
@@ -2297,7 +2302,7 @@
authorized = ( my_event || object.authorized?("view", current_viewer) )
if authorized
- rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>added</span> #{link_to "citation", workflow_citation_path(object.id, citation.id)} for #{link_to object_visible_name, object_path} #{model_visible_name(log_entry.referenced_type.to_s, true, object)}."]
+ rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>added</span> #{link_to "citation", workflow_citation_path(object.id, citation.id)} for #{link_to object_visible_name, object_path} #{model_visible_name(log_entry.referenced_type.to_s, true, object)}.", "Citations"]
end
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing citation / cited item
@@ -2307,7 +2312,7 @@
when "PictureSelection"
# TODO: how to check that picture selection is still valid?
# anyone can see picture selections of others (news only generated for friends / user's networks' members anyway)
- rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>selected</span> a new profile picture.<br/>#{link_to image_tag(avatar_url(log_entry.referenced_id, 50), :alt => h(culprit.name), :class => 'framed', :style => "vertical-align:text-top; margin: 0.2em 0;"), user_path(log_entry.culprit_id)}"]
+ rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>selected</span> a new profile picture.<br/>#{link_to image_tag(avatar_url(log_entry.referenced_id, 50), :alt => h(culprit.name), :class => 'framed', :style => "vertical-align:text-top; margin: 0.2em 0;"), user_path(log_entry.culprit_id)}", "Profile Picture Selections"]
when "Profile"
case action
@@ -2316,7 +2321,7 @@
when "update"
# only friends of the user will see this event
if my_event || (logged_in? && current_viewer.friend?(log_entry.culprit_id))
- rtn << [timestamp, "#{culprit_link} has <span class='news_feed_action'>updated</span> their #{link_to "profile", user_path(log_entry.culprit_id)}."]
+ rtn << [timestamp, "#{culprit_link} has <span class='news_feed_action'>updated</span> their #{link_to "profile", user_path(log_entry.culprit_id)}.", "User Profile Updates"]
end
end
@@ -2328,7 +2333,7 @@
user_link = name(log_entry.activity_loggable_id, nil, false)
return nil if user_link.nil?
- rtn << [timestamp, "#{user_link} <span class='news_feed_action'>joined</span> #{link_to "myExperiment", "/"}."]
+ rtn << [timestamp, "#{user_link} <span class='news_feed_action'>joined</span> #{link_to "myExperiment", "/"}.", "New Users"]
when "update"
# for now this event is not shown to anyone - event to the user themself,
# partly because every time when user logs in "last seen" field is set, which
@@ -2355,7 +2360,7 @@
end
# anyone allowed to see site announcements
- rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>made</span> a #{link_to_unless ann_link.nil?, "site announcement", ann_link}#{ann_title_link}."]
+ rtn << [timestamp, "#{culprit_link} <span class='news_feed_action'>made</span> a #{link_to_unless ann_link.nil?, "site announcement", ann_link}#{ann_title_link}.", "Site Announcements"]
rescue ActiveRecord::RecordNotFound
# do nothing, but don't display the news entry for missing site announcement
end