Class: CamaleonCms::PostTypeDecorator
- Inherits:
-
TermTaxonomyDecorator
- Object
- Draper::Decorator
- ApplicationDecorator
- TermTaxonomyDecorator
- CamaleonCms::PostTypeDecorator
- Defined in:
- app/decorators/camaleon_cms/post_type_decorator.rb
Instance Method Summary collapse
-
#generate_breadcrumb(add_post_type = true, is_parent = false) ⇒ Object
add_post_type: true/false to include post type link is_parent: true/false (internal control).
-
#the_admin_url(list_type = "post") ⇒ Object
return the admin list url for this post type.
-
#the_categories ⇒ Object
return main categories (first level) for the post_type (active_record) filtered by permissions in return object, you can add custom where’s or pagination like here: edgeguides.rubyonrails.org/active_record_querying.html.
-
#the_category(slug_or_id) ⇒ Object
return a category from this post_type with id (integer) or by slug (string).
-
#the_edit_url ⇒ Object
return edit url for this post type.
-
#the_full_categories ⇒ Object
return full categories (all levels) for the post_type (active_record) filtered by permissions in return object, you can add custom where’s or pagination like here: edgeguides.rubyonrails.org/active_record_querying.html.
-
#the_group_url(*args) ⇒ Object
return the public url with group structure Sample: localhost/group/10-my-group.html.
-
#the_post_tags ⇒ Object
return all post_tags for the post_type (active_record) filtered by permissions + hidden posts + roles + etc…
-
#the_thumb_url(default = nil) ⇒ Object
return thumbnail for this post type default: if thumbnail is not present, will render default.
-
#the_url(*args) ⇒ Object
return the public url for this post type Sample: localhost/my-group.html.
Methods inherited from TermTaxonomyDecorator
#the_content, #the_edit_link, #the_excerpt, #the_owner, #the_parent, #the_post, #the_posts, #the_slug, #the_status, #the_title
Methods included from CustomFieldsConcern
#render_fields, #the_attribute_field, #the_attribute_fields, #the_field, #the_field!, #the_fields, #the_fields_grouped
Methods inherited from ApplicationDecorator
#_calc_locale, #get_locale, #set_decoration_locale, #the_breadcrumb, #the_created_at, #the_id, #the_keywords, #the_slug, #the_updated_at
Methods included from MetasDecoratorMethods
Instance Method Details
#generate_breadcrumb(add_post_type = true, is_parent = false) ⇒ Object
add_post_type: true/false to include post type link is_parent: true/false (internal control)
47 48 49 |
# File 'app/decorators/camaleon_cms/post_type_decorator.rb', line 47 def (add_post_type = true, is_parent = false) h.(self.the_title, is_parent ? self.the_url : nil) if add_post_type end |
#the_admin_url(list_type = "post") ⇒ Object
return the admin list url for this post type
35 36 37 38 39 40 41 42 43 |
# File 'app/decorators/camaleon_cms/post_type_decorator.rb', line 35 def the_admin_url(list_type = "post") if list_type == "post" h.cama_admin_post_type_posts_path(object.id) elsif list_type == "tag" h.(object.id) else # categories h.cama_admin_post_type_categories_path(object.id) end end |
#the_categories ⇒ Object
return main categories (first level) for the post_type (active_record) filtered by permissions in return object, you can add custom where’s or pagination like here: edgeguides.rubyonrails.org/active_record_querying.html
54 55 56 |
# File 'app/decorators/camaleon_cms/post_type_decorator.rb', line 54 def the_categories object.categories end |
#the_category(slug_or_id) ⇒ Object
return a category from this post_type with id (integer) or by slug (string)
66 67 68 69 |
# File 'app/decorators/camaleon_cms/post_type_decorator.rb', line 66 def the_category(slug_or_id) return the_categories.where(id: slug_or_id).first if slug_or_id.is_a?(Integer) return the_categories.find_by_slug(slug_or_id) if slug_or_id.is_a?(String) end |
#the_edit_url ⇒ Object
return edit url for this post type
30 31 32 |
# File 'app/decorators/camaleon_cms/post_type_decorator.rb', line 30 def the_edit_url h.edit_cama_admin_settings_post_type_url(object.id) end |
#the_full_categories ⇒ Object
return full categories (all levels) for the post_type (active_record) filtered by permissions in return object, you can add custom where’s or pagination like here: edgeguides.rubyonrails.org/active_record_querying.html
61 62 63 |
# File 'app/decorators/camaleon_cms/post_type_decorator.rb', line 61 def the_full_categories object.full_categories end |
#the_group_url(*args) ⇒ Object
return the public url with group structure Sample: localhost/group/10-my-group.html
18 19 20 21 22 23 24 25 26 27 |
# File 'app/decorators/camaleon_cms/post_type_decorator.rb', line 18 def the_group_url(*args) args = args. args[:post_type_id] = the_id args[:title] = the_title.parameterize args[:title] = the_slug unless args[:title].present? args[:locale] = get_locale unless args.include?(:locale) args[:format] = "html" as_path = args.delete(:as_path) h.cama_url_to_fixed("cama_post_type#{_calc_locale(args[:locale])}_#{as_path.present? ? "path" : "url"}", args) end |
#the_post_tags ⇒ Object
return all post_tags for the post_type (active_record) filtered by permissions + hidden posts + roles + etc… in return object, you can add custom where’s or pagination like here: edgeguides.rubyonrails.org/active_record_querying.html
74 75 76 |
# File 'app/decorators/camaleon_cms/post_type_decorator.rb', line 74 def object. end |
#the_thumb_url(default = nil) ⇒ Object
return thumbnail for this post type default: if thumbnail is not present, will render default
80 81 82 83 |
# File 'app/decorators/camaleon_cms/post_type_decorator.rb', line 80 def the_thumb_url(default = nil) th = object.get_option("thumb", object.get_option("default_thumb")) th.present? ? th : (default || h.asset_url("camaleon_cms/image-not-found.png")) end |
#the_url(*args) ⇒ Object
return the public url for this post type Sample: localhost/my-group.html
6 7 8 9 10 11 12 13 14 |
# File 'app/decorators/camaleon_cms/post_type_decorator.rb', line 6 def the_url(*args) args = args. args[:post_type_id] = the_id args[:post_type_slug] = I18n.t("routes.post_types.#{the_slug}", default: the_slug) args[:locale] = get_locale unless args.include?(:locale) args[:format] = "html" as_path = args.delete(:as_path) h.cama_url_to_fixed("cama_post_type_#{self.id}_#{as_path.present? ? "path" : "url"}", args) end |