liquid4-rails5 0.2.1 → 0.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0accabc83ca1c951eae826837a0c678ddaae243
4
- data.tar.gz: 85f55167dbcc776bae246168b3352bedc0493588
3
+ metadata.gz: ba30caa8676da98a2ed6ac3037094790d8d1a93f
4
+ data.tar.gz: 1f135293ee0d8c6012eafc92499544592a0e4993
5
5
  SHA512:
6
- metadata.gz: b003d9a49347be1a9ab2871c9730e8f111db40559056ed61c769402124146c4b27c395ef4716a49ebed946ed93418170001cf829be5a257d8cba5dac13775003
7
- data.tar.gz: f993c02dca25e049673a00108c1f73f54120b4098d376314e5c387e433d2d035e013830f6d15e8b4d552c7edbfc3ee64d30860b849639bc7d85e233dbc73bdc6
6
+ metadata.gz: 7a7e2b1d626156344f39f1618b06258a4e833eab02d8aa4c235b709ab2c514bb36a105d44342f15f38fa33838f11b5e62be279501e400b746378c4a69b87b3fe
7
+ data.tar.gz: 4f8c800d0049f3332bd43f4b93c69a75281ca153e14f2cedc8c2411ee90fd5abdb78f3599707a4d662a79e85f34e9d00745c0c9878e37b4fb46dc30ab4cb89f2
@@ -7,7 +7,7 @@ module Liquid
7
7
 
8
8
  for part in paginate['parts']
9
9
  if part['is_link']
