radiant-tags-extension 1.6.1 → 1.6.2

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.
@@ -95,7 +95,7 @@ module RadiusTags
95
95
  output = "<ol class=\"tag_cloud\">"
96
96
  if tag_cloud.length > 0
97
97
  build_tag_cloud(tag_cloud, %w(size1 size2 size3 size4 size5 size6 size7 size8 size9)) do |tag, cloud_class, amount|
98
- output += "<li class=\"#{cloud_class}\"><span>#{pluralize(amount, 'page is', 'pages are')} tagged with </span><a href=\"#{results_page}/#{tag}\" class=\"tag\">#{tag}</a></li>"
98
+ output += "<li class=\"#{cloud_class}\"><span>#{pluralize(amount, 'page is', 'pages are')} tagged with </span><a href=\"#{results_page}/#{url_encode(tag)}\" class=\"tag\">#{tag}</a></li>"
99
99
  end
100
100
  else
101
101
  return I18n.t('tags_extension.no_tags_found')
@@ -118,7 +118,7 @@ module RadiusTags
118
118
  output = "<div class=\"tag_cloud\">"
119
119
  if tag_cloud.length > 0
120
120
  build_tag_cloud(tag_cloud, %w(size1 size2 size3 size4 size5 size6 size7 size8 size9)) do |tag, cloud_class, amount|
121
- output += "<div class=\"#{cloud_class}\"><a href=\"#{results_page}/#{tag}\" class=\"tag\">#{tag}</a></div>\n"
121
+ output += "<div class=\"#{cloud_class}\"><a href=\"#{results_page}/#{url_encode(tag)}\" class=\"tag\">#{tag}</a></div>\n"
122
122
  end
123
123
  else
124
124
  return I18n.t('tags_extension.no_tags_found')
@@ -141,7 +141,7 @@ module RadiusTags
141
141
  output = "<ul class=\"tag_list\">"
142
142
  if tag_cloud.length > 0
143
143
  build_tag_cloud(tag_cloud, %w(size1 size2 size3 size4 size5 size6 size7 size8 size9)) do |tag, cloud_class, amount|
144
- output += "<li class=\"#{cloud_class}\"><a href=\"#{results_page}/#{tag}\" class=\"tag\">#{tag} (#{amount})</a></li>"
144
+ output += "<li class=\"#{cloud_class}\"><a href=\"#{results_page}/#{url_encode(tag)}\" class=\"tag\">#{tag} (#{amount})</a></li>"
145
145
  end
146
146
  else
147
147
  return I18n.t('tags_extension.no_tags_found')
@@ -175,7 +175,7 @@ module RadiusTags
175
175
  Usage: <pre><code><r:tags:each [limit="4"]>...</r:tags:each></code></pre>
176
176
  }
177
177
  tag "tags:each" do |tag|
178
- selected_tags = tag.locals.page.meta_tags
178
+ selected_tags = tag.locals.page.ordered_meta_tags
179
179
  if tag.attr['limit']
180
180
  selected_tags = selected_tags.first(tag.attr['limit'].to_i)
181
181
  end
@@ -194,7 +194,7 @@ module RadiusTags
194
194
  tag "tags:each:link" do |tag|
195
195
  results_page = tag.attr['results_page'] || Radiant::Config['tags.results_page_url']
196
196
  name = tag.locals.meta_tag.name
197
- return "<a href=\"#{results_page}/#{name}\" class=\"tag\">#{name}</a>"
197
+ return "<a href=\"#{results_page}/#{url_encode(name)}\" class=\"tag\">#{name}</a>"
198
198
  end
199
199
 
200
200
  tag 'tags:each:if_first' do |tag|
@@ -246,7 +246,7 @@ module RadiusTags
246
246
  tag "all_tags:each:link" do |tag|
247
247
  results_page = tag.attr['results_page'] || Radiant::Config['tags.results_page_url']
248
248
  name = tag.locals.meta_tag.name
249
- "<a href=\"#{results_page}/#{name}\" class=\"tag\">#{name}</a>"
249
+ "<a href=\"#{results_page}/#{url_encode(name)}\" class=\"tag\">#{name}</a>"
250
250
  end
251
251
 
252
252
  tag "all_tags:each:popularity" do |tag|
@@ -256,7 +256,7 @@ module RadiusTags
256
256
  tag "all_tags:each:url" do |tag|
