Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

radius tags updated, made consistent with (now deprecated) event views

  • Loading branch information...
commit 5763eea40d7a4224d35c457c210100271c002cb4 1 parent bdc63a8
@will-r will-r authored
View
74 README.md
@@ -65,44 +65,9 @@ Should be obvious. There are a few points to remember:
* Recurrence is for the repetition of identical separate events. A single event that spans several days only needs to have the right start and end times.
* End times are optional: an event with just a start time is just listed where it begins.
-### Displaying events with the EventsController
-
-The events controller uses `share_layouts` to define various page parts that your layout can bring in. To use it, create a layout with any or all of these parts:
-
-* `title` is the page title and can also be shown with `r:title`
-* `events` is a formatted list of events with date stamps and descriptions
-* `continuing_events` is a compact list of events that have already begun but which continue into the period being shown
-* `calendar` is a usual calendar block with links to months and days. Days without events are not linked.
-* `pagination` is the usual will_paginate block.
-* `faceting` here only gives the option to remove any date filters that have been applied. If you add the `taggable_events` extension it gets more useful.
-
-Set the config entry `event_calendar.layout` to the name of your layout and point a browser at /calendar to see what you've got.
-
-Here's a basic sample layout that should just work:
-
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-
- <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
- <head>
- <title><r:title /></title>
- <link rel="stylesheet" href="/stylesheets/event_calendar.css" />
- </head>
- <body>
- <h1 id="pagetitle"><r:title /></h1>
- <r:content part="faceting" />
- <r:content part="calendar" />
- <r:content part="events" />
- <r:content part="continuing_events" />
- <r:content part="pagination" />
- </body>
- </html>
-
-One quirk that might go away: at the moment if there are few new events then the continuing events are moved into the events page part. Most layouts work better that way.
-
### Displaying events with an EventCalendar page
-Set up a new page at /events/ with the type 'EventCalendar'. To show a pageable calendar view of the current month, all you need is this:
+This is the preferred method. Set up a new page at /events/ with the type 'EventCalendar'. To show a pageable calendar view of the current month, all you need is this:
<r:events:as_calendar month="now" month_links="true" />
@@ -139,6 +104,43 @@ If you have another column in your layout, try adding this:
For clickable thumbnails of coming months.
+### Displaying events with the EventsController
+
+I think I'm going to deprecate this use some time soon: it's too hard to adapt to local circumstances. For now it still works:
+
+The events controller uses `share_layouts` to define various page parts that your layout can bring in. To use it, create a layout with any or all of these parts.
+
+* `title` is the page title and can also be shown with `r:title`
+* `events` is a formatted list of events with date stamps and descriptions
+* `continuing_events` is a compact list of events that have already begun but which continue into the period being shown
+* `calendar` is a usual calendar block with links to months and days. Days without events are not linked.
+* `pagination` is the usual will_paginate block.
+* `faceting` here only gives the option to remove any date filters that have been applied. If you add the `taggable_events` extension it gets more useful.
+
+Set the config entry `event_calendar.layout` to the name of your layout and point a browser at /calendar to see what you've got.
+
+Here's a basic sample layout that should just work:
+
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+ <html xmlns="http://www.w3.org/1999/xhtml" lang="en">
+ <head>
+ <title><r:title /></title>
+ <link rel="stylesheet" href="/stylesheets/event_calendar.css" />
+ </head>
+ <body>
+ <h1 id="pagetitle"><r:title /></h1>
+ <r:content part="faceting" />
+ <r:content part="calendar" />
+ <r:content part="events" />
+ <r:content part="continuing_events" />
+ <r:content part="pagination" />
+ </body>
+ </html>
+
+One quirk that might go away: at the moment if there are few new events then the continuing events are moved into the events page part. Most layouts work better that way.
+
### 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.
View
1  app/controllers/events_controller.rb
@@ -1,5 +1,6 @@
class EventsController < SiteController
require "uri"
+ require "ri_cal"
include Radiant::Pagination::Controller
helper_method :events, :all_events, :continuing_events, :period, :calendars, :list_description
View
4 app/models/event.rb
@@ -191,6 +191,10 @@ def day
I18n.l start_date, :format => :calendar_day_name
end
+ def short_day
+ I18n.l start_date, :format => :calendar_short_day
+ end
+
def mday
I18n.l start_date, :format => :calendar_day_of_month
end
View
7 app/views/events/_event.html.haml
@@ -5,9 +5,12 @@
- event_master_id = event.master_id || event.id
- repeating = true if @seen_events[event_master_id]
- @seen_events[event_master_id] = true;
- - cssclass = event.calendar ? "event #{event.calendar.slug}" : "event"
+ - cssclasses = ['event']
+ - cssclasses << 'repeat' if repeating
+ - cssclasses << event.calendar.slug if event.calendar
- %div{:class => cssclass}
+
+ %div{:class => cssclasses.join(' ')}
- unless no_date
.datemark
.mon= event.short_month
View
2  config/initializers/radiant_config.rb
@@ -1,6 +1,6 @@
Radiant.config do |config|
config.namespace('event_calendar') do |calendar|
- calendar.define 'path', :default => "/calendar", :allow_blank => false
+ calendar.define 'path', :default => "cal", :allow_blank => false
calendar.define 'icals_path', :default => "/icals", :allow_blank => false
calendar.define 'cache_duration', :type => :integer, :default => 3600, :units => 'seconds'
calendar.define 'refresh_interval', :type => :integer, :default => 3600, :units => 'seconds'
View
1  config/locales/en.yml
@@ -17,6 +17,7 @@ en:
calendar_period_minicalendar_title: "%B %Y"
calendar_period_minicalendar_month: "%B"
calendar_month: "%B"
+ calendar_short_day: "%a"
calendar_short_month: "%b"
calendar_day_name: "%A"
calendar_day_of_month: "%d"
View
3  config/routes.rb
@@ -7,7 +7,8 @@
cal.calendars_home '/', :controller => 'events', :action => 'index'
end
- calendar_prefix = Radiant.config['event_calendar.path'] || "/calendar"
+ calendar_prefix = Radiant.config['event_calendar.path'] || "cal"
+ calendar_prefix = nil if calendar_prefix.blank?
map.resources :events, :path_prefix => calendar_prefix, :only => [:index, :show]
map.calendar "#{calendar_prefix}.:format", :controller => 'events', :action => 'index'
map.calendar_year "#{calendar_prefix}/:year", :controller => 'events', :action => 'index'
View
97 lib/event_calendar_tags.rb
@@ -359,43 +359,6 @@ class TagError < StandardError; end
%{<a href="#{tag.render('calendar:url')}#{anchor}"#{attributes}>#{text}</a>}
end
- desc %{
- Renders the path to the local .ics file for this calendar, suitable for read-only subscription in iCal or other calendar programs.
-
- Usage:
- <pre><code><r:calendar:ical_url /></code></pre>
- }
- tag "calendar:ical_url" do |tag|
- tag.locals.calendar.to_ics
- end
-
- desc %{
- Renders a link to the local .ics file for this calendar, suitable for read-only subscription in iCal or other calendar programs.
- Link attributes are passed through as usual.
-
- Usage:
- <pre><code><r:calendar:ical_link /></code></pre>
- }
- tag "calendar:ical_link" do |tag|
- options = tag.attr.dup
- anchor = options['anchor'] ? "##{options.delete('anchor')}" : ''
- attributes = options.inject('') { |s, (k, v)| s << %{#{k.downcase}="#{v}" } }.strip
- attributes = " #{attributes}" unless attributes.empty?
- text = tag.double? ? tag.expand : tag.render('calendar:name')
- %{<a href="#{tag.render('calendar:ical_url')}#{anchor}"#{attributes}>#{text}</a>}
- end
-
- desc %{
- Renders a small graphical link to the local .ics file for this calendar.
-
- Usage:
- <pre><code><r:calendar:ical_icon /></code></pre>
- }
- tag "calendar:ical_icon" do |tag|
- text = tag.attr['text'] || ''
- %{<a href="#{tag.render('calendar:ical_url')}" class="ical"><img src="/images/event_calendar/ical16.png" alt="subscribe to #{tag.render('calendar:name')}" width="16" height="16" /> #{text}</a>}
- end
-
#### Event:* tags
#### display attributes of a single event
@@ -426,7 +389,7 @@ class TagError < StandardError; end
end
end
- [:id, :title, :description, :short_description, :location, :url, :facebook_id].each do |attribute|
+ [:id, :title, :description, :short_description, :location, :url, :facebook_id, :facebook_url].each do |attribute|
desc %{
Renders the #{attribute} attribute of the current event.
@@ -459,13 +422,16 @@ class TagError < StandardError; 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>
+ Sets the active calendar to that of the present event, if any.
}
- tag "event:facebook_url" do |tag|
- tag.locals.event.facebook_url
+ tag "event:calendar" do |tag|
+ if tag.locals.calendar = tag.locals.event.calendar
+ if tag.double?
+ tag.expand
+ else
+ tag.locals.calendar.name
+ end
+ end
end
desc %{
@@ -497,6 +463,7 @@ class TagError < StandardError; end
tag "event:facebook_link" do |tag|
if tag.locals.event.facebook_id
options = tag.attr.dup
+ options['class'] ||= 'facebook event'
options['title'] ||= I18n.t('event_calendar_extension.view_on_facebook')
attributes = options.inject('') { |s, (k, v)| s << %{#{k.downcase}="#{v}" } }.strip
attributes = " #{attributes}" unless attributes.empty?
@@ -546,8 +513,34 @@ class TagError < StandardError; end
text = tag.double? ? tag.expand : I18n.t('event_calendar_extension.tweet_this')
%{<a href="#{twitter_url}"#{attributes}>#{text}</a>}
end
+
+ desc %{
+ Renders the path to the local .ics file for this calendar, suitable for read-only subscription in iCal or other calendar programs.
+
+ Usage:
+ <pre><code><r:calendar:ical_url /></code></pre>
+ }
+ tag "calendar:ical_url" do |tag|
+ tag.locals.calendar.to_ics
+ end
+
+ desc %{
+ Renders a link to the ical representation of this event, which should drop the event into
+ a user's desktop calendar. Link attributes are passed through as usual.
- #todo: venues:* tags
+ Usage:
+ <pre><code><r:event:ical_link class="ical event" /></code></pre>
+ }
+ tag "event:ical_link" do |tag|
+ options = tag.attr.dup
+ options['title'] ||= I18n.t('event_calendar_extension.download_event')
+ options['class'] ||= 'ical download'
+ attributes = options.inject('') { |s, (k, v)| s << %{#{k.downcase}="#{v}" } }.strip
+ text = tag.double? ? tag.expand : I18n.t('event_calendar_extension.tweet_this')
+ %{<a href="#{event_path(tag.locals.event, :format => 'ics')}" #{attributes}>#{text}</a>}
+ end
+
+ #TODO: venues:* tags
desc %{
Renders a sensible location string, based on whatever venue information is available.
@@ -800,15 +793,12 @@ class TagError < StandardError; end
<pre><code><r:event:datemark /></code></pre>
}
tag "event:datemark" do |tag|
- html = ""
- html << _datemark(tag.locals.event.start_date)
- html
- end
-
- def _datemark(date=Time.now)
%{
- <div class="datemark"><span class="mon">#{Date::ABBR_MONTHNAMES[date.month]}</span><span class="dom">#{"%02d" % date.mday}</span></div>
- }
+<div class="datemark">
+ <span class="dow">#{tag.locals.event.short_day}</span>
+ <span class="dom">#{tag.locals.event.mday}</span>
+</div>
+}
end
desc %{
@@ -818,7 +808,6 @@ def _datemark(date=Time.now)
Usage:
<pre><code><r:events:minimonth [year=""] [month=""] /></code></pre>
-
}
tag "events:minimonth" do |tag|
attr = parse_boolean_attributes(tag)
View
2  lib/radiant-event_calendar-extension.rb
@@ -1,5 +1,5 @@
module RadiantEventCalendarExtension
- VERSION = '1.5.1'
+ VERSION = '1.5.2'
SUMMARY = %Q{Event Calendar Extension for Radiant CMS}
DESCRIPTION = "An event calendar extension that administers events locally or draws them from any ical or CalDAV publishers (Google Calendar, .Mac, Darwin Calendar Server, etc.)"
URL = "http://github.com/radiant/radiant-event_calendar-extension"
View
8 spec/lib/event_calendar_page_spec.rb
@@ -12,12 +12,12 @@
end
describe ".find_by_url" do
- it "should return self to our own url" do
- pages(:calendar).find_by_url("/#{pages(:calendar).slug}/").should == pages(:calendar)
+ it "should return self to our own path" do
+ pages(:calendar).find_by_path("/#{pages(:calendar).slug}/").should == pages(:calendar)
end
- it "should return self to any child url" do
- pages(:calendar).find_by_url("/#{pages(:calendar).slug}/something").should == pages(:calendar)
+ it "should return self to any child path" do
+ pages(:calendar).find_by_path("/#{pages(:calendar).slug}/something").should == pages(:calendar)
end
end
View
5 spec/lib/event_calendar_tags_spec.rb
@@ -9,10 +9,9 @@
context "rendering event: tags" do
before do
Radiant.config['site.host'] = "test.host"
- Radiant.config['event_calendar.path'] = "/test_calendar"
end
- [:id, :title, :description, :short_description, :location, :url, :facebook_id].each do |tag|
+ [:id, :title, :description, :short_description, :location, :url, :facebook_id, :facebook_url].each do |tag|
it "event:#{tag}" do
page.should render(%{<r:event id="#{event.id}"><r:event:#{tag} /></r:event>}).as( event.send(tag.to_sym).to_s )
end
@@ -20,7 +19,7 @@
it "event:ical_link" do
page.should render(%{<r:event id="#{event.id}"><r:event:ical_link class="ical">I</r:event:ical_link></r:event>}).as(
- %{<a href="/test_calendar/events/#{event.id}.ics" title="Download event" class="ical">I</a>}
+ %{<a href="/cal/events/#{event.id}.ics" title="Download event" class="ical">I</a>}
)
end
Please sign in to comment.
Something went wrong with that request. Please try again.