fix issue #166 (page.title on templatized pages) + with_scope works with dates as integer

did committed Apr 29, 2014
commit 652d5fa7be328b857ba82dd4668fcbcd4f8366f2
Showing 5 changed files with 20 additions and 3 deletions
Gemfile +1 -1
@@ @@ -6,7 +6,7 @@ gemspec
# Development
# gem 'locomotivecms-liquid', path: '../gems/liquid', require: false
# gem 'locomotivecms-solid', path: '../gems/solid', require: false
- # gem 'locomotivecms_mounter', path: '../gems/mounter', require: false
+ gem 'locomotivecms_mounter', path: '../gems/mounter', require: false
# gem 'locomotivecms_mounter', github: 'locomotivecms/mounter', ref: '34d24feeb8', require: false
gem 'rb-fsevent', '~> 0.9.1'
locomotive/wagon/liquid/drops/page.rb b/lib/locomotive/wagon/liquid/drops/page.rb +9 -1
@@ @@ -4,9 +4,17 @@ module Locomotive
module Drops
class Page < Base
- delegate :title, :slug, :fullpath, :parent, :depth, :seo_title, :redirect_url, :meta_description, :meta_keywords,
+ delegate :slug, :fullpath, :parent, :depth, :seo_title, :redirect_url, :meta_description, :meta_keywords,
:templatized?, :published?, :redirect?, :listed?, :handle, to: :@_source
+ def title
+ if @_source.templatized?
+ @context['entry'].try(:_label) || @_source.title
+ else
+ @_source.title
+ end
+ end
+
def children
_children = @_source.children || []
_children = _children.sort { |a, b| a.position.to_i <=> b.position.to_i }
locomotive/wagon/misc/core_ext.rb b/lib/locomotive/wagon/misc/core_ext.rb +8 -0
@@ @@ -52,3 +52,11 @@ unless Array.instance_methods.include?(:contains?)
end
end
+ unless Integer.instance_methods.include?(:to_datetime)
+ class Integer
+ def to_datetime
+ Time.at(self).to_datetime
+ end
+ end
+ end
+
spec/fixtures/default/app/views/pages/index.liquid.haml +1 -1
@@ @@ -7,7 +7,7 @@ title: Home page
%head
%meta{ :charset => "utf-8" }
- %title {{ site.name }}
+ %title {{ site.name }} | {{ page.title }}
%meta{ :content => "{{ site.meta_description }}", :name => "description" }
%meta{ :content => "{{ site.meta_keywords }}", :name => "keywords" }
spec/integration/server/basic_spec.rb +1 -0
@@ @@ -37,6 +37,7 @@ describe Locomotive::Wagon::Server do
it 'shows a content type template ' do
get '/songs/song-number-1'
last_response.body.should =~ /Song #1/
+ last_response.body.should =~ /Sample website | Song #1/
end
it 'renders a page under a templatized one' do