myexperiment-hackers
[Top][All Lists]
Advanced

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

[myexperiment-hackers] [1967] branches/event_logging/app/views/layouts:


From: noreply
Subject: [myexperiment-hackers] [1967] branches/event_logging/app/views/layouts: Subscriptions.
Date: Fri, 14 Nov 2008 11:40:09 -0500 (EST)

Revision
1967
Author
alekses6
Date
2008-11-14 11:40:07 -0500 (Fri, 14 Nov 2008)

Log Message

Subscriptions.

* Icons in RSS partials for workflows/files/packs removed.
* Contents of partials for workflows/files/packs made similar to HTML manifest of downloaded pack.
* File types removed from headings of RSS items (kept in categories, though); workflow types kept.

Modified Paths

Diff

Modified: branches/event_logging/app/views/layouts/_blob.rxml (1966 => 1967)


--- branches/event_logging/app/views/layouts/_blob.rxml	2008-11-13 17:44:06 UTC (rev 1966)
+++ branches/event_logging/app/views/layouts/_blob.rxml	2008-11-14 16:40:07 UTC (rev 1967)
@@ -1,19 +1,65 @@
+# initialize extra local variables
+# (these will only be passed in if non-standard behaviour is required -
+#  for example, when the partial is called from pack_items.rss instead of
+#  /files.rss)
+extra_metadata ||= nil
+overriden_pubDate ||= nil
+overriden_author ||= nil
+make_title_non_clickable ||= false
+overriden_item_link ||= nil
+
+
 xm.item do
-  xm.title "#{h(contributable_name_from_instance(blob))} (#{h(blob.contribution.contributor.name || blob.contribution.contributor.title)}) [#{blob.content_type.strip}]"
+  # file details
+  filename = h(contributable_name_from_instance(blob))
+  filepath = file_url(blob)
+  file_type = blob.content_type.strip
   
-  # 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)
+  # original uploader of the file
+  uploader = blob.contribution.contributor
+  uploader_name = h(uploader.name || uploader.title)
+  uploader_path = eval("#{visible_name(uploader).downcase}_url(#{uploader.id})")
   
+  xm.title "File: #{h(contributable_name_from_instance(blob))} (#{uploader_name})"
+  
+  # body of RSS item will have all file details in it
+  desc = "<b>File: </b>" +  link_to(filename, filepath)
+  desc += "<br/><b>Type: </b>" + file_type
+  desc += "<br/><br/><b>Uploader: </b>" + link_to(uploader_name, uploader_path)
+  desc += "<br/><b>Uploaded on: </b>" + blob.contribution.created_at.strftime('%d/%m/%Y @ %H:%M:%S')
+  
+  desc += "<br/><br/><b>Description: </b><br/><blockquote>" + ((blob.body_html.nil? || blob.body_html.blank?) ? "<i>No description</i>" : blob.body_html) + "</blockquote>"
+  unless extra_metadata.nil?
+    desc += extra_metadata
+  end
+  xm.description white_list(desc)
+  
   # next line should be enabled when files become versioned
   # xm.version blob.current_version
-  xm.pubDate blob.contribution.updated_at.rfc822
+  
+  # if this needs to be set to something else from outside
+  unless overriden_pubDate.nil?    
+    xm.pubDate overriden_pubDate
+  else
+    xm.pubDate blob.contribution.created_at.rfc822
+  end
+  
   xm.category "Files [All]"
-  xm.category "Files [#{blob.content_type.strip}]"
+  xm.category "Files [#{file_type}]"
   xm.guid [request.host_with_port, "blob", blob.id.to_s].join(":"), "isPermaLink" => "false"
-  xm.author h(blob.contribution.contributor.name || blob.contribution.contributor.title)
-  xm.link file_url(blob)
+  
+  # when this partial is used, for example, for listing pack items -
+  # "author" or RSS entry is not the uploader of the file, but the one
+  # who added this file to the pack  
+  unless overriden_author.nil?
+    uploader_name = overriden_author
+  end
+  xm.author uploader_name
+  
+  unless make_title_non_clickable
+    unless overriden_item_link.nil?
+      filepath = overriden_item_link
+    end
+    xm.link filepath
+  end
 end
\ No newline at end of file

Modified: branches/event_logging/app/views/layouts/_pack.rxml (1966 => 1967)


--- branches/event_logging/app/views/layouts/_pack.rxml	2008-11-13 17:44:06 UTC (rev 1966)
+++ branches/event_logging/app/views/layouts/_pack.rxml	2008-11-14 16:40:07 UTC (rev 1967)
@@ -1,16 +1,59 @@
+# initialize extra local variables
+# (these will only be passed in if non-standard behaviour is required -
+#  for example, when the partial is called from pack_items.rss instead of
+#  /packs.rss)
+extra_metadata ||= nil
+overriden_pubDate ||= nil
+overriden_author ||= nil
+make_title_non_clickable ||= false
+overriden_item_link ||= nil
+
+
 xm.item do