257
257
  results_page = tag.attr['results_page'] || Radiant::Config['tags.results_page_url']
258
258
  name = tag.locals.meta_tag.name
259
- "#{results_page}/#{name}"
259
+ "#{results_page}/#{url_encode(name)}"
260
260
  end
261
261
 
262
262
  desc "Set the scope for the tag's pages"
@@ -304,7 +304,8 @@ module RadiusTags
304
304
  raise TagError, "`tagged' tag must contain a `with' attribute." unless (tag.attr['with'] || tag.locals.page.class_name = TagSearchPage)
305
305
  ttag = tag.attr['with'] || @request.parameters[:tag]
306
306
 
307
- scope = scope_attr == 'current_page' ? Page.find_by_url(@request.request_uri) : Page.find_by_url(scope_attr)
307
+ scope_path = scope_attr == 'current_page' ? @request.request_uri : scope_attr
308
+ scope = Page.find_by_path scope_path
308
309
  return "The scope attribute must be a valid url to an existing page." if scope.nil? || scope.class_name.eql?('FileNotFoundPage')
309
310
 
310
311
  if with_any
@@ -95,7 +95,7 @@ class TagSearchPage < Page
95
95
  super
96
96
  end
97
97
 
98
- def find_by_url(url, live = true, clean = false)
98
+ def find_by_path(url, live = true, clean = false)
99
99
  url = clean_url(url).chop # chop off trailing slash added by clean_url
100
100
  if url =~ /^#{self.url}([a-zA-Z0-9,\_\-\s\/()'.&]*)\/?$/
101
101
  self.requested_tag = $1
@@ -1,3 +1,3 @@
1
1
  module RadiantTagsExtension
2
- VERSION = '1.6.1'
2
+ VERSION = '1.6.2'
3
3
  end
@@ -5,15 +5,15 @@ TaggingMethods = Proc.new do
5
5
  end
6
6
  alias_method_chain :valid?, :tags
7
7
 
8
- def tag_with tags
8
+ def tag_with new_tags
9
9
  self.save if self.new_record?
10
10
  # just skip the whole method if the tags string hasn't changed
11
- return if tags == tag_list
12
- # do we need to delete any tags?
13
- tags_to_delete = tag_list.split(MetaTag::DELIMITER) - tags.split(MetaTag::DELIMITER)
14
- tags_to_delete.select{|t| meta_tags.delete(MetaTag.find_by_name(t))}
11
+ return if new_tags == tag_list
15
12
 
16
- tags.split(MetaTag::DELIMITER).each do |tag|
13
+ # tags have changed, so we delete all taggings and re-create to preserve order
14
+ taggings.clear
15
+
16
+ new_tags.split(MetaTag::DELIMITER).each do |tag|
17
17
  begin
18
18
  tag = MetaTag.find_or_initialize_by_name(tag.strip.squeeze(" "))
19
19
  meta_tags << tag unless meta_tags.include?(tag)
@@ -29,8 +29,14 @@ TaggingMethods = Proc.new do
29
29
 
30
30
  alias :meta_tags= :tag_with
31
31
 
32
+ def ordered_meta_tags
33
+ # HACK: need to order by tagging to preserve creation order, otherwise
34
+ # list gets ordered by tag.id
35
+ meta_tags.find(:all, :order => 'taggings.id')
36
+ end
37
+
32
38
  def tag_list
33
- meta_tags.map(&:name).join(MetaTag::DELIMITER)
39
+ ordered_meta_tags.map(&:name).join(MetaTag::DELIMITER)
34
40
  end
35
41
 
36
42
  #
@@ -262,7 +262,8 @@ var FacebookList = Class.create(TextboxList, {
262
262
  children.each(function(el) { this.add({value:el.readAttribute('value'),caption:el.innerHTML}); }, this);
263
263
 
264
264
  $F(this.element).split(this.options.get('separator')).each(function(item) {
265
- this.add({value:item,caption:item});
265
+ if (item != "")
266
+ this.add({value:item,caption:item});
266
267
  }, this)
267
268
 
268
269
  // Loading the options list only once at initialize.
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: 13
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 6
9
- - 1
10
- version: 1.6.1
9
+ - 2
10
+ version: 1.6.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Benny Degezelle
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-29 00:00:00 +02:00
18
+ date: 2011-06-12 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -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.1'\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.2'\n "
246
246
  rdoc_options: []
247
247
 
248
248
  require_paths: