# Be sure to restart your web server when you modify this file.
# Uncomment below to force Rails into production mode when
# you don't control web/app server and can't set it the proper way
# ENV['RAILS_ENV'] ||= 'production'
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
require 'RedCloth-3.0.4/lib/redcloth'
Rails::Initializer.run do |config|
# Settings in config/environments/* take precedence those specified here
# Skip frameworks you're not going to use
# config.frameworks -= [ :action_web_service, :action_mailer ]
# Add additional load paths for your own custom dirs
config.load_paths += %W( #{RAILS_ROOT}/app/cachers )
# Force all environments to use the same logger level
# (by default production uses :info, the others :debug)
# config.log_level = :debug
# Use the database for sessions instead of the file system
# (create the session table with 'rake create_sessions_table')
config.action_controller.session_store = :active_record_store
# Enable page/fragment caching by setting a file-based store
# (remember to create the caching directory and make it readable to the application)
# config.action_controller.fragment_cache_store = :file_store, "#{RAILS_ROOT}/cache"
# Activate observers that should always be running
# config.active_record.observers = [:article_observer]
# Make Active Record use UTC-base instead of local time
config.active_record.default_timezone = :utc
# Use Active Record's schema dumper instead of SQL when creating the test database
# (enables use of different database adapters for development and test environments)
config.active_record.schema_format = :ruby
# See Rails::Configuration for more options
end
# Add new inflection rules using the following format
# (all these examples are active by default):
# Inflector.inflections do |inflect|
# inflect.plural /^(ox)$/i, '\1en'
# inflect.singular /^(ox)en/i, '\1'
# inflect.irregular 'person', 'people'
# inflect.uncountable %w( fish sheep )
# end
# Include your application configuration below
require 'tzinfo'
require 'time_ext'
require 'zip/zipfilesystem'
require 'dispatcher'
class << Dispatcher
def register_liquid_tags
Liquid::Template.register_filter(Mephisto::Liquid::Filters)
Liquid::Template.register_tag(:textile, Mephisto::Liquid::Textile)
Liquid::Template.register_tag(:commentform, Mephisto::Liquid::CommentForm)
Liquid::Template.register_tag(:pagenavigation, Mephisto::Liquid::PageNavigation)
Liquid::Template.register_tag(:head, Mephisto::Liquid::Head)
end
def reset_application_with_plugins!
returning reset_application_without_plugins! do
register_liquid_tags
end
end
alias_method_chain :reset_application!, :plugins
end
Dispatcher.register_liquid_tags
RubyPants # load RubyPants
ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.update \
:standard => '%B %d, %Y @ %I:%M %p',
:stub => '%B %d', # XXX what is the meaning of stub in this context? (Basically it means short)
:time_only => '%I:%M %p',
:plain => '%B %d %I:%M %p'
# Time.now.to_ordinalized_s :long
# => "February 28th, 2006 21:10"
module ActiveSupport::CoreExtensions::Time::Conversions
def to_ordinalized_s(format = :default)
format = ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS[format]
return to_default_s if format.nil?
strftime(format.gsub(/%d/, '_%d_')).gsub(/_(\d+)_/) { |s| s.to_i.ordinalize }
end
end
# http://rails.techno-weenie.net/tip/2005/12/23/make_fixtures
ActiveRecord::Base.class_eval do
# person.dom_id #-> "person-5"
# new_person.dom_id #-> "person-new"
# new_person.dom_id(:bare) #-> "new"
# person.dom_id(:person_name) #-> "person-name-5"
def dom_id(prefix=nil)
display_id = new_record? ? "new" : id
prefix ||= self.class.name.underscore
prefix != :bare ? "#{prefix.to_s.dasherize}-#{display_id}" : display_id
end
# Write a fixture file for testing
def self.to_fixture(fixture_path = nil)
File.open(File.expand_path(fixture_path || "test/fixtures/#{table_name}.yml", RAILS_ROOT), 'w') do |out|
YAML.dump find(:all).inject({}) { |hsh, record| hsh.merge(record.id => record.attributes) }, out
end
end
end
class Time
class << self
# Used for getting multifield attributes like those generated by a
# select_datetime into a new Time object. For example if you have
# following <tt>params={:meetup=>{:"time(1i)=>..."}}</tt> just do
# following:
#
# <tt>Time.parse_from_attributes(params[:meetup], :time)</tt>
def parse_from_attributes(attrs, field, method=:gm)
attrs = attrs.keys.sort.grep(/^#{field.to_s}\(.+\)$/).map { |k| attrs[k] }
attrs.any? ? Time.send(method, *attrs) : nil
end
end
end