Sha256: 64cd2c691c4554797073e5899402dd9637d3be1a6379e2ed871119e832133f96

Contents?: true

Size: 1.2 KB

Versions: 32

Compression:

Stored size: 1.2 KB

Contents

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

      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

32 entries across 32 versions & 1 rubygems

Version Path
rocket_cms-0.7.1 lib/rocket_cms/models/news.rb
rocket_cms-0.7.0 lib/rocket_cms/models/news.rb
rocket_cms-0.6.18 lib/rocket_cms/models/news.rb
rocket_cms-0.6.17 lib/rocket_cms/models/news.rb
rocket_cms-0.6.16 lib/rocket_cms/models/news.rb
rocket_cms-0.6.15 lib/rocket_cms/models/news.rb
rocket_cms-0.6.14 lib/rocket_cms/models/news.rb
rocket_cms-0.6.13 lib/rocket_cms/models/news.rb
rocket_cms-0.6.12 lib/rocket_cms/models/news.rb
rocket_cms-0.6.11 lib/rocket_cms/models/news.rb
rocket_cms-0.6.10 lib/rocket_cms/models/news.rb
rocket_cms-0.6.9 lib/rocket_cms/models/news.rb
rocket_cms-0.6.8 lib/rocket_cms/models/news.rb
rocket_cms-0.6.7 lib/rocket_cms/models/news.rb
rocket_cms-0.6.6 lib/rocket_cms/models/news.rb
rocket_cms-0.6.5 lib/rocket_cms/models/news.rb
rocket_cms-0.6.4 lib/rocket_cms/models/news.rb
rocket_cms-0.6.3 lib/rocket_cms/models/news.rb
rocket_cms-0.6.2 lib/rocket_cms/models/news.rb
rocket_cms-0.6.1 lib/rocket_cms/models/news.rb