closes #55
Ivan Youroff
committed May 22, 2013
commit 45fbfae87e5341321360c0f68c15258b04fcf7d1
Showing 4
changed files with
46 additions
and 14 deletions
locomotive/wagon/liquid/drops/page.rb b/lib/locomotive/wagon/liquid/drops/page.rb
+6
-14
| @@ | @@ -4,31 +4,23 @@ module Locomotive |
| module Drops | |
| class Page < Base | |
| - | delegate :title, :slug, :fullpath, :parent, :depth, :seo_title, :redirect_url, :meta_description, :meta_keywords, :to => '_source' |
| + | delegate :title, :slug, :fullpath, :parent, :depth, :seo_title, :redirect_url, :meta_description, :meta_keywords, |
| + | :templatized?, :published?, :redirect?, :listed?, to: '_source' |
| def children | |
| - | _children = @_source.children || [] |
| + | _children = _source.children || [] |
| _children = _children.sort { |a, b| a.position.to_i <=> b.position.to_i } | |
| @children ||= liquify(*_children) | |
| end | |
| - | def published? |
| - | @_source.published? |
| + | def content_type |
| + | ProxyCollection.new(_source.content_type) if _source.content_type |
| end | |
| - | |
| - | def redirect? |
| - | self._source.redirect? |
| - | end |
| - | |
| + | |
| def breadcrumbs | |
| # TODO | |
| '' | |
| end | |
| - | |
| - | def listed? |
| - | @_source.listed? |
| - | end |
| - | |
| end | |
| end | |
| end | |
spec/fixtures/default/app/views/pages/index.liquid.haml
+3
-0
| @@ | @@ -89,6 +89,9 @@ title: Home page |
| .clear | |
| #footer | |
| + | #is_templatized{templatized: "{{ page.templatized? }}"} |
| + | #is_listed{listed: "{{ page.listed? }}"} |
| + | |
| %p {% locale_switcher %} | |
| %p | |
spec/fixtures/default/app/views/pages/songs/template.liquid.haml
+3
-0
| @@ | @@ -10,4 +10,7 @@ content_type: songs |
| %p {{ song.short_description }} | |
| + | #is_templatized{templatized: "{{ page.templatized? }}"} |
| + | #content_type_size{content_type_size: "{{ page.content_type.size }}"} |
| + | |
| {% endblock %} | |
| \ No newline at end of file | |
spec/integration/server/liquid_spec.rb
+34
-0
| @@ | @@ -0,0 +1,34 @@ |
| + | # encoding: utf-8 |
| + | |
| + | require File.dirname(__FILE__) + '/../integration_helper' |
| + | require 'locomotive/wagon/server' |
| + | require 'rack/test' |
| + | |
| + | describe Locomotive::Wagon::Server do |
| + | |
| + | include Rack::Test::Methods |
| + | |
| + | def app |
| + | run_server |
| + | end |
| + | |
| + | it "converts {{ page.templatized? }} => true on templatized page" do |
| + | get '/songs/song-1' |
| + | last_response.body.should =~ /templatized=.true./ |
| + | end |
| + | |
| + | it "converts {{ page.templatized? }} => false on regular page" do |
| + | get '/index' |
| + | last_response.body.should =~ /templatized=.false./ |
| + | end |
| + | |
| + | it "converts {{ page.listed? }} => true on listed page" do |
| + | get '/index' |
| + | last_response.body.should =~ /listed=.true./ |
| + | end |
| + | |
| + | it "provides an access to page's content_type collection" do |
| + | get '/songs/song-1' |
| + | last_response.body.should =~ /content_type_size=.8./ |
| + | end |
| + | end |
| \ No newline at end of file | |