radiant-tags-extension 1.6.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -168,14 +168,23 @@ module RadiusTags
168
168
  tag.expand
169
169
  end
170
170
 
171
- desc "Iterates over the tags of the current page"
171
+ desc %{
172
+ Cycles through the tags of the current page
173
+ Accepts an optional @limit@ attributem default is to show everything.
174
+
175
+ Usage: <pre><code><r:tags:each [limit="4"]>...</r:tags:each></code></pre>
176
+ }
172
177
  tag "tags:each" do |tag|
173
- result = []
174
- tag.locals.page.meta_tags.each do |meta_tag|
178
+ selected_tags = tag.locals.page.meta_tags
179
+ if tag.attr['limit']
180
+ selected_tags = selected_tags.first(tag.attr['limit'].to_i)
181
+ end
182
+ selected_tags.enum_with_index.collect do |meta_tag, index|
175
183
  tag.locals.meta_tag = meta_tag
176
- result << tag.expand
184
+ tag.locals.is_first_meta_tag = index == 0
185
+ tag.locals.is_last_meta_tag = index == selected_tags.length - 1
186
+ tag.expand
177
187
  end
178
- result
179
188
  end
180
189
 
181
190
  tag "tags:each:name" do |tag|
@@ -187,6 +196,22 @@ module RadiusTags
187
196
  name = tag.locals.meta_tag.name
188
197
  return "<a href=\"#{results_page}/#{name}\" class=\"tag\">#{name}</a>"
189
198
  end
199
+
200
+ tag 'tags:each:if_first' do |tag|
201
+ tag.expand if tag.locals.is_first_meta_tag
202
+ end
203
+
204
+ tag 'tags:each:unless_first' do |tag|
205
+ tag.expand unless tag.locals.is_first_meta_tag
206
+ end
207
+
208
+ tag 'tags:each:if_last' do |tag|
209
+ tag.expand if tag.locals.is_last_meta_tag
210
+ end
211
+
212
+ tag 'tags:each:unless_last' do |tag|
213
+ tag.expand unless tag.locals.is_last_meta_tag
214
+ end
190
215
 
191
216
  desc "Set the scope for all tags in the database"
192
217
  tag "all_tags" do |tag|
@@ -195,7 +220,7 @@ module RadiusTags
195
220
 
196
221
  desc %{
197
222
  Iterates through each tag and allows you to specify the order: by popularity or by name.
198
- The default is by name. You may also limit the search; the default is 5 results.
223
+ § The default is by name. You may also limit the search; the default is 5 results.
199
224
 
200
225
  Usage: <pre><code><r:all_tags:each [order="asc|desc"] [by="name|popularity"] limit="5">...</r:all_tags:each></code></pre>
201
226
  }
@@ -1,3 +1,3 @@
1
1
  module RadiantTagsExtension
2
- VERSION = '1.6.0'
2
+ VERSION = '1.6.1'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiant-tags-extension
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 6
9
- - 0
10
- version: 1.6.0
9
+ - 1
10
+ version: 1.6.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Benny Degezelle
@@ -242,7 +242,7 @@ has_rdoc: true
242
242
  homepage: http://ext.radiantcms.org/extensions/195-tags
243
243
  licenses: []
244
244
 
245
- post_install_message: "\n Add this to your radiant project by adding the following line to your environment.rb:\n config.gem 'radiant-tags-extension', :version => '1.6.0'\n "
245
+ post_install_message: "\n Add this to your radiant project by adding the following line to your environment.rb:\n config.gem 'radiant-tags-extension', :version => '1.6.1'\n "
246
246
  rdoc_options: []
247
247
 
248
248
  require_paths: