radiant-library-extension 2.0.3 → 2.1.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.
data/Rakefile CHANGED
@@ -7,8 +7,8 @@ begin
7
7
  gem.email = "will@spanner.org"
8
8
  gem.homepage = "http://github.com/spanner/radiant-library-extension"
9
9
  gem.authors = ["spanner"]
10
- gem.add_dependency "radiant", ">= 0.9.0"
11
- gem.add_dependency "radiant-taggable-extension", ">= 1.2.0"
10
+ gem.add_dependency "radiant", "~> 0.9.0"
11
+ gem.add_dependency "radiant-taggable-extension", "~> 1.2.0"
12
12
  end
13
13
  rescue LoadError
14
14
  puts "Jeweler (or a dependency) not available. This is only required if you plan to package library as a gem."
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.3
1
+ 2.1.0
@@ -0,0 +1,23 @@
1
+ require 'sanitize'
2
+
3
+ module LibraryHelper
4
+
5
+ def clean_html(text)
6
+ Sanitize.clean(text, Sanitize::Config::RELAXED)
7
+ end
8
+
9
+ def strip_html(text)
10
+ Sanitize.clean(text)
11
+ end
12
+
13
+ def truncate_words(text='', options={})
14
+ return '' if text.blank?
15
+ ellipsis = options[:ellipsis] || '…'
16
+ limit = (options[:limit] || 64).to_i
17
+ text = strip_html(text) if options[:strip]
18
+ words = text.split
19
+ ellipsis = '' unless words.size > limit
20
+ words[0..(limit-1)].join(" ") + ellipsis
21
+ end
22
+
23
+ end
@@ -1,31 +1,14 @@
1
- - content_for :page_css do
2
- :sass
3
- div#a_header
4
- :width 99%
5
- div#a_title
6
- :width 70%
7
- :float left
8
- div#a_keywords
9
- :width 28%
10
- :float right
11
- div#content
12
- .form-area
13
- .keywords
14
- .textbox
15
- :font-family Georgia, Palatino, "Times New Roman", Times, serif
16
- :font-size 200%
17
- :width 100%
18
- :color #c00
1
+ - include_stylesheet 'admin/taggable'
2
+ - include_javascript 'autocomplete'
3
+ - include_javascript 'admin/taggable'
19
4
 
20
5
  - fields_for :asset, @asset do |fields|
21
- #a_header
22
- #a_title
23
- %p.title
24
- %label{:for=>"asset_title"}
25
- Title
26
- = fields.text_field :title, :class => 'textbox', :maxlength => 100
27
- #a_keywords
28
- %p.keywords
29
- %label{:for=>"asset_keywords"}
30
- Tags
31
- = fields.text_field :keywords, :class => 'textbox'
6
+ %p.keywords
7
+ %label{:for=>"asset_keywords"}
8
+ Tags
9
+ = fields.text_field :keywords, :class => 'textbox tagger'
10
+
11
+ %p.title
12
+ %label{:for=>"asset_title"}
13
+ Title
14
+ = fields.text_field :title, :class => 'textbox', :maxlength => 100
@@ -1,9 +1,40 @@
1
1
  module Library
2
2
  module LibraryTags
3
3
  include Radiant::Taggable
4
+ include LibraryHelper
4
5
 
5
6
  class TagError < StandardError; end
6
7
 
8
+ ############### libraryish utility tags that don't really belong here
9
+ desc %{
10
+ Truncates the contained text to the specified number of words. Attributes:
11
+ * `limit` sets the number of words shown. Default is 64.
12
+ * `ellipsis` is the suffix used to indicate truncation. Default is '&hellip;'
13
+ * `strip="true"` will cause all html tags to be stripped from the contained text before it is truncated. Default is false.
14
+ }
15
+ tag "truncate" do |tag|
16
+ # truncate_words is in LibraryHelper
17
+ truncate_words tag.expand, :limit => tag.attr['limit'], :ellipsis => tag.attr['ellipsis'], :strip => tag.attr['strip'] == 'true'
18
+ end
19
+
20
+ desc %{
21
+ Strips all html tags from the contained text, leaving the text itself unchanged.
22
+ Useful when, for example, using a page part to populate a meta tag.
23
+ }
24
+ tag "strip" do |tag|
25
+ # strip_html is in LibraryHelper
26
+ strip_html tag.expand
27
+ end
28
+
29
+ desc %{
30
+ Removes all unsafe html tags and attributes from the enclosed text, protecting from cross-site scripting attacks while leaving the text intact.
31
+ }
32
+ tag "clean" do |tag|
33
+ # clean_html is in LibraryHelper
34
+ clean_html tag.expand
35
+ end
36
+
37
+
7
38
  ############### tags for use on library pages
