implement session (close #108) + use the solid gem + new version of the mounter + clean the code + bump version to 1.3.0
did
committed Aug 19, 2013
commit a70fe57002ce2060574535b7f23081229e9397f7
Showing 7
changed files with
35 additions
and 20 deletions
Gemfile
+2
-1
| @@ | @@ -4,6 +4,7 @@ source 'https://rubygems.org' |
| gemspec | |
| # Development | |
| - | gem 'locomotivecms_mounter', path: '../gems/mounter', require: false |
| + | # gem 'locomotivecms_solid', path: '../gems/solid', require: false |
| + | # gem 'locomotivecms_mounter', path: '../gems/mounter', require: false |
| gem 'rb-fsevent', '~> 0.9.1' | |
| \ No newline at end of file | |
locomotive/wagon/liquid.rb b/lib/locomotive/wagon/liquid.rb
+1
-1
| @@ | @@ -1,4 +1,4 @@ |
| - | require 'liquid' |
| + | require 'solid' |
| require 'locomotive/mounter' | |
| require 'locomotive/wagon/liquid/scopeable' | |
| require 'locomotive/wagon/liquid/drops/base' | |
locomotive/wagon/misc.rb b/lib/locomotive/wagon/misc.rb
+2
-1
| @@ | @@ -2,4 +2,5 @@ require 'locomotive/wagon/misc/core_ext.rb' |
| require 'locomotive/wagon/misc/will_paginate.rb' | |
| require 'locomotive/wagon/misc/httparty.rb' | |
| require 'locomotive/wagon/misc/dragonfly.rb' | |
| - | require 'locomotive/wagon/misc/i18n.rb' |
| \ No newline at end of file | |
| + | require 'locomotive/wagon/misc/i18n.rb' |
| + | require 'locomotive/wagon/misc/mounter.rb' |
| \ No newline at end of file | |
locomotive/wagon/server/renderer.rb b/lib/locomotive/wagon/server/renderer.rb
+9
-14
| @@ | @@ -11,7 +11,7 @@ module Locomotive::Wagon |
| self.redirect_to(self.page.redirect_url, self.page.redirect_type) | |
| else | |
| type = self.page.response_type || 'text/html' | |
| - | html = self.render |
| + | html = self.page.render(self.locomotive_context) |
| self.log " Rendered liquid page template" | |
| @@ | @@ -25,17 +25,6 @@ module Locomotive::Wagon |
| protected | |
| - | def render |
| - | context = self.locomotive_context |
| - | |
| - | template = ::Liquid::Template.parse(self.page.source, { |
| - | page: self.page, |
| - | mounting_point: self.mounting_point |
| - | }) |
| - | |
| - | template.render(context) |
| - | end |
| - | |
| # Build the Liquid context used to render the Locomotive page. It | |
| # stores both assigns and registers. | |
| # | |
| @@ | @@ -77,12 +66,16 @@ module Locomotive::Wagon |
| 'path' => self.request.path, | |
| 'fullpath' => self.request.fullpath, | |
| 'url' => self.request.url, | |
| + | 'ip_address' => self.request.ip, |
| + | 'post?' => self.request.post?, |
| 'now' => Time.zone.now, | |
| 'today' => Date.today, | |
| 'locale' => I18n.locale.to_s, | |
| 'default_locale' => self.mounting_point.default_locale.to_s, | |
| 'locales' => self.mounting_point.locales.map(&:to_s), | |
| - | 'current_user' => {} |
| + | 'current_user' => {}, |
| + | 'session' => Locomotive::Wagon::Liquid::Drops::SessionProxy.new, |
| + | 'wagon' => true |
| } | |
| end | |
| @@ | @@ -92,10 +85,12 @@ module Locomotive::Wagon |
| # | |
| def locomotive_default_registers | |
| { | |
| + | request: self.request, |
| site: self.site, | |
| page: self.page, | |
| mounting_point: self.mounting_point, | |
| - | inline_editor: false |
| + | inline_editor: false, |
| + | logger: Locomotive::Wagon::Logger |
| } | |
| end | |
locomotive/wagon/version.rb b/lib/locomotive/wagon/version.rb
+1
-1
| @@ | @@ -1,5 +1,5 @@ |
| module Locomotive | |
| module Wagon | |
| - | VERSION = '1.2.2' |
| + | VERSION = '1.3.0' |
| end | |
| end | |
locomotivecms_wagon.gemspec
+2
-2
| @@ | @@ -21,7 +21,7 @@ Gem::Specification.new do |gem| |
| gem.add_dependency 'thor' | |
| gem.add_dependency 'thin' | |
| gem.add_dependency 'activesupport', '~> 3.2.11' | |
| - | gem.add_dependency 'locomotive_liquid', '~> 2.4.2' |
| + | gem.add_dependency 'locomotivecms_solid', '~> 0.2.1' |
| gem.add_dependency 'RedCloth', '~> 4.2.9' | |
| gem.add_dependency 'dragonfly', '~> 0.9.12' | |
| gem.add_dependency 'sprockets', '~> 2.0' | |
| @@ | @@ -34,7 +34,7 @@ Gem::Specification.new do |gem| |
| gem.add_dependency 'httmultiparty', '0.3.10' | |
| gem.add_dependency 'will_paginate', '~> 3.0.3' | |
| - | # gem.add_dependency 'locomotivecms_mounter', '~> 1.2.2' |
| + | gem.add_dependency 'locomotivecms_mounter', '~> 1.2.3' |
| gem.add_dependency 'faker', '~> 0.9.5' | |
spec/integration/server/basic_spec.rb
+18
-0
| @@ | @@ -114,4 +114,22 @@ describe Locomotive::Wagon::Server do |
| end | |
| + | describe 'session' do |
| + | |
| + | subject { get '/contest'; last_response.body } |
| + | |
| + | it { should match(/Your code is: HELLO WORLD/) } |
| + | it { should_not match(/You've already participated to that contest ! Come back later./) } |
| + | |
| + | describe 'assign tag' do |
| + | |
| + | subject { 2.times { get '/contest' }; last_response.body } |
| + | |
| + | it { should_not match(/Your code is: HELLO WORLD/) } |
| + | it { should match(/You've already participated to that contest ! Come back later./) } |
| + | |
| + | end |
| + | |
| + | end |
| + | |
| end | |
| \ No newline at end of file | |