Sha256: a104091dbbffbc19247b81390a92003a3be9c2f324348423851dd17028ac89df
Contents?: true
Size: 1.42 KB
Versions: 4
Compression:
Stored size: 1.42 KB
Contents
module Enjoy module Admin module News extend ActiveSupport::Concern include Enjoy::Model include Seoable include Enableable include ManualSlug include SitemapData include Enjoy.orm_specific('News') if Enjoy.config.search_enabled include Enjoy::ElasticSearch end included do unless Enjoy.config.news_image_styles.nil? validates_attachment_content_type :image, content_type: /\Aimage\/.*\Z/, if: :image? end validates_presence_of :name if Enjoy.config.news_content_required validates_presence_of :content end before_validation do self.time = Time.now if self.time.blank? end scope :recent, ->(count = 5) { enabled.after_now.by_date.limit(count) } unless Enjoy.config.news_per_page.nil? paginates_per Enjoy.config.news_per_page end smart_excerpt :excerpt, :content, Enjoy.config.news_excerpt manual_slug :report_slug Enjoy.apply_patches self end def report_slug if time.blank? name elsif name.blank? time.strftime('%Y-%m-%d') else time.strftime('%Y-%m-%d') + '-' + name[0..20] end end def html5_date time.strftime('%Y-%m-%d') end def format_date time.strftime(I18n.t('rs.format_time')) end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
enjoy_cms-0.2.0.2 | lib/enjoy/admin/news.rb |
enjoy_cms-0.2.0.1.beta | lib/enjoy/admin/news.rb |
enjoy_cms-0.2.0.beta | lib/enjoy/admin/news.rb |
enjoy_cms-0.1.0.beta1 | lib/enjoy/admin/news.rb |