radiant-taggable-extension 2.0.4 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,10 +2,10 @@ class KeywordsField < ActiveRecord::Migration
2
2
  def self.up
3
3
  Page.find(:all).each do |page|
4
4
  if keywords = page.field(:keywords).try(:content)
5
- page.attached_tags = Tag.from_list(keywords)
6
- page.save
5
+ page.attached_tags = Tag.from_list(keywords) if keywords.any?
6
+ page.save if page.changed?
7
+ page.field(:keywords).delete
7
8
  end
8
- page.field(:keywords).delete
9
9
  end
10
10
  end
11
11
 
@@ -1,5 +1,5 @@
1
1
  module RadiantTaggableExtension
2
- VERSION = '2.0.4'
2
+ VERSION = '2.0.5'
3
3
  SUMMARY = %q{Tagging, clouding and faceting extension for Radiant CMS}
4
4
  DESCRIPTION = %q{General purpose tagging and retrieval extension: more versatile but less focused than the tags extension. A good way to support faceted search.}
5
5
  URL = "http://spanner.org/radiant/taggable"
@@ -24,6 +24,8 @@ module Radius
24
24
  <r:library:tags:list />
25
25
  <r:library:tags:cloud />
26
26
  </code></pre>
27
+
28
+ A cloud is the default.
27
29
 
28
30
  To show only those tags attached to a particular kind of object, supply a 'for' parameter.
29
31
  The parameter can be 'pages', 'assets' or the plural of any asset type. If you're displaying an image gallery,
@@ -37,7 +39,11 @@ module Radius
37
39
  }
38
40
  tag "library:tags" do |tag|
39
41
  tag.locals.tags = _get_coincident_tags(tag).sort
40
- tag.expand
42
+ if tag.double?
43
+ tag.expand
44
+ else
45
+ tag.render("library:tags:cloud", tag.attr.dup, &tag.block)
46
+ end
41
47
  end
42
48
  tag "library:tags:each" do |tag|
43
49
  tag.render('each_tag', tag.attr.dup, &tag.block)
@@ -193,6 +199,18 @@ module Radius
193
199
  tag.expand if _get_assets(tag).any?
194
200
  end
195
201
 
202
+ desc %{
203
+ Expands if there are any assets associated with all of the current tag set.
204
+
205
+ *Usage:*
206
+ <pre><code>
207
+ <r:library:unless_assets><h2>No assets</h2>...</r:library:unless_assets>
208
+ </code></pre>
209
+ }
210
+ tag "library:unless_assets" do |tag|
211
+ tag.expand unless _get_assets(tag).any?
212
+ end
213
+
196
214
  Asset.known_types.each do |type|
197
215
  these = type.to_s.pluralize
198
216
 
@@ -225,6 +243,18 @@ module Radius
225
243
  tag.locals.assets = _get_assets(tag).send(these.to_sym)
226
244
  tag.expand if tag.locals.assets.any?
227
245
  end
246
+ desc %{
247
+ Expands unless there are any #{these} associated with all of the current tag set.
248
+
249
+ *Usage:*
250
+ <pre><code>
251
+ <r:library:unless_#{these}><h2>#{these.titlecase}</h2>...</r:library:unless_#{these}>
252
+ </code></pre>
253
+ }
254
+ tag "library:unless_#{these}" do |tag|
255
+ tag.locals.assets = _get_assets(tag).send(these.to_sym)
256
+ tag.expand unless tag.locals.assets.any?
257
+ end
228
258
  end
229
259
 
230
260
  ############### extra tags:* tags that only make sense on library or other faceting pages
@@ -169,13 +169,13 @@ module Radius
169
169
  *Usage:*
170
170
  <pre><code><r:tag_cloud /></code></pre>
171
171
 
172
- You can supply a url parameter to work from a page other than the present one.
172
+ You can supply a path parameter to work from a page other than the present one.
173
173
 
174
- <pre><code><r:tag_cloud url="/elsewhere" /></code></pre>
174
+ <pre><code><r:tag_cloud path="/elsewhere" /></code></pre>
175
175
 
176
176
  So if you want to show all the tags attached to any page (but ignore their attachment to anything else):
177
177
 
178
- <pre><code><r:tag_cloud url="/" /></code></pre>
178
+ <pre><code><r:tag_cloud path="/" /></code></pre>
179
179
 
180
180
  As usual you can limit the size of the cloud (the most popular will be shown) and set the destination of tag links:
181
181
 
@@ -185,9 +185,9 @@ module Radius
185
185
  tag.locals.tags ||= _get_tags(tag)
186
186
  options = tag.attr.dup
187
187
  limit = options.delete('limit')
