radiant-taggable_events-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.
@@ -1,5 +1,5 @@
1
1
  module RadiantTaggableEventsExtension
2
- VERSION = '2.0.0'
2
+ VERSION = '2.0.1'
3
3
  SUMMARY = %q{Adds event tags, tag clouds and faceted search to the event_calendar extension.}
4
4
  DESCRIPTION = %q{A tiny bit of glue to attach tags to event_calendar events and put tag clouds and faceted retrieval on event calendar pages.}
5
5
  URL = "http://spanner.org/radiant/taggable_event"
@@ -0,0 +1,20 @@
1
+ module Taggable
2
+ module Event
3
+ def self.included(base)
4
+ base.class_eval {
5
+ before_validation_on_create :inherit_tags
6
+ }
7
+ end
8
+
9
+ private
10
+
11
+ # tags are inherited from context on creation but subsequently editable
12
+
13
+ def inherit_tags
14
+ self.attached_tags += calendar.attached_tags if calendar
15
+ self.attached_tags += event_venue.attached_tags if event_venue
16
+ self.attached_tags.uniq!
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,80 @@
1
+ module Taggable
2
+ module EventTags
3
+ include Radiant::Taggable
4
+ include EventCalendarTags
5
+
6
+ class TagError < StandardError; end
7
+
8
+ desc %{
9
+ Cycles through all tags attached to present event.
10
+
11
+ *Usage:*
12
+ <pre><code><r:assets:tags><r:tag:title /></r:assets:tags></code></pre>
13
+ }
14
+ tag 'event:tags' do |tag|
15
+ tag.locals.tags = tag.locals.event.attached_tags
16
+ tag.expand
17
+ end
18
+ # tag 'event:tags:each' do |tag|
19
+ # tag.render('tags:each', tag.attr.dup, &tag.block)
20
+ # end
21
+
22
+ desc %{
23
+ Expands if the present event has any tags.
24
+ }
25
+ tag 'event:if_tags' do |tag|
26
+ tag.expand if tag.locals.event.attached_tags.any?
27
+ end
28
+
29
+ desc %{
30
+ Expands if the present event has no tags.
31
+ }
32
+ tag 'event:unless_tags' do |tag|
33
+ tag.expand unless tag.locals.event.attached_tags.any?
34
+ end
35
+
36
+ desc %{
37
+ Presents a tag cloud built from the current set of events.
38
+
39
+ See r:tag_cloud for formatting and linking parameters. By default we show the top 50 most used tags.
40
+
41
+ *Usage:*
42
+ <pre><code><r:events:tag_cloud /></code></pre>
43
+ }
44
+ tag 'events:tag_cloud' do |tag|
45
+ options = tag.attr.dup
46
+ tag.locals.events ||= get_events(tag)
47
+ limit = options.delete('limit') || 50
48
+ tag.locals.tags = Tag.sized(Tag.attached_to(tag.locals.events).most_popular(limit))
49
+ tag.render('tag_cloud', options)
50
+ end
51
+
52
+ desc %{
53
+ Presents a tag cloud built from the entire population of events.
54
+
55
+ See r:tag_cloud for formatting and linking parameters. By default we show the top 50 most used tags.
56
+
57
+ *Usage:*
58
+ <pre><code><r:all_events:tag_cloud /></code></pre>
59
+ }
60
+ tag 'all_events:tag_cloud' do |tag|
61
+ options = tag.attr.dup
62
+ limit = options.delete('limit') || 50
63
+ tag.locals.tags = Tag.sized(Tag.attached_to(tag.locals.events).most_popular(limit))
64
+ tag.render('tags:cloud', options)
65
+ end
66
+
67
+ def event_finder_with_tags(tag)
68
+ ef = event_finder_without_tags(tag)
69
+ ef = ef.from_all_tags(Tag.from_list(tag.attr['tags'])) unless tag.attr['tags'].blank?
70
+ ef
71
+ end
72
+
73
+ def self.included(base)
74
+ base.class_eval {
75
+ alias_method_chain :event_finder, :tags
76
+ }
77
+ end
78
+
79
+ end
80
+ end
@@ -0,0 +1,46 @@
1
+ module Taggable
2
+ module EventsController
3
+
4
+ def self.included(base)
5
+ base.class_eval {
6
+ helper_method :tags, :url_with_tag, :url_without_tag
7
+ alias_method_chain :event_finder, :tags
8
+ alias_method_chain :continuing_events, :tags
9
+ alias_method_chain :calendar_parameter_names, :tags
10
+ }
11
+ end
12
+
13
+ def tags
14
+ @tags ||= Tag.from_list(params[:tags], false) || []
15
+ end
16
+
17
+ def event_finder_with_tags
18
+ ef = event_finder_without_tags
19
+ ef = ef.from_all_tags(tags) if tags.any?
20
+ ef
21
+ end
22
+
23
+ def continuing_events_with_tags
24
+ continuing_events_without_tags
25
+ @continuing_events = @continuing_events.from_all_tags(tags) if tags.any?
26
+ @continuing_events
27
+ end
28
+
29
+ def calendar_parameter_names_with_tags
30
+ calendar_parameter_names_without_tags + [:tags]
31
+ end
32
+
33
+ def url_without_tag(tag)
34
+ url_for(url_parts({
35
+ :tags => Tag.to_list(tags - [tag])
36
+ }))
37
+ end
38
+
39
+ def url_with_tag(tag)
40
+ url_for(url_parts({
41
+ :tags => Tag.to_list(tags + [tag])
42
+ }))
43
+ end
44
+
45
+ end
46
+ end
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
13
13
  s.description = RadiantTaggableEventsExtension::DESCRIPTION
