This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
engines = Dir[File.expand_path('../vendor/engines/*', __FILE__)] | |
guard 'spork', :wait => 60, :cucumber => false, :rspec_env => { 'RAILS_ENV' => 'test' } do | |
watch('config/application.rb') | |
watch('config/environment.rb') | |
watch(%r{^config/environments/.+\.rb$}) | |
watch(%r{^config/initializers/.+\.rb$}) | |
watch('spec/spec_helper.rb') | |
watch(%r{^spec/support/.+\.rb$}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Refinery::Pages.configure do |pages| | |
pages.types do |types| | |
types.define :home do |home| | |
home.parts = %w[intro body] | |
home.template = 'refinery/pages/home' # this is automatic but shows overriding | |
end | |
types.define :show do |show| | |
show.parts = %w[body side] | |
# show.template is automatically 'refinery/pages/show' and thus not required. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'yaml' | |
my_yaml = YAML::load(File.read('en.yml')).to_yaml | |
=begin | |
1.9.3-p0 :002 > YAML::load(File.read('en.yml')).to_yaml | |
=> "---\nen:\n refinery:\n plugins:\n lovelies:\n title: Lovely Profiles\n people:\n admin:\n lovelies:\n actions:\n create_new: Add New Lovely profile\n reorder: Reorder Lovely profiles\n reorder_done: Done Reordering Lovely profiles\n records:\n title: Lovely\n sorry_no_results: Sorry! There are no results found.\n no_items_yet: There are no Lovely profiles yet. Click \"Add New Lovely\n profile\" to add one.\n lovely:\n view_live_html: View the lovely area live <br/><em>(opens in a new window)</em>\n edit: Edit this lovely profile\n delete: Remove this lovely profile forever\n lovelies:\n show:\n other: Other Lovely profiles\n activerecord:\n attributes:\n refinery/things/lovely:\n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails 3.1: | |
16:04:10: (master $) /code/foo/bar$ time script/rails runner "" | |
real 0m8.653s | |
user 0m7.731s | |
sys 0m0.822s | |
Rails 3.2: | |
16:04:33: (master *$) /code/foo/bar$ time script/rails runner "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def confirmation_message=(value) | |
value.first.keys.each do |locale| | |
Refinery::Setting.set("inquiry_confirmation_message_#{locale}".to_sym, { | |
:value => value.first[locale.to_sym], | |
:scoping => "inquiries" | |
}) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
::PagesController.module_eval do | |
caches_page :show, :unless => proc {|c| c.user_signed_in? || c.flash.any? } | |
caches_page :home, :unless => proc {|c| c.user_signed_in? || c.flash.any? } | |
end | |
::Page.module_eval do | |
after_save :clear_static_caching! | |
after_destroy :clear_static_caching! | |
def clear_static_caching! | |
Page.all.map(&:url).map{|u| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= stylesheet_link_tag(current_theme) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def current_theme | |
# first, check if we've tried to access this already and if so @current_theme will be populated with a value. | |
@current_theme ||= if params[:ChangeTheme] == "true" | |
# If the user is trying to change the theme, first: construct an array of possible themes. | |
# then: reject the theme in the current session if it is present. | |
# Finally, grab a random sample to use a random theme from the array of themes. | |
%w[power.css creative.css communication.css].reject{|theme| theme == session[:current_theme]}.sample | |
else | |
# The user is not trying to change the theme so just return the current theme saved to sesssion OR | |
# return the default theme which is 'power.css' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Refinery::Core::Engine.routes.draw do | |
namespace :admin, :path => 'refinery' do | |
resources :users, :except => :show | |
end | |
end | |
# Can I default namespace :admin to use :path => 'refinery' ? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
page_position = -1 | |
I18n.locale = :en | |
tuning_page = Page.create(:title => "Tuning", :deletable => true, :position => (page_position += 1)) | |
I18n.locale = :fr | |
tuning_page.title = 'French Tuning' | |
tuning_page.save | |
I18n.locale = :es | |
tuning_page.title = 'Spanish Tuning' | |
tuning_page.save |