188
- if url = options.delete('url')
189
- found = Page.find_by_url(absolute_path_for(tag.locals.page.url, url))
190
- raise TagError, "no page at url #{url}" unless page_found?(found)
188
+ if path = options.delete('path') || options.delete('url')
189
+ found = Page.find_by_path(absolute_path_for(tag.locals.page.path, path))
190
+ raise TagError, "no page at path #{path}" unless page_found?(found)
191
191
  tag.locals.page = found
192
192
  end
193
193
  raise TagError, "no page for tag_cloud" unless tag.locals.page
@@ -210,9 +210,9 @@ module Radius
210
210
  tag.locals.tags ||= _get_tags(tag)
211
211
  options = tag.attr.dup
212
212
  limit = options.delete('limit')
213
- if url = options.delete('url')
214
- found = Page.find_by_url(absolute_path_for(tag.locals.page.url, url))
215
- raise TagError, "no page at url #{url}" unless page_found?(found)
213
+ if path = options.delete('path') || options.delete('url')
214
+ found = Page.find_by_path(absolute_path_for(tag.locals.page.path, path))
215
+ raise TagError, "no page at path #{path}" unless page_found?(found)
216
216
  tag.locals.page = found
217
217
  end
218
218
  raise TagError, "no page for tag_list" unless tag.locals.page
@@ -417,9 +417,9 @@ module Radius
417
417
  text = tag.double? ? tag.expand : tag.render('tag:name')
418
418
  if tag.locals.page.is_a? LibraryPage
419
419
  tagset = tag.locals.page.requested_tags + [tag.locals.tag]
420
- destination = tag.locals.page.url(tagset)
421
- elsif page_url = (options.delete('linkto') || Radiant::Config['library.path'])
422
- destination = clean_url(page_url + '/' + tag.locals.tag.clean_title)
420
+ destination = tag.locals.page.path(tagset)
421
+ elsif page_path = (options.delete('linkto') || Radiant::Config['library.path'])
422
+ destination = clean_path(page_path + '/' + tag.locals.tag.clean_title)
423
423
  else
424
424
  # note that this only works if you're at a url with a trailing slash...
425
425
  destination = Rack::Utils.escape("#{tag.locals.tag.title}") + '/'
@@ -21,15 +21,6 @@ module Taggable
21
21
  end
22
22
 
23
23
  module InstanceMethods
24
-
25
- # Faceted pages map nicely onto urls and are cacheable.
26
- # There can be redundancy if tags are specified in varying order,
27
- # but the site controller tries to normalize everything.
28
- #
29
- def cache?
30
- true
31
- end
32
-
33
24
  # We override the normal Page#find_by_path mechanism and treat nonexistent child paths
34
25
  # are understood as tag sets. Note that the extended site_controller will add to this set
35
26
  # any tags that have been supplied in query string parameters. This may trigger a redirect
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiant-taggable-extension
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 5
5
5
  prerelease:
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
- - 4
10
- version: 2.0.4
9
+ - 5
10
+ version: 2.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - William Ross
@@ -15,7 +15,8 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-10-11 00:00:00 Z
18
+ date: 2011-10-17 00:00:00 +01:00
19
+ default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
21
22
  name: sanitize
@@ -89,6 +90,7 @@ files:
89
90
  - public/javascripts/autocomplete.js
90
91
  - public/stylesheets/sass/admin/taggable.sass
91
92
  - public/stylesheets/sass/tagcloud.sass
93
+ - radiant-taggable-extension-2.0.4.gem
92
94
  - radiant-taggable-extension.gemspec
93
95
  - Rakefile
94
96
  - README.md
@@ -101,10 +103,11 @@ files:
101
103
  - spec/spec.opts
102
104
  - spec/spec_helper.rb
103
105
  - taggable_extension.rb
106
+ has_rdoc: true
104
107
  homepage: http://spanner.org/radiant/taggable
105
108
  licenses: []
106
109
 
107
- post_install_message: "\n Add this to your Gemfile with:\n\n gem 'radiant-taggable-extension', '~> 2.0.4'\n\n "
110
+ post_install_message: "\n Add this to your Gemfile with:\n\n gem 'radiant-taggable-extension', '~> 2.0.5'\n\n "
108
111
  rdoc_options: []
109
112
 
110
113
  require_paths:
@@ -130,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
133
  requirements: []
131
134
 
132
135
  rubyforge_project:
133
- rubygems_version: 1.8.10
136
+ rubygems_version: 1.5.3
134
137
  signing_key:
135
138
  specification_version: 3
136
139
  summary: Tagging, clouding and faceting extension for Radiant CMS