radiant-library-extension 2.0.0 → 2.0.1

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/VERSION ADDED
@@ -0,0 +1 @@
1
+ 2.0.1
@@ -145,6 +145,10 @@ module Library
145
145
  Displays a list of the pages associated with the current tag set. If no tags are specified, this will show all pages.
146
146
  You can use all the usual r:page tags within the list.
147
147
 
148
+ :by, :order, :limit, :offset, :status and all the usual list-control attributes are obeyed.
149
+
150
+ To paginate the list, set paginated="true" and, optionally, per_page="xx".
151
+
148
152
  *Usage:*
149
153
  <pre><code>
150
154
  <r:library:pages:each><li><r:link /><br /><r:content part="description" /></li></r:library:pages:each>
@@ -174,6 +178,10 @@ module Library
174
178
  Displays a list of the assets associated with the current tag set. If no tags are specified, this will show all assets.
175
179
  You can use all the usual r:assets tags within the list.
176
180
 
181
+ By, order, limit and offset attributes are obeyed. The default is to sort by creation date, descending.
182
+
183
+ To paginate the list, set paginated="true" and, optionally, per_page="xx".
184
+
177
185
  *Usage:*
178
186
  <pre><code>
179
187
  <r:library:assets:each><li><r:assets:thumbnail /></li></r:library:assets:each>
@@ -184,7 +192,7 @@ module Library
184
192
  tag.expand
185
193
  end
186
194
  tag "library:assets:each" do |tag|
187
- tag.render('asset_list', tag.attr.dup, &tag.block)
195
+ tag.render('asset_list', tag.attr.dup, &tag.block) # r:page_list is defined in spanner's paperclipped
188
196
  end
189
197
 
