Skip to content
Browse files

basic facebook links, various small improvements

  • Loading branch information...
1 parent 6d60444 commit e127b2f3d88b36679dec8bab5f15d78f03629573 @will-r will-r committed Jul 18, 2011
View
14 README.md
@@ -1,22 +1,22 @@
# Event Calendar Extension for Radiant
-This extension lets your radiant site present calendar events in various useful ways. The events can be administered directly or retrieved by subscription to ical and caldav services including Google Calendar, and can be served as RSS, Ical or JSON feeds as well as through a broad set of radius tags on your normal pages. This extension supports a wide range of uses from a basic display of forthcoming events through to a full calendar aggregation and mapping service.
+This extension lets your radiant site present calendar events in various useful ways. The events can be administered directly or retrieved by subscription to ical and caldav services including Google Calendar, and can be served as RSS, Ical or JSON feeds as well as through a broad set of radius tags on your normal pages. This extension supports a wide range of uses from a single-tag display of forthcoming events through to a full calendar aggregation and mapping service.
The calendaring functionality comes from [ri_cal](http://github.com/rubyredrick/ri_cal) and supports proper recurrence and duration. We also recognise all-day events and pass through notes and urls: the ical subscription and redistribution should be fully RFC2445 compliant. It is not yet a full CalDAV client, and we don't have proper support for principals, groups or availability.
-See the [event_map](http://github.com/spanner/radiant-event_map-extension) extension for googlemapping of events and [taggable_events](http://github.com/spanner/radiant-taggable_events-extension) for more fine-grained tagging and retrieval options. A `reader_events` extension is also in the works for reader-submitted calendar events, but [reader](http://github.com/spanner/radiant-reader-extension) will need to be updated for 0.9 first.
+See the [event_map](http://github.com/spanner/radiant-event_map-extension) extension for googlemapping of events and [taggable_events](http://github.com/spanner/radiant-taggable_events-extension) for more fine-grained tagging and retrieval options. A `reader_events` extension is also in the works for public submission of calendar events.
## Requirements
-Radiant 0.9, `layouts` or `share_layouts` and the `ri_cal` gem to handle iCal data. It's declared in the extension so this should do it:
+Radiant 0.9 or 1, `layouts` or `share_layouts` and the `ri_cal` gem to handle iCal data. It's declared in the extension so this should do it:
sudo rake gems:install
This is compatible with `multi_site` and with the [sites](http://github.com/spanner/radiant-sites-extension) extension. With the latter everything will be site-scoped.
There is a 0.81 tag in the repository for the last version good with radiant 0.8.1 and `scoped_admin`.
-This version includes some experiments in dashboard integration. If you're using dashboard you need the spanner fork.
+This version includes some optional experiments in dashboard integration. If you're using dashboard you need the spanner fork.
## Installation
@@ -137,14 +137,12 @@ If you have another column in your layout, try adding this:
For clickable thumbnails of coming months.
-## Notes
-
-This is developing quite quickly at the moment but it's in production use on one big and several small sites. If there are bugs they will be fixed immediately.
-
### Compatibility
I've tested this with Darwin Calendar Server (on Ubuntu), with Google Calendar and with feeds published from iCal on a mac. It should work just as well with iCal server on OS X Server, and in theory any other CalDav-compliant back end. See http://caldav.calconnect.org/ for more possibilities.
+It should in theory be possible to display a feed from facebook, but I haven't tried it. The 'export events' url is supposed to give an ical-compatible feed that is updated each time you accept or decline an invitation.
+
### Connecting to Google Calendar
Create a calendar in your Google Calendar account. Call it 'public', or whatever you like, and tick the box marked 'make this calendar public'.
View
20 app/controllers/events_controller.rb
@@ -25,12 +25,28 @@ def index
render :layout => false
}
format.ics {
- headers["Content-disposition"] = %{attachment; filename="#{filename}.ics"}
- render :layout => false
+ ical = RiCal.Calendar do |cal|
+ events.each { |event| cal.add_subcomponent(event.to_ri_cal) }
+ end
+ send_data ical, :filename => "#{filename}.ics"
}
end
end
+ def show
+ @event = Event.find(params[:id])
+ format.html {
+ timeout = Radiant::Config['event_calendar:cache_duration'] || self.class.cache_timeout || 1.hour
+ expires_in timeout.to_i, :public => true, :private => false
+ }
+ format.ics {
+ ical = RiCal.Calendar { |cal| cal.add_subcomponent(@event.to_ri_cal) }
+ send_data ical, :filename => "#{@event.title.slugify}.ics"
+ }
+ end
+
+ ### helper methods
+
def period
return @period if @period
this = Date.today
View
4 app/models/event.rb
@@ -281,6 +281,10 @@ def url
end
end
+ def facebook_url
+ %{}
+ end
+
def one_day?
all_day? && within_day?
end
View
2 app/models/event_calendar_page.rb
@@ -97,7 +97,7 @@ def day_names
desc %{
Renders a trail of breadcrumbs to the current page. On an event calendar page this tag is
- overridden to show the filters applied to calendar data (including category, slug and date rage)
+ overridden to show the filters applied to calendar data (including category, slug and date range)
as well as the path to this page.
*Usage:*
View
4 app/views/admin/events/_form.html.haml
@@ -85,6 +85,10 @@
= f.label :url, t('event_admin.form.event_url')
= f.text_field :url, :class => 'textbox', :disabled => imported
+ %p.facebook
+ = f.label :facebook_id, t('event_admin.form.facebook_id')
+ = f.text_field :facebook_id, :class => 'textbox', :disabled => imported
+
- form_bottom.edit_venue do
- toggle_precedence = %w{venue new_venue}
- toggle_precedence.reverse! if @venues.empty?
View
2 app/views/events/_event.html.haml
@@ -33,6 +33,8 @@
- elsif event.location
%span.location
= event.location
+ - if event.facebook_id
+ = link_to t('event_calendar_extension.view_on_facebook'), event.facebook_url, :class => 'facebook event'
- unless repeating
= event.description_paragraph
View
7 app/views/events/index.ics.erb
@@ -1,7 +0,0 @@
-<%-
-ical = RiCal.Calendar do |cal|
- events.each do |event|
- cal.add_subcomponent(event.to_ri_cal) if event.master?
- end
-end
-%><%= ical.to_s %>
View
21 app/views/events/show.html.haml
@@ -0,0 +1,21 @@
+- content_for :events do
+ = render :partial => 'event', :collection => events
+
+- content_for :calendar do
+ #calendar
+ = render :partial => "events/minicalendar", :locals => {:date => period ? period.start : Date.today}
+
+- content_for :title do
+ = @event.title
+
+- content_for :event do
+ = render :partial => 'event', :object => @event
+
+- content_for :facebook_id do
+ = @event.facebook_id
+
+- content_for :facebook_url do
+ = event.facebook_url
+
+#events
+ = yield :event
View
17 config/locales/en.yml
@@ -26,6 +26,11 @@ en:
calendar_short_month: "%b"
calendar_day_name: "%A"
calendar_day_of_month: "%d"
+ event_calendar_extension:
+ view_on_facebook: "view on facebook"
+ attend_on_facebook: "attend on facebook"
+
+ # all this is going to be moved into the more conventional activerecord and event_calendar_extension namespaces when I get a chance.
refresh_calendar: "refresh calendar"
edit_calendar: "edit calendar"
delete_calendar: "delete calendar"
@@ -102,6 +107,7 @@ en:
no_events: No events to display
show_all: (show all)
events: Events
+ many_times: many times
new:
title: New calendar
header: New Calendar
@@ -118,6 +124,7 @@ en:
start: Start date and time
end: end date and time
event_url: Event url
+ facebook_id: Facebook event id
repeat_note: (this is for separate similar events. For events that span several days you only need to set the start and end.)
calendar_note: This is optional but can be used to file your events or to mix local events into a subscribed calendar.
all_day: All-day event?
@@ -154,13 +161,13 @@ en:
form:
title: Venue or location title
choose: choose an existing place
- choose_note: We remember these details for you, so changes here affect every event occurring in this place
- choose_list: choose it from the list
- choose_before: If you've used this place before, please
- choose_after: so that you can update it globally
+ choose_note: "We remember these details for you, so changes here affect every event occurring in this place"
+ choose_list: "choose it from the list"
+ choose_before: "If you've used this place before, please"
+ choose_after: "so that you can update it globally"
keywords: Keywords
location_tag: Location tag
- location_tag_note: This is used to recognise the venue in a calendar feed. It can be postcode, grid reference or any distinctive string.
+ location_tag_note: "If your address is very specific or difficult to locate, you can enter a postcode, grid reference or lat/long pair here."
address: Address or directions
postcode: Postcode or grid reference
postcode_note: This is only required if your address is unusual or you want these events to show on a map in a particular place.
View
2 config/routes.rb
@@ -6,6 +6,8 @@
cal.resources :event_venues, :member => {:remove => :get}, :has_many => :events
cal.calendars_home '/', :controller => 'events', :action => 'index'
end
+
+ map.calendar "/calendar/events/:id.:format", :controller => 'events', :action => 'show'
map.calendar "/calendar.:format", :controller => 'events', :action => 'index'
map.calendar_year "/calendar/:year", :controller => 'events', :action => 'index'
map.calendar_month "/calendar/:year/:month", :controller => 'events', :action => 'index'
View
9 db/migrate/20110717171550_facebook.rb
@@ -0,0 +1,9 @@
+class Facebook < ActiveRecord::Migration
+ def self.up
+ add_column :events, :facebook_id, :string
+ end
+
+ def self.down
+ remove_column :events, :facebook_id
+ end
+end
View
14 lib/event_calendar_tags.rb
@@ -424,7 +424,7 @@ class TagError < StandardError; end
end
end
- [:id, :title, :description, :short_description, :location, :url].each do |attribute|
+ [:id, :title, :description, :short_description, :location, :url, :facebook_id].each do |attribute|
desc %{
Renders the #{attribute} attribute of the current event.
@@ -455,8 +455,18 @@ class TagError < StandardError; end
tag.expand unless tag.locals.event.send(attribute)
end
end
+
+ desc %{
+ Renders the url of the facebook event corresponding to this event, if there is one.
+
+ Usage:
+ <pre><code><r:facebook_url /></code></pre>
+ }
+ tag "event:facebook_url" do |tag|
+ tag.locals.event.facebook_url
+ end
- #todo: venue:* tags
+ #todo: venues:* tags
desc %{
Renders a sensible location string, based on whatever venue information is available.

0 comments on commit e127b2f

Please sign in to comment.
Something went wrong with that request. Please try again.