14
14
 
15
15
  s.add_dependency "radiant-event_calendar-extension", "~> 1.5.0"
16
- s.add_dependency "radiant-taggable-extension", "~> 2.0.0.rc4"
16
+ s.add_dependency "radiant-taggable-extension", "~> 2.0.1"
17
17
 
18
18
  ignores = if File.exist?('.gitignore')
19
19
  File.read('.gitignore').split("\n").inject([]) {|a,p| a + Dir[p] }
@@ -11,9 +11,10 @@ class TaggableEventsExtension < Radiant::Extension
11
11
  Calendar.send :has_tags # make calendars taggable
12
12
  EventVenue.send :has_tags # make event venues taggable
13
13
  Event.send :has_tags # make events taggable
14
- Event.send :include, TaggableEvent # ...and inherit tags from venue and calendar
15
- EventsController.send :include, TaggableEventsController # further complicate the retrieval of events by adding tag-filters
16
- Page.send :include, TaggableEventTags # support tag conditions on r:events:* radius tags
14
+ Event.send :include, Taggable::Event # ...and inherit attached tags from venue and calendar on creation
15
+ EventsController.send :include, Taggable::EventsController # further complicate the retrieval of events by adding tag-filters
16
+ Page.send :include, Taggable::EventTags # support tag conditions on r:events:* radius tags
17
+ EventCalendarPage.send :include, Taggable::FacetedPage # faceting tags are understood by calendar pages
17
18
  end
18
19
 
19
20
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiant-taggable_events-extension
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
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
  - William Ross
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-09-06 00:00:00 +01:00
18
+ date: 2011-10-05 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -42,14 +42,12 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- hash: 15424093
45
+ hash: 13
46
46
  segments:
47
47
  - 2
48
48
  - 0
49
- - 0
50
- - rc
51
- - 4
52
- version: 2.0.0.rc4
49
+ - 1
50
+ version: 2.0.1
53
51
  type: :runtime
54
52
  version_requirements: *id002
55
53
  description: A tiny bit of glue to attach tags to event_calendar events and put tag clouds and faceted retrieval on event calendar pages.
@@ -71,9 +69,9 @@ files:
71
69
  - features/support/env.rb
72
70
  - features/support/paths.rb
73
71
  - lib/radiant-taggable_events-extension.rb
74
- - lib/taggable_event.rb
75
- - lib/taggable_event_tags.rb
76
- - lib/taggable_events_controller.rb
72
+ - lib/taggable/event.rb
73
+ - lib/taggable/event_tags.rb
74
+ - lib/taggable/events_controller.rb
77
75
  - lib/tasks/taggable_events_extension_tasks.rake
78
76
  - public/images/furniture/detag.png
79
77
  - radiant-taggable_events-extension.gemspec
@@ -89,7 +87,7 @@ has_rdoc: true
89
87
  homepage: http://spanner.org/radiant/taggable_event
