From 8b4dbf410582237c15e121a207080ee9c7c8afe3 Mon Sep 17 00:00:00 2001 From: Carlos Morais Date: Tue, 6 Dec 2011 13:46:32 -0200 Subject: [PATCH] Adding content type and view_path hotspots --- app/controllers/my_profile/cms_controller.rb | 10 +++++++++- app/controllers/public/content_viewer_controller.rb | 8 ++++++++ lib/noosfero/plugin.rb | 12 ++++++++++++ 3 files changed, 29 insertions(+), 1 deletion(-) diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index 2e9372c..989d223 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -50,7 +50,7 @@ class CmsController < MyProfileController end def special_article_types - [Folder, Blog, UploadedFile, Forum, Gallery, RssFeed] + [Folder, Blog, UploadedFile, Forum, Gallery, RssFeed] + @plugins.map(:content_types) end def view @@ -79,6 +79,7 @@ class CmsController < MyProfileController end def edit + plugins_prepend_view_paths @article = profile.articles.find(params[:id]) @parent_id = params[:parent_id] @type = params[:type] || @article.class.to_s @@ -102,6 +103,7 @@ class CmsController < MyProfileController end def new + plugins_prepend_view_paths # FIXME this method should share some logic wirh edit !!! # user must choose an article type first @@ -352,6 +354,12 @@ class CmsController < MyProfileController } end.to_json end + + def plugins_prepend_view_paths + @plugins.map(:view_path).each do |view_path| + prepend_view_path(view_path) + end + end def content_editor? true diff --git a/app/controllers/public/content_viewer_controller.rb b/app/controllers/public/content_viewer_controller.rb index 6ec74ab..957b945 100644 --- a/app/controllers/public/content_viewer_controller.rb +++ b/app/controllers/public/content_viewer_controller.rb @@ -6,6 +6,7 @@ class ContentViewerController < ApplicationController helper TagsHelper def view_page + plugins_prepend_view_paths path = params[:page].join('/') if path.blank? @@ -151,5 +152,12 @@ class ContentViewerController < ApplicationController end end end + + # FIXME duplicated + def plugins_prepend_view_paths + @plugins.map(:view_path).each do |view_path| + prepend_view_path(view_path) + end + end end diff --git a/lib/noosfero/plugin.rb b/lib/noosfero/plugin.rb index e006117..bd50cbb 100644 --- a/lib/noosfero/plugin.rb +++ b/lib/noosfero/plugin.rb @@ -105,6 +105,18 @@ class Noosfero::Plugin nil end + # -> Adds plugin-specific content types to CMS + # returns = { content type class } + def content_types + nil + end + + # -> Can be used to add plugin-specific view paths to controllers + # returns = { plugins' view paths } + def view_path + nil + end + # -> Adds content to calalog item # returns = lambda block that creates a html code def catalog_item_extras(item) -- libgit2 0.21.2