radiant-eventbrite-extension 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.mdown ADDED
@@ -0,0 +1,27 @@
1
+ #Eventbrite
2
+
3
+ Provides a few Radius Tags to access data from the EventBrite API
4
+
5
+ Right now, functionality is limited to getting the events of a user,
6
+ iterating over them and displaying their data (useful e.g. for Events listings).
7
+
8
+ The Tag names closely align with the fields the EventBrite API returns, see
9
+ http://developer.eventbrite.com/doc/users/user_list_events/
10
+
11
+ ##Example
12
+
13
+ <r:eventbrite user="1235467890">
14
+ <h2>Event Listing</h2>
15
+ <ul>
16
+ <r:events:each>
17
+ <li><a href="<r:url />"><r:title /> - starts on <r:start_date format="%D" /></a></li>
18
+ </r:events:each>
19
+ </ul>
20
+ </r:eventbrite>
21
+
22
+ ##Todo
23
+
24
+ - Read Venue Details
25
+ - Read Ticket/Pricing Details
26
+ - Event Searching functionality
27
+ - Write functionality
data/Rakefile ADDED
@@ -0,0 +1,46 @@
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |gem|
4
+ gem.name = 'radiant-eventbrite-extension'
5
+ gem.summary = 'Eventbrite Extension for Radiant CMS'
6
+ gem.description = 'Provides a few Radius Tags to access data from the EventBrite API'
7
+ gem.email = 'gerrit@gerritkaiser.de'
8
+ gem.homepage = 'http://ext.radiantcms.org/extensions/265-eventbrite'
9
+ gem.authors = ['Gerrit Kaiser']
10
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
11
+ end
12
+ rescue LoadError
13
+ puts "Jeweler (or a dependency) not available. This is only required if you plan to package eventbrite as a gem."
14
+ end
15
+
16
+ # In rails 1.2, plugins aren't available in the path until they're loaded.
17
+ # Check to see if the rspec plugin is installed first and require
18
+ # it if it is. If not, use the gem version.
19
+
20
+ # Determine where the RSpec plugin is by loading the boot
21
+ unless defined? RADIANT_ROOT
22
+ ENV["RAILS_ENV"] = "test"
23
+ case
24
+ when ENV["RADIANT_ENV_FILE"]
25
+ require File.dirname(ENV["RADIANT_ENV_FILE"]) + "/boot"
26
+ when File.dirname(__FILE__) =~ %r{vendor/radiant/vendor/extensions}
27
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../")}/config/boot"
28
+ else
29
+ require "#{File.expand_path(File.dirname(__FILE__) + "/../../../")}/config/boot"
30
+ end
31
+ end
32
+
33
+ require 'rake'
34
+ require 'rake/rdoctask'
35
+
36
+ desc 'Generate documentation for the eventbrite extension.'
37
+ Rake::RDocTask.new(:rdoc) do |rdoc|
38
+ rdoc.rdoc_dir = 'rdoc'
39
+ rdoc.title = 'EventbriteExtension'
40
+ rdoc.options << '--line-numbers' << '--inline-source'
41
+ rdoc.rdoc_files.include('README')
42
+ rdoc.rdoc_files.include('lib/**/*.rb')
43
+ end
44
+
45
+ # Load any custom rakefiles for extension
46
+ Dir[File.dirname(__FILE__) + '/tasks/*.rake'].sort.each { |f| require f }
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,69 @@
1
+ module EventbriteTags
2
+ include Radiant::Taggable
3
+ class TagError < StandardError; end
4
+
5
+ desc %{
6
+ Set a user for the Eventbrite API.
7
+
8
+ Needs an attribute @user@ witha a valid Eventbrite API User Key
9
+ Obtain yours at http://www.eventbrite.com/userkeyapi
10
+ }
11
+ tag 'eventbrite' do |tag|
12
+ user_attr_msg = 'r:eventbrite tag must contain a “user” attribute with a Eventbrite API User Key.'
13
+ raise TagError.new(user_attr_msg) unless tag.attr.has_key?('user')
14
+ EventBright.setup(EventbriteExtension.api_key)
15
+ tag.locals.eventbrite_user = EventBright::User.new(tag.attr['user'])
16
+ tag.expand
17
+ end
18
+
19
+ # namespace
20
+ tag 'eventbrite:events' do |tag|
21
+ tag.expand
22
+ end
23
+
24
+ desc %{
25
+ Iterates over a user's events
26
+
27
+ Defaults to showing only “live” events
28
+ (i.e. active and public ones that are in the future).
29
+ This can be overriden by using the @status@ attribute to one of
30
+ “draft”, “live”, “started”, “ended”, or “canceled”.
31
+ }
32
+ tag 'eventbrite:events:each' do |tag|
33
+ requested_status = (tag.attr['status'] || 'live')
34
+ tag.locals.eventbrite_user.events.collect do |event|
35
+ if event.status.downcase == requested_status
36
+ tag.locals.eventbrite_event = event
37
+ tag.expand
38
+ end
39
+ end
40
+ end
41
+
42
+ %w[start_date end_date created modified].each do |date_attr|
43
+ desc %{
44
+ Renders the #{date_attr} Time/Date of the current event
45
+
46
+ Accepts an optional @format@ attribute (see documentation for r:date tag)
47
+ }
48
+ tag "eventbrite:events:each:#{date_attr}" do |tag|
49
+ format = (tag.attr['format'] || '%A, %B %d, %Y')
50
+ time = tag.locals.eventbrite_event.attributes[date_attr.to_sym]
51
+ time.strftime(format)
52
+ end
53
+ end
54
+
55
+ %w[
56
+ title description category tags timezone
57
+ capacity url logo logo_ssl status
58
+ ].each do |attribute|
59
+ desc %{
60
+ Renders the #{attribute} of the current event
61
+
62
+ (see http://developer.eventbrite.com/doc/users/user_list_events/)
63
+ }
64
+ tag "eventbrite:events:each:#{attribute}" do |tag|
65
+ tag.locals.eventbrite_event.send attribute
66
+ end
67
+ end
68
+
69
+ end
@@ -0,0 +1,21 @@
1
+ class EventbriteExtension < Radiant::Extension
2
+ version File.read(File.join(File.dirname(__FILE__), 'VERSION'))
3
+ description 'Provides a few Radius Tags to access data from the EventBrite API'
4
+ url "http://ext.radiantcms.org/extensions/265-eventbrite"
5
+
6
+ extension_config do |config|
7
+ config.gem 'eventbright'
8
+ end
9
+
10
+ # Registered for use with this extension
11
+ # May be rate-limited at some point
12
+ API_KEY = 'MzUxOTYzYTRkNzEy'
13
+
14
+ def self.api_key
15
+ Radiant::Config['eventbrite.api_key'] || API_KEY
16
+ end
17
+
18
+ def activate
19
+ Page.send :include, EventbriteTags
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: radiant-eventbrite-extension
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 1
9
+ - 0
10
+ version: 0.1.0
11
+ platform: ruby
12
+ authors:
13
+ - Gerrit Kaiser
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-02-13 00:00:00 +00:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: Provides a few Radius Tags to access data from the EventBrite API
23
+ email: gerrit@gerritkaiser.de
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files:
29
+ - README.mdown
30
+ files:
31
+ - README.mdown
32
+ - Rakefile
33
+ - VERSION
34
+ - app/models/eventbrite_tags.rb
35
+ - eventbrite_extension.rb
36
+ has_rdoc: true
37
+ homepage: http://ext.radiantcms.org/extensions/265-eventbrite
38
+ licenses: []
39
+
40
+ post_install_message:
41
+ rdoc_options: []
42
+
43
+ require_paths:
44
+ - lib
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ hash: 3
51
+ segments:
52
+ - 0
53
+ version: "0"
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ requirements: []
64
+
65
+ rubyforge_project:
66
+ rubygems_version: 1.3.7
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: Eventbrite Extension for Radiant CMS
70
+ test_files: []
71
+