Module: Mokio::Concerns::Models::Content
- Extended by:
- ActiveSupport::Concern
- Included in:
- Mokio::Content
- Defined in:
- lib/mokio/concerns/models/content.rb
Overview
Concern for Content model
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #author_name ⇒ Object
-
#breadcrumb_name ⇒ Object
Specify what’s showed in breadcrumb.
- #can_add_to_sitemap? ⇒ Boolean
-
#compare_dates ⇒ Object
Compare dates from display_from and display_to fields.
- #editor_name ⇒ Object
- #sitemap_url_strategy ⇒ Object
-
#title_view ⇒ Object
Output for title field.
-
#type_view ⇒ Object
Output for type field.
-
#update_display_to ⇒ Object
Update display_to field: set time to 23:59:59 if time is set to 00:00:00.
-
#update_etag ⇒ Object
Touching etag field.
Instance Method Details
#author_name ⇒ Object
66 67 68 |
# File 'lib/mokio/concerns/models/content.rb', line 66 def .name_view unless .blank? end |
#breadcrumb_name ⇒ Object
Specify what’s showed in breadcrumb
125 126 127 |
# File 'lib/mokio/concerns/models/content.rb', line 125 def title end |
#can_add_to_sitemap? ⇒ Boolean
62 63 64 |
# File 'lib/mokio/concerns/models/content.rb', line 62 def can_add_to_sitemap? true end |
#compare_dates ⇒ Object
Compare dates from display_from and display_to fields
107 108 109 110 111 112 113 |
# File 'lib/mokio/concerns/models/content.rb', line 107 def compare_dates if self[:display_from] && self[:display_to] if self[:display_from] > self[:display_to] errors.add(:display_from) end end end |
#editor_name ⇒ Object
70 71 72 |
# File 'lib/mokio/concerns/models/content.rb', line 70 def editor_name editor.name_view unless editor.blank? end |
#sitemap_url_strategy ⇒ Object
58 59 60 |
# File 'lib/mokio/concerns/models/content.rb', line 58 def sitemap_url_strategy {loc: "#{self.title}",priority: 1,lastmod: self.updated_at } end |
#title_view ⇒ Object
Output for title field
95 96 97 98 99 100 |
# File 'lib/mokio/concerns/models/content.rb', line 95 def title_view html = "" html << "<span class=\"icon12 icomoon-icon-home home_page\"></span>" if self[:home_page] html << (ActionController::Base.helpers.link_to self[:title], ApplicationController.helpers.edit_url(self.class.base_class, self)) html.html_safe end |
#type_view ⇒ Object
Output for type field
118 119 120 |
# File 'lib/mokio/concerns/models/content.rb', line 118 def type_view I18n.t("contents.types.#{self[:type]}") end |
#update_display_to ⇒ Object
Update display_to field: set time to 23:59:59 if time is set to 00:00:00
85 86 87 88 89 90 |
# File 'lib/mokio/concerns/models/content.rb', line 85 def update_display_to if self.display_to && self.display_to.time.strftime("%H:%M") == "00:00" updated = self.display_to.end_of_day self.display_to = updated end end |
#update_etag ⇒ Object
Touching etag field
77 78 79 |
# File 'lib/mokio/concerns/models/content.rb', line 77 def update_etag self.touch(:etag) end |