<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>app/controllers/event_sweeper.rb</filename>
    </added>
    <added>
      <filename>app/views/events/_subscribe.html.haml</filename>
    </added>
    <added>
      <filename>public/images/icons/ical.gif</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -14,6 +14,7 @@ Requirements:
 	  rake 0.8.3
 	  haml 2.0.5
 	  calendar_date_select
+	  icalendar
 	  aws-s3 (if using s3 for photos)
 
 Getting CommunityEngine Running</diff>
      <filename>README.markdown</filename>
    </modified>
    <modified>
      <diff>@@ -1,8 +1,44 @@
 class EventsController &lt; BaseController
+
+  require 'htmlentities'
+  caches_page :ical
+  cache_sweeper :event_sweeper, :only =&gt; [:create, :update, :destroy]
+ 
+  #These two methods make it easy to use helpers in the controller.
+  #This could be put in application_controller.rb if we want to use
+  #helpers in many controllers
+  def help
+    Helper.instance
+  end
+
+  class Helper
+    include Singleton
+    include ActionView::Helpers::SanitizeHelper
+    extend ActionView::Helpers::SanitizeHelper::ClassMethods
+  end
+
   uses_tiny_mce(:options =&gt; AppConfig.default_mce_options, :only =&gt; [:new, :edit, :create, :update ])
   uses_tiny_mce(:options =&gt; AppConfig.simple_mce_options, :only =&gt; [:show])
 