-  xm.title "#{h(pack.title)} (#{h(pack.contribution.contributor.name || pack.contribution.contributor.title)})"
+  # pack details
+  pack_name = h(pack.title)
+  pack_path = pack_url(pack)
   
-  # 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)
+  # original uploader of the pack
+  creator = pack.contribution.contributor
+  creator_name = h(creator.name || creator.title)
+  creator_path = eval("#{visible_name(creator).downcase}_url(#{creator.id})")
   
-  xm.pubDate pack.contribution.updated_at.rfc822
+  xm.title "Pack: #{pack_name} (#{creator_name})"
+  
+  # body of RSS item will have all pack details in it
+  desc = "<b>Pack: </b>" +  link_to(pack_name, pack_path)
+  desc += "<br/><br/><b>Creator: </b>" + link_to(creator_name, creator_path)
+  desc += "<br/><b>Created on: </b>" + pack.contribution.created_at.strftime('%d/%m/%Y @ %H:%M:%S')
+  
+  desc += "<br/><br/><b>Description: </b><br/><blockquote>" + ((pack.description_html.nil? || pack.description_html.blank?) ? "<i>No description</i>" : pack.description_html) + "</blockquote>"
+  unless extra_metadata.nil?
+    desc += extra_metadata
+  end
+  xm.description white_list(desc)
+  
+  # if this needs to be set to something else from outside
+  unless overriden_pubDate.nil?    
+    xm.pubDate overriden_pubDate
+  else
+    xm.pubDate pack.contribution.created_at.rfc822
+  end
+  
   xm.category "Packs"
   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)
-  xm.link pack_url(pack)
+  
+  # when this partial is used, for example, for listing pack items -
+  # "author" or RSS entry is not the uploader of the pack, but the one
+  # who added this pack to the pack  
+  unless overriden_author.nil?
+    creator_name = overriden_author
+  end
+  xm.author creator_name
+  
+  unless make_title_non_clickable
+    unless overriden_item_link.nil?
+      pack_path = overriden_item_link
+    end
+    xm.link pack_path
+  end
 end
\ No newline at end of file

Modified: branches/event_logging/app/views/layouts/_pack_items.rxml (1966 => 1967)


--- branches/event_logging/app/views/layouts/_pack_items.rxml	2008-11-13 17:44:06 UTC (rev 1966)
+++ branches/event_logging/app/views/layouts/_pack_items.rxml	2008-11-14 16:40:07 UTC (rev 1967)
@@ -1,47 +1,37 @@
 pack.contributable_entries.each do |e|
   item_instance = e.contributable
   show = e.available? ? thing_authorized?('show', item_instance) : false
-  xm.item do
-    if show
-      # infer category metadata: for files and workflows fetch their type
-      item_visible_type = visible_name(e.contributable_type)
-      item_title_type = ""
-      item_categories = []
-      if item_visible_type == "File"
-        item_title_type = " [#{h(item_instance.content_type.strip)}]"
-        item_categories << "Files [All]"
-        item_categories << "Files" + item_title_type
-      elsif item_visible_type == "Workflow"
-        item_title_type = " [#{h(item_instance.type_display_name)}]"
-        item_categories << "Workflows [All]"
-        item_categories << "Workflows" + item_title_type
-      else
-        item_categories << item_visible_type.pluralize
-      end
-      
-      xm.title "#{item_visible_type}: #{contributable_name_from_instance(item_instance)}" + item_title_type
-      
-      # Description
-      desc = ''
-      desc += "<b>Comment:</b> #{h(e.comment)}" unless e.comment.blank?
-      xm.description desc
-      
-      item_categories.each do |cat|
-        xm.category cat
-      end
-    else
+  
+  if show
+    
+    # Description
+    desc = "<div style='border-left: 4px dotted; padding-left: 1em;'>"
+    desc += "<b>Added to pack by: </b>" + link_to(h(e.user.name), user_url(e.user.id))
+    desc += "<br/><b>Added to pack on: </b>" + e.created_at.strftime('%d/%m/%Y @ %H:%M:%S')
+    desc += "<br/><b>Comment (in pack):</b><blockquote>#{e.comment.blank? ? "<i>No comment</i>" : h(e.comment)}</blockquote>"
+    desc += "</div>"
+    
+    render(:partial => "layouts/#{e.contributable_type.to_s.downcase}", :object => item_instance, 
+                                                                        :locals => { :xm => xm, 
+                                                                                     :extra_metadata => desc,
+                                                                                     :overriden_pubDate => e.created_at.rfc822,
+                                                                                     :overriden_author => h(e.user.name),
+                                                                                     :overriden_item_link => pack_url(pack) + "#item_contributable_#{e.id.to_s}"})
+  else
+    xm.item do
       if not e.available?
         xm.title "{The item this entry points to is not available. It may have been deleted.}"
       else
         xm.title "{You are not authorised to view the item this entry points to.}"
       end
+      
+      xm.pubDate e.created_at.rfc822
+      xm.guid [request.host_with_port, "pack", pack.id.to_s, "item", "contributable", e.id.to_s].join(":"), "isPermaLink" => "false"
+      xm.author contributor_name(e.user_id, 'User')
+      xm.link pack_url(pack) + "#item_contributable_#{e.id.to_s}"
     end
