Sha256: d4f9f30f0c1f1f76860e48efe9aee90ad3b3931c9cec518360a65332a9ec9d1f

Contents?: true

Size: 1.22 KB

Versions: 5

Compression:

Stored size: 1.22 KB

Contents

module RocketCMS
  module Models
    module News
      extend ActiveSupport::Concern
      include RocketCMS::Model
      include Seoable
      include Enableable
      include ManualSlug
      include SitemapData
      include RocketCMS.orm_specific('News')

      if RocketCMS.configuration.search_enabled
        include RocketCMS::ElasticSearch
      end

      included do

        validates_presence_of :name, :content
        before_validation do
          self.time = Time.now if self.time.blank?
        end
        scope :recent, ->(count = 5) { enabled.after_now.by_date.limit(count) }
        unless RocketCMS.configuration.news_per_page.nil?
          paginates_per RocketCMS.configuration.news_per_page
        end
        smart_excerpt :excerpt, :content, RocketCMS.configuration.news_excerpt
        manual_slug :report_slug

        RocketCMS.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('%d.%m.%Y')
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ack_rocket_cms-0.7.5.1 lib/rocket_cms/models/news.rb
ack_rocket_cms-0.7.5 lib/rocket_cms/models/news.rb
ack_rocket_cms-0.7.4.1 lib/rocket_cms/models/news.rb
ack_rocket_cms-0.7.4 lib/rocket_cms/models/news.rb
ack_rocket_cms-0.7.3 lib/rocket_cms/models/news.rb