puffer_pages 0.5.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.travis.yml +6 -2
- data/CHANGELOG.md +16 -0
- data/README.md +1 -0
- data/gemfiles/Gemfile.rails-3-1 +1 -1
- data/gemfiles/Gemfile.rails-3-2 +1 -1
- data/gemfiles/Gemfile.rails-head +1 -1
- data/lib/puffer_pages.rb +1 -0
- data/lib/puffer_pages/engine.rb +1 -1
- data/lib/puffer_pages/extensions/pagenator.rb +1 -1
- data/lib/puffer_pages/liquid/backend.rb +1 -0
- data/lib/puffer_pages/liquid/tags/image.rb +37 -0
- data/lib/puffer_pages/liquid/tags/translate.rb +7 -0
- data/lib/puffer_pages/version.rb +1 -1
- data/spec/controllers/puffer_pages_controller_spec.rb +12 -0
- data/spec/lib/liquid/backend_spec.rb +12 -0
- data/spec/lib/liquid/tags/image_spec.rb +11 -0
- data/spec/lib/liquid/tags/translate_spec.rb +27 -4
- metadata +7 -4
data/.travis.yml
CHANGED
@@ -7,8 +7,12 @@ gemfile:
|
|
7
7
|
- Gemfile
|
8
8
|
- gemfiles/Gemfile.rails-3-1
|
9
9
|
- gemfiles/Gemfile.rails-3-2
|
10
|
-
|
10
|
+
- gemfiles/Gemfile.rails-head
|
11
11
|
|
12
12
|
env:
|
13
13
|
- LOCALIZE=true
|
14
|
-
- LOCALIZE=false
|
14
|
+
- LOCALIZE=false
|
15
|
+
|
16
|
+
matrix:
|
17
|
+
allow_failures:
|
18
|
+
- gemfile: gemfiles/Gemfile.rails-head
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,25 @@
|
|
1
1
|
## 0.6.0 \[ In Development \] \[ Branch: master \]
|
2
2
|
|
3
|
+
### New features
|
4
|
+
|
5
|
+
## 0.5.1
|
6
|
+
|
7
|
+
### New features
|
8
|
+
|
9
|
+
* Added abulity to cancel puffer_page rendering with `render puffer_page: false` option.
|
10
|
+
|
11
|
+
* Added pluralization support to liquid backend (Exoth).
|
12
|
+
|
13
|
+
* Added `image` liquid tag - alias to image_path helper (andrewgr).
|
14
|
+
|
15
|
+
### Bugfixes
|
16
|
+
|
3
17
|
## 0.5.0
|
4
18
|
|
5
19
|
### New features
|
6
20
|
|
21
|
+
* PufferPages is mountable engine now, so `mount PufferPages::Engine => '/'`
|
22
|
+
|
7
23
|
* `scope` tag. Just creates variables scope inside its block.
|
8
24
|
|
9
25
|
* Origins - full import-export system. Just add your remote server and syncronize all the pages.
|
data/README.md
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
[](https://codeclimate.com/github/puffer/puffer_pages)
|
1
2
|
[](http://travis-ci.org/puffer/puffer_pages)
|
2
3
|
|
3
4
|
# PufferPages is lightweight but powerful rails >= 3.1 CMS
|
data/gemfiles/Gemfile.rails-3-1
CHANGED
data/gemfiles/Gemfile.rails-3-2
CHANGED
data/gemfiles/Gemfile.rails-head
CHANGED
data/lib/puffer_pages.rb
CHANGED
@@ -65,6 +65,7 @@ require 'puffer_pages/liquid/tags/url'
|
|
65
65
|
require 'puffer_pages/liquid/tags/yield'
|
66
66
|
require 'puffer_pages/liquid/tags/array'
|
67
67
|
require 'puffer_pages/liquid/tags/assets'
|
68
|
+
require 'puffer_pages/liquid/tags/image'
|
68
69
|
require 'puffer_pages/liquid/tags/helper'
|
69
70
|
require 'puffer_pages/liquid/tags/render'
|
70
71
|
require 'puffer_pages/liquid/tags/scope'
|
data/lib/puffer_pages/engine.rb
CHANGED
@@ -7,7 +7,7 @@ module PufferPages
|
|
7
7
|
config.puffer_pages = ActiveSupport::OrderedOptions.new
|
8
8
|
config.puffer_pages.raise_errors = false
|
9
9
|
|
10
|
-
|
10
|
+
initializer 'puffer_pages.install_i18n_backend', after: 'build_middleware_stack' do
|
11
11
|
if PufferPages.install_i18n_backend
|
12
12
|
I18n.backend = I18n::Backend::Chain.new(PufferPages.i18n_backend, I18n.backend)
|
13
13
|
end
|
@@ -24,7 +24,7 @@ module PufferPages
|
|
24
24
|
|
25
25
|
def _normalize_options options
|
26
26
|
super
|
27
|
-
if options[:puffer_page] || _puffer_pages_action?
|
27
|
+
if options[:puffer_page] || (options[:puffer_page] != false && _puffer_pages_action?)
|
28
28
|
scope = options[:puffer_scope].presence || _puffer_pages_options[:scope].presence
|
29
29
|
page = options.values_at(:puffer_page, :partial, :action, :file).delete_if(&:blank?).first
|
30
30
|
options[:puffer_page] = _puffer_pages_template(page, scope)
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module PufferPages
|
2
|
+
module Liquid
|
3
|
+
module Tags
|
4
|
+
|
5
|
+
class Image < ::Liquid::Tag
|
6
|
+
Syntax = /^(#{::Liquid::QuotedFragment})/
|
7
|
+
|
8
|
+
def initialize(tag_name, markup, tokens)
|
9
|
+
if markup =~ Syntax
|
10
|
+
@path = $1
|
11
|
+
else
|
12
|
+
raise SyntaxError.new("Syntax Error in 'image' - Valid syntax: image '/path/to/image'")
|
13
|
+
end
|
14
|
+
|
15
|
+
@attributes = {}
|
16
|
+
markup.scan(::Liquid::TagAttributes) do |key, value|
|
17
|
+
@attributes[key] = value
|
18
|
+
end
|
19
|
+
|
20
|
+
super
|
21
|
+
end
|
22
|
+
|
23
|
+
def render(context)
|
24
|
+
attributes = {}
|
25
|
+
@attributes.each do |key, value|
|
26
|
+
attributes[key] = context[value]
|
27
|
+
end
|
28
|
+
|
29
|
+
context.registers[:tracker].register("<%= image_tag #{@path}, #{attributes} %>")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
Liquid::Template.register_tag('image', PufferPages::Liquid::Tags::Image)
|
@@ -27,6 +27,13 @@ module PufferPages
|
|
27
27
|
end
|
28
28
|
processed = context[:processed]
|
29
29
|
|
30
|
+
if options[:count].is_a?(String)
|
31
|
+
begin
|
32
|
+
options[:count] = (options[:count] =~ /\./ ? Float(options[:count]) : Integer(options[:count]))
|
33
|
+
rescue ArgumentError
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
30
37
|
if processed && key.first == '.'
|
31
38
|
I18n.translate i18n_key(processed, key.last(-1)),
|
32
39
|
options.merge!(:default => i18n_defaults(processed, key.last(-1)))
|
data/lib/puffer_pages/version.rb
CHANGED
@@ -129,6 +129,18 @@ describe 'PufferPagesController' do
|
|
129
129
|
it { should_not render_page }
|
130
130
|
end
|
131
131
|
|
132
|
+
context do
|
133
|
+
controller do
|
134
|
+
puffer_pages
|
135
|
+
|
136
|
+
def index
|
137
|
+
render nothing: true, puffer_page: false
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
it { should_not render_page }
|
142
|
+
end
|
143
|
+
|
132
144
|
context do
|
133
145
|
controller do
|
134
146
|
puffer_pages
|
@@ -17,4 +17,16 @@ describe PufferPages::Liquid::Backend do
|
|
17
17
|
backend.translate(:en, 'hello')
|
18
18
|
end.should == 'PufferPages world'
|
19
19
|
end
|
20
|
+
|
21
|
+
context 'backend installation' do
|
22
|
+
context 'fallbacks' do
|
23
|
+
specify do
|
24
|
+
contextualize(page_translations: translations) do
|
25
|
+
I18n.with_locale :ru do
|
26
|
+
I18n.translate('hello')
|
27
|
+
end
|
28
|
+
end.should == 'PufferPages world'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
20
32
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe PufferPages::Liquid::Tags::Image do
|
4
|
+
describe 'snippet' do
|
5
|
+
let!(:root) { Fabricate :root }
|
6
|
+
|
7
|
+
specify { root.render("{% image 'i.png' %}").should == "<%= image_tag 'i.png', {} %>" }
|
8
|
+
specify { root.render("{% image 'i.png', alt:'txt' %}").should == "<%= image_tag 'i.png', {\"alt\"=>\"txt\"} %>" }
|
9
|
+
specify { root.render("{% image 'i.png', alt:var %}", var: 'txt').should == "<%= image_tag 'i.png', {\"alt\"=>\"txt\"} %>" }
|
10
|
+
end
|
11
|
+
end
|
@@ -2,10 +2,6 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe PufferPages::Liquid::Tags::Translate do
|
4
4
|
|
5
|
-
def render_page(page, drops = {})
|
6
|
-
page.render({ self: page }.merge(drops))
|
7
|
-
end
|
8
|
-
|
9
5
|
before do
|
10
6
|
@backend = I18n.backend
|
11
7
|
I18n.backend = I18n::Backend::Simple.new
|
@@ -104,4 +100,31 @@ describe PufferPages::Liquid::Tags::Translate do
|
|
104
100
|
specify { root.render.should == 'some params hello' }
|
105
101
|
end
|
106
102
|
|
103
|
+
context 'count in options' do
|
104
|
+
let!(:root) { Fabricate :root }
|
105
|
+
before do
|
106
|
+
I18n.backend.store_translations(:en, layouts:
|
107
|
+
{ application: { hello: {one: 'one %{count}', other: 'many %{count}'} } })
|
108
|
+
end
|
109
|
+
|
110
|
+
context 'with integer count' do
|
111
|
+
let!(:layout) { Fabricate :application, body: "{% t '.hello' count: 1 %}" }
|
112
|
+
specify { root.render.should == 'one 1' }
|
113
|
+
end
|
114
|
+
|
115
|
+
context 'with float count' do
|
116
|
+
let!(:layout) { Fabricate :application, body: "{% t '.hello' count: 1.0 %}" }
|
117
|
+
specify { root.render.should == 'one 1.0' }
|
118
|
+
end
|
119
|
+
|
120
|
+
context 'with integer as string count' do
|
121
|
+
let!(:layout) { Fabricate :application, body: "{% t '.hello' count: '1' %}" }
|
122
|
+
specify { root.render.should == 'one 1' }
|
123
|
+
end
|
124
|
+
|
125
|
+
context 'with float as string count' do
|
126
|
+
let!(:layout) { Fabricate :application, body: "{% t '.hello' count: '1.0' %}" }
|
127
|
+
specify { root.render.should == 'one 1.0' }
|
128
|
+
end
|
129
|
+
end
|
107
130
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puffer_pages
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -409,6 +409,7 @@ files:
|
|
409
409
|
- lib/puffer_pages/liquid/tags/array.rb
|
410
410
|
- lib/puffer_pages/liquid/tags/assets.rb
|
411
411
|
- lib/puffer_pages/liquid/tags/helper.rb
|
412
|
+
- lib/puffer_pages/liquid/tags/image.rb
|
412
413
|
- lib/puffer_pages/liquid/tags/include.rb
|
413
414
|
- lib/puffer_pages/liquid/tags/javascript.rb
|
414
415
|
- lib/puffer_pages/liquid/tags/partials.rb
|
@@ -495,6 +496,7 @@ files:
|
|
495
496
|
- spec/lib/handlers_spec.rb
|
496
497
|
- spec/lib/liquid/backend_spec.rb
|
497
498
|
- spec/lib/liquid/interpolation_spec.rb
|
499
|
+
- spec/lib/liquid/tags/image_spec.rb
|
498
500
|
- spec/lib/liquid/tags/include_spec.rb
|
499
501
|
- spec/lib/liquid/tags/partials_spec.rb
|
500
502
|
- spec/lib/liquid/tags/scope_spec.rb
|
@@ -526,7 +528,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
526
528
|
version: '0'
|
527
529
|
segments:
|
528
530
|
- 0
|
529
|
-
hash:
|
531
|
+
hash: -3853080892470689805
|
530
532
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
531
533
|
none: false
|
532
534
|
requirements:
|
@@ -535,7 +537,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
535
537
|
version: '0'
|
536
538
|
segments:
|
537
539
|
- 0
|
538
|
-
hash:
|
540
|
+
hash: -3853080892470689805
|
539
541
|
requirements: []
|
540
542
|
rubyforge_project: puffer_pages
|
541
543
|
rubygems_version: 1.8.24
|
@@ -612,6 +614,7 @@ test_files:
|
|
612
614
|
- spec/lib/handlers_spec.rb
|
613
615
|
- spec/lib/liquid/backend_spec.rb
|
614
616
|
- spec/lib/liquid/interpolation_spec.rb
|
617
|
+
- spec/lib/liquid/tags/image_spec.rb
|
615
618
|
- spec/lib/liquid/tags/include_spec.rb
|
616
619
|
- spec/lib/liquid/tags/partials_spec.rb
|
617
620
|
- spec/lib/liquid/tags/scope_spec.rb
|