<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/views/admin/calendars/_actions.html.haml</filename>
    </added>
    <added>
      <filename>public/images/admin/edit.png</filename>
    </added>
    <added>
      <filename>public/images/admin/refresh.png</filename>
    </added>
    <added>
      <filename>public/images/admin/remove.png</filename>
    </added>
    <added>
      <filename>public/images/event_calendar/ical16.png</filename>
    </added>
    <added>
      <filename>public/stylesheets/calendar.css</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -2,6 +2,7 @@ require 'rubygems'
 require 'net/http'
 require 'vpim'
 require 'date'
+require 'ftools'
 
 class Ical &lt; ActiveRecord::Base
   belongs_to :calendar
@@ -12,7 +13,9 @@ class Ical &lt; ActiveRecord::Base
   
 	# Download and save the .ics calendar file, parse and save events to database
 	def refresh
-    filename = RAILS_ROOT + &quot;/public/&quot; + @@calendars_path + &quot;/&quot; + self.calendar.slug + &quot;.ics&quot;
+    filepath = File.join RAILS_ROOT, &quot;public&quot;, ics_path
+    filename = File.join filepath, ics_file
+    File.makedirs filepath
 
     # Retrieve calendar specified by URL and Name attributes
     begin
@@ -69,9 +72,9 @@ class Ical &lt; ActiveRecord::Base
   end
   
   def ics_file
-	  &quot;#{self.calendar.name}.ics&quot;
+	  &quot;#{self.calendar.slug}.ics&quot;
   end
-	
+  	
 	def refresh_automatically?
 	  refresh_interval.nil? || refresh_interval.to_i != 0
   end</diff>
      <filename>app/models/ical.rb</filename>
    </modified>
    <modified>
      <diff>@@ -4,6 +4,8 @@
   - main.edit_header do
     %h1 
       Edit Calendar Subscription
+      = render :partial =&gt; 'actions'
+      
 
   - main.edit_form do
     - form_for :calendar, @calendar, :url =&gt; admin_calendar_path(@calendar), :html =&gt; { :method =&gt; &quot;put&quot;, :multipart =&gt; true } do |f|</diff>
      <filename>app/views/admin/calendars/edit.html.haml</filename>
    </modified>
    <modified>
      <diff>@@ -44,11 +44,7 @@
 
           - tbody.action_cell do
             %td
-              = link_to 'Refresh', refresh_admin_ical_url(calendar.ical.id), :method =&gt; :put 
-              | 
-              = link_to 'Edit', edit_admin_calendar_path(calendar) 
-              |
-              = link_to 'Delete', admin_calendar_path(calendar), :confirm =&gt; &quot;Are you sure you want to delete the #{calendar.name} calendar ?&quot;, :method =&gt; :delete
+              = render :partial =&gt; 'actions', :locals =&gt; {:calendar =&gt; calendar}
 
 - render_region :bottom do |bottom|
   - bottom.buttons do</diff>
      <filename>app/views/admin/calendars/index.html.haml</filename>
    </modified>
    <modified>
      <diff>@@ -3,11 +3,7 @@
 %h1
   = @calendar.name
   calendar
-
-%p
-  = link_to 'Edit', edit_admin_calendar_path(@calendar)
-  |
-  = link_to 'Refresh', refresh_admin_ical_url(@calendar.ical.id), :method =&gt; :put 
+  = render :partial =&gt; 'actions'
 
 %div#calendar_help
   %h3</diff>
      <filename>app/views/admin/calendars/show.html.haml</filename>
    </modified>
    <modified>
      <diff>@@ -138,13 +138,14 @@ module EventCalendarTags
 
   desc %{
     Renders a sensible description of the currently displayed calendars, with links to each separate calendar.
+    Pass with_subscription=&quot;true&quot; to append a little ical subscription icon to each link.
     
     *Usage:* 
     &lt;pre&gt;&lt;code&gt;&lt;r:calendars:summary /&gt;&lt;/code&gt;&lt;/pre&gt;
   }
   tag 'calendars:summary' do |tag|
     result = &quot;Showing events from the &quot;
