radiant-tags-extension 1.6.3 → 1.6.4
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/app/models/meta_tag.rb +20 -26
- data/app/models/radius_tags.rb +12 -10
- data/lib/radiant-tags-extension.rb +1 -1
- metadata +26 -44
data/app/models/meta_tag.rb
CHANGED
@@ -35,34 +35,28 @@ class MetaTag < ActiveRecord::Base
|
|
35
35
|
find_by_name(name) || create!(:name => name)
|
36
36
|
end
|
37
37
|
|
38
|
-
def cloud(
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
38
|
+
def cloud(options = {})
|
39
|
+
options = {:by => 'popularity', :order => 'asc', :limit => 5}.merge(options)
|
40
|
+
validate_by options[:by]
|
41
|
+
validate_order options[:order]
|
42
|
+
all(
|
43
|
+
:select => 'meta_tags.*, count(*) as popularity',
|
44
|
+
:limit => options[:limit],
|
45
|
+
:joins => "JOIN taggings ON taggings.meta_tag_id = meta_tags.id",
|
46
|
+
:conditions => options[:conditions],
|
47
|
+
:group => "meta_tags.id, meta_tags.name",
|
48
|
+
:order => "#{options[:by]} #{options[:order].upcase}"
|
49
|
+
)
|
47
50
|
end
|
48
|
-
|
49
|
-
def
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
raise TagError.new("`by' attribute of `each' tag must be set to a valid field name")
|
57
|
-
end
|
58
|
-
if order =~ /^(asc|desc)$/i
|
59
|
-
order_string << " #{$1.upcase}"
|
60
|
-
else
|
61
|
-
raise TagError.new(%{`order' attribute of `each' tag must be set to either "asc" or "desc"})
|
62
|
-
end
|
63
|
-
|
51
|
+
|
52
|
+
def validate_by(by)
|
53
|
+
valid_field_names = column_names + ['popularity']
|
54
|
+
valid_field_names.include?(by) or raise %Q{"by" must be one of #{valid_field_names.to_sentence}, was #{by}}
|
55
|
+
end
|
56
|
+
|
57
|
+
def validate_order(order)
|
58
|
+
order =~ /^(asc|desc)$/i or raise %Q{"order" must be set to either "asc" or "desc"}
|
64
59
|
end
|
65
|
-
|
66
60
|
end
|
67
61
|
|
68
62
|
def <=>(other)
|
data/app/models/radius_tags.rb
CHANGED
@@ -220,22 +220,24 @@ module RadiusTags
|
|
220
220
|
|
221
221
|
desc %{
|
222
222
|
Iterates through each tag and allows you to specify the order: by popularity or by name.
|
223
|
-
|
223
|
+
The default is by name. You may also limit the search; the default is 5 results.
|
224
224
|
|
225
225
|
Usage: <pre><code><r:all_tags:each [order="asc|desc"] [by="name|popularity"] limit="5">...</r:all_tags:each></code></pre>
|
226
226
|
}
|
227
227
|
tag "all_tags:each" do |tag|
|
228
|
-
by = tag.attr['by'] || 'name'
|
229
|
-
order = tag.attr['order'] || 'asc'
|
228
|
+
by = (tag.attr['by'] || 'name').strip
|
229
|
+
order = (tag.attr['order'] || 'asc').strip
|
230
230
|
limit = tag.attr['limit'] || '5'
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
tag.locals.meta_tag = t
|
236
|
-
result << tag.expand
|
231
|
+
begin
|
232
|
+
all_tags = MetaTag.cloud(:limit => limit, :order => order, :by => by)
|
233
|
+
rescue => e
|
234
|
+
raise TagError, "all_tags:each: "+e.message
|
237
235
|
end
|
238
|
-
|
236
|
+
used_tags = all_tags.reject { |t| t.pages.empty? }
|
237
|
+
used_tags.collect do |t|
|
238
|
+
tag.locals.meta_tag = t
|
239
|
+
tag.expand
|
240
|
+
end.join
|
239
241
|
end
|
240
242
|
|
241
243
|
desc "Renders the tag's name"
|
metadata
CHANGED
@@ -1,34 +1,24 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: radiant-tags-extension
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 1
|
8
|
-
- 6
|
9
|
-
- 3
|
10
|
-
version: 1.6.3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.6.4
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Benny Degezelle
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2011-06-21 00:00:00 +02:00
|
19
|
-
default_executable:
|
12
|
+
date: 2012-01-11 00:00:00.000000000Z
|
20
13
|
dependencies: []
|
21
|
-
|
22
|
-
|
23
|
-
email:
|
14
|
+
description: This extension enhances the page model with tagging capabilities, tagging
|
15
|
+
as in \"2.0" and tagclouds.
|
16
|
+
email:
|
24
17
|
- benny@gorilla-webdesign.be
|
25
18
|
executables: []
|
26
|
-
|
27
19
|
extensions: []
|
28
|
-
|
29
20
|
extra_rdoc_files: []
|
30
|
-
|
31
|
-
files:
|
21
|
+
files:
|
32
22
|
- HELP.md
|
33
23
|
- HELP_admin.md
|
34
24
|
- README
|
@@ -238,41 +228,33 @@ files:
|
|
238
228
|
- vendor/plugins/has_many_polymorphs/test/setup.rb
|
239
229
|
- vendor/plugins/has_many_polymorphs/test/test_helper.rb
|
240
230
|
- vendor/plugins/has_many_polymorphs/test/unit/has_many_polymorphs_test.rb
|
241
|
-
has_rdoc: true
|
242
231
|
homepage: http://ext.radiantcms.org/extensions/195-tags
|
243
232
|
licenses: []
|
244
|
-
|
245
|
-
|
233
|
+
post_install_message: ! "\n Add this to your radiant project by adding the following
|
234
|
+
line to your environment.rb:\n config.gem 'radiant-tags-extension', :version
|
235
|
+
=> '1.6.4'\n "
|
246
236
|
rdoc_options: []
|
247
|
-
|
248
|
-
require_paths:
|
237
|
+
require_paths:
|
249
238
|
- lib
|
250
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
239
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
251
240
|
none: false
|
252
|
-
requirements:
|
253
|
-
- -
|
254
|
-
- !ruby/object:Gem::Version
|
255
|
-
|
256
|
-
|
257
|
-
- 0
|
258
|
-
version: "0"
|
259
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
241
|
+
requirements:
|
242
|
+
- - ! '>='
|
243
|
+
- !ruby/object:Gem::Version
|
244
|
+
version: '0'
|
245
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
260
246
|
none: false
|
261
|
-
requirements:
|
262
|
-
- -
|
263
|
-
- !ruby/object:Gem::Version
|
264
|
-
|
265
|
-
segments:
|
266
|
-
- 0
|
267
|
-
version: "0"
|
247
|
+
requirements:
|
248
|
+
- - ! '>='
|
249
|
+
- !ruby/object:Gem::Version
|
250
|
+
version: '0'
|
268
251
|
requirements: []
|
269
|
-
|
270
252
|
rubyforge_project:
|
271
|
-
rubygems_version: 1.
|
253
|
+
rubygems_version: 1.8.10
|
272
254
|
signing_key:
|
273
255
|
specification_version: 3
|
274
256
|
summary: Tagging for Radiant CMS
|
275
|
-
test_files:
|
257
|
+
test_files:
|
276
258
|
- test/fixtures/meta_tags.yml
|
277
259
|
- test/fixtures/page_parts.yml
|
278
260
|
- test/fixtures/pages.yml
|