190
198
  desc %{
@@ -249,24 +257,65 @@ module Library
249
257
  end
250
258
  end
251
259
 
252
- # in the absence of any requested tags we default to all, not none
253
-
260
+ # a bit of extra logic so that in the absence of any requested tags we default to all, not none
261
+
262
+ def _default_library_find_options
263
+ {
264
+ :by => 'created_at',
265
+ :order => 'desc'
266
+ }
267
+ end
268
+
254
269
  def _get_pages(tag)
270
+ options = children_find_options(tag)
255
271
  requested = _get_requested_tags(tag)
256
- if requested.any?
257
- Page.tagged_with(requested)
258
- else
259
- Page.scoped({}) # there must be a better way to return a new scope
260
- end
272
+ pages = Page.scoped(options)
273
+ pages = pages.tagged_with(requested) if requested.any?
274
+ pages
261
275
  end
262
276
 
263
277
  def _get_assets(tag)
278
+ options = asset_find_options(tag)
264
279
  requested = _get_requested_tags(tag)
265
- if requested.any?
266
- Asset.tagged_with(requested)
280
+ assets = Asset.scoped(options)
281
+ assets = assets.tagged_with(requested) if requested.any?
282
+ assets
283
+ end
284
+
285
+ # duplicate of children_find_options except:
286
+ # no virtual or status options
287
+ # defaults to chronological descending
288
+
289
+ def asset_find_options(tag)
290
+ attr = tag.attr.symbolize_keys
291
+
292
+ options = {}
293
+
294
+ [:limit, :offset].each do |symbol|
295
+ if number = attr[symbol]
296
+ if number =~ /^\d{1,4}$/
297
+ options[symbol] = number.to_i
298
+ else
299
+ raise TagError.new("`#{symbol}' attribute of `each' tag must be a positive number between 1 and 4 digits")
300
+ end
301
+ end
302
+ end
303
+
304
+ by = (attr[:by] || 'created_at').strip
305
+ order = (attr[:order] || 'desc').strip
306
+ order_string = ''
307
+ if self.attributes.keys.include?(by)
308
+ order_string << by
309
+ else
310
+ raise TagError.new("`by' attribute of `each' tag must be set to a valid field name")
311
+ end
312
+ if order =~ /^(asc|desc)$/i
313
+ order_string << " #{$1.upcase}"
267
314
  else
268
- Asset.scoped({})
315
+ raise TagError.new(%{`order' attribute of `each' tag must be set to either "asc" or "desc"})
269
316
  end
317
+ options[:order] = order_string
318
+ options
270
319
  end
271
320
 
272
321
  end
@@ -0,0 +1,79 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{radiant-library-extension}
8
+ s.version = "2.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["spanner"]
12
+ s.date = %q{2010-09-14}
13
+ s.description = %q{Combines paperclipped and taggable to create a general purpose faceted library}
14
+ s.email = %q{will@spanner.org}
15
+ s.extra_rdoc_files = [
16
+ "README.md"
17
+ ]
18
+ s.files = [
19
+ "README.md",
20
+ "Rakefile",
21
+ "VERSION",
22
+ "app/models/library_page.rb",
23
+ "app/views/admin/assets/_edit_metadata.html.haml",
24
+ "app/views/admin/assets/_edit_title.html.haml",
25
+ "app/views/admin/tags/_show_assets.html.haml",
26
+ "cucumber.yml",
27
+ "db/migrate/20091030115120_furniture.rb",
28
+ "features/support/env.rb",
29
+ "features/support/paths.rb",
30
+ "lib/library/library_tag.rb",
31
+ "lib/library/library_tags.rb",
32
+ "lib/library/link_renderer.rb",
33
+ "lib/library/more_asset_tags.rb",
34
+ "lib/library/more_tag_tags.rb",
35
+ "lib/library/site_controller.rb",
36
+ "lib/library/tagged_asset.rb",
37
+ "lib/tasks/library_extension_tasks.rake",
38
+ "library_extension.rb",
39
+ "pkg/radiant-library-extension-2.0.0.gem",
40
+ "radiant-library-extension.gemspec",
41
+ "spec/controllers/library_site_controller_spec.rb",
42
+ "spec/datasets/library_pages_dataset.rb",
43
+ "spec/datasets/library_sites_dataset.rb",
44
+ "spec/datasets/library_tags_dataset.rb",
45
+ "spec/models/library_page_spec.rb",
46
+ "spec/spec.opts",
47
+ "spec/spec_helper.rb"
48
+ ]
49
+ s.homepage = %q{http://github.com/spanner/radiant-library-extension}
50
+ s.rdoc_options = ["--charset=UTF-8"]
51
+ s.require_paths = ["lib"]
52
+ s.rubygems_version = %q{1.3.7}
53
+ s.summary = %q{Library Extension for Radiant CMS}
54
+ s.test_files = [
55
+ "spec/controllers/library_site_controller_spec.rb",
56
+ "spec/datasets/library_pages_dataset.rb",
57
+ "spec/datasets/library_sites_dataset.rb",
58
+ "spec/datasets/library_tags_dataset.rb",
59
+ "spec/models/library_page_spec.rb",
60
+ "spec/spec_helper.rb"
61
+ ]
62
+
63
+ if s.respond_to? :specification_version then
64
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
65
+ s.specification_version = 3
66
+
67
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
68
+ s.add_runtime_dependency(%q<radiant>, [">= 0.9.0"])
69
+ s.add_runtime_dependency(%q<radiant-taggable-extension>, [">= 1.2.0"])
70
+ else
71
+ s.add_dependency(%q<radiant>, [">= 0.9.0"])
72
+ s.add_dependency(%q<radiant-taggable-extension>, [">= 1.2.0"])
73
+ end
74
+ else
75
+ s.add_dependency(%q<radiant>, [">= 0.9.0"])
76
+ s.add_dependency(%q<radiant-taggable-extension>, [">= 1.2.0"])
77
+ end
78
+ end
79
+
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: 15
4
+ hash: 13
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
- - 0
10
- version: 2.0.0
9
+ - 1
10
+ version: 2.0.1
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-09-10 00:00:00 +01:00
18
+ date: 2010-09-14 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -61,6 +61,7 @@ extra_rdoc_files:
61
61
  files:
62
62
  - README.md
63
63
  - Rakefile
64
+ - VERSION
64
65
  - app/models/library_page.rb
65
66
  - app/views/admin/assets/_edit_metadata.html.haml
66
67
  - app/views/admin/assets/_edit_title.html.haml
@@ -78,6 +79,8 @@ files:
78
79
  - lib/library/tagged_asset.rb
79
80
  - lib/tasks/library_extension_tasks.rake
80
81
  - library_extension.rb
82
+ - pkg/radiant-library-extension-2.0.0.gem
83
+ - radiant-library-extension.gemspec
81
84
  - spec/controllers/library_site_controller_spec.rb
82
85
  - spec/datasets/library_pages_dataset.rb
83
86
  - spec/datasets/library_sites_dataset.rb