app/models/page.rb in locomotive_cms-0.0.2.8 vs app/models/page.rb in locomotive_cms-0.0.2.9
- old
+ new
@@ -10,11 +10,11 @@
## fields ##
field :title
field :slug
field :fullpath
field :published, :type => Boolean, :default => false
- field :cache_expires_in, :type => Integer, :default => 0
+ field :cache_strategy, :default => 'none'
## associations ##
belongs_to_related :site
belongs_to_related :layout
embeds_many :parts, :class_name => 'PagePart'
@@ -33,11 +33,10 @@
named_scope :latest_updated, :order_by => [[:updated_at, :desc]], :limit => Locomotive.config.lastest_items_nb
named_scope :index, :where => { :slug => 'index', :depth => 0, :published => true }
named_scope :not_found, :where => { :slug => '404', :depth => 0, :published => true }
## behaviours ##
- # liquid_methods :title, :fullpath
liquify_template :joined_parts
## methods ##
def index?
@@ -64,19 +63,20 @@
def url
"http://#{self.site.domains.first}/#{self.fullpath}.html"
end
+ def with_cache?
+ self.cache_strategy != 'none'
+ end
+
def to_liquid(options = {})
Locomotive::Liquid::Drops::Page.new(self)
end
protected
def do_not_remove_index_and_404_pages
- # safe_site = self.site rescue nil
-
- # return if safe_site.nil?
return if (self.site rescue nil).nil?
if self.index? || self.not_found?
raise I18n.t('errors.messages.protected_page')
end
\ No newline at end of file