radiant-taggable_events-extension 1.1.0 → 1.2.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/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  This is a tiny bit of glue to associate taggable's tags with event_calendar's events. It also provides a few useful radius tags for your calendar pages.
4
4
 
5
+
6
+
5
7
  ## Author & Copyright
6
8
 
7
9
  * William Ross, for spanner. will at spanner.org
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.0
1
+ 1.2.0
@@ -0,0 +1,19 @@
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
@@ -14,7 +14,7 @@ module TaggableEventTags
14
14
  options = tag.attr.dup
15
15
  tag.locals.events ||= get_events(tag)
16
16
  limit = options.delete('limit') || 100
17
- tag.locals.tags = Tag.banded(Tag.attached_to(tag.locals.events).most_popular(limit))
17
+ tag.locals.tags = Tag.sized(Tag.attached_to(tag.locals.events).most_popular(limit))
18
18
  tag.render('tags:cloud', options)
19
19
  end
20
20
 
@@ -29,7 +29,7 @@ module TaggableEventTags
29
29
  tag 'all_events:tag_cloud' do |tag|
30
30
  options = tag.attr.dup
31
31
  limit = options.delete('limit') || 100
32
- tag.locals.tags = Tag.banded(Tag.attached_to(tag.locals.events).most_popular(limit))
32
+ tag.locals.tags = Tag.sized(Tag.attached_to(tag.locals.events).most_popular(limit))
33
33
  tag.render('tags:cloud', options)
34
34
  end
35
35
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{radiant-taggable_events-extension}
8
- s.version = "1.1.0"
8
+ s.version = "1.2.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-09-10}
12
+ s.date = %q{2010-10-04}
13
13
  s.description = %q{A tiny bit of glue to attach tags to event_calendar events and define some radius tags useful on calendar pages}
14
14
  s.email = %q{will@spanner.org}
