Author: tekgrrl
Date: Thu Jun 4 19:03:57 2009
New Revision: 781829
URL: http://svn.apache.org/viewvc?rev=781829&view=rev
Log:
OLIO-59 and OLIO-99 resolved. Merged caching branch and updated to Rails 2.3.2
Added:
incubator/olio/webapp/rails/trunk/app/controllers/application_controller.rb
incubator/olio/webapp/rails/trunk/app/sweepers/
incubator/olio/webapp/rails/trunk/app/sweepers/event_sweeper.rb
incubator/olio/webapp/rails/trunk/config/environments/development_file_cached.rb
incubator/olio/webapp/rails/trunk/config/environments/development_mem_cached.rb
incubator/olio/webapp/rails/trunk/config/environments/development_nocache.rb
incubator/olio/webapp/rails/trunk/lib/lazy.rb
incubator/olio/webapp/rails/trunk/script/dbconsole (with props)
Modified:
incubator/olio/webapp/rails/trunk/app/controllers/application.rb
incubator/olio/webapp/rails/trunk/app/controllers/comments_controller.rb
incubator/olio/webapp/rails/trunk/app/controllers/events_controller.rb
incubator/olio/webapp/rails/trunk/app/controllers/friends_controller.rb
incubator/olio/webapp/rails/trunk/app/controllers/users_controller.rb
incubator/olio/webapp/rails/trunk/app/helpers/application_helper.rb
incubator/olio/webapp/rails/trunk/app/helpers/events_helper.rb
incubator/olio/webapp/rails/trunk/app/views/comments/_list.html.erb
incubator/olio/webapp/rails/trunk/app/views/events/_calendar.html.erb
incubator/olio/webapp/rails/trunk/app/views/events/_event_list.html.erb
incubator/olio/webapp/rails/trunk/app/views/events/_filtered_events.html.erb
incubator/olio/webapp/rails/trunk/app/views/events/_map.html.erb
incubator/olio/webapp/rails/trunk/app/views/events/show.html.erb
incubator/olio/webapp/rails/trunk/app/views/layouts/site.rhtml
incubator/olio/webapp/rails/trunk/config/boot.rb
incubator/olio/webapp/rails/trunk/config/environment.rb
incubator/olio/webapp/rails/trunk/config/environments/development.rb
incubator/olio/webapp/rails/trunk/config/environments/production.rb
incubator/olio/webapp/rails/trunk/config/routes.rb
incubator/olio/webapp/rails/trunk/public/dispatch.fcgi
incubator/olio/webapp/rails/trunk/public/javascripts/controls.js
incubator/olio/webapp/rails/trunk/public/javascripts/dragdrop.js
incubator/olio/webapp/rails/trunk/public/javascripts/effects.js
incubator/olio/webapp/rails/trunk/public/javascripts/prototype.js
Modified: incubator/olio/webapp/rails/trunk/app/controllers/application.rb
URL:
http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/app/controllers/application.rb?rev=781829&r1=781828&r2=781829&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/app/controllers/application.rb (original)
+++ incubator/olio/webapp/rails/trunk/app/controllers/application.rb Thu Jun 4
19:03:57 2009
@@ -19,8 +19,6 @@
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
- # Pick a unique cookie name to distinguish our session data from others'
- session :session_key => '_perf_session_id'
def authorize
begin
Added:
incubator/olio/webapp/rails/trunk/app/controllers/application_controller.rb
URL:
http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/app/controllers/application_controller.rb?rev=781829&view=auto
==============================================================================
--- incubator/olio/webapp/rails/trunk/app/controllers/application_controller.rb
(added)
+++ incubator/olio/webapp/rails/trunk/app/controllers/application_controller.rb
Thu Jun 4 19:03:57 2009
@@ -0,0 +1,69 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Filters added to this controller apply to all controllers in the application.
+# Likewise, all the methods added will be available for all controllers.
+
+class ApplicationController < ActionController::Base
+
+ def authorize
+ begin
+ @user = User.find(session[:user_id])
+ rescue
+ @user = nil
+ end
+
+ unless @user
+ session[:original_uri] = request.request_uri
+ flash[:error] = "You must log in before accessing that page."
+ redirect_to(root_path)
+ end
+ end
+
+ def logged_in_as(user = nil)
+ logged_in_as_user_id = false
+ if !user.nil?
+ if user.id == session[:user_id]
+ logged_in_as_user_id = true
+ end
+ end
+ user = nil
+ logged_in_as_user_id
+ end
+
+ def generate_friend_cloud(all_friends)
+ friends = all_friends.clone
+ @friendcloud = []
+ 6.times do
+ random_friend = rand(friends.size)
+ @friendcloud << friends[random_friend] unless friends.empty?
+ friends.delete_at(random_friend)
+ end
+ end
+
+ def validate_event
+ begin
+ @event = Event.find(params[:event_id])
+ rescue ActiveRecord::RecordNotFound
+ respond_to do |format|
+ flash[:error] = "Event does not exist."
+ format.html { redirect_to root_path }
+ end
+ end
+ end
+
+end
Modified:
incubator/olio/webapp/rails/trunk/app/controllers/comments_controller.rb
URL:
http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/app/controllers/comments_controller.rb?rev=781829&r1=781828&r2=781829&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/app/controllers/comments_controller.rb
(original)
+++ incubator/olio/webapp/rails/trunk/app/controllers/comments_controller.rb
Thu Jun 4 19:03:57 2009
@@ -21,6 +21,8 @@
before_filter :validate_event
layout "site"
+ after_filter :expire_comment, :only => [:create, :destroy, :update]
+
# GET /events/1/comments
def index
@comments = Comment.find_all_by_event_id(params[:event_id])
@@ -168,4 +170,8 @@
end
end
+ def expire_comment
+ expire_fragment(:controller => "events", :action => "show", :id => @comment.event_id,
:part => "event_comments")
+ end
+
end
Modified: incubator/olio/webapp/rails/trunk/app/controllers/events_controller.rb
URL:
http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/app/controllers/events_controller.rb?rev=781829&r1=781828&r2=781829&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/app/controllers/events_controller.rb
(original)
+++ incubator/olio/webapp/rails/trunk/app/controllers/events_controller.rb Thu
Jun 4 19:03:57 2009
@@ -26,49 +26,51 @@
MAX_ATTENDEES = 20
- # caches_page :index
+ if CACHED
+ after_filter :expire_home, :only => :index
+ after_filter :expire_calendar, :only => :update_calendar
+ after_filter :expire_tag, :only => :tag
+
+ # caches_page :index, {:expire => 2.minutes.to_i}
+ cache_sweeper :event_sweeper, :only => [:create, :destroy, :update]
+ end
### CRUD Actions ########################################################
# GET /events
# GET /events.xml
- def index
- unless params[:month].nil? and params[:day].nil? and params[:year].nil?
- date = Date.parse("#{params[:month]}/#{params[:day]}/#{params[:year]}")
- end
- @zipcode = params[:zipcode] ? params[:zipcode] : session[:zipcode] #
Update zipcode filter if changed by the user
- session[:zipcode] = @zipcode # Store the new zipcode filter in the user's
session
-
- @date = Date.parse(date.to_s) unless date.nil?
- session[:date] = @date
-
- conditions = @date ? "event_date = '#...@date}'" : "event_date >= '#{Date.today}'"
-
- session[:order] = params[:order] || session[:order] || 'event_date'
-
- @events = Event.paginate :page => params[:page], :conditions => conditions, :order => session[:order], :per_page => 10
- if @zipcode and [email protected]?
- @events.delete_if { |e| e.address.zip != @zipcode }
- end
-
- @tags = Event.top_n_tags(50)
-
- respond_to do |format|
- format.html # index.html.erb
- format.js # index.js.rjs
- format.xml { render :xml => @events }
+ def home
+ if CACHED and !session[:user_id].nil?
+ do_index_page
+ respond_to do |format|
+ format.html { render :template => "events/index.html.erb" } #
index.html.erb
+ format.js { render :template => "events/index.js.rjs", :layout =>
false } # index.js.rjs
+ format.xml { render :xml => @events }
+ end
+ else
+ redirect_to(root_path)
end
end
+ # "home" = root page for those not logged in
+ def index
+ if !CACHED or session[:user_id].nil?
+ do_index_page
+ respond_to do |format|
+ format.html # index.html.erb
+ format.js # index.js.rjs
+ format.xml { render :xml => @events }
+ end
+ else
+ redirect_to(home_path)
+ end
+ end
+
# GET /events/1
# GET /events/1.xml
def show
- @event = Event.find(params[:id], :include => [:image, :document, {:comments
=> :user }, :address])
- @address = @event.address
- @attendees = attendee_list(@event, MAX_ATTENDEES)
- @image = @event.image
- @document = @event.document
- @comments = @event.comments
+ @event = lazy { Event.find(params[:id], :include => [:image, :document,
{:comments => :user }, :address]) }
+ @attendees = lazy { attendee_list(@event, MAX_ATTENDEES) }
@comment = Comment.new
@comment.rating = 0
respond_to do |format|
@@ -154,14 +156,13 @@
@event.attributes = params[:event]
@event.set_date
@address.attributes = params[:address]
- @geolocation = Geolocation.new(@address.street1, @address.city,
@address.state, @address.zip)
- @address.longitude = @geolocation.longitude
- @address.latitude = @geolocation.latitude
@address.save!
@event.image = Image.make_from_upload(params[:event_image], @event.id) if new_image?
@event.document = Document.make_from_upload(params[:event_document],
@event.id) if new_document?
-
+ @geolocation = Geolocation.new(@address.street1, @address.city, @address.state, @address.zip)
+ @address.longitude = @geolocation.longitude
+ @address.latitude = @geolocation.latitude
@event.save! # must come after all other updates
set_tags(@event)
@@ -178,7 +179,6 @@
format.xml { render :xml => @event.errors, :status =>
:unprocessable_entity }
end
end
-
end
# DELETE /events/1
@@ -250,6 +250,7 @@
flash[:error] = "You are already attending #[email protected]}"
else
@event.new_attendee(user)
+ expire_attendees
flash[:notice] = "You are attending #[email protected]}"
end
session[:upcoming] = user.upcoming_events.map { |e| e.id }
@@ -272,6 +273,7 @@
flash[:error] = "You are not attending #[email protected]}"
else
@event.remove_attendee(user)
+ expire_attendees
flash[:notice] = "You are no longer attending #[email protected]}"
end
session[:upcoming] = user.upcoming_events.map { |e| e.id }
@@ -304,6 +306,7 @@
# GET /events/update_calendar (AJAX)
def update_calendar
+ expire_fragment(:controller => "events", :part => "default_calendar")
respond_to do |format|
format.html { redirect_to(root_path) }
format.js
@@ -313,6 +316,29 @@
private ####################################################################################
+ def do_index_page
+ unless params[:month].nil? and params[:day].nil? and params[:year].nil?
+ date = Date.parse("#{params[:month]}/#{params[:day]}/#{params[:year]}")
+ end
+
+ @zipcode = params[:zipcode] ? params[:zipcode] : session[:zipcode] #
Update zipcode filter if changed by the user
+ session[:zipcode] = @zipcode # Store the new zipcode filter in the user's
session
+
+ @date = Date.parse(date.to_s) unless date.nil?
+ session[:date] = @date
+
+ conditions = @date ? "event_date = '#...@date}'" : "event_date >= '#{Date.today}'"
+
+ session[:order] = params[:order] || session[:order] || 'event_date'
+
+ @events = lazy { Event.paginate :page => params[:page], :conditions => conditions,
:order => session[:order], :per_page => 10, :include => [:address, :image] }
+ if @zipcode and [email protected]?
+ @events.delete_if { |e| e.address.zip != @zipcode }
+ end
+
+ @tags = lazy { Event.top_n_tags(50) }
+ end
+
def check_creator(event_user_id, action)
if event_user_id != session[:user_id]
flash[:error] = "You can only #{action} events you created"
@@ -345,4 +371,26 @@
users
end
+ # CACHING - methods to expire fragments
+
+ def expire_home
+ expire_page(root_path)
+ end
+
+ def expire_calendar
+ expire_fragment(:controller => "events", :part => "default_calendar")
+ end
+
+ def expire_tag
+ unless session.nil?
+ expire_fragment(:controller => 'events', :action => 'index', :part =>
'tag_cloud')
+ end
+ expire_page(root_path)
+ end
+
+ def expire_attendees
+ expire_fragment(:controller => "events", :action => "show", :id => @event.id, :part
=> "event_attendees")
+ expire_fragment(:controller => "events", :action => "show", :id => @event.id, :part =>
"event_attendees", :login => true)
+ end
+
end
Modified:
incubator/olio/webapp/rails/trunk/app/controllers/friends_controller.rb
URL:
http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/app/controllers/friends_controller.rb?rev=781829&r1=781828&r2=781829&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/app/controllers/friends_controller.rb
(original)
+++ incubator/olio/webapp/rails/trunk/app/controllers/friends_controller.rb Thu
Jun 4 19:03:57 2009
@@ -49,6 +49,7 @@
respond_to do |format|
if flash[:error].blank?
flash[:notice] = "Friendship requested"
+ expire_fragment ("events/friend_requests/#[email protected]}")
format.html { redirect_to(search_users_path) }
format.js { render :layout => false }
else
@@ -72,6 +73,7 @@
decrement_friendship_requests
generate_friend_cloud @user.friends
flash[:notice] = 'Friendship approved.'
+ expire_fragment ("events/friend_requests/#[email protected]}")
else
flash[:error] = 'Friendship could not be approved.'
end
@@ -118,6 +120,7 @@
if @user.unfriend(@target)
flash[:notice] = confirmation_msg
+ expire_fragment ("events/friend_requests/#[email protected]}")
decrement_friendship_requests if @friend_action =~ /^reject/i
generate_friend_cloud @user.friends if @friend_action =~ /^remove/i
else
Modified: incubator/olio/webapp/rails/trunk/app/controllers/users_controller.rb
URL:
http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/app/controllers/users_controller.rb?rev=781829&r1=781828&r2=781829&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/app/controllers/users_controller.rb
(original)
+++ incubator/olio/webapp/rails/trunk/app/controllers/users_controller.rb Thu
Jun 4 19:03:57 2009
@@ -19,7 +19,7 @@
before_filter :authorize, :except => [ :new, :create, :login, :check_name, :show ]
layout "site"
-
+
# GET /users
# GET /users.xml
def index
@@ -176,7 +176,11 @@
session[:original_uri] = nil
flash[:notice] = "Successfully logged in!"
- redirect_to(uri || events_path)
+ if CACHED
+ redirect_to(uri || home_path)
+ else
+ redirect_to(uri || events_path)
+ end
else
user = nil
params[:email] = nil
Modified: incubator/olio/webapp/rails/trunk/app/helpers/application_helper.rb
URL:
http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/app/helpers/application_helper.rb?rev=781829&r1=781828&r2=781829&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/app/helpers/application_helper.rb
(original)
+++ incubator/olio/webapp/rails/trunk/app/helpers/application_helper.rb Thu Jun
4 19:03:57 2009
@@ -82,7 +82,7 @@
#depends on calling controller having a tagged action, defaults to
events_controller
def tag_cloud_items(tags, target_controller = 'events')
links = []
- tag_cloud_font_sizes tags do |name, font_size|
+ tag_cloud_font_sizes(tags) do |name, font_size|
link = link_to name, {:controller => target_controller, :action => 'tagged',
:tag => name}, {:style => font_size}
links << link
end
Modified: incubator/olio/webapp/rails/trunk/app/helpers/events_helper.rb
URL:
http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/app/helpers/events_helper.rb?rev=781829&r1=781828&r2=781829&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/app/helpers/events_helper.rb (original)
+++ incubator/olio/webapp/rails/trunk/app/helpers/events_helper.rb Thu Jun 4
19:03:57 2009
@@ -22,11 +22,11 @@
if logged_in?
attending = @attendees.find { |u| u.id == session[:user_id] }
if attending
- links += form_remote_tag :url => unattend_event_path(event), :method =>
:post, :html => {:method => :post}
+ links += form_remote_tag :url => unattend_event_path(event.id), :method =>
:post, :html => {:method => :post}
links += submit_tag "Unattend"
links += "</form>"
else
- links += form_remote_tag :url => attend_event_path(event), :method => :post,
:html => {:method => :post}
+ links += form_remote_tag :url => attend_event_path(event.id), :method =>
:post, :html => {:method => :post}
links += submit_tag "Attend"
links += "</form>"
end
@@ -65,4 +65,13 @@
text_field_tag 'zipcode', "#{zip}"
end
+ def my_event?(event_id)
+ event = Event.find_by_id(event_id)
+ if !session[:user_id].nil? && event.user_id == session[:user_id]
+ return true;
+ else
+ return false;
+ end
+ end
+
end
Added: incubator/olio/webapp/rails/trunk/app/sweepers/event_sweeper.rb
URL:
http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/app/sweepers/event_sweeper.rb?rev=781829&view=auto
==============================================================================
--- incubator/olio/webapp/rails/trunk/app/sweepers/event_sweeper.rb (added)
+++ incubator/olio/webapp/rails/trunk/app/sweepers/event_sweeper.rb Thu Jun 4
19:03:57 2009
@@ -0,0 +1,33 @@
+class EventSweeper < ActionController::Caching::Sweeper
+
+ observe Event, Comment
+
+ def after_create(record)
+ expire_record(record)
+ end
+
+ def after_save(record)
+ expire_record(record)
+ end
+
+ def after_destroy(record)
+ expire_record(record)
+ end
+
+ private ############################################
+
+ def expire_record(record)
+ unless session.nil?
+ expire_fragment(:controller => 'events', :action => 'index', :part =>
'tag_cloud')
+ end
+
+ expire_fragment(:controller => "events", :action => "show", :id => record.id, :part => "event_description")
+
+ expire_fragment(:controller => "events", :action => "show", :id => record.id, :part => "main_event_details")
+ expire_fragment(:controller => "events", :action => "show", :id => record.id, :part =>
"main_event_details", :creator => true)
+
+ expire_page(root_path)
+ end
+
+end
+
Modified: incubator/olio/webapp/rails/trunk/app/views/comments/_list.html.erb
URL:
http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/app/views/comments/_list.html.erb?rev=781829&r1=781828&r2=781829&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/app/views/comments/_list.html.erb
(original)
+++ incubator/olio/webapp/rails/trunk/app/views/comments/_list.html.erb Thu Jun
4 19:03:57 2009
@@ -18,6 +18,8 @@
-->
<h2 class="event_detail_heading">Comments</h2>
+<% cache({:controller => "events", :action => "show", :id => params[:id], :part => "event_comments"}, {:expire => 30.seconds.to_i}) do -%>
+
<% if @comments.nil? or @comments.empty? -%>
<span class="subliminal">There are no comments for this event.</span>
<% else -%>
@@ -25,3 +27,5 @@
<%= render :partial => 'comments/comment', :collection => @comments %>
</ol>
<% end -%>
+
+<% end -%>
Modified: incubator/olio/webapp/rails/trunk/app/views/events/_calendar.html.erb
URL:
http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/app/views/events/_calendar.html.erb?rev=781829&r1=781828&r2=781829&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/app/views/events/_calendar.html.erb
(original)
+++ incubator/olio/webapp/rails/trunk/app/views/events/_calendar.html.erb Thu
Jun 4 19:03:57 2009
@@ -16,18 +16,20 @@
* limitations under the License.
*
-->
-<div id="calendar">
- <%
- year = (params[:year]) ? params[:year].to_i : Time.now.year
- month = (params[:month]) ? params[:month].to_i : Time.now.month
- -%>
- <%=
- calendar(:year => year, :month => month, :abbrev => (0..0)) do |d|
- link_to_remote d.mday, {
- :url => events_path, :method => :get,
- :with => "'month=#{d.mon}&day=#{d.mday}&year=#{d.year}'"
- },
- :href => events_path(:month => d.mon, :day => d.mday, :year => d.year)
- end
- %>
-</div>
+<% cache(:controller => "events", :part => "default_calendar") do -%>
+ <div id="calendar">
+ <%
+ year = (params[:year]) ? params[:year].to_i : Time.now.year
+ month = (params[:month]) ? params[:month].to_i : Time.now.month
+ -%>
+ <%=
+ calendar(:year => year, :month => month, :abbrev => (0..0)) do |d|
+ link_to_remote d.mday, {
+ :url => events_path, :method => :get,
+ :with => "'month=#{d.mon}&day=#{d.mday}&year=#{d.year}'"
+ },
+ :href => events_path(:month => d.mon, :day => d.mday, :year => d.year)
+ end
+ %>
+ </div>
+<% end -%>
Modified:
incubator/olio/webapp/rails/trunk/app/views/events/_event_list.html.erb
URL:
http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/app/views/events/_event_list.html.erb?rev=781829&r1=781828&r2=781829&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/app/views/events/_event_list.html.erb
(original)
+++ incubator/olio/webapp/rails/trunk/app/views/events/_event_list.html.erb Thu
Jun 4 19:03:57 2009
@@ -33,15 +33,13 @@
<%= zipcode_filter(@zipcode) %>
<br />
- <% unless @events.empty? -%>
<% unless @date -%>
Sort:
- <%= created_at_radio_button %>
- Created Date
+ <%= created_at_radio_button %>
+ Created Date
- <%= event_date_radio_button %>
- Event Date
- <% end -%>
+ <%= event_date_radio_button %>
+ Event Date
<% end -%>
<% if @date -%>
<input type="hidden" name="month" value="<%= month %>" />
@@ -75,8 +73,10 @@
<div id="tag_cloud">
<h2 class="tight_heading">Tag Cloud</h2>
<div>
+ <% cache(:action => 'index', :part => 'tag_cloud') do -%>
<% tag_cloud_items(@tags).each do |link| -%>
<%= link %>
<% end -%>
+ <% end -%>
</div>
</div>
Modified:
incubator/olio/webapp/rails/trunk/app/views/events/_filtered_events.html.erb
URL:
http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/app/views/events/_filtered_events.html.erb?rev=781829&r1=781828&r2=781829&view=diff
==============================================================================
---
incubator/olio/webapp/rails/trunk/app/views/events/_filtered_events.html.erb
(original)
+++
incubator/olio/webapp/rails/trunk/app/views/events/_filtered_events.html.erb
Thu Jun 4 19:03:57 2009
@@ -16,35 +16,37 @@
* limitations under the License.
*
-->
-<div id="event_table">
- <% if @events.empty? -%>
- No events.
- <% else -%>
- <ol id="event_list" style="list-style-type: none;">
- <% @events.each do |event| -%>
- <% which_class = cycle('even_event', 'odd_event') -%>
- <li id="event_<%= event.id %>_details" class="event_item <%= which_class %>" style="padding:
7px;" onmouseover="Element.findChildren(this, 'extra_details', true, 'div').first().show();"
onmouseout="Element.findChildren(this, 'extra_details', true, 'div').first().hide();">
- <div class="thumbnail_for_list">
- <%= thumbnail(get_image(event), event_path(event), :small) %>
- </div>
- <div class="event_details_for_list">
- <h2 class="tight_heading"><%= link_to h(event.title), event %></h2>
- <%= simple_date(event.event_timestamp) %>
+<% cache({:controller => "events", :action => "index", :part => "index_event_list"},
{:expire => 30.seconds.to_i}) do -%>
+ <div id="event_table">
+ <% if @events.empty? -%>
+ No events.
+ <% else -%>
+ <ol id="event_list" style="list-style-type: none;">
+ <% @events.each do |event| -%>
+ <% which_class = cycle('even_event', 'odd_event') -%>
+ <li id="event_<%= event.id %>_details" class="event_item <%= which_class %>" style="padding:
7px;" onmouseover="Element.findChildren(this, 'extra_details', true, 'div').first().show();"
onmouseout="Element.findChildren(this, 'extra_details', true, 'div').first().hide();">
+ <div class="thumbnail_for_list">
+ <%= thumbnail(get_image(event), event_path(event), :small) %>
+ </div>
+ <div class="event_details_for_list">
+ <h2 class="tight_heading"><%= link_to h(event.title), event %></h2>
+ <%= simple_date(event.event_timestamp) %>
- <div class="extra_details" style="display: none;">
- <%= edit_delete_links(event) if logged_in? %>
- <br />
- Created: <%= output_date(event.created_at) %> <br/><br/>
- <%=white_list event.summary %>
+ <div class="extra_details" style="display: none;">
+ <%= edit_delete_links(event) if logged_in? %>
+ <br />
+ Created: <%= output_date(event.created_at) %> <br/><br/>
+ <%=white_list event.summary %>
+ </div>
</div>
- </div>
- <div class="clr"></div>
- </li>
- <% if which_class == 'odd_event' -%>
- <li class="clr"></li>
+ <div class="clr"></div>
+ </li>
+ <% if which_class == 'odd_event' -%>
+ <li class="clr"></li>
+ <% end -%>
<% end -%>
+ </ol>
<% end -%>
- </ol>
- <% end -%>
- <%= will_paginate @events if @events.respond_to? :page_count %>
-</div>
+ <%= will_paginate @events if @events.respond_to? :page_count %>
+ </div>
+<% end -%>
Modified: incubator/olio/webapp/rails/trunk/app/views/events/_map.html.erb
URL:
http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/app/views/events/_map.html.erb?rev=781829&r1=781828&r2=781829&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/app/views/events/_map.html.erb (original)
+++ incubator/olio/webapp/rails/trunk/app/views/events/_map.html.erb Thu Jun 4
19:03:57 2009
@@ -30,7 +30,7 @@
// Set map type to either of: YAHOO_MAP_SAT, YAHOO_MAP_HYB,
YAHOO_MAP_REG
map.setMapType(YAHOO_MAP_REG);
// Display the map centered on a geocoded location
- map.drawZoomAndCenter("<%= "#[email protected]} #[email protected]}
#[email protected]} #[email protected]} #[email protected]} #[email protected]}" %>", 4);
+ map.drawZoomAndCenter("<%= "#[email protected]} #[email protected]}
#[email protected]} #[email protected]} #[email protected]}
#[email protected]}" %>", 4);
</script>
<script type="text/javascript">
map.addOverlay(new YMarker(map.getCenterLatLon()));
Modified: incubator/olio/webapp/rails/trunk/app/views/events/show.html.erb
URL:
http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/app/views/events/show.html.erb?rev=781829&r1=781828&r2=781829&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/app/views/events/show.html.erb (original)
+++ incubator/olio/webapp/rails/trunk/app/views/events/show.html.erb Thu Jun 4
19:03:57 2009
@@ -17,38 +17,43 @@
*
-->
<div id="event_header">
- <div id="event_thumbnail"><%= thumbnail(@image) %></div>
-
- <div id="main_event_details">
- <h1 class="inline"><%=h @event.title %></h1> <%= edit_delete_links(@event)
%>
- <hr />
- <%= output_date(@event.event_timestamp) %><br />
- <br />
- <% unless @document.nil? -%>
- <%= link_to 'Event Literature', @document.public_filename %>
- <% end -%>
+ <% cache({:controller => "events", :action => "show", :id => params[:id], :part =>
"main_event_details", :creator => (session[:user_id])}, {:expire => 30.seconds.to_i}) do -%>
+ end
+ <div id="event_thumbnail"><%= thumbnail(@event.image) %></div>
+ <div id="main_event_details">
+ <h1 class="inline"><%=h @event.title %></h1> <%= edit_delete_links(@event)
%>
+ <hr />
+ <%= output_date(@event.event_timestamp) %><br />
+ <br />
+ <% unless @event.document.nil? -%>
+ <%= link_to 'Event Literature', @event.document.public_filename
%>
+ <% end -%>
<br />
- <div id="event_address">
- <%=h @address.street1 %><br />
- <% unless @address.street2.nil? or @address.street2.empty? -%>
- <%=h @address.street2 %><br />
- <% end -%>
- <%=h @address.city %>, <%=h @address.state %> <%=h @address.zip %><br />
- <%=h @address.country %>
+ <div id="event_address">
+ <%=h @event.address.street1 %><br />
+ <% unless @event.address.street2.nil? or @event.address.street2.empty?
-%>
+ <%=h @event.address.street2 %><br />
+ <% end -%>
+ <%=h @event.address.city %>, <%=h @event.address.state %> <%=h
@event.address.zip %><br />
+ <%=h @event.address.country %>
+ </div>
+ Contact: <span id="event_contact"><%=h @event.telephone %></span><br />
</div>
- Contact: <span id="event_contact"><%=h @event.telephone %></span><br />
- </div>
+ <% end -%>
<div class="clr"></div>
</div>
-<div id="event_attendees">
- <%= render :partial => 'attendees' %>
-</div>
+<% cache({:controller => "events", :action => "show", :id => params[:id], :part =>
"event_attendees", :login => !session[:user_id].nil?}, {:expire => 30.seconds.to_i}) do -%>
+ <div id="event_attendees">
+ <%= render :partial => 'attendees' %>
+ </div>
+<% end -%>
+<% cache({:controller => "events", :action => "show", :id => params[:id], :part => "event_description"}, {:expire => 30.seconds.to_i}) do -%>
<div id="event_description">
- <p><strong>Summary</strong></p>
- <p><%= @event.summary %></p>
+ <p><strong>Summary</strong></p>
+ <p><%= @event.summary %></p>
<p><strong>Description</strong></p>
<p><%= @event.description %></p>
</div>
@@ -66,6 +71,7 @@
</div>
<div class="clr"></div>
</div>
+<% end -%>
<div id="event_comments">
<%= render :partial => 'comments/list' %>
Modified: incubator/olio/webapp/rails/trunk/app/views/layouts/site.rhtml
URL:
http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/app/views/layouts/site.rhtml?rev=781829&r1=781828&r2=781829&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/app/views/layouts/site.rhtml (original)
+++ incubator/olio/webapp/rails/trunk/app/views/layouts/site.rhtml Thu Jun 4
19:03:57 2009
@@ -41,12 +41,13 @@
<% end -%>
<ul id="main_nav">
- <li><%= link_to 'Home', events_path %></li>
<% if logged_in? -%>
+ <li><%= link_to 'Home', home_path %></li>
<li><%= link_to 'Add Event', new_event_path %></li>
<li><%= link_to 'Users', search_users_path %></li>
<li><%= link_to 'Edit Profile', edit_user_path(session[:user_id])
%></li>
<% else -%>
+ <li><%= link_to 'Home', events_path %></li>
<li><%= link_to 'Register', new_user_path %></li>
<% end -%>
</ul>
Modified: incubator/olio/webapp/rails/trunk/config/boot.rb
URL:
http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/config/boot.rb?rev=781829&r1=781828&r2=781829&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/config/boot.rb (original)
+++ incubator/olio/webapp/rails/trunk/config/boot.rb Thu Jun 4 19:03:57 2009
@@ -41,9 +41,8 @@
File.exist?("#{RAILS_ROOT}/vendor/rails")
end
- # FIXME : Ruby 1.9
def preinitialize
- load(preinitializer_path) if File.exists?(preinitializer_path)
+ load(preinitializer_path) if File.exist?(preinitializer_path)
end
def preinitializer_path
@@ -61,6 +60,8 @@
class VendorBoot < Boot
def load_initializer
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
+ Rails::Initializer.run(:install_gem_spec_stubs)
+ Rails::GemDependency.add_frozen_gem_path
end
end
@@ -84,7 +85,7 @@
class << self
def rubygems_version
- Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
+ Gem::RubyGemsVersion rescue nil
end
def gem_version
@@ -99,15 +100,14 @@
def load_rubygems
require 'rubygems'
-
- gem_ver = defined? Gem::RubyGemsVersion ? Gem::RubyGemsVersion :
rubygems_version
- unless gem_ver >= '0.9.4'
- $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have
#{rubygems_version}). Please `gem update --system` and try again.)
+ min_version = '1.3.1'
+ unless rubygems_version >= min_version
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have
#{rubygems_version}). Please `gem update --system` and try again.)
exit 1
end
rescue LoadError
- $stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install
RubyGems and try again: http://rubygems.rubyforge.org)
+ $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please
install RubyGems and try again: http://rubygems.rubyforge.org)
exit 1
end
Modified: incubator/olio/webapp/rails/trunk/config/environment.rb
URL:
http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/config/environment.rb?rev=781829&r1=781828&r2=781829&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/config/environment.rb (original)
+++ incubator/olio/webapp/rails/trunk/config/environment.rb Thu Jun 4 19:03:57
2009
@@ -22,12 +22,16 @@
ENV['RAILS_ENV'] ||= 'production'
# Specifies gem version of Rails to use when vendor/rails is not present
-# RAILS_GEM_VERSION = '2.1.2' unless defined? RAILS_GEM_VERSION
+# RAILS_GEM_VERSION = '2.2.2' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
require 'hodel_3000_compliant_logger'
+CACHED = false
+MEMCACHED = false
+CACHE_SERVER = 'localhost'
+
IMAGE_STORE_PATH = 'public/uploaded_files'
DOCUMENT_STORE_PATH = 'public/uploaded_files'
@@ -42,6 +46,7 @@
# Add additional load paths for your own custom dirs
# config.load_paths += %W( #{RAILS_ROOT}/extras )
+ config.load_paths += %W( #{RAILS_ROOT}/app/sweepers )
# Force all environments to use the same logger level
# (by default production uses :info, the others :debug)
@@ -87,8 +92,8 @@
# Include your application configuration below
require 'uploadable'
require 'will_paginate'
+require 'lazy'
#require RAILS_ROOT + '/test/selenium_helper' if defined?
SeleniumOnRails::FixtureLoader
require 'geolocation'
Geolocation.url = 'http://localhost:8080/geocoder/geocode?appid=gsd5f'
-
Modified: incubator/olio/webapp/rails/trunk/config/environments/development.rb
URL:
http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/config/environments/development.rb?rev=781829&r1=781828&r2=781829&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/config/environments/development.rb
(original)
+++ incubator/olio/webapp/rails/trunk/config/environments/development.rb Thu
Jun 4 19:03:57 2009
@@ -28,7 +28,6 @@
# Show full error reports and disable caching
config.action_controller.consider_all_requests_local = true
config.action_controller.perform_caching = false
-# config.action_view.cache_template_extensions = false
config.action_view.debug_rjs = true
# Don't care if the mailer can't send
Added:
incubator/olio/webapp/rails/trunk/config/environments/development_file_cached.rb
URL:
http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/config/environments/development_file_cached.rb?rev=781829&view=auto
==============================================================================
---
incubator/olio/webapp/rails/trunk/config/environments/development_file_cached.rb
(added)
+++
incubator/olio/webapp/rails/trunk/config/environments/development_file_cached.rb
Thu Jun 4 19:03:57 2009
@@ -0,0 +1,36 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Settings specified here will take precedence over those in config/environment.rb
+
+# In the development environment your application's code is reloaded on
+# every request. This slows down response time but is perfect for development
+# since you don't have to restart the webserver when you make code changes.
+config.cache_classes = true
+
+# Log error messages when you accidentally call methods on nil.
+config.whiny_nils = true
+
+# Show full error reports and disable caching
+config.action_controller.consider_all_requests_local = true
+config.action_controller.perform_caching = true
+config.action_view.debug_rjs = true
+
+# Don't care if the mailer can't send
+config.action_mailer.raise_delivery_errors = false
+
+config.action_controller.cache_store = :file_store, RAILS_ROOT + '/tmp/cache/'
Added:
incubator/olio/webapp/rails/trunk/config/environments/development_mem_cached.rb
URL:
http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/config/environments/development_mem_cached.rb?rev=781829&view=auto
==============================================================================
---
incubator/olio/webapp/rails/trunk/config/environments/development_mem_cached.rb
(added)
+++
incubator/olio/webapp/rails/trunk/config/environments/development_mem_cached.rb
Thu Jun 4 19:03:57 2009
@@ -0,0 +1,36 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Settings specified here will take precedence over those in config/environment.rb
+
+# In the development environment your application's code is reloaded on
+# every request. This slows down response time but is perfect for development
+# since you don't have to restart the webserver when you make code changes.
+config.cache_classes = false
+
+# Log error messages when you accidentally call methods on nil.
+config.whiny_nils = true
+
+# Show full error reports and disable caching
+config.action_controller.consider_all_requests_local = true
+config.action_controller.perform_caching = true
+config.action_view.debug_rjs = true
+
+# Don't care if the mailer can't send
+config.action_mailer.raise_delivery_errors = false
+
+config.action_controller.cache_store = :mem_cache_store
Added:
incubator/olio/webapp/rails/trunk/config/environments/development_nocache.rb
URL:
http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/config/environments/development_nocache.rb?rev=781829&view=auto
==============================================================================
---
incubator/olio/webapp/rails/trunk/config/environments/development_nocache.rb
(added)
+++
incubator/olio/webapp/rails/trunk/config/environments/development_nocache.rb
Thu Jun 4 19:03:57 2009
@@ -0,0 +1,34 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Settings specified here will take precedence over those in config/environment.rb
+
+# In the development environment your application's code is reloaded on
+# every request. This slows down response time but is perfect for development
+# since you don't have to restart the webserver when you make code changes.
+config.cache_classes = false
+
+# Log error messages when you accidentally call methods on nil.
+config.whiny_nils = true
+
+# Show full error reports and disable caching
+config.action_controller.consider_all_requests_local = true
+config.action_controller.perform_caching = false
+config.action_view.debug_rjs = true
+
+# Don't care if the mailer can't send
+config.action_mailer.raise_delivery_errors = false
Modified: incubator/olio/webapp/rails/trunk/config/environments/production.rb
URL:
http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/config/environments/production.rb?rev=781829&r1=781828&r2=781829&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/config/environments/production.rb
(original)
+++ incubator/olio/webapp/rails/trunk/config/environments/production.rb Thu Jun
4 19:03:57 2009
@@ -27,10 +27,22 @@
# Full error reports are disabled and caching is turned on
config.action_controller.consider_all_requests_local = false
-config.action_controller.perform_caching = true
# Enable serving of images, stylesheets, and javascripts from an asset server
# config.action_controller.asset_host =
"http://assets.example.com"
# Disable delivery errors, bad email addresses will be ignored
-# config.action_mailer.raise_delivery_errors = false
+if CACHED
+
+ config.action_controller.perform_caching = true
+
+ if MEMCACHED
+ config.action_controller.cache_store = :mem_cache_store, CACHE_SERVER
+ else
+ config.action_mailer.raise_delivery_errors = false
+ config.action_controller.cache_store = :file_store, RAILS_ROOT +
'/tmp/cache/'
+ end
+
+else
+ config.action_controller.perform_caching = false
+end
Modified: incubator/olio/webapp/rails/trunk/config/routes.rb
URL:
http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/config/routes.rb?rev=781829&r1=781828&r2=781829&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/config/routes.rb (original)
+++ incubator/olio/webapp/rails/trunk/config/routes.rb Thu Jun 4 19:03:57 2009
@@ -29,6 +29,7 @@
event.resources :comments, :member => { :delete => :get }
end
map.resources :events
+ map.home "home", :controller => "events", :action => "home"
map.resources(:users,:collection => { :login => :any,
:logout => :get,
@@ -66,7 +67,7 @@
# end
# You can have the root of your site routed with map.root -- just remember to delete public/index.html.
- map.root :controller => "events"
+ map.root :controller => "events", :action => "index"
# See how all your routes lay out with "rake routes"
Added: incubator/olio/webapp/rails/trunk/lib/lazy.rb
URL:
http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/lib/lazy.rb?rev=781829&view=auto
==============================================================================
--- incubator/olio/webapp/rails/trunk/lib/lazy.rb (added)
+++ incubator/olio/webapp/rails/trunk/lib/lazy.rb Thu Jun 4 19:03:57 2009
@@ -0,0 +1,48 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Don't change this file!
+# Configure your app in config/environment.rb and config/environments/*.rb
+
+class LazySunday
+ %w{== === =~ class clone display dup eql? equal? extend freeze frozen? gem
hash id inspect instance_eval instance_of? instance_variable_defined?
instance_variable_get instance_variable_set instance_variables is_a? kind_of?
method methods nil? object_id private_methods protected_methods public_methods
require respond_to? send singleton_methods taint tainted? to_a to_s type
untaint }.each do |m|
+ module_eval <<-EOS
+ def #{m}(*args, &block)
+ self.resolve.__send__(:#{m}, *args, &block)
+ end
+ EOS
+ end
+
+ def initialize(&block)
+ @block = block
+ end
+
+ def resolve
+ # puts caller.join("\n") unless @obj
+ @obj ||= @block.call
+ end
+
+ def method_missing(method, *args, &block)
+ resolve.send(method, *args, &block)
+ end
+end
+
+module Kernel
+ def lazy(&block)
+ LazySunday.new(&block)
+ end
+end
Modified: incubator/olio/webapp/rails/trunk/public/dispatch.fcgi
URL:
http://svn.apache.org/viewvc/incubator/olio/webapp/rails/trunk/public/dispatch.fcgi?rev=781829&r1=781828&r2=781829&view=diff
==============================================================================
--- incubator/olio/webapp/rails/trunk/public/dispatch.fcgi (original)
+++ incubator/olio/webapp/rails/trunk/public/dispatch.fcgi Thu Jun 4 19:03:57
2009
@@ -1,4 +1,4 @@
-#!/opt/local/bin/ruby
+#!/usr/bin/ruby
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file