-    result &lt;&lt; tag.render('calendars:list')
+    result &lt;&lt; tag.render('calendars:list', tag.attr.dup)
     result &lt;&lt; ' '
     result &lt;&lt; pluralize(tag.locals.calendars.length, 'calendar')
     result &lt;&lt; %{ &lt;a href=&quot;#{tag.render('url')}&quot; class=&quot;note&quot;&gt;(show all)&lt;/a&gt;} if calendar_category
@@ -154,15 +155,19 @@ module EventCalendarTags
 
   desc %{
     Renders a plain list (in sentence form) of the currently displayed calendars, with links to each separate calendar.
+    Pass with_subscription=&quot;true&quot; to append a little ical subscription icon to each link.
     
     *Usage:* 
     &lt;pre&gt;&lt;code&gt;&lt;r:calendars:list /&gt;&lt;/code&gt;&lt;/pre&gt;
   }
   tag 'calendars:list' do |tag|
     links = []
+    with_subscription = (tag.attr['with_subscription'] == 'true')
     tag.locals.calendars.each do |calendar|
       tag.locals.calendar = calendar
-      links &lt;&lt; tag.render(&quot;calendar:link&quot;)
+      link = tag.render(&quot;calendar:link&quot;)
+      link &lt;&lt; tag.render(&quot;calendar:ical_icon&quot;) if with_subscription
+      links &lt;&lt; link
     end
     links.to_sentence
   end
@@ -286,6 +291,42 @@ module EventCalendarTags
     %{&lt;a href=&quot;#{tag.render('calendar:url')}#{anchor}&quot;#{attributes}&gt;#{text}&lt;/a&gt;}
   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:
+    &lt;pre&gt;&lt;code&gt;&lt;r:calendar:ical_url /&gt;&lt;/code&gt;&lt;/pre&gt; 
+  }
+  tag &quot;calendar:ical_url&quot; 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:
+    &lt;pre&gt;&lt;code&gt;&lt;r:calendar:ical_link /&gt;&lt;/code&gt;&lt;/pre&gt; 
+  }
+  tag &quot;calendar:ical_link&quot; do |tag|
+    options = tag.attr.dup
+    anchor = options['anchor'] ? &quot;##{options.delete('anchor')}&quot; : ''
+    attributes = options.inject('') { |s, (k, v)| s &lt;&lt; %{#{k.downcase}=&quot;#{v}&quot; } }.strip
+    attributes = &quot; #{attributes}&quot; unless attributes.empty?
+    text = tag.double? ? tag.expand : tag.render('calendar:name')
+    %{&lt;a href=&quot;#{tag.render('calendar:ical_url')}#{anchor}&quot;#{attributes}&gt;#{text}&lt;/a&gt;}
+  end
+
+  desc %{
+    Renders a small graphical link to the local .ics file for this calendar.
+    
+    Usage:
+    &lt;pre&gt;&lt;code&gt;&lt;r:calendar:ical_icon /&gt;&lt;/code&gt;&lt;/pre&gt; 
+  }
+  tag &quot;calendar:ical_icon&quot; do |tag|
+    %{&lt;a href=&quot;#{tag.render('calendar:ical_url')}&quot; class=&quot;ical&quot;&gt;&lt;img src=&quot;/images/event_calendar/ical16.png&quot; alt=&quot;subscribe to #{tag.render('calendar:name')}&quot; width=&quot;16&quot; height=&quot;16&quot; /&gt;&lt;/a&gt;}
+  end
+
   # Event:* tags
   # display attributes of a single event 
 </diff>
      <filename>lib/event_calendar_tags.rb</filename>
    </modified>
    <modified>
      <diff>@@ -26,6 +26,14 @@ table.index td.subscription-title {
   font-weight: bold;
 }
 
+span.calendar_actions img {
+  opacity: 0.5;
+}
+
+span.calendar_actions a img {
+  opacity: 1;
+}
+
 /**** calendar/show ****/
 
 table.calendar {
@@ -63,6 +71,15 @@ table.calendar td div {
   overflow: hidden;
 }
 
+table.calendar td.other_month {
+  color: #ccc;
+  background-color: white;
+}
+
+table.calendar td.weekend_day {
+  background-color: #eee;
+}
+
 table.calendar td.eventful {
 	background-color: #fee;
 }
@@ -71,21 +88,12 @@ table.calendar td.eventful_weekend {
 	background-color: #edd;
 }
 
-table.calendar td.other_month {
-  color: #ccc;
-  background-color: white;
-}
-
 table.calendar td.today {
 	background-color: #eef;
   font-weight: bold;
 	color: #00c;
 }
 
-table.calendar td.weekend_day {
-  background-color: #eee;
-}
-
 table.calendar td.weekend_today {
 	background-color: #dde;
 }
@@ -118,3 +126,53 @@ table.calendar td ul {
   padding: 0 0 0 12px;
   list-style: square;
 }
+
+/**** calendar/new ****/
+
+#content .form-area p, #content .form-area p.title {
+  margin-bottom: 10px;
+}
+
+#content .form-area p label {
+  display: block;
+}
+
+#content .form-area p.thirdwidth {
+  float: left;
+  width: 31%;
+  margin-right: 2%;
+}
+
+#content .form-area p.halfwidth {
+  float: left;
+  width: 48%;
+  margin-right: 2%;
+}
+
+#content .form-area p.fullwidth {
+  clear: both;
+  width: 100%;
+  margin-right: 2%;
+}
+
+#content .form-area p input.textbox {
+  width: 100%;
+  border:1px solid #CDC295;
+  font-family:Monaco,&quot;Courier New&quot;,Courier,monospace;
+  font-size:95%;
+  padding: 4px;
+}
+
+#content .form-area p textarea {
+  width: 100%;
+  height: 60px;
+  border:1px solid #CDC295;
+  font-family:Monaco,&quot;Courier New&quot;,Courier,monospace;
+  font-size:95%;
+  padding: 4px;
+}
+
+#content .form-area span.info {
+  font-size: 80%;
+  color: #7D796C;
+}</diff>
      <filename>public/stylesheets/admin/calendar.css</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>11290f24d958305eb53b4bea64db6aaf86711caa</id>
    </parent>
  </parents>
  <author>
    <name>will</name>
    <email>will@spanner.org</email>
  </author>
  <url>http://github.com/radiant/radiant-event-calendar-extension/commit/2becadee1ae3eef8df792fbd9be25f3b14613c18</url>
  <id>2becadee1ae3eef8df792fbd9be25f3b14613c18</id>
  <committed-date>2009-08-20T03:38:43-07:00</committed-date>
  <authored-date>2009-08-20T03:38:43-07:00</authored-date>
  <message>ical subscription links and general tidying up</message>
  <tree>feabfb6ab7cefe87364204cebf553a8b15bb802f</tree>
  <committer>
    <name>will</name>
    <email>will@spanner.org</email>
  </committer>
</commit>
