Module: Cms::PathHelper
- Included in:
- ApplicationController
- Defined in:
- app/helpers/cms/path_helper.rb
Overview
All methods really need to be renamed to match conventions for Engines.
In CMS::Engine, shouldn’t have cms_ in method name. From app, should be cms.xyz_path
Instance Method Summary collapse
-
#attachment_path_for(attachment) ⇒ Object
Returns the relative path to the given attachment.
-
#cms_connectable_path(connectable, options = {}) ⇒ String
Path suitable to give to link_to.
-
#cms_index_path_for(resource, options = {}) ⇒ Object
deprecated
Deprecated.
Use cms_connectable_path instead.
-
#cms_index_url_for(resource, options = {}) ⇒ Object
deprecated
Deprecated.
Remove all usages of this in favor of cms_index_path_for ()
- #cms_new_path_for(resource, options = {}) ⇒ Object
-
#cms_new_url_for(resource, options = {}) ⇒ Object
deprecated
Deprecated.
Remove all usages of this in favor of cms_new_path_for ()
-
#cms_sortable_column_path(content_type, column_to_sort) ⇒ Object
Returns a path to sort a table of Content Blocks by a given parameter.
-
#edit_cms_connectable_path(connectable, options = {}) ⇒ Object
In CMS::Engine, should be edit_connectable_path From app, should be cms.edit_connectable_path.
-
#engine_for(resource) ⇒ Object
Returns the Engine Proxy that this resource is from.
- #link_to_usages(block) ⇒ Object
- #path_elements_for(resource) ⇒ Object
Instance Method Details
#attachment_path_for(attachment) ⇒ Object
Returns the relative path to the given attachment. Content editors will see exact specific version path, while other users will see the ‘public’ url for the path.
10 11 12 13 14 15 16 17 |
# File 'app/helpers/cms/path_helper.rb', line 10 def () return "" unless if current_user.able_to?(:edit_content) . else .url end end |
#cms_connectable_path(connectable, options = {}) ⇒ String
Returns path suitable to give to link_to.
54 55 56 57 58 59 60 |
# File 'app/helpers/cms/path_helper.rb', line 54 def cms_connectable_path(connectable, ={}) if Portlet === connectable cms.portlet_path(connectable) else polymorphic_path(build_path_for(connectable), ) end end |
#cms_index_path_for(resource, options = {}) ⇒ Object
Use cms_connectable_path instead.
32 33 34 |
# File 'app/helpers/cms/path_helper.rb', line 32 def cms_index_path_for(resource, ={}) polymorphic_path(build_path_for(resource), ) end |
#cms_index_url_for(resource, options = {}) ⇒ Object
Remove all usages of this in favor of cms_index_path_for ()
37 38 39 |
# File 'app/helpers/cms/path_helper.rb', line 37 def cms_index_url_for(resource, ={}) send("#{resource_collection_name(resource).underscore.pluralize.gsub('/', '_')}_url", ) end |
#cms_new_path_for(resource, options = {}) ⇒ Object
41 42 43 |
# File 'app/helpers/cms/path_helper.rb', line 41 def cms_new_path_for(resource, ={}) new_polymorphic_path(build_path_for(resource), ) end |
#cms_new_url_for(resource, options = {}) ⇒ Object
Remove all usages of this in favor of cms_new_path_for ()
46 47 48 |
# File 'app/helpers/cms/path_helper.rb', line 46 def cms_new_url_for(resource, ={}) send("new_#{resource_collection_name(resource).underscore.gsub('/', '_')}_url", ) end |
#cms_sortable_column_path(content_type, column_to_sort) ⇒ Object
Returns a path to sort a table of Content Blocks by a given parameter. Retains other relevant parameters (like search criteria).
23 24 25 26 27 28 29 |
# File 'app/helpers/cms/path_helper.rb', line 23 def cms_sortable_column_path(content_type, column_to_sort) filtered_params = params.clone filtered_params.delete(:action) filtered_params.delete(:controller) filtered_params.merge!(:order => determine_order(filtered_params[:order], column_to_sort)) cms_connectable_path(content_type.model_class, filtered_params) end |
#edit_cms_connectable_path(connectable, options = {}) ⇒ Object
Really needs to be renamed to match conventions for Engines.
In CMS::Engine, should be edit_connectable_path From app, should be cms.edit_connectable_path
65 66 67 68 69 70 71 |
# File 'app/helpers/cms/path_helper.rb', line 65 def edit_cms_connectable_path(connectable, ={}) if Portlet === connectable edit_portlet_path(connectable, ) else edit_polymorphic_path(build_path_for(connectable), ) end end |
#engine_for(resource) ⇒ Object
Returns the Engine Proxy that this resource is from.
93 94 95 96 |
# File 'app/helpers/cms/path_helper.rb', line 93 def engine_for(resource) EngineHelper.decorate(resource) send(resource.engine_name) end |
#link_to_usages(block) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'app/helpers/cms/path_helper.rb', line 73 def link_to_usages(block) count = block.connected_pages.count if count > 0 # Would love a cleaner solution to this problem, see http://stackoverflow.com/questions/702728 path = if Portlet === block usages_portlet_path(block) else p = [] p << engine_for(block) p << :usages p.concat path_elements_for(block) p end link_to count, path, :id => block.id, :block_type => block.content_block_type else count end end |
#path_elements_for(resource) ⇒ Object
98 99 100 101 |
# File 'app/helpers/cms/path_helper.rb', line 98 def path_elements_for(resource) EngineHelper.decorate(resource) resource.path_elements end |