diff --git a/app/controllers/application.rb b/app/controllers/application.rb index f919da3..0e6741c 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -25,6 +25,13 @@ class ApplicationController < ActionController::Base end end + before_filter :load_profile_from_params + def load_profile_from_params + if params[:profile] + @profile = Profile.find_by_identifier(params[:profile]) + end + end + def self.acts_as_virtual_community_admin_controller before_filter :load_admin_controller end diff --git a/app/controllers/edit_template_controller.rb b/app/controllers/edit_template_controller.rb index e19447d..60b76aa 100644 --- a/app/controllers/edit_template_controller.rb +++ b/app/controllers/edit_template_controller.rb @@ -6,6 +6,7 @@ class EditTemplateController < ApplicationController { 'ListBlock' => _("List Block"), 'LinkBlock' => _("Link Block"), + 'RecentDocumentsBlock' => _('Recent documents'), 'Design::MainBlock' => _('Main content block'), } end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 3fe7c40..f385a65 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,7 +1,7 @@ -# Methods added to this helper will be available to all templates in the application. +# Methods added to this helper will be available to all templates in the +# application. module ApplicationHelper - # Displays context help. You can pass the content of the help message as the # first parameter or using template code inside a block passed to this # method. *Note*: the block is ignored if content is not @@ -100,7 +100,9 @@ module ApplicationHelper end def link_to_document(doc) - link_homepage(doc.title, doc.profile.identifier, :page => doc.full_path) + path = doc.full_path.split(/\//) + profile = path.shift + link_to doc.title, homepage_path(:profile => profile , :page => path) end # TODO: add the actual links @@ -145,4 +147,13 @@ module ApplicationHelper 'nothing in the footer yet' end + # returns the current profile beign viewed. + # + # Make sure that you use this helper method only in contexts where there + # should be a currnt profile (i.e. while viewing some profile's pages, or the + # profile info, etc), because if there is no profile an exception is thrown. + def profile + @profile || raise("There is no current profile") + end + end -- libgit2 0.21.2