8
39
  # usually to build a faceted browser
9
40
 
@@ -16,13 +47,12 @@ module Library
16
47
  Displays a list of the tags that can be used to narrow the set of results displayed. This begins as a list of
17
48
  all available tags, and as they are chosen it shrinks to show only the coincident tags that will further reduce the set.
18
49
 
19
- This is normally used to display a list or cloud of facets that can be added to a search. The default is to show a cloud.
50
+ This is normally used to display a list or cloud of facets that can be added to a search.
20
51
 
21
52
  <pre><code>
22
53
  <r:library:tags:each><li><r:tag:link /></li></r:library:tags:each>
23
54
  <r:library:tags:list />
24
55
  <r:library:tags:cloud />
25
- <r:library:tags />
26
56
  </code></pre>
27
57
 
28
58
  To show only those tags attached to a particular kind of object, supply a 'for' parameter.
@@ -36,21 +66,17 @@ module Library
36
66
  You can still display pages associated with those tags, but the list will not include tags that only have pages.
37
67
  }
38
68
  tag "library:tags" do |tag|
39
- tag.locals.tags = _get_coincident_tags(tag)
40
- if tag.double?
41
- tag.expand
42
- else
43
- tag.render('tags:cloud', tag.attr.dup)
44
- end
69
+ tag.locals.tags = _get_coincident_tags(tag).sort
70
+ tag.expand
45
71
  end
46
72
  tag "library:tags:each" do |tag|
47
- tag.render('tags:each', tag.attr.dup, &tag.block)
73
+ tag.render('each_tag', tag.attr.dup, &tag.block)
48
74
  end
49
75
  tag "library:tags:list" do |tag|
50
- tag.render('tags:list', tag.attr.dup)
76
+ tag.render('tag_list', tag.attr.dup)
51
77
  end
52
78
  tag "library:tags:cloud" do |tag|
53
- tag.render('tags:cloud', tag.attr.dup)
79
+ tag.render('tag_cloud', tag.attr.dup)
54
80
  end
55
81
 
56
82
  desc %{
@@ -64,7 +90,7 @@ module Library
64
90
  </code></pre>
65
91
  }
66
92
  tag "library:if_tags" do |tag|
67
- tag.locals.tags = _get_coincident_tags(tag)
93
+ tag.locals.tags = _get_coincident_tags(tag).sort
68
94
  tag.expand if tag.locals.tags.length > 1
69
95
  end
70
96
  desc %{
@@ -76,7 +102,7 @@ module Library
76
102
  </code></pre>
77
103
  }
78
104
  tag "library:unless_tags" do |tag|
79
- tag.locals.tags = _get_coincident_tags(tag)
105
+ tag.locals.tags = _get_coincident_tags(tag).sort
80
106
  tag.expand if tag.locals.tags.length > 1
81
107
  end
82
108
 
@@ -91,7 +117,7 @@ module Library
91
117
  </code></pre>
92
118
  }
93
119
  tag "library:requested_tags" do |tag|
94
- tag.locals.tags = _get_requested_tags(tag)
120
+ tag.locals.tags = _get_requested_tags(tag).sort
95
121
  if tag.double?
96
122
  tag.expand
97
123
  else
@@ -99,7 +125,7 @@ module Library
99
125
  end
100
126
  end
101
127
  tag "library:requested_tags:each" do |tag|
102
- tag.render('tags:each', tag.attr.dup, &tag.block)
128
+ tag.render('each_tag', tag.attr.dup, &tag.block)
103
129
  end
104
130
 
105
131
  desc %{
@@ -113,7 +139,7 @@ module Library
113
139
  </code></pre>
114
140
  }
115
141
  tag "library:if_requested_tags" do |tag|
116
- tag.locals.tags = _get_requested_tags(tag)
142
+ tag.locals.tags = _get_requested_tags(tag).sort
117
143
  tag.expand if tag.locals.tags.any?
118
144
  end
119
145
 
data/library_extension.rb CHANGED
@@ -1,10 +1,14 @@
1
1
  require_dependency 'application_controller'
2
2
 
3
3
  class LibraryExtension < Radiant::Extension
4
- version "2.0.3"
4
+ version "2.1.0"
5
5
  description "Combines paperclipped and taggable to create a general purpose faceted library"
6
6
  url "http://github.com/spanner/radiant-library-extension"
7
-
7
+
8
+ extension_config do |config|
9
+ config.gem 'sanitize'
10
+ end
11
+
8
12
  def activate
