Commit 8b4dbf410582237c15e121a207080ee9c7c8afe3
Committed by
Paulo Meireles
1 parent
816c2a4e
Exists in
master
and in
28 other branches
Adding content type and view_path hotspots
Showing
3 changed files
with
29 additions
and
1 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
| ... | ... | @@ -50,7 +50,7 @@ class CmsController < MyProfileController |
| 50 | 50 | end |
| 51 | 51 | |
| 52 | 52 | def special_article_types |
| 53 | - [Folder, Blog, UploadedFile, Forum, Gallery, RssFeed] | |
| 53 | + [Folder, Blog, UploadedFile, Forum, Gallery, RssFeed] + @plugins.map(:content_types) | |
| 54 | 54 | end |
| 55 | 55 | |
| 56 | 56 | def view |
| ... | ... | @@ -79,6 +79,7 @@ class CmsController < MyProfileController |
| 79 | 79 | end |
| 80 | 80 | |
| 81 | 81 | def edit |
| 82 | + plugins_prepend_view_paths | |
| 82 | 83 | @article = profile.articles.find(params[:id]) |
| 83 | 84 | @parent_id = params[:parent_id] |
| 84 | 85 | @type = params[:type] || @article.class.to_s |
| ... | ... | @@ -102,6 +103,7 @@ class CmsController < MyProfileController |
| 102 | 103 | end |
| 103 | 104 | |
| 104 | 105 | def new |
| 106 | + plugins_prepend_view_paths | |
| 105 | 107 | # FIXME this method should share some logic wirh edit !!! |
| 106 | 108 | |
| 107 | 109 | # user must choose an article type first |
| ... | ... | @@ -352,6 +354,12 @@ class CmsController < MyProfileController |
| 352 | 354 | } |
| 353 | 355 | end.to_json |
| 354 | 356 | end |
| 357 | + | |
| 358 | + def plugins_prepend_view_paths | |
| 359 | + @plugins.map(:view_path).each do |view_path| | |
| 360 | + prepend_view_path(view_path) | |
| 361 | + end | |
| 362 | + end | |
| 355 | 363 | |
| 356 | 364 | def content_editor? |
| 357 | 365 | true | ... | ... |
app/controllers/public/content_viewer_controller.rb
| ... | ... | @@ -6,6 +6,7 @@ class ContentViewerController < ApplicationController |
| 6 | 6 | helper TagsHelper |
| 7 | 7 | |
| 8 | 8 | def view_page |
| 9 | + plugins_prepend_view_paths | |
| 9 | 10 | path = params[:page].join('/') |
| 10 | 11 | |
| 11 | 12 | if path.blank? |
| ... | ... | @@ -151,5 +152,12 @@ class ContentViewerController < ApplicationController |
| 151 | 152 | end |
| 152 | 153 | end |
| 153 | 154 | end |
| 155 | + | |
| 156 | + # FIXME duplicated | |
| 157 | + def plugins_prepend_view_paths | |
| 158 | + @plugins.map(:view_path).each do |view_path| | |
| 159 | + prepend_view_path(view_path) | |
| 160 | + end | |
| 161 | + end | |
| 154 | 162 | |
| 155 | 163 | end | ... | ... |
lib/noosfero/plugin.rb
| ... | ... | @@ -105,6 +105,18 @@ class Noosfero::Plugin |
| 105 | 105 | nil |
| 106 | 106 | end |
| 107 | 107 | |
| 108 | + # -> Adds plugin-specific content types to CMS | |
| 109 | + # returns = { content type class } | |
| 110 | + def content_types | |
| 111 | + nil | |
| 112 | + end | |
| 113 | + | |
| 114 | + # -> Can be used to add plugin-specific view paths to controllers | |
| 115 | + # returns = { plugins' view paths } | |
| 116 | + def view_path | |
| 117 | + nil | |
| 118 | + end | |
| 119 | + | |
| 108 | 120 | # -> Adds content to calalog item |
| 109 | 121 | # returns = lambda block that creates a html code |
| 110 | 122 | def catalog_item_extras(item) | ... | ... |