15
15
  s.extra_rdoc_files = [
@@ -26,13 +26,16 @@ Gem::Specification.new do |s|
26
26
  "db/migrate/20100301074622_import_keywords.rb",
27
27
  "features/support/env.rb",
28
28
  "features/support/paths.rb",
29
+ "lib/taggable_event.rb",
29
30
  "lib/taggable_event_tags.rb",
30
- "lib/tagged_event_finder.rb",
31
31
  "lib/tagged_events_controller.rb",
32
32
  "lib/tasks/taggable_events_extension_tasks.rake",
33
33
  "pkg/radiant-taggable_events-extension-1.1.0.gem",
34
34
  "public/images/furniture/detag.png",
35
35
  "radiant-taggable_events-extension.gemspec",
36
+ "spec/datasets/events_dataset.rb",
37
+ "spec/datasets/tags_dataset.rb",
38
+ "spec/lib/taggable_event_spec.rb",
36
39
  "spec/spec.opts",
37
40
  "spec/spec_helper.rb",
38
41
  "taggable_events_extension.rb"
@@ -43,7 +46,10 @@ Gem::Specification.new do |s|
43
46
  s.rubygems_version = %q{1.3.7}
44
47
  s.summary = %q{Tagging Extension for the Radiant CMS Event_Calendar}
45
48
  s.test_files = [
46
- "spec/spec_helper.rb"
49
+ "spec/datasets/events_dataset.rb",
50
+ "spec/datasets/tags_dataset.rb",
51
+ "spec/lib/taggable_event_spec.rb",
52
+ "spec/spec_helper.rb"
47
53
  ]
48
54
 
49
55
  if s.respond_to? :specification_version then
@@ -0,0 +1,94 @@
1
+ class EventsDataset < Dataset::Base
2
+ uses :tags
3
+
4
+ def load
5
+ create_venue "Elsewhere"
6
+ create_venue "Somewhere" do
7
+ add_tags"colourless, green"
8
+ create_calendar :local do
9
+ add_tags "ideas"
10
+ create_event 'simple', :title => "Simple", :start_date => "2009-11-03 18:30:00" do
11
+ add_tags "sleep, furiously"
12
+ end
13
+ create_event 'other', :title => "Another", :start_date => "2009-11-03 18:30:00" do
14
+ add_tags "furiously"
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ helpers do
21
+ def create_venue(title, attributes={})
22
+ attributes = event_venue_attributes(attributes.update(:title => title))
23
+ venue = create_model EventVenue, title.symbolize, attributes
24
+ if block_given?
25
+ @venue = venue
26
+ yield
27
+ end
28
+ end
29
+
30
+ def create_calendar(name, attributes={})
31
+ attributes = calendar_attributes(attributes.update(:name => name))
32
+ calendar = create_model Calendar, name.symbolize, attributes
33
+ calendar.ical = calendar.build_ical(:url => 'stubbed')
34
+ if block_given?
35
+ @calendar = calendar
36
+ yield
37
+ end
38
+ end
39
+
40
+ def create_event(title, attributes={})
41
+ attributes = event_attributes(attributes.update(:title => title))
42
+ event = create_model Event, title.symbolize, attributes
43
+ if block_given?
44
+ @event = event
45
+ yield
46
+ end
47
+ event
48
+ end
49
+
50
+ def add_tags(tags)
51
+ (@event || @calendar || @venue).attached_tags << Tag.from_list(tags)
52
+ end
53
+ end
54
+
55
+ def event_venue_attributes(attributes={})
56
+ title = attributes[:title] || "Default"
57
+ symbol = title.symbolize
58
+ attributes = {
59
+ :title => title,
60
+ :description => 'A venue'
61
+ }.merge(attributes)
62
+ attributes
63
+ end
64
+
65
+ def calendar_attributes(attributes={})
66
+ name = attributes[:name] || "Default"
67
+ symbol = name.symbolize
68
+ attributes = {
69
+ :name => name,
70
+ :description => 'A calendar',
71
+ :category => 'test',
72
+ :slug => name.to_s
73
+ }.merge(attributes)
74
+ attributes
75
+ end
76
+
77
+ def event_attributes(attributes={})
78
+ title = attributes[:title] || "Default"
79
+ symbol = title.symbolize
80
+ attributes = {
81
+ :calendar => @calendar,
82
+ :event_venue => @venue,
83
+ :title => title,
84
+ :description => 'An event'
85
+ }.merge(attributes)
86
+ attributes
87
+ end
88
+
89
+
90
+ def add_recurrence(attributes={})
91
+ @event.recurrence_rules.create(attributes)
92
+ end
93
+
94
+ end
@@ -0,0 +1,43 @@
1
+ require 'digest/sha1'
2
+
3
+ class TagsDataset < Dataset::Base
4
+ datasets = [:pages]
5
+ datasets << :tag_sites if defined? Site
6
+ uses *datasets
7
+
8
+ def load
9
+ create_tag "colourless"
10
+ create_tag "green"
11
+ create_tag "ideas"
12
+ create_tag "sleep"
13
+ create_tag "furiously"
14
+
15
+ apply_tag :colourless, pages(:first)
16
+ apply_tag :ideas, pages(:first), pages(:another), pages(:grandchild)
17
+ apply_tag :sleep, pages(:first)
18
+ apply_tag :furiously, pages(:first)
19
+ end
20
+
21
+ helpers do
22
+ def create_tag(title, attributes={})
23
+ attributes = tag_attributes(attributes.update(:title => title))
24
+ tag = create_model Tag, title.symbolize, attributes
25
+ end
26
+
27
+ def tag_attributes(attributes={})
28
+ title = attributes[:name] || "Tag"
29
+ attributes = {
30
+ :title => title
31
+ }.merge(attributes)
32
+ attributes[:site] = sites(:test) if defined? Site
33
+ attributes
34
+ end
35
+
36
+ def apply_tag(tag, *items)
37
+ tag = tag.is_a?(Tag) ? tag : tags(tag)
38
+ items.each { |i| i.attached_tags << tag }
39
+ end
40
+
41
+ end
42
+
43
+ end
@@ -0,0 +1,50 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Calendar do
4
+ dataset :events
5
+
6
+ it "should report itself taggable" do
7
+ Calendar.is_taggable?.should be_true
8
+ end
9
+
10
+ it "should have attached tags" do
11
+ calendars(:local).attached_tags.should == Tag.from_list("ideas")
12
+ end
13
+ end
14
+
15
+ describe EventVenue do
16
+ dataset :events
17
+
18
+ it "should report itself taggable" do
19
+ EventVenue.is_taggable?.should be_true
20
+ end
21
+
22
+ it "should have attached tags" do
23
+ event_venues(:somewhere).attached_tags.should == Tag.from_list("colourless, green")
24
+ end
25
+ end
26
+
27
+ describe Event do
28
+ dataset :events
29
+
30
+ it "should report itself taggable" do
31
+ Event.is_taggable?.should be_true
32
+ end
33
+
34
+ it "should have attached tags" do
35
+ events(:other).attached_tags.include?(Tag.for('furiously')).should be_true
36
+ end
37
+
38
+ it "should inherit tags from its calendar" do
39
+ events(:simple).attached_tags.include?(Tag.for('ideas')).should be_true
40
+ end
41
+
42
+ it "should inherit tags from its venue" do
43
+ events(:simple).attached_tags.include?(Tag.for('colourless')).should be_true
44
+ end
45
+
46
+ it "should return a list of all its tags" do
47
+ events(:simple).attached_tags.should == Tag.from_list("colourless, green, ideas, sleep, furiously")
48
+ end
49
+
50
+ end
@@ -2,13 +2,16 @@
2
2
  require_dependency 'application_controller'
3
3
 
4
4
  class TaggableEventsExtension < Radiant::Extension
5
- version "1.1.0"
5
+ version "1.2.0"
6
6
  description "A tiny bit of glue to attach tags to event_calendar events and define some radius tags useful on calendar pages"
7
7
  url "http://github.com/spanner/radiant-taggable_events-extension"
8
8
 
9
9
  def activate
10
- Event.send :is_taggable
11
- EventsController.send :include, TaggedEventsController
10
+ Calendar.send :is_taggable # make calendars taggable
11
+ EventVenue.send :is_taggable # make event venues taggable
12
+ Event.send :is_taggable # make events taggable
13
+ Event.send :include, TaggableEvent # and inherit tags from venue and calendar
14
+ EventsController.send :include, TaggedEventsController # further complicate the retrieval of events by adding tag-filters
12
15
  end
13
16
 
14
17
  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: 19
4
+ hash: 31
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 1.1.0
10
+ version: 1.2.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-09-10 00:00:00 +01:00
18
+ date: 2010-10-04 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -81,13 +81,16 @@ files:
81
81
  - db/migrate/20100301074622_import_keywords.rb
82
82
  - features/support/env.rb
83
83
  - features/support/paths.rb
84
+ - lib/taggable_event.rb
84
85
  - lib/taggable_event_tags.rb
85
- - lib/tagged_event_finder.rb
86
86
  - lib/tagged_events_controller.rb
87
87
  - lib/tasks/taggable_events_extension_tasks.rake
88
88
  - pkg/radiant-taggable_events-extension-1.1.0.gem
89
89
  - public/images/furniture/detag.png
90
90
  - radiant-taggable_events-extension.gemspec
91
+ - spec/datasets/events_dataset.rb
92
+ - spec/datasets/tags_dataset.rb
93
+ - spec/lib/taggable_event_spec.rb
91
94
  - spec/spec.opts
92
95
  - spec/spec_helper.rb
93
96
  - taggable_events_extension.rb
@@ -126,4 +129,7 @@ signing_key:
126
129
  specification_version: 3
127
130
  summary: Tagging Extension for the Radiant CMS Event_Calendar
128
131
  test_files:
132
+ - spec/datasets/events_dataset.rb
133
+ - spec/datasets/tags_dataset.rb
134
+ - spec/lib/taggable_event_spec.rb
129
135
  - spec/spec_helper.rb
@@ -1,25 +0,0 @@
1
- module TaggedEventFinder
2
-
3
- def self.included(base)
4
- base.class_eval {
5
- alias_method_chain :event_finder, :tags
6
- alias_method_chain :filters_applied, :tags
7
- }
8
- end
9
-
10
- def event_finder_with_tags(tag)
11
- ef = event_finder_without_tags(tag)
12
- ef = ef.from_all_tags(calendar_tags) if tags_applied?
13
- ef
14
- end
15
-
16
- def filters_applied_with_tags(tag)
17
- filters = filters_applied_without_tags(tag)
18
- if tags_applied?
19
- tags = @calendar_tags.map { |t| %{<a href="#{tag.locals.page.url(:tags => tags_without(t))}" class="defilter">#{t}</a> } }.to_sentence
20
- filters << %{tagged with #{tags}}
21
- end
22
- filters
23
- end
24
-
25
- end