Sha256: e03d27c403eebff9bed8d38c9a03660bf325c06bb47da07dba10f918c3aa17fe
Contents?: true
Size: 1.47 KB
Versions: 5
Compression:
Stored size: 1.47 KB
Contents
module Ants module Content extend ActiveSupport::Concern included do include Mongoid::Document include Mongoid::Timestamps include Mongoid::Search include Ants::Id include Ants::Slug include Ants::Hideable include Ants::Meta include Ants::Scheduled ## Attributes field :title field :body_markdown field :body_html ## Validation validates_presence_of :title ## Search & Slug search_in :title slug :title ## Helpers alias_attribute :_list_item_title, :title def canonical_url "#{protocole}#{host}/#{slug}" end def meta_type "article" end def meta_title _meta_title.presence || title end def meta_description _meta_description.presence end def meta_keywords _meta_keywords.presence end def opengraph_image_url url = _opengraph_image_url.presence if url if !url.include?('//') "#{protocole}#{host}#{url}" else url end else "" end end protected def host @host ||= (Rails.env.production? ? ENV.fetch("HOST") : "") end def protocole if Rails.env.production? @protocole ||= Rails.application.config.force_ssl ? "https://" : "http://" else @protocole ||= "" end end end end end
Version data entries
5 entries across 5 versions & 1 rubygems