-    
-    xm.pubDate e.updated_at.rfc822
-    xm.guid [request.host_with_port, "pack", pack.id.to_s, "item", "contributable", e.id.to_s].join(":"), "isPermaLink" => "false"
-    xm.author contributor_name(e.user_id, 'User')
-    xm.link pack_url(pack) + "#item_contributable_#{e.id.to_s}"
   end
+  
 end
 
 pack.remote_entries.each do |e|

Modified: branches/event_logging/app/views/layouts/_workflow.rxml (1966 => 1967)


--- branches/event_logging/app/views/layouts/_workflow.rxml	2008-11-13 17:44:06 UTC (rev 1966)
+++ branches/event_logging/app/views/layouts/_workflow.rxml	2008-11-14 16:40:07 UTC (rev 1967)
@@ -1,18 +1,82 @@
+# initialize extra local variables
+# (these will only be passed in if non-standard behaviour is required -
+#  for example, when the partial is called from pack_items.rss instead of
+#  /workflows.rss)
+overriden_version ||= nil
+extra_metadata ||= nil
+overriden_pubDate ||= nil
+overriden_author ||= nil
+make_title_non_clickable ||= false
+overriden_item_link ||= nil
+
+
 xm.item do
-  xm.title "#{h(workflow.title)} (#{h(workflow.contribution.contributor.name || workflow.contribution.contributor.title)}) [#{h(workflow.type_display_name)} Workflow]"
+  # workflow details
+  workflow_name = h(contributable_name_from_instance(workflow))
+  workflow_type = workflow.type_display_name
+  unless overriden_version.nil?
+    workflow_version = overriden_version
+  else
+    workflow_version = workflow.current_version
+  end
+  workflow_path = workflow_url(workflow) + "?version=#{workflow_version}"
   
-  # 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
+  # original uploader of the workflow
+  original_uploader = workflow.contribution.contributor
+  original_uploader_name = h(original_uploader.name || original_uploader.title)
+  original_uploader_path = eval("#{visible_name(original_uploader).downcase}_url(#{original_uploader.id})")
+  # version uploader
+  version_uploader = workflow.contributor
+  version_uploader_name = h(version_uploader.name || version_uploader.title)
+  version_uploader_path = eval("#{visible_name(version_uploader).downcase}_url(#{version_uploader.id})")
+  
+  # title is always the title of the latest version
+  xm.title "Workflow: #{h(workflow.title)} (#{version_uploader_name}) [#{h(workflow_type)}]"
+  
+  # body of RSS item will have all workflow details in it
+  desc = "<b>Workflow: </b>" +  link_to(workflow_name, workflow_path)
+  desc += "<br/><b>Type: </b>" + workflow_type
+  desc += "<br/><br/><b>Original uploader: </b>" + link_to(original_uploader_name, original_uploader_path)
+  desc += "<br/><b>Originally uploaded on: </b>" + workflow.contribution.created_at.strftime('%d/%m/%Y @ %H:%M:%S')
+  desc += "<br/><b>Version: </b>#{workflow_version}"
+  if workflow_version > 1  
+    desc += " (created on: #{workflow.created_at.strftime('%d/%m/%Y @ %H:%M:%S')})"
+    desc += "<br/><b>Version uploaded by: </b>" + link_to(version_uploader_name, version_uploader_path)
+  end
+  
+  desc += "<br/><br/><b>Description: </b><br/><blockquote>" + ((workflow.body_html.nil? || workflow.body_html.blank?) ? "<i>No description</i>" : workflow.body_html) + "</blockquote>"
+  unless extra_metadata.nil?
+    desc += extra_metadata
+  end
+  xm.description white_list(desc)
+  
+  
+  # if this needs to be set to something else from outside
+  unless overriden_pubDate.nil?    
+    xm.pubDate overriden_pubDate
+  else
+    # by default this is the date / time when the current workflow version was uploaded
+    xm.pubDate workflow.created_at.rfc822
+  end
+  
+  xm.version workflow_version
   xm.category "Workflows [All]"
-  xm.category "Workflows [#{h(workflow.type_display_name)}]"
+  xm.category "Workflows [#{h(workflow_type)}]"
   xm.guid [request.host_with_port, "workflow", workflow.id.to_s].join(":"), "isPermaLink" => "false"
-  xm.author h(workflow.contribution.contributor.name || workflow.contribution.contributor.title)
-  xm.link workflow_url(workflow)
+  
+  
+  # when this partial is used, for example, for listing pack items -
+  # "author" or RSS entry is not the uploader of the workflow, but the one
+  # who added this workflow to the pack  
+  unless overriden_author.nil?
+    version_uploader_name = overriden_author
+  end
+  xm.author version_uploader_name
+  
+  unless make_title_non_clickable
+    unless overriden_item_link.nil?
+      workflow_path = overriden_item_link
+    end
+    xm.link workflow_path
+  end
 end
\ No newline at end of file

reply via email to

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