Module: Evil::Extensions
- Defined in:
- lib/evil/extensions.rb
Instance Method Summary collapse
- #connect_to_database ⇒ Object
- #initialize_evil ⇒ Object
- #load_all_plugins ⇒ Object
- #load_template_routes ⇒ Object
- #reload! ⇒ Object
- #require_whitelisted_openid(pattern) ⇒ Object
Instance Method Details
#connect_to_database ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/evil/extensions.rb', line 27 def connect_to_database if Evil.heroku? dbconfig = YAML.load(File.read(File.join(Evil.app_root, 'config/database.yml'))) ActiveRecord::Base.establish_connection dbconfig['production'] else ActiveRecord::Base.establish_connection :adapter => 'sqlite3', :database => File.join(Evil.app_root, 'evil.db') end end |
#initialize_evil ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/evil/extensions.rb', line 6 def initialize_evil set :public => File.join(Evil.app_root, 'public'), :views => File.join(Evil.gem_root, 'views'), :haml => { :format => :html5 }, :logging => true, :static => true, :dump_errors => true Liquid::Template.file_system = Evil::Plugin::Filesystem.new connect_to_database load_all_plugins end |
#load_all_plugins ⇒ Object
43 44 45 46 47 48 49 50 51 |
# File 'lib/evil/extensions.rb', line 43 def load_all_plugins Dir[File.join(Evil.gem_root, 'lib', 'plugin/builtin', '*.rb')].each do |plugin| Evil::Plugin.from_file(plugin) end Dir[File.join(Evil.app_root, 'plugins', '*.evil')].each do |plugin| Evil::Plugin.from_file(plugin) end end |
#load_template_routes ⇒ Object
37 38 39 40 41 |
# File 'lib/evil/extensions.rb', line 37 def load_template_routes Evil::Models::Template.in_order.each do |template| get(template.route, &proc_for(template)) unless template.route.nil? || template.route.empty? end end |
#reload! ⇒ Object
20 21 22 23 24 25 |
# File 'lib/evil/extensions.rb', line 20 def reload! @reloading = true reset! Kernel.load 'evil/application.rb' @reloading = false end |
#require_whitelisted_openid(pattern) ⇒ Object
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/evil/extensions.rb', line 53 def require_whitelisted_openid(pattern) before do if request.path_info =~ pattern && !params[:openid_url] unless whitelisted_openid? session[:destination_url] = request.url end end end end |