-  before_filter :admin_required, :except =&gt; [:index, :show]
+  before_filter :admin_required, :except =&gt; [:index, :show, :ical]
+
+  def ical
+    @calendar = Icalendar::Calendar.new
+    @calendar.custom_property('x-wr-caldesc',&quot;#{AppConfig.community_name} #{:events.l}&quot;)
+    Event.find(:all).each do |event|
+      ical_event = Icalendar::Event.new
+      ical_event.start = event.start_time.strftime(&quot;%Y%m%dT%H%M%S&quot;)
+      ical_event.end = event.end_time.strftime(&quot;%Y%m%dT%H%M%S&quot;)
+      ical_event.summary = event.name + (event.metro_area.blank? ? '' : &quot; (#{event.metro_area})&quot;)
+      coder = HTMLEntities.new
+      ical_event.description = (event.description.blank? ? '' : coder.decode(help.strip_tags(event.description).to_s) + &quot;\n\n&quot;) + event_url(event)
+      ical_event.location = event.location unless event.location.blank?
+      @calendar.add ical_event
+   end
+   @calendar.publish
+   headers['Content-Type'] = &quot;text/calendar; charset=UTF-8&quot;
+   render :text =&gt; @calendar.to_ical, :layout =&gt; false
+  end
 
   def show
     @is_admin_user = (current_user &amp;&amp; current_user.admin?)</diff>
      <filename>app/controllers/events_controller.rb</filename>
    </modified>
    <modified>
      <diff>@@ -5,12 +5,10 @@
     -box :class =&gt; &quot;alt first_alt&quot; do 
       = link_to_unless_current :past_events.l, past_events_path
       = link_to_unless_current :upcoming_events.l, events_path
-      
-
   -box do 
     %h3= :events.l
     = :find_out_where_to_be_and_when_to_be_there.l
-
+  =render :partial=&gt;'subscribe'
 #yui-main
   .yui-b
     -box do </diff>
      <filename>app/views/events/index.html.haml</filename>
    </modified>
    <modified>
      <diff>@@ -5,7 +5,7 @@
     - if @is_admin_user
       = link_to :administer_events.l, admin_events_path
     = link_to :see_all_events.l, events_path
-
+  =render :partial=&gt;'subscribe'
 #yui-main
   .yui-b
     -box :class=&gt;'entry-content event-content' do </diff>
      <filename>app/views/events/show.html.haml</filename>
    </modified>
    <modified>
      <diff>@@ -75,6 +75,7 @@ gem 'htmlentities', :lib =&gt; 'htmlentities'
 gem 'haml', :lib =&gt; 'htmlentities'        
 gem &quot;aws-s3&quot;, :lib =&gt; &quot;aws/s3&quot; 
 gem 'calendar_date_select'
+gem 'icalendar'
 rake('gems:install', :sudo =&gt; true)
 
 </diff>
      <filename>community_engine_setup_template.rb</filename>
    </modified>
    <modified>
      <diff>@@ -85,7 +85,7 @@ search_tags '/search/tags', :controller =&gt; 'tags', :action =&gt; 'show'
 
 resources :categories
 resources :skills
-resources :events, :collection =&gt; { :past =&gt; :get } do |event|
+resources :events, :collection =&gt; { :past =&gt; :get, :ical =&gt; :get } do |event|
   event.resources :rsvps, :except =&gt; [:index, :show]
 end
 resources :favorites, :path_prefix =&gt; '/:favoritable_type/:favoritable_id'</diff>
      <filename>config/desert_routes.rb</filename>
    </modified>
    <modified>
      <diff>@@ -568,6 +568,7 @@
 #en: sticky: Sticky
 #en: subject: Subject
 #en: subscribe_to: Subscribe to
+#en: subscribe_events_instructions:  Keep up to date with events using your favorite software (Outlook, Lightning / Thunderbird, Sunbird, iCal, etc.) or online service (Google Calendar, AirSet, iScrybe, etc.).
 #en: tag_does_not_exists: The tag {{tag}} does not exist
 #en: tag_name: Tag name
 #en: tag_yourself: tag yourself</diff>
      <filename>lang/base.yml</filename>
    </modified>
    <modified>
      <diff>@@ -1153,6 +1153,8 @@ en:
   subject: Subject
   #en: subscribe_to: Subscribe to
   subscribe_to: Subscribe to
+  #en: subscribe_events_instructions:  Keep up to date with events using your favorite software (Outlook, Lightning / Thunderbird, Sunbird, iCal, etc.) or online service (Google Calendar, AirSet, iScrybe, etc.).
+  subscribe_events_instructions:  Keep up to date with events using your favorite software (Outlook, Lightning / Thunderbird, Sunbird, iCal, etc.) or online service (Google Calendar, AirSet, iScrybe, etc.).
   #en: tag_does_not_exists: The tag {{tag}} does not exist
   tag_does_not_exists: &quot;The tag {{tag}} does not exist&quot;
   #en: tag_name: Tag name</diff>
      <filename>lang/ui/en-US.yml</filename>
    </modified>
    <modified>
      <diff>@@ -1034,3 +1034,11 @@ table.poll {
 #user-menu:hover {
 	background: url(/plugin_assets/community_engine/images/icons/bullet_arrow_down.png) no-repeat right;	
 }
+
+.icon_row a {
+   margin-right:5px;
+}
+.icon_row a img {
+   border:0;
+   vertical-align:middle;
+}</diff>
      <filename>public/stylesheets/screen.css</filename>
    </modified>
    <modified>
      <diff>@@ -79,4 +79,10 @@ class EventsControllerTest &lt; ActionController::TestCase
     assert_no_tag :tag=&gt;'a', :attributes=&gt;{:href=&gt;'/events/past'}, :content=&gt;:past_events.l
     assert_tag :tag=&gt;'a', :attributes=&gt;{:href=&gt;'/events'}, :content=&gt;:upcoming_events.l
   end
+
+  def test_should_get_ical
+    get :ical, :format =&gt; 'ics'
+    assert_response :success
+    assert assigns(:calendar)
+  end
 end</diff>
      <filename>test/functional/events_controller_test.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>36810b83420ec61198f3c6cbb971f06223cefe7d</id>
    </parent>
    <parent>
      <id>39ebb3463beb586157cee6335c6868c7256831ae</id>
    </parent>
  </parents>
  <author>
    <name>bborn</name>
    <email>bruno.bornsztein@gmail.com</email>
  </author>
  <url>http://github.com/bborn/communityengine/commit/81f62f028c6fb8114016c283639bc838c002c98b</url>
  <id>81f62f028c6fb8114016c283639bc838c002c98b</id>
  <committed-date>2009-09-08T12:16:51-07:00</committed-date>
  <authored-date>2009-09-08T12:16:51-07:00</authored-date>
  <message>Merge branch 'eksatx/TRY-pages/master' into edge</message>
  <tree>12d426b9381b9147d0d8ea9c1ed4e2ca76c39ee5</tree>
  <committer>
    <name>bborn</name>
    <email>bruno.bornsztein@gmail.com</email>
  </committer>
</commit>