10
- html << %(<span class="page">#{link_to(part['title'], part['url'])}</span>)
10
+ html << %(<span class="page"><a href="#{part['url']}">#{part['title']}</a></span>)
11
11
  elsif part['title'].to_i == paginate['current_page'].to_i
12
12
  html << %(<span class="page current">#{part['title']}</span>)
13
13
  else
@@ -18,42 +18,8 @@ module Liquid
18
18
  html << %(<span class="next"><a href="#{paginate['next']['url']}" rel="next">#{paginate['next']['title']}</a></span>) if paginate['next']
19
19
  html.join(' ')
20
20
  end
21
-
22
- # Bootstrap pagination filter
23
- #
24
- # @param [ paginate ]
25
- # @param [ size ]: .pagination-lg, .pagination-sm
26
- def bootstrap_pagination(paginate, size='')
27
- html = []
28
- html << %{<nav><ul class="pagination #{size}">}
29
-
30
- if paginate['previous']
31
- html << %(<li><a href="#{paginate['previous']['url']}" aria-label="Previous"><span aria-hidden="true">#{paginate['previous']['title']}</span></a></li>)
32
- else
33
- html << %(<li class="disabled"><a href="#" aria-label="Previous"><span aria-hidden="true">&laquo; Previous</span></a></li>)
34
- end
35
-
36
- for part in paginate['parts']
37
- if part['is_link']
38
- html << %(<li><a href="#{part['url']}">#{part['title']}</a></li>)
39
- elsif part['title'].to_i == paginate['current_page'].to_i
40
- html << %(<li class="active"><span>#{part['title']}</span></li>)
41
- else
42
- html << %(<li class="disabled"><span>#{part['title']}</span></li>)
43
- end
44
- end
45
-
46
- if paginate['next']
47
- html << %(<li><a href="#{paginate['next']['url']}" aria-label="Next"><span aria-hidden="true">#{paginate['next']['title']}</span></a></li>)
48
- else
49
- html << %(<li class="disabled"><a href="#" aria-label="Next"><span aria-hidden="true">Next &raquo;</span></a></li>)
50
- end
51
-
52
- html << '</ul></nav>'
53
- html.join(' ')
54
- end
55
21
  end
56
22
  end
57
23
  end
58
24
 
59
- Liquid::Template.register_filter(Liquid::Rails::PaginateFilter)
25
+ Liquid::Template.register_filter(Liquid::Rails::PaginateFilter)
@@ -1,5 +1,5 @@
1
1
  module Liquid
2
2
  module Rails
3
- VERSION = '0.2.1'
3
+ VERSION = '0.3.0'
4
4
  end
5
5
  end
@@ -136,25 +136,6 @@ module Liquid
136
136
  expect_template_result("{% paginate post.comments by 2 %}{{ paginate | default_pagination }}{% endpaginate %}", %|<span class=\"prev\"><a href=\"/?page=2\" rel=\"prev\">&laquo; Previous</a></span> <span class=\"page\"><a href=\"/?page=1\">1</a></span> <span class=\"page\"><a href=\"/?page=2\">2</a></span> <span class=\"page current\">3</span>|, { 'post' => @post_drop })
137
137
  end
138
138
  end
139
-
140
- context 'bootstrap_pagination' do
141
- after(:all) { controller.params[:page] = nil }
142
-
143
- it 'is in the first_page' do
144
- controller.params[:page] = 1
145
- expect_template_result("{% paginate post.comments by 2 %}{{ paginate | bootstrap_pagination }}{% endpaginate %}", %|<nav><ul class="pagination "> <li class="disabled"><a href="#" aria-label="Previous"><span aria-hidden="true">&laquo; Previous</span></a></li> <li class="active"><span>1</span></li> <li><a href="/?page=2">2</a></li> <li><a href="/?page=3">3</a></li> <li><a href="/?page=2" aria-label="Next"><span aria-hidden="true">Next &raquo;</span></a></li> </ul></nav>|, { 'post' => @post_drop })
146
- end
147
-
148
- it 'is in the second_page' do
149
- controller.params[:page] = 2
150
- expect_template_result("{% paginate post.comments by 2 %}{{ paginate | bootstrap_pagination }}{% endpaginate %}", %|<nav><ul class="pagination "> <li><a href="/?page=1" aria-label="Previous"><span aria-hidden="true">&laquo; Previous</span></a></li> <li><a href="/?page=1">1</a></li> <li class="active"><span>2</span></li> <li><a href="/?page=3">3</a></li> <li><a href="/?page=3" aria-label="Next"><span aria-hidden="true">Next &raquo;</span></a></li> </ul></nav>|, { 'post' => @post_drop })
151
- end
152
-
153
- it 'is in the last_page' do
154
- controller.params[:page] = 3
155
- expect_template_result("{% paginate post.comments by 2 %}{{ paginate | bootstrap_pagination }}{% endpaginate %}", %|<nav><ul class="pagination "> <li><a href="/?page=2" aria-label="Previous"><span aria-hidden="true">&laquo; Previous</span></a></li> <li><a href="/?page=1">1</a></li> <li><a href="/?page=2">2</a></li> <li class="active"><span>3</span></li> <li class="disabled"><a href="#" aria-label="Next"><span aria-hidden="true">Next &raquo;</span></a></li> </ul></nav>|, { 'post' => @post_drop })
156
- end
157
- end
158
139
  end
159
140
  end
160
- end
141
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liquid4-rails5
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Viktor Fonic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-23 00:00:00.000000000 Z
11
+ date: 2017-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -174,17 +174,9 @@ files:
174
174
  - lib/liquid-rails/drops/drop.rb
175
175
  - lib/liquid-rails/drops/droppable.rb
176
176
  - lib/liquid-rails/file_system.rb
177
- - lib/liquid-rails/filters/asset_tag_filter.rb
178
- - lib/liquid-rails/filters/asset_url_filter.rb
179
177
  - lib/liquid-rails/filters/date_filter.rb
180
- - lib/liquid-rails/filters/google_static_map_url_filter.rb
181
- - lib/liquid-rails/filters/misc_filter.rb
182
- - lib/liquid-rails/filters/number_filter.rb
183
178
  - lib/liquid-rails/filters/paginate_filter.rb
184
- - lib/liquid-rails/filters/sanitize_filter.rb
185
- - lib/liquid-rails/filters/text_filter.rb
186
179
  - lib/liquid-rails/filters/translate_filter.rb
187
- - lib/liquid-rails/filters/url_filter.rb
188
180
  - lib/liquid-rails/liquid_monkey_patch.rb
189
181
  - lib/liquid-rails/matchers.rb
190
182
  - lib/liquid-rails/railtie.rb
@@ -257,10 +249,6 @@ files:
257
249
  - spec/dummy/public/favicon.ico
258
250
  - spec/fixtures/poro.rb
259
251
  - spec/lib/liquid-rails/drops/drop_spec.rb
260
- - spec/lib/liquid-rails/filters/asset_tag_filter_spec.rb
261
- - spec/lib/liquid-rails/filters/asset_url_filter_spec.rb
262
- - spec/lib/liquid-rails/filters/google_static_map_url_filter_spec.rb
263
- - spec/lib/liquid-rails/filters/misc_filter_spec.rb
264
252
  - spec/lib/liquid-rails/filters/translate_filter_spec.rb
265
253
  - spec/lib/liquid-rails/railtie_spec.rb
266
254
  - spec/lib/liquid-rails/rspec/drop_matchers_spec.rb
@@ -353,10 +341,6 @@ test_files:
353
341
  - spec/dummy/public/favicon.ico
354
342
  - spec/fixtures/poro.rb
355
343
  - spec/lib/liquid-rails/drops/drop_spec.rb
356
- - spec/lib/liquid-rails/filters/asset_tag_filter_spec.rb
357
- - spec/lib/liquid-rails/filters/asset_url_filter_spec.rb
358
- - spec/lib/liquid-rails/filters/google_static_map_url_filter_spec.rb
359
- - spec/lib/liquid-rails/filters/misc_filter_spec.rb
360
344
  - spec/lib/liquid-rails/filters/translate_filter_spec.rb
361
345
  - spec/lib/liquid-rails/railtie_spec.rb
362
346
  - spec/lib/liquid-rails/rspec/drop_matchers_spec.rb
@@ -1,23 +0,0 @@
1
- module Liquid
2
- module Rails
3
- module AssetTagFilter
4
- delegate \
5
- :audio_tag,
6
- :auto_discovery_link_tag,
7
- :favicon_link_tag,
8
- :image_alt,
9
- :image_tag,
10
- :javascript_include_tag,
11
- :stylesheet_link_tag,
12
- :video_tag,
13
-
14
- to: :h
15
-
16
- def h
17
- @h ||= @context.registers[:view]
18
- end
19
- end
20
- end
21
- end
22
-
23
- Liquid::Template.register_filter(Liquid::Rails::AssetTagFilter)
@@ -1,35 +0,0 @@
1
- module Liquid
2
- module Rails
3
- module AssetUrlFilter
4
- delegate \
5
- :asset_path,
6
- :asset_url,
7
-
8
- :audio_path,
9
- :audio_url,
10
-
11
- :font_path,
12
- :font_url,
13
-
14
- :image_path,
15
- :image_url,
16
-
17
- :javascript_path,
18
- :javascript_url,
19
-
20
- :stylesheet_path,
21
- :stylesheet_url,
22
-
23
- :video_path,
24
- :video_url,
25
-
26
- to: :h
27
-
28
- def h
29
- @h ||= @context.registers[:view]
30
- end
31
- end
32
- end
33
- end
34
-
35
- Liquid::Template.register_filter(Liquid::Rails::AssetUrlFilter)
@@ -1,30 +0,0 @@
1
- module Liquid
2
- module Rails
3
- module GoogleStaticMapUrlFilter
4
-
5
- # size: '600x300'
6
- #
7
- # Available keys inside options
8
- # center: '40.714728,-73.998672'
9
- # zoom: 13
10
- # maptype: 'roadmap', 'satellite', 'terrain', or 'hybrid'
11
- # markers: an array of this 'color:blue|label:S|40.702147,-74.015794'
12
- # or string with semicolon
13
- def google_static_map_url(size, options={})
14
- markers = options.delete('markers')
15
- markers = if markers
16
- markers = markers.split(';') if markers.is_a?(String)
17
- markers.map { |marker| { markers: marker }.to_query }
18
- else
19
- ''
20
- end
21
- options = options.merge('size' => size)
22
- querystring = [options.to_query, markers].delete_if { |value| value.blank? }.join('&')
23
-
24
- "https://maps.googleapis.com/maps/api/staticmap?#{querystring}"
25
- end
26
- end
27
- end
28
- end
29
-
30
- Liquid::Template.register_filter(Liquid::Rails::GoogleStaticMapUrlFilter)
@@ -1,29 +0,0 @@
1
- require 'json'
2
-
3
- module Liquid
4
- module Rails
5
- module MiscFilter
6
- # Get the nth element of the passed in array
7
- def index(array, position)
8
- array.at(position) if array.respond_to?(:at)
9
- end
10
-
11
- def random(input)
12
- rand(input.to_i)
13
- end
14
-
15
- def jsonify(object)
16
- JSON.dump(object)
17
- end
18
-
19
- # If condition is true, the class_name is returned. Otherwise, it returns nil.
20
- # class_name: css class name
21
- # condition: boolean
22
- def toggle_class_name(class_name, condition)
23
- condition ? class_name : nil
24
- end
25
- end
26
- end
27
- end
28
-
29
- Liquid::Template.register_filter(Liquid::Rails::MiscFilter)
@@ -1,22 +0,0 @@
1
- module Liquid
2
- module Rails
3
- module NumberFilter
4
- delegate \
5
- :number_to_phone,
6
- :number_to_currency,
7
- :number_to_percentage,
8
- :number_with_delimiter,
9
- :number_with_precision,
10
- :number_to_human_size,
11
- :number_to_human,
12
-
13
- to: :h
14
-
15
- def h
16
- @h ||= @context.registers[:view]
17
- end
18
- end
19
- end
20
- end
21
-
22
- Liquid::Template.register_filter(Liquid::Rails::NumberFilter)
@@ -1,17 +0,0 @@
1
- module Liquid
2
- module Rails
3
- module SanitizeFilter
4
- delegate \
5
- :strip_tags,
6
- :strip_links,
7
-
8
- to: :h
9
-
10
- def h
11
- @h ||= @context.registers[:view]
12
- end
13
- end
14
- end
15
- end
16
-
17
- Liquid::Template.register_filter(Liquid::Rails::SanitizeFilter)
@@ -1,44 +0,0 @@
1
- module Liquid
2
- module Rails
3
- module TextFilter
4
- delegate \
5
- :highlight,
6
- :excerpt,
7
- :pluralize,
8
- :word_wrap,
9
- :simple_format,
10
-
11
- to: :h
12
-
13
- # right justify and padd a string
14
- def rjust(input, integer, padstr = '')
15
- input.to_s.rjust(integer, padstr)
16
- end
17
-
18
- # left justify and padd a string
19
- def ljust(input, integer, padstr = '')
20
- input.to_s.ljust(integer, padstr)
21
- end
22
-
23
- def underscore(input)
24
- input.to_s.gsub(' ', '_').gsub('/', '_').underscore
25
- end
26
-
27
- def dasherize(input)
28
- input.to_s.gsub(' ', '-').gsub('/', '-').dasherize
29
- end
30
-
31
- def concat(input, *args)
32
- result = input.to_s
33
- args.flatten.each { |a| result << a.to_s }
34
- result
35
- end
36
-
37
- def h
38
- @h ||= @context.registers[:view]
39
- end
40
- end
41
- end
42
- end
43
-
44
- Liquid::Template.register_filter(Liquid::Rails::TextFilter)
@@ -1,24 +0,0 @@
1
- module Liquid
2
- module Rails
3
- module UrlFilter
4
-
5
- def link_to(name, url, options={})
6
- @context.registers[:view].link_to(name, url.to_s, options)
7
- end
8
-
9
- def link_to_unless_current(name, url, options={})
10
- @context.registers[:view].link_to_unless_current(name, url.to_s, options)
11
- end
12
-
13
- def mail_to(email_address, name=nil, options={})
14
- @context.registers[:view].mail_to(email_address, name, options)
15
- end
16
-
17
- def current_page?(path)
18
- @context.registers[:view].current_page?(path.to_s)
19
- end
20
- end
21
- end
22
- end
23
-
24
- Liquid::Template.register_filter(Liquid::Rails::UrlFilter)
@@ -1,22 +0,0 @@
1
- require 'spec_helper'
2
-
3
- class AssetTagFilterKlass
4
- include Liquid::Rails::AssetTagFilter
5
- end
6
-
7
- module Liquid
8
- module Rails
9
- describe AssetTagFilter do
10
- subject { AssetTagFilterKlass.new }
11
-
12
- it { should delegate(:audio_tag).to(:h) }
13
- it { should delegate(:auto_discovery_link_tag).to(:h) }
14
- it { should delegate(:favicon_link_tag).to(:h) }
15
- it { should delegate(:image_alt).to(:h) }
16
- it { should delegate(:image_tag).to(:h) }
17
- it { should delegate(:javascript_include_tag).to(:h) }
18
- it { should delegate(:stylesheet_link_tag).to(:h) }
19
- it { should delegate(:video_tag).to(:h) }
20
- end
21
- end
22
- end
@@ -1,34 +0,0 @@
1
- require 'spec_helper'
2
-
3
- class AssetUrlFilterKlass
4
- include Liquid::Rails::AssetUrlFilter
5
- end
6
-
7
- module Liquid
8
- module Rails
9
- describe AssetUrlFilter do
10
- subject { AssetUrlFilterKlass.new }
11
-
12
- it { should delegate(:asset_path).to(:h) }
13
- it { should delegate(:asset_url).to(:h) }
14
-
15
- it { should delegate(:audio_path).to(:h) }
16
- it { should delegate(:audio_url).to(:h) }
17
-
18
- it { should delegate(:font_path).to(:h) }
19
- it { should delegate(:font_url).to(:h) }
20
-
21
- it { should delegate(:image_path).to(:h) }
22
- it { should delegate(:image_url).to(:h) }
23
-
24
- it { should delegate(:javascript_path).to(:h) }
25
- it { should delegate(:javascript_url).to(:h) }
26
-
27
- it { should delegate(:stylesheet_path).to(:h) }
28
- it { should delegate(:stylesheet_url).to(:h) }
29
-
30
- it { should delegate(:video_path).to(:h) }
31
- it { should delegate(:video_url).to(:h) }
32
- end
33
- end
34
- end
@@ -1,23 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Liquid
4
- module Rails
5
- describe GoogleStaticMapUrlFilter, type: :filter do
6
- it 'returns url with center' do
7
- expect_template_result("{{ '600x300' | google_static_map_url: center: '40.714728,-73.998672' }}", 'https://maps.googleapis.com/maps/api/staticmap?center=40.714728%2C-73.998672&size=600x300')
8
- end
9
-
10
- it 'returns url with zoom' do
11
- expect_template_result("{{ '600x300' | google_static_map_url: zoom: 13 }}", 'https://maps.googleapis.com/maps/api/staticmap?size=600x300&zoom=13')
12
- end
13
-
14
- it 'returns url with maptype' do
15
- expect_template_result("{{ '600x300' | google_static_map_url: maptype: 'hybrid' }}", 'https://maps.googleapis.com/maps/api/staticmap?maptype=hybrid&size=600x300')
16
- end
17
-
18
- it 'returns url with markers' do
19
- expect_template_result("{{ '600x300' | google_static_map_url: markers: 'color:blue|label:S|40.702147,-74.015794;color:green|label:G|40.711614,-74.012318' }}", 'https://maps.googleapis.com/maps/api/staticmap?size=600x300&markers=color%3Ablue%7Clabel%3AS%7C40.702147%2C-74.015794&markers=color%3Agreen%7Clabel%3AG%7C40.711614%2C-74.012318')
20
- end
21
- end
22
- end
23
- end
@@ -1,27 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Liquid
4
- module Rails
5
- describe MiscFilter do
6
- let(:context) { ::Liquid::Context.new }
7
- let(:parse_context) { ParseContext.new({}) }
8
-
9
- context '#index' do
10
- it 'returns value at the specified index' do
11
- context['array'] = [1, 2, 3]
12
- expect(::Liquid::Variable.new("array | index: 0", parse_context).render(context)).to eq(1)
13
- end
14
-
15
- it 'returns nil when outside range' do
16
- context['array'] = [1, 2, 3]
17
- expect(::Liquid::Variable.new("array | index: 5", parse_context).render(context)).to eq(nil)
18
- end
19
- end
20
-
21
- it '#jsonify' do
22
- context['listing'] = { name: 'Listing A' }
23
- expect(::Liquid::Variable.new("listing | jsonify", parse_context).render(context)).to eq(%|{"name":"Listing A"}|)
24
- end
25
- end
26
- end
27
- end