9
13
  Asset.send :is_taggable # make assets taggable
10
14
  Asset.send :include, Library::TaggedAsset # add a keywords method for likeness with pages
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{radiant-library-extension}
8
- s.version = "2.0.3"
8
+ s.version = "2.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["spanner"]
12
- s.date = %q{2010-10-04}
12
+ s.date = %q{2011-04-20}
13
13
  s.description = %q{Combines paperclipped and taggable to create a general purpose faceted library}
14
14
  s.email = %q{will@spanner.org}
15
15
  s.extra_rdoc_files = [
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
19
19
  "README.md",
20
20
  "Rakefile",
21
21
  "VERSION",
22
+ "app/helpers/library_helper.rb",
22
23
  "app/models/library_page.rb",
23
24
  "app/views/admin/assets/_edit_metadata.html.haml",
24
25
  "app/views/admin/assets/_edit_title.html.haml",
@@ -36,9 +37,6 @@ Gem::Specification.new do |s|
36
37
  "lib/library/tagged_asset.rb",
37
38
  "lib/tasks/library_extension_tasks.rake",
38
39
  "library_extension.rb",
39
- "pkg/radiant-library-extension-2.0.0.gem",
40
- "pkg/radiant-library-extension-2.0.1.gem",
41
- "pkg/radiant-library-extension-2.0.2.gem",
42
40
  "public/images/library/bigframe.png",
43
41
  "public/images/library/close.png",
44
42
  "public/images/library/detag.png",
@@ -77,15 +75,15 @@ Gem::Specification.new do |s|
77
75
  s.specification_version = 3
78
76
 
79
77
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
80
- s.add_runtime_dependency(%q<radiant>, [">= 0.9.0"])
81
- s.add_runtime_dependency(%q<radiant-taggable-extension>, [">= 1.2.0"])
78
+ s.add_runtime_dependency(%q<radiant>, ["~> 0.9.0"])
79
+ s.add_runtime_dependency(%q<radiant-taggable-extension>, ["~> 1.2.0"])
82
80
  else
83
- s.add_dependency(%q<radiant>, [">= 0.9.0"])
84
- s.add_dependency(%q<radiant-taggable-extension>, [">= 1.2.0"])
81
+ s.add_dependency(%q<radiant>, ["~> 0.9.0"])
82
+ s.add_dependency(%q<radiant-taggable-extension>, ["~> 1.2.0"])
85
83
  end
86
84
  else
87
- s.add_dependency(%q<radiant>, [">= 0.9.0"])
88
- s.add_dependency(%q<radiant-taggable-extension>, [">= 1.2.0"])
85
+ s.add_dependency(%q<radiant>, ["~> 0.9.0"])
86
+ s.add_dependency(%q<radiant-taggable-extension>, ["~> 1.2.0"])
89
87
  end
90
88
  end
91
89
 
@@ -1,5 +1,4 @@
1
1
  require File.dirname(__FILE__) + '/../spec_helper'
2
- Radiant::Config['reader.layout'] = 'Main'
3
2
 
4
3
  describe SiteController do
5
4
  dataset :library_pages
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiant-library-extension
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
+ - 1
8
9
  - 0
9
- - 3
10
- version: 2.0.3
10
+ version: 2.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - spanner
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-04 00:00:00 +01:00
18
+ date: 2011-04-20 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -24,7 +24,7 @@ dependencies:
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ">="
27
+ - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  hash: 59
30
30
  segments:
@@ -40,7 +40,7 @@ dependencies:
40
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ">="
43
+ - - ~>
44
44
  - !ruby/object:Gem::Version
45
45
  hash: 31
46
46
  segments:
@@ -62,6 +62,7 @@ files:
62
62
  - README.md
63
63
  - Rakefile
64
64
  - VERSION
65
+ - app/helpers/library_helper.rb
65
66
  - app/models/library_page.rb
66
67
  - app/views/admin/assets/_edit_metadata.html.haml
67
68
  - app/views/admin/assets/_edit_title.html.haml
@@ -79,9 +80,6 @@ files:
79
80
  - lib/library/tagged_asset.rb
80
81
  - lib/tasks/library_extension_tasks.rake
81
82
  - library_extension.rb
82
- - pkg/radiant-library-extension-2.0.0.gem
83
- - pkg/radiant-library-extension-2.0.1.gem
84
- - pkg/radiant-library-extension-2.0.2.gem
85
83
  - public/images/library/bigframe.png
86
84
  - public/images/library/close.png
87
85
  - public/images/library/detag.png