Skip to content

Commit

Permalink
Merge branch 'master' into rical_remodel
Browse files Browse the repository at this point in the history
* master: (29 commits)
  Update INSTALL.md to explain bundler usage, along with other improvements.
  Create Gemfile and rewrite the environment.rb to use it.
  Rework SettingsReader to work within bundler without active_support.
  Rework SecretsReader to work within bundler withoutrubygems or active_support.
  Add bundler boostrap.
  Update config/boot.rb by running "rake rails:update"
  Improve INSTALL.md to describe some production server setup steps.
  THEME: Improve theming documentation, made it clearer and more detailed.
  THEME: Remove "tz" setting, only "timezone" is needed now.
  THEME: Added partial to describe appropriate content for your site. See `themes/README.txt` for details.
  Fix theme_support so that exception_notification works properly.
  Fix events#_item to emit valid HTML.
  Fix DuplicateChecking::find_duplicates_by to deal with blanks. Remove magic.
  Fix Event::find_duplicates_by_type to cope with empty strings. Wrote specs.
  Improve venues#destroy to prevent removal of venues with events.
  Send exception notification from same address its sent to, so it can be replied to.
  Allow passing of params to EventsController#new, so that links can be constructed to pre-populated new event forms.
  Fix issue when attempting to preview a new event with a new venue: don't try to generate a URL for the unsaved event object.
  Fix test of event previewing so that it actually tests that the preview is  displayed. To do this, integrate views when testing EventsController#create
  Improve evil robot detector to use present? instead of !x.blank?
  ...

Conflicts:
	config/environment.rb
  • Loading branch information
igal committed May 24, 2011
2 parents 0110f90 + f5b1bf9 commit 61e9d5a
Show file tree
Hide file tree
Showing 30 changed files with 593 additions and 338 deletions.
35 changes: 35 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
source :rubygems

gem 'sqlite3'

gem 'rails', '2.3.11'
gem 'columnize', '0.3.2'
gem 'geokit', '1.5.0'
gem 'hpricot', '0.8.3'
gem 'htmlentities', '4.2.3'
gem 'linecache', '0.43'
gem 'paper_trail', '1.6.4'
gem 'ri_cal', '0.8.7'
gem 'rubyzip', '0.9.4', :require => 'zip/zip'
gem 'will_paginate', '2.3.15'

# NOTE: mofo 0.2.9 and above are evil, defining their own defective Object#try method and are unable to extract "postal-code" address fields from hCalendar. Mofo is used in Calagator's SourceParser::Hcal and throughout for String#strip_html. The library has been abandoned and its author recommends switching to the incompatible "prism" gem.
gem 'mofo', '0.2.8'

# Some dependencies are only needed for test and development environments. On
# production servers, you can skip their installation by running:
# bundle install --without development test
group :development, :test do
gem 'rspec', '1.3.1', :require => false
gem 'rspec-rails', '1.3.3', :require => false
gem 'annotate-models', '1.0.4', :require => false
end

# Some dependencies are activated through server settings.
require 'lib/secrets_reader'
secrets = SecretsReader.read(:silent => true)
case secrets.search_engine
when 'sunspot'
gem 'sunspot', '1.2.1', :require => 'sunspot'
gem 'sunspot_rails', '1.2.1', :require => 'sunspot/rails'
end
61 changes: 61 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
GEM
remote: http://rubygems.org/
specs:
actionmailer (2.3.11)
actionpack (= 2.3.11)
actionpack (2.3.11)
activesupport (= 2.3.11)
rack (~> 1.1.0)
activerecord (2.3.11)
activesupport (= 2.3.11)
activeresource (2.3.11)
activesupport (= 2.3.11)
activesupport (2.3.11)
annotate-models (1.0.4)
columnize (0.3.2)
geokit (1.5.0)
hpricot (0.8.3)
htmlentities (4.2.3)
linecache (0.43)
mofo (0.2.8)
hpricot (>= 0.4.59)
paper_trail (1.6.4)
actionpack (>= 2.3)
activerecord (>= 2.3)
rack (1.1.2)
rails (2.3.11)
actionmailer (= 2.3.11)
actionpack (= 2.3.11)
activerecord (= 2.3.11)
activeresource (= 2.3.11)
activesupport (= 2.3.11)
rake (>= 0.8.3)
rake (0.9.0)
ri_cal (0.8.7)
rspec (1.3.1)
rspec-rails (1.3.3)
rack (>= 1.0.0)
rspec (= 1.3.1)
rubyzip (0.9.4)
sqlite3 (1.3.3)
will_paginate (2.3.15)

