Commit ff7e56b9d14b806b55bbe78661e389efad4c0e4b

Authored by AntonioTerceiro
1 parent a122a741

ActionItem18: displaying recent documents in a block



git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@436 3f533792-8f58-4932-b0fe-aaf55b0a4547
app/controllers/application.rb
... ... @@ -25,6 +25,13 @@ class ApplicationController < ActionController::Base
25 25 end
26 26 end
27 27  
  28 + before_filter :load_profile_from_params
  29 + def load_profile_from_params
  30 + if params[:profile]
  31 + @profile = Profile.find_by_identifier(params[:profile])
  32 + end
  33 + end
  34 +
28 35 def self.acts_as_virtual_community_admin_controller
29 36 before_filter :load_admin_controller
30 37 end
... ...
app/controllers/edit_template_controller.rb
... ... @@ -6,6 +6,7 @@ class EditTemplateController < ApplicationController
6 6 {
7 7 'ListBlock' => _("List Block"),
8 8 'LinkBlock' => _("Link Block"),
  9 + 'RecentDocumentsBlock' => _('Recent documents'),
9 10 'Design::MainBlock' => _('Main content block'),
10 11 }
11 12 end
... ...
app/helpers/application_helper.rb
1   -# Methods added to this helper will be available to all templates in the application.
  1 +# Methods added to this helper will be available to all templates in the
  2 +# application.
2 3 module ApplicationHelper
3 4  
4   -
5 5 # Displays context help. You can pass the content of the help message as the
6 6 # first parameter or using template code inside a block passed to this
7 7 # method. *Note*: the block is ignored if <tt>content</tt> is not
... ... @@ -100,7 +100,9 @@ module ApplicationHelper
100 100 end
101 101  
102 102 def link_to_document(doc)
103   - link_homepage(doc.title, doc.profile.identifier, :page => doc.full_path)
  103 + path = doc.full_path.split(/\//)
  104 + profile = path.shift
  105 + link_to doc.title, homepage_path(:profile => profile , :page => path)
104 106 end
105 107  
106 108 # TODO: add the actual links
... ... @@ -145,4 +147,13 @@ module ApplicationHelper
145 147 'nothing in the footer yet'
146 148 end
147 149  
  150 + # returns the current profile beign viewed.
  151 + #
  152 + # Make sure that you use this helper method only in contexts where there
  153 + # should be a currnt profile (i.e. while viewing some profile's pages, or the
  154 + # profile info, etc), because if there is no profile an exception is thrown.
  155 + def profile
  156 + @profile || raise("There is no current profile")
  157 + end
  158 +
148 159 end
... ...