90
88
  licenses: []
91
89
 
92
- post_install_message: "\n Add this to your Gemfile with:\n\n gem 'radiant-taggable_events-extension', '~> 2.0.0'\n\n "
90
+ post_install_message: "\n Add this to your Gemfile with:\n\n gem 'radiant-taggable_events-extension', '~> 2.0.1'\n\n "
93
91
  rdoc_options: []
94
92
 
95
93
  require_paths:
@@ -1,19 +0,0 @@
1
- module TaggableEvent # for inclusion into Event
2
-
3
- def self.included(base)
4
- base.class_eval {
5
- before_validation_on_create :inherit_tags
6
- }
7
- end
8
-
9
- private
10
-
11
- # tags are inherited from context on creation but subsequently editable
12
-
13
- def inherit_tags
14
- self.attached_tags += calendar.attached_tags if calendar
15
- self.attached_tags += event_venue.attached_tags if event_venue
16
- self.attached_tags.uniq!
17
- end
18
-
19
- end
@@ -1,50 +0,0 @@
1
- module TaggableEventTags
2
- include Radiant::Taggable
3
- include EventCalendarTags
4
-
5
- class TagError < StandardError; end
6
-
7
- desc %{
8
- Presents a tag cloud built from the current set of events.
9
-
10
- See r:tag_cloud for formatting and linking parameters. By default we show the top 50 most used tags.
11
-
12
- *Usage:*
13
- <pre><code><r:events:tag_cloud /></code></pre>
14
- }
15
- tag 'events:tag_cloud' do |tag|
16
- options = tag.attr.dup
17
- tag.locals.events ||= get_events(tag)
18
- limit = options.delete('limit') || 50
19
- tag.locals.tags = Tag.sized(Tag.attached_to(tag.locals.events).most_popular(limit))
20
- tag.render('tags:cloud', options)
21
- end
22
-
23
- desc %{
24
- Presents a tag cloud built from the entire population of events.
25
-
26
- See r:tag_cloud for formatting and linking parameters. By default we show the top 50 most used tags.
27
-
28
- *Usage:*
29
- <pre><code><r:all_events:tag_cloud /></code></pre>
30
- }
31
- tag 'all_events:tag_cloud' do |tag|
32
- options = tag.attr.dup
33
- limit = options.delete('limit') || 50
34
- tag.locals.tags = Tag.sized(Tag.attached_to(tag.locals.events).most_popular(limit))
35
- tag.render('tags:cloud', options)
36
- end
37
-
38
- def event_finder_with_tags(tag)
39
- ef = event_finder_without_tags(tag)
40
- ef = ef.from_all_tags(Tag.from_list(tag.attr['tags'])) unless tag.attr['tags'].blank?
41
- ef
42
- end
43
-
44
- def self.included(base)
45
- base.class_eval {
46
- alias_method_chain :event_finder, :tags
47
- }
48
- end
49
-
50
- end
@@ -1,44 +0,0 @@
1
- module TaggableEventsController
2
-
3
- def self.included(base)
4
- base.class_eval {
5
- helper_method :tags, :url_with_tag, :url_without_tag
6
- alias_method_chain :event_finder, :tags
7
- alias_method_chain :continuing_events, :tags
8
- alias_method_chain :calendar_parameter_names, :tags
9
- }
10
- end
11
-
12
- def tags
13
- @tags ||= Tag.from_list(params[:tags], false) || []
14
- end
15
-
16
- def event_finder_with_tags
17
- ef = event_finder_without_tags
18
- ef = ef.from_all_tags(tags) if tags.any?
19
- ef
20
- end
21
-
22
- def continuing_events_with_tags
23
- continuing_events_without_tags
24
- @continuing_events = @continuing_events.from_all_tags(tags) if tags.any?
25
- @continuing_events
26
- end
27
-
28
- def calendar_parameter_names_with_tags
29
- calendar_parameter_names_without_tags + [:tags]
30
- end
31
-
32
- def url_without_tag(tag)
33
- url_for(url_parts({
34
- :tags => Tag.to_list(tags - [tag])
35
- }))
36
- end
37
-
38
- def url_with_tag(tag)
39
- url_for(url_parts({
40
- :tags => Tag.to_list(tags + [tag])
41
- }))
42
- end
43
-
44
- end