PLATFORMS
ruby

DEPENDENCIES
annotate-models (= 1.0.4)
columnize (= 0.3.2)
geokit (= 1.5.0)
hpricot (= 0.8.3)
htmlentities (= 4.2.3)
linecache (= 0.43)
mofo (= 0.2.8)
paper_trail (= 1.6.4)
rails (= 2.3.11)
ri_cal (= 0.8.7)
rspec (= 1.3.1)
rspec-rails (= 1.3.3)
rubyzip (= 0.9.4)
sqlite3
will_paginate (= 2.3.15)
64 changes: 30 additions & 34 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,46 +7,42 @@ Setup

To use Calagator, you'll need to:

1. [Install git](http://git-scm.com/) 1.5.x or newer, a distributed version control system. Read the [Github Git Guides](http://github.com/guides/home) to learn how to use *git*.
2. [Install Ruby](http://www.ruby-lang.org/), a programming language. You can use MRI Ruby 1.8.6, MRI Ruby 1.8.7, or [Phusion REE (Ruby Enterprise Edition)](http://rubyenterpriseedition.com/). Your operating system may already have Ruby installed or offer it as a prebuilt package.
3. [Install RubyGems](http://rubyforge.org/projects/rubygems/) 1.3.x, a tool for managing software packages for Ruby. If you already have `rubygems` installed, you may need to update it by running `gem update --system` as root or an administrator.
4. [Install SQLite3](http://www.sqlite.org/), a database engine. Your operating system may already have Ruby installed or offer it as a prebuilt package.
5. [Install Ruby on Rails](http://rubyonrails.org/), a web development framework. You should run `gem install rails -v '~> 2.3.10' --no-ri --no-rdoc` as root or an administrator.
* [Install git](http://git-scm.com/) 1.5.x or newer, a distributed version control system. Read the [Github Git Guides](http://github.com/guides/home) to learn how to use *git*.
* [Install Ruby](http://www.ruby-lang.org/), a programming language. You can use MRI Ruby 1.8.6, MRI Ruby 1.8.7, or [Phusion REE (Ruby Enterprise Edition)](http://rubyenterpriseedition.com/). Your operating system may already have Ruby installed or offer it as a prebuilt package.
* [Install RubyGems](http://rubyforge.org/projects/rubygems/) 1.3.x, a tool for managing software packages for Ruby. If you already have `rubygems` installed, you may need to update it by running `gem update --system` as root or an administrator.
* [Install SQLite3](http://www.sqlite.org/), a database engine. Your operating system may already have Ruby installed or offer it as a prebuilt package.
* [Install Bundler](http://gembundler.com/), a Ruby dependency management tool. You should run `gem install bundler` as root or an administrator.
* Checkout the Calagator source code. Run `git clone git://github.com/calagator/calagator.git` or equivalent, which will create a `calagator` directory with the source code. Go into this directory and run the remaining commands from there.
* Install Bundler-managed gems, the actual libraries that this application uses, like Ruby on Rails. You should run `bundle update`, which may take a long time to complete.
* Optionally specify the theme to use, see the **Customizing** section for details.
* Optionally setup API keys for external services so that maps will be displayed, see the **API Keys** section for details.
* Start the search service if needed, see the **Search engine** section for details.

Additional, but out of date, instructions can be found at http://code.google.com/p/calagator/wiki/DevelopmentSoftware


Checkout
--------

To get the Calagator source code:

1. Follow the **Setup** instructions above.
2. Run `git clone git://github.com/calagator/calagator.git` or equivalent, which will create a `calagator` directory with the source code. Go into this directory and run the remaining commands from there.

Development
-----------

Configuration
-------------
To run Calagator in `development` mode, which automatically reloads code as you change it:

To configure Calagator:
* Follow the **Setup** instructions above.
* Initialize your database, run `rake db:migrate db:test:prepare`
* Start the *Ruby on Rails* web application by running `./script/server` (UNIX) or `ruby script/server` (Windows).
* Open a web browser to <http://localhost:3000/> to use the development server
* Read the [Rails Guides](http://guides.rubyonrails.org/) to learn how to develop a Ruby on Rails application.
* When done, stop the *Ruby on Rails* server `script/server` by pressing `CTRL-C`.

1. Follow the **Checkout** instructions above.
2. Initialize your database, run `rake db:migrate db:test:prepare`
3. Optionally setup API keys so that maps display and such, see 'API Keys'.

Production
----------

Development
-----------
To run Calagator in `production` mode, which runs more quickly, but doesn't reload code:

To run Calagator in development mode:
* Follow the **Setup** instructions above. Don't forget to do things like create the theme and secrets files.
* Initialize your database, run `rake RAILS_ENV=production db:migrate`
* Run `rake clear` to clear your cache after updating your application's code.
* Setup a production web server using [Phusion Passenger](http://www.modrails.com/), [Thin](http://code.macournoyer.com/thin/), [Rainbows](http://rainbows.rubyforge.org/), etc. These will be able to serve more users more quickly than `script/server`.

1. Follow the **Configuration** instructions above.
2. Start your search service if needed, see "Search engine" below for details.
3. Start the *Ruby on Rails* web application by running `./script/server` (UNIX) or `ruby script/server` (Windows).
4. Open a web browser to http://localhost:3000/ to use the development server
5. Read the [Rails Guides](http://guides.rubyonrails.org/) to learn how to develop a Ruby on Rails application.
6. When done, stop the *Ruby on Rails* server `script/server` by pressing **CTRL-C**.
7. Stop your search service if needed, see "Search engine" below for details.
The Calagator.org site runs on [Ubuntu Linux](http://ubuntu.com/), [Phusion REE (Ruby Enterprise Edition)](http://rubyenterpriseedition.com/) and [Phusion Passenger](http://www.modrails.com/).


Customization
Expand Down Expand Up @@ -118,7 +114,7 @@ You can stop the Solr search service a command like:
rake RAILS_ENV=production solr:stop


Production
----------
Feedback wanted
---------------

Calagator.org runs on [Ubuntu Linux](http://ubuntu.com/), [Phusion REE (Ruby Enterprise Edition)](http://rubyenterpriseedition.com/) and [Phusion Passenger](http://www.modrails.com/).
Is there something wrong, unclear or outdated in this documentation? Please get in touch so we can make it better. If you can contribute improved text, we'd really appreciate it.
5 changes: 3 additions & 2 deletions app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def show
# GET /events/new
# GET /events/new.xml
def new
@event = Event.new
@event = Event.new(params[:event])
@page_title = "Add an Event"

respond_to do |format|
Expand All @@ -87,7 +87,7 @@ def create
@event.start_time = params[:start_date], params[:start_time]
@event.end_time = params[:end_date], params[:end_time]

if evil_robot = !params[:trap_field].blank?
if evil_robot = params[:trap_field].present?
flash[:failure] = "<h3>Evil Robot</h3> We didn't create this event because we think you're an evil robot. If you're really not an evil robot, look at the form instructions more carefully. If this doesn't work please file a bug report and let us know."
end

Expand Down Expand Up @@ -141,6 +141,7 @@ def update
if params[:preview]
@event.attributes = params[:event]
@event.valid?
@event.tags.reload # Reload the #tags association because its members may have been modified when #tag_list was set above.
end
format.html { render :action => "edit" }
format.xml { render :xml => @event.errors, :status => :unprocessable_entity }
Expand Down
24 changes: 20 additions & 4 deletions app/controllers/venues_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,27 @@ def update
# DELETE /venues/1.xml
def destroy
@venue = Venue.find(params[:id])
@venue.destroy

respond_to do |format|
format.html { redirect_to(venues_url) }
format.xml { head :ok }
if @venue.events.count > 0
message = "Cannot destroy venue that has associated events, you must reassociate all its events first."
respond_to do |format|
format.html {
flash[:failure] = message
redirect_to(@venue)
}
format.xml {
render :xml => message, :status => :unprocessable_entity
}
end
else
@venue.destroy
respond_to do |format|
format.html {
flash[:success] = "Destroyed venue."
redirect_to(venues_url)
}
format.xml { head :ok }
end
end
end

Expand Down
1 change: 0 additions & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def render_flash
result = ""
for name in FLASH_TYPES
result += "<div class='flash #{name} flash_#{name}'>#{name == :failure ? 'ERROR: ' : ''}#{flash[name]}</div>" if flash[name]
flash[name] = nil
end
return(result.blank? ? nil : "<div id='flash'>#{result}</div>")
end
Expand Down
19 changes: 14 additions & 5 deletions app/mixins/duplicate_checking.rb
Original file line number Diff line number Diff line change
Expand Up @@ -177,31 +177,40 @@ def find_duplicates_by(fields, options={})
attributes = new.attribute_names
matched_fields = nil

if fields.nil? || (fields.respond_to?(:blank?) && fields.blank?)
fields = :all
end

if fields == :all || fields == :any
matched = false
attributes.each do |attr|
# TODO make find_duplicates_by(:all) pay attention to ignore fields
next if ['id','created_at','updated_at', 'duplicate_of_id','version'].include?(attr)
if fields == :all
query += " ((a.#{attr} = b.#{attr}) OR (a.#{attr} IS NULL AND b.#{attr} IS NULL)) AND"
query << " AND" if matched
query << " ((a.#{attr} = b.#{attr}) OR (a.#{attr} IS NULL AND b.#{attr} IS NULL))"
else
query += " (a.#{attr} = b.#{attr} AND (a.#{attr} != '' AND a.#{attr} != 0 AND a.#{attr} IS NOT NULL)) OR "
query << " OR" if matched
query << " (a.#{attr} = b.#{attr} AND (a.#{attr} != '' AND a.#{attr} != 0 AND a.#{attr} IS NOT NULL))"
end
matched = true
end
else
matched = false
fields = [fields].flatten
fields.each do |attr|
if attributes.include?(attr.to_s)
query += " a.#{attr} = b.#{attr} AND"
query << " AND" if matched
query << " a.#{attr} = b.#{attr}"
matched = true
else
raise ArgumentError, "Unknow fields: #{fields.inspect}"
end
end
matched_fields = lambda {|r| fields.map {|f| r.read_attribute(f.to_sym) }}
end
# Remove last word from the query, e.g., "AND"
query.sub!(/\s+\S+\s*$/, " )")

query << " )"

query << " GROUP BY #{options[:group_by]}" if options[:group_by]

Expand Down
4 changes: 2 additions & 2 deletions app/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ def self.find_by_dates(start_of_range, end_of_range, opts={})

# Return Hash of Events grouped by the +type+.
def self.find_duplicates_by_type(type='na')
case type
when 'na', nil
case type.to_s.strip
when 'na', ''
return { [] => self.find_future_events }
else
kind = %w[all any].include?(type) ? type.to_sym : type.split(',')
Expand Down
17 changes: 8 additions & 9 deletions app/views/events/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,14 @@
<div id="event_preview">
<h2>Preview your event</h2>

<%= render :partial => "preview", :locals => { :event => event } %>
<%= render :partial => "item", :locals => { :event => event, :has_contentbar => false } %>
</div>
<% end -%>
<% form_for(event, :html => {:id => "event_form", :class => "standard_form"}) do |f| %>
<fieldset>
<legend><% unless event.new_record? %>Editing: <em><%= event.title %></em><% end %></legend>

<p>You can edit the details of your event below. The more information we have about your event, the easier it will be for people to find it.</p>

<%= error_messages_for :event %>
<div>
<%= f.label :title, "Event Name" %>
Expand Down Expand Up @@ -143,17 +141,18 @@
<div>
<%= f.label :description %>
<%= f.text_area :description %>
<span class='help'>
(HTML formatting allowed)
</span>
<div class='help'>
(HTML formatting allowed: <%= WhiteListHelper.tags.sort.join(', ') %>)
</div>
</div>

<div>
<%= f.label :tag_list, "Tags" %>
<%= f.text_field :tag_list %>
<span class="help">
(comma-separated keywords)
</span>
<div class="clearfix"></div>
<div class="help">
(Tags are comma-separated keywords that make it easier to find your event and boost its position in searches. You can also use a tag like <code>plancast:plan=ABCD</code> to associate this with a particular <a href="http://plancast.com/">Plancast</a> event, or a tag like <code>epdx:group=1234</code> to associate the event with a particular <a href="http://epdx.org/">ePDX</a> group)
</div>
</div>

<div class='trap'>
Expand Down
Loading

0 comments on commit 61e9d5a

Please sign in to comment.