project setup

* added refinerycms(-blog) as depencies
* removed capybara (we won't do any browsertests here)
* initialized refinery in dummy app
This commit is contained in:
Marc Remolt 2011-06-01 21:07:20 +02:00
parent 3ec27fdfe6
commit 1a68663552
46 changed files with 1263 additions and 211 deletions

View File

@ -1,11 +1,13 @@
source "http://rubygems.org"
gem "rails", "3.0.7"
gem "capybara", ">= 0.4.0"
#gem "capybara", ">= 1.0.0.beta1"
gem "sqlite3"
gem "rspec-rails", ">= 2.0.0.beta"
gem "rspec-rails", ">= 2.6.0"
# To use debugger (ruby-debug for Ruby 1.8.7+, ruby-debug19 for Ruby 1.9.2+)
# gem 'ruby-debug'
# gem 'ruby-debug19'
gem 'refinerycms-wordpress-import', :path => './'

170
Gemfile.lock Normal file
View File

@ -0,0 +1,170 @@
PATH
remote: ./
specs:
refinerycms-wordpress-import (0.0.1)
refinerycms (~> 1.0.0)
refinerycms-blog (~> 1.3.2)
GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
actionmailer (3.0.7)
actionpack (= 3.0.7)
mail (~> 2.2.15)
actionpack (3.0.7)
activemodel (= 3.0.7)
activesupport (= 3.0.7)
builder (~> 2.1.2)
erubis (~> 2.6.6)
i18n (~> 0.5.0)
rack (~> 1.2.1)
rack-mount (~> 0.6.14)
rack-test (~> 0.5.7)
tzinfo (~> 0.3.23)
activemodel (3.0.7)
activesupport (= 3.0.7)
builder (~> 2.1.2)
i18n (~> 0.5.0)
activerecord (3.0.7)
activemodel (= 3.0.7)
activesupport (= 3.0.7)
arel (~> 2.0.2)
tzinfo (~> 0.3.23)
activeresource (3.0.7)
activemodel (= 3.0.7)
activesupport (= 3.0.7)
activesupport (3.0.7)
acts_as_indexed (0.7.2)
arel (2.0.10)
awesome_nested_set (2.0.0)
activerecord (>= 3.0.0)
babosa (0.3.4)
bcrypt-ruby (2.1.4)
builder (2.1.2)
devise (1.3.4)
bcrypt-ruby (~> 2.1.2)
orm_adapter (~> 0.0.3)
warden (~> 1.0.3)
diff-lcs (1.1.2)
dragonfly (0.9.2)
rack
erubis (2.6.6)
abstract (>= 1.0.0)
filters_spam (0.3)
friendly_id_globalize3 (3.2.1.3)
babosa (~> 0.3.0)
globalize3 (0.1.0)
activemodel (>= 3.0.0)
activerecord (>= 3.0.0)
i18n (0.5.0)
mail (2.2.19)
activesupport (>= 2.3.6)
i18n (>= 0.4.0)
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.16)
orm_adapter (0.0.5)
polyglot (0.3.1)
rack (1.2.3)
rack-cache (1.0.2)
rack (>= 0.4)
rack-mount (0.6.14)
rack (>= 1.0.0)
rack-test (0.5.7)
rack (>= 1.0)
rails (3.0.7)
actionmailer (= 3.0.7)
actionpack (= 3.0.7)
activerecord (= 3.0.7)
activeresource (= 3.0.7)
activesupport (= 3.0.7)
bundler (~> 1.0)
railties (= 3.0.7)
railties (3.0.7)
actionpack (= 3.0.7)
activesupport (= 3.0.7)
rake (>= 0.8.7)
thor (~> 0.14.4)
rake (0.9.1)
refinerycms (1.0.0)
bundler (~> 1.0)
refinerycms-authentication (= 1.0.0)
refinerycms-base (= 1.0.0)
refinerycms-core (= 1.0.0)
refinerycms-dashboard (= 1.0.0)
refinerycms-images (= 1.0.0)
refinerycms-pages (= 1.0.0)
refinerycms-resources (= 1.0.0)
refinerycms-settings (= 1.0.0)
refinerycms-authentication (1.0.0)
devise (~> 1.3.0)
friendly_id_globalize3 (~> 3.2.1)
refinerycms-core (= 1.0.0)
refinerycms-base (1.0.0)
refinerycms-blog (1.3.2)
filters_spam (~> 0.2)
refinerycms (>= 0.9.8)
refinerycms-core (1.0.0)
acts_as_indexed (~> 0.7)
awesome_nested_set (~> 2.0)
friendly_id_globalize3 (~> 3.2.1)
globalize3 (~> 0.1)
rails (~> 3.0.7)
refinerycms-base (= 1.0.0)
refinerycms-generators (~> 1.0)
refinerycms-settings (= 1.0.0)
truncate_html (~> 0.5)
will_paginate (~> 3.0.pre)
refinerycms-dashboard (1.0.0)
refinerycms-core (= 1.0.0)
refinerycms-generators (1.0.1)
refinerycms-images (1.0.0)
dragonfly (~> 0.9.0)
rack-cache (>= 0.5.3)
refinerycms-core (= 1.0.0)
refinerycms-pages (1.0.0)
awesome_nested_set (~> 2.0)
friendly_id_globalize3 (~> 3.2.1)
globalize3 (~> 0.1)
refinerycms-core (= 1.0.0)
seo_meta (~> 1.1)
refinerycms-resources (1.0.0)
dragonfly (~> 0.9.0)
rack-cache (>= 0.5.3)
refinerycms-core (= 1.0.0)
refinerycms-settings (1.0.0)
refinerycms-base (= 1.0.0)
rspec (2.6.0)
rspec-core (~> 2.6.0)
rspec-expectations (~> 2.6.0)
rspec-mocks (~> 2.6.0)
rspec-core (2.6.3)
rspec-expectations (2.6.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.6.0)
rspec-rails (2.6.1)
actionpack (~> 3.0)
activesupport (~> 3.0)
railties (~> 3.0)
rspec (~> 2.6.0)
seo_meta (1.1.1)
refinerycms-generators (~> 1.0.1)
sqlite3 (1.3.3)
thor (0.14.6)
treetop (1.4.9)
polyglot (>= 0.3.1)
truncate_html (0.5.1)
tzinfo (0.3.27)
warden (1.0.4)
rack (>= 1.0)
will_paginate (3.0.pre2)
PLATFORMS
ruby
DEPENDENCIES
rails (= 3.0.7)
refinerycms-wordpress-import!
rspec-rails (>= 2.6.0)
sqlite3

View File

@ -7,7 +7,7 @@ rescue LoadError
end
require 'rake'
require 'rake/rdoctask'
require 'rdoc/task'
require 'rspec/core'
require 'rspec/core/rake_task'

View File

@ -1,2 +1,8 @@
module Refinerycms-wordpress-import
require 'refinerycms'
require 'refinerycms-blog'
module Refinery
module WordPress
end
end

View File

@ -1,9 +1,12 @@
# Provide a simple gemspec so you can easily use your enginex
# project in your rails apps through git.
Gem::Specification.new do |s|
s.name = "refinerycms_wordpress_import"
s.summary = "Insert Refinerycms-wordpress-import summary."
s.name = "refinerycms-wordpress-import"
s.summary = "Import WordPress XML dumps into refinerycms(-blog)."
s.description = "Insert Refinerycms-wordpress-import description."
s.files = Dir["{app,lib,config}/**/*"] + ["MIT-LICENSE", "Rakefile", "Gemfile", "README.rdoc"]
s.version = "0.0.1"
s.add_dependency 'refinerycms', '~> 1.0.0'
s.add_dependency 'refinerycms-blog', '~> 1.3.2'
end

76
spec/dummy/.gitignore vendored Normal file
View File

@ -0,0 +1,76 @@
# Rails
.bundle
db/*.sqlite3
db/*.sqlite3-journal
*.log
tmp
tmp/**/*
# Documentation
doc/api
doc/app
.yardoc
.yardopts
# Public Uploads
public/system/*
public/themes/*
# Public Cache
public/javascripts/cache
public/stylesheets/cache
# Vendor Cache
vendor/cache
# Acts as Indexed
index/**/*
# Refinery Specific
*.tmproj
*.autobackupbyrefinery.*
refinerycms-*.gem
.autotest
# Mac
.DS_Store
# Windows
Thumbs.db
# NetBeans
nbproject
# Eclipse
.project
# Redcar
.redcar
# Rubinius
*.rbc
# Vim
*.swp
*.swo
# RubyMine
.idea
# E-texteditor
.eprj
# Backup
*~
# Capybara Bug
capybara-*html
# sass
.sass-cache
.sass-cache/*
#rvm
.rvmrc
.rvmrc.*

View File

@ -0,0 +1,25 @@
xml.instruct!
xml.urlset "xmlns" => "http://www.sitemaps.org/schemas/sitemap/0.9" do
@locales.each do |locale|
::I18n.locale = locale
Page.live.in_menu.includes(:parts).each do |page|
# exclude sites that are external to our own domain.
page_url = if page.url.is_a?(Hash)
# This is how most pages work without being overriden by link_url
page.url.merge({:only_path => false})
elsif page.url.to_s !~ /^http/
# handle relative link_url addresses.
[request.protocol, request.host_with_port, page.url].join
end
# Add XML entry only if there is a valid page_url found above.
xml.url do
xml.loc url_for(page_url)
xml.lastmod page.updated_at.to_date
end if page_url.present? and page.show_in_menu?
end
end
end

View File

@ -0,0 +1,17 @@
### uncomment any of the following requires applicable for your system
### and then copy this to .autotest if you are using the ZenTest autotest.
# require "autotest/restart"
# require "test_notifier/runner/autotest"
# require "redgreen/autotest"
# require "autotest/timestamp"
# adds exceptions from .gitignore file, please modify exceptions there!
imported_exceptions = IO.readlines('.gitignore').inject([]) do |acc, line|
acc << line.strip if line.to_s[0] != '#' && line.strip != ''; acc
end
Autotest.add_hook :initialize do |autotest|
imported_exceptions.each do |exception|
autotest.add_exception(exception)
end
end

View File

@ -0,0 +1,2 @@
Autotest.add_discovery { "rails" }
Autotest.add_discovery { "rspec2" }

View File

@ -24,3 +24,4 @@ Dummy::Application.configure do
config.action_dispatch.best_standards_support = :builtin
end
Refinery.rescue_not_found = false

View File

@ -29,7 +29,7 @@ Dummy::Application.configure do
# Disable Rails's static asset server
# In production, Apache or nginx will already do this
config.serve_static_assets = false
config.serve_static_assets = true # Refinery CMS requires this to be true
# Enable serving of images, stylesheets, and javascripts from an asset server
# config.action_controller.asset_host = "http://assets.example.com"
@ -47,3 +47,4 @@ Dummy::Application.configure do
# Send deprecation notices to registered listeners
config.active_support.deprecation = :notify
end
Refinery.rescue_not_found = true

View File

@ -33,3 +33,4 @@ Dummy::Application.configure do
# Print deprecation notices to the stderr
config.active_support.deprecation = :stderr
end
Refinery.rescue_not_found = false

View File

@ -0,0 +1,144 @@
require 'devise'
# Use this hook to configure devise mailer, warden hooks and so forth. The first
# four configuration values can also be set straight in your models.
::Devise.setup do |config|
# ==> Mailer Configuration
# Configure the e-mail address which will be shown in DeviseMailer.
config.mailer_sender = "please-change-me@config-initializers-devise.com"
# Configure the class responsible to send e-mails.
# config.mailer = "::Devise::Mailer"
# ==> ORM configuration
# Load and configure the ORM. Supports :active_record (default) and
# :mongoid (bson_ext recommended) by default. Other ORMs may be
# available as additional gems.
require 'devise/orm/active_record'
# ==> Configuration for any authentication mechanism
# Configure which keys are used when authenticating an user. By default is
# just :email. You can configure it to use [:username, :subdomain], so for
# authenticating an user, both parameters are required. Remember that those
# parameters are used only when authenticating and not when retrieving from
# session. If you need permissions, you should implement that in a before filter.
# config.authentication_keys = [ :email ]
# Tell if authentication through request.params is enabled. True by default.
# config.params_authenticatable = true
# Tell if authentication through HTTP Basic Auth is enabled. False by default.
# config.http_authenticatable = false
# Set this to true to use Basic Auth for AJAX requests. True by default.
# config.http_authenticatable_on_xhr = true
# The realm used in Http Basic Authentication
# config.http_authentication_realm = "Application"
# ==> Configuration for :database_authenticatable
# For bcrypt, this is the cost for hashing the password and defaults to 10. If
# using other encryptors, it sets how many times you want the password re-encrypted.
# config.stretches = 20
# Define which will be the encryption algorithm. Devise also supports encryptors
# from others authentication tools as :clearance_sha1, :authlogic_sha512 (then
# you should set stretches above to 20 for default behavior) and :restful_authentication_sha1
# (then you should set stretches to 10, and copy REST_AUTH_SITE_KEY to pepper)
# config.encryptor = :bcrypt
# Setup a pepper to generate the encrypted password.
# config.pepper = "2e20a8abdd34d729ba6d05f679e513cfea9fbb1e83c81f84b29e9e4fdbd4ee59b56a32200064082a15a72b05a4d4a6a2c3784a09c0554b3a47a67cc8333ccbc7"
# ==> Configuration for :confirmable
# The time you want to give your user to confirm his account. During this time
# he will be able to access your application without confirming. Default is nil.
# When confirm_within is zero, the user won't be able to sign in without confirming.
# You can use this to let your user access some features of your application
# without confirming the account, but blocking it after a certain period
# (ie 2 days).
# config.confirm_within = 2.days
# ==> Configuration for :rememberable
# The time the user will be remembered without asking for credentials again.
# config.remember_for = 2.weeks
# If true, a valid remember token can be re-used between multiple browsers.
# config.remember_across_browsers = true
# If true, extends the user's remember period when remembered via cookie.
# config.extend_remember_period = false
# ==> Configuration for :validatable
# Range for password length
config.password_length = 4..20
# Regex to use to validate the email address
# config.email_regexp = /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i
# ==> Configuration for :timeoutable
# The time you want to timeout the user session without activity. After this
# time the user will be asked for credentials again.
# config.timeout_in = 10.minutes
# ==> Configuration for :lockable
# Defines which strategy will be used to lock an account.
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
# :none = No lock strategy. You should handle locking by yourself.
# config.lock_strategy = :failed_attempts
# Defines which strategy will be used to unlock an account.
# :email = Sends an unlock link to the user email
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
# :both = Enables both strategies
# :none = No unlock strategy. You should handle unlocking by yourself.
# config.unlock_strategy = :both
# Number of authentication tries before locking an account if lock_strategy
# is failed attempts.
# config.maximum_attempts = 20
# Time interval to unlock the account if :time is enabled as unlock_strategy.
# config.unlock_in = 1.hour
# ==> Configuration for :token_authenticatable
# Defines name of the authentication token params key
# config.token_authentication_key = :auth_token
# ==> Scopes configuration
# Turn scoped views on. Before rendering "sessions/new", it will first check for
# "users/sessions/new". It's turned off by default because it's slower if you
# are using only default views.
# config.scoped_views = true
# Configure the default scope given to Warden. By default it's the first
# devise role declared in your routes.
# config.default_scope = :user
# Configure sign_out behavior.
# By default sign_out is scoped (i.e. /users/sign_out affects only :user scope).
# In case of sign_out_all_scopes set to true any logout action will sign out all active scopes.
# config.sign_out_all_scopes = false
# ==> Navigation configuration
# Lists the formats that should be treated as navigational. Formats like
# :html, should redirect to the sign in page when the user does not have
# access, but formats like :xml or :json, should return 401.
# If you have any extra navigational formats, like :iphone or :mobile, you
# should add them to the navigational formats lists. Default is [:html]
# config.navigational_formats = [:html, :iphone]
# ==> Warden configuration
# If you want to use other strategies, that are not (yet) supported by Devise,
# you can configure them inside the config.warden block. The example below
# allows you to setup OAuth, using http://github.com/roman/warden_oauth
#
# config.warden do |manager|
# manager.oauth(:twitter) do |twitter|
# twitter.consumer_secret = <YOUR CONSUMER SECRET>
# twitter.consumer_key = <YOUR CONSUMER KEY>
# twitter.options :site => 'http://twitter.com'
# end
# manager.default_strategies(:scope => :user).unshift :twitter_oauth
# end
end

View File

@ -0,0 +1,23 @@
class CreateRefinerycmsCoreSchema < ActiveRecord::Migration
def self.up
create_table ::Slug.table_name, :force => true do |t|
t.string "name"
t.integer "sluggable_id"
t.integer "sequence", :default => 1, :null => false
t.string "sluggable_type", :limit => 40
t.string "scope", :limit => 40
t.datetime "created_at"
end
add_index ::Slug.table_name, ["name", "sluggable_type", "scope", "sequence"], :name => "index_#{::Slug.table_name}_on_n_s_s_and_s", :unique => true
add_index ::Slug.table_name, ["sluggable_id"], :name => "index_#{::Slug.table_name}_on_sluggable_id"
end
def self.down
[::Slug].reject{|m|
!(defined?(m) and m.respond_to?(:table_name))
}.each do |model|
drop_table model.table_name
end
end
end

View File

@ -0,0 +1,13 @@
class AddLocaleToSlugs < ActiveRecord::Migration
def self.up
add_column :slugs, :locale, :string
add_index :slugs, :locale
end
def self.down
remove_column :slugs, :locale
remove_index :slugs, :locale
end
end

View File

@ -0,0 +1,24 @@
class CreateRefinerycmsSettingsSchema < ActiveRecord::Migration
def self.up
create_table ::RefinerySetting.table_name, :force => true do |t|
t.string "name"
t.text "value"
t.boolean "destroyable", :default => true
t.datetime "created_at"
t.datetime "updated_at"
t.string "scoping"
t.boolean "restricted", :default => false
t.string "callback_proc_as_string"
end
add_index ::RefinerySetting.table_name, ["name"], :name => "index_#{::RefinerySetting.table_name}_on_name"
end
def self.down
[::RefinerySetting].reject{|m|
!(defined?(m) and m.respond_to?(:table_name))
}.each do |model|
drop_table model.table_name
end
end
end

View File

@ -0,0 +1,9 @@
class AddValueTypeToRefinerySettings < ActiveRecord::Migration
def self.up
add_column ::RefinerySetting.table_name, :form_value_type, :string
end
def self.down
remove_column ::RefinerySetting.table_name, :form_value_type
end
end

View File

@ -0,0 +1,43 @@
class CreateRefinerycmsAuthenticationSchema < ActiveRecord::Migration
def self.up
# Postgres apparently requires the roles_users table to exist before creating the roles table.
create_table ::RolesUsers.table_name, :id => false, :force => true do |t|
t.integer "user_id"
t.integer "role_id"
end
create_table ::Role.table_name, :force => true do |t|
t.string "title"
end
create_table ::UserPlugin.table_name, :force => true do |t|
t.integer "user_id"
t.string "name"
t.integer "position"
end
add_index ::UserPlugin.table_name, ["name"], :name => "index_#{::UserPlugin.table_name}_on_title"
add_index ::UserPlugin.table_name, ["user_id", "name"], :name => "index_unique_#{::UserPlugin.table_name}", :unique => true
create_table ::User.table_name, :force => true do |t|
t.string "login", :null => false
t.string "email", :null => false
t.string "crypted_password", :null => false
t.string "password_salt", :null => false
t.string "persistence_token"
t.datetime "created_at"
t.datetime "updated_at"
t.string "perishable_token"
end
add_index ::User.table_name, ["id"], :name => "index_#{::User.table_name}_on_id"
end
def self.down
[::User].reject{|m|
!(defined?(m) and m.respond_to?(:table_name))
}.each do |model|
drop_table model.table_name
end
end
end

View File

@ -0,0 +1,11 @@
class AddMissingIndexesToRolesUsers < ActiveRecord::Migration
def self.up
add_index ::RolesUsers.table_name, [:role_id, :user_id]
add_index ::RolesUsers.table_name, [:user_id, :role_id]
end
def self.down
remove_index ::RolesUsers.table_name, :column => [:role_id, :user_id]
remove_index ::RolesUsers.table_name, :column => [:user_id, :role_id]
end
end

View File

@ -0,0 +1,27 @@
class ChangeToDeviseUsersTable < ActiveRecord::Migration
def self.up
add_column ::User.table_name, :current_sign_in_at, :datetime
add_column ::User.table_name, :last_sign_in_at, :datetime
add_column ::User.table_name, :current_sign_in_ip, :string
add_column ::User.table_name, :last_sign_in_ip, :string
add_column ::User.table_name, :sign_in_count, :integer
add_column ::User.table_name, :remember_token, :string
add_column ::User.table_name, :reset_password_token, :string
rename_column ::User.table_name, :crypted_password, :encrypted_password
rename_column ::User.table_name, :login, :username
end
def self.down
remove_column ::User.table_name, :current_sign_in_at
remove_column ::User.table_name, :last_sign_in_at
remove_column ::User.table_name, :current_sign_in_ip
remove_column ::User.table_name, :last_sign_in_ip
remove_column ::User.table_name, :sign_in_count
remove_column ::User.table_name, :remember_token
remove_column ::User.table_name, :reset_password_token
rename_column ::User.table_name, :encrypted_password, :crypted_password
rename_column ::User.table_name, :username, :login
end
end

View File

@ -0,0 +1,9 @@
class AddRememberCreatedAtToUsers < ActiveRecord::Migration
def self.up
add_column :users, :remember_created_at, :datetime
end
def self.down
remove_column :users, :remember_created_at
end
end

View File

@ -0,0 +1,13 @@
class RemovePasswordSaltFromUsers < ActiveRecord::Migration
def self.up
remove_column :users, :password_salt
# Make the current password invalid :(
User.all.each do |u|
u.update_attribute(:encrypted_password, u.encrypted_password[29..-1])
end
end
def self.down
add_column :users, :password_salt, :string
end
end

View File

@ -0,0 +1,23 @@
class CreateRefinerycmsImagesSchema < ActiveRecord::Migration
def self.up
create_table ::Image.table_name, :force => true do |t|
t.string "image_mime_type"
t.string "image_name"
t.integer "image_size"
t.integer "image_width"
t.integer "image_height"
t.datetime "created_at"
t.datetime "updated_at"
t.string "image_uid"
t.string "image_ext"
end
end
def self.down
[::Image].reject{|m|
!(defined?(m) and m.respond_to?(:table_name))
}.each do |model|
drop_table model.table_name
end
end
end

View File

@ -0,0 +1,52 @@
class CreateRefinerycmsPagesSchema < ActiveRecord::Migration
def self.up
create_table ::PagePart.table_name, :force => true do |t|
t.integer "page_id"
t.string "title"
t.text "body"
t.integer "position"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index ::PagePart.table_name, ["id"], :name => "index_#{::PagePart.table_name}_on_id"
add_index ::PagePart.table_name, ["page_id"], :name => "index_#{::PagePart.table_name}_on_page_id"
create_table ::Page.table_name, :force => true do |t|
t.string "title"
t.integer "parent_id"
t.integer "position"
t.string "path"
t.datetime "created_at"
t.datetime "updated_at"
t.string "meta_keywords"
t.text "meta_description"
t.boolean "show_in_menu", :default => true
t.string "link_url"
t.string "menu_match"
t.boolean "deletable", :default => true
t.string "custom_title"
t.string "custom_title_type", :default => "none"
t.boolean "draft", :default => false
t.string "browser_title"
t.boolean "skip_to_first_child", :default => false
t.integer "lft"
t.integer "rgt"
t.integer "depth"
end
add_index ::Page.table_name, ["depth"], :name => "index_#{::Page.table_name}_on_depth"
add_index ::Page.table_name, ["id"], :name => "index_#{::Page.table_name}_on_id"
add_index ::Page.table_name, ["lft"], :name => "index_#{::Page.table_name}_on_lft"
add_index ::Page.table_name, ["parent_id"], :name => "index_#{::Page.table_name}_on_parent_id"
add_index ::Page.table_name, ["rgt"], :name => "index_#{::Page.table_name}_on_rgt"
end
def self.down
[::Page, ::PagePart].reject{|m|
!(defined?(m) and m.respond_to?(:table_name))
}.each do |model|
drop_table model.table_name
end
end
end

View File

@ -0,0 +1,29 @@
class TranslatePagePlugin < ActiveRecord::Migration
def self.up
PagePart.create_translation_table!({
:body => :text
}, {
:migrate_data => true
})
Page.create_translation_table!({
:title => :string,
:meta_keywords => :string,
:meta_description => :text,
:browser_title => :string
}, {
:migrate_data => true
})
if (seed_file = Rails.root.join('db', 'seeds', 'pages.rb')).file?
load seed_file.to_s unless Page.where(:link_url => '/').any?
end
Slug.update_all(:locale => ::I18n.locale)
end
def self.down
Page.drop_translation_table! :migrate_data => true
PagePart.drop_translation_table! :migrate_data => true
end
end

View File

@ -0,0 +1,11 @@
class RemoveCachedSlugFromPages < ActiveRecord::Migration
def self.up
if ::Page.column_names.map(&:to_s).include?('cached_slug')
remove_column ::Page.table_name, :cached_slug
end
end
def self.down
# Don't add this column back, it breaks stuff.
end
end

View File

@ -0,0 +1,26 @@
class TranslateCustomTitleOnPages < ActiveRecord::Migration
def self.up
unless ::Page::Translation.column_names.map(&:to_sym).include?(:custom_title)
add_column ::Page::Translation.table_name, :custom_title, :string
# Re-save custom_title
::Page.all.each do |page|
page.update_attribute(:custom_title, page.untranslated_attributes['custom_title'])
end
end
end
def self.down
# Re-save custom_title
::Page.all.each do |page|
::Page.update_all({
:custom_title => page.attributes['custom_title']
}, {
:id => page.id.to_s
}) unless page.attributes['custom_title'].nil?
end
remove_column ::Page::Translation.table_name, :custom_title
end
end

View File

@ -0,0 +1,13 @@
class RemoveTranslatedFieldsFromPages < ActiveRecord::Migration
def self.up
::Page.translated_attribute_names.map(&:to_sym).each do |column_name|
remove_column ::Page.table_name, column_name if ::Page.column_names.map(&:to_sym).include?(column_name)
end
end
def self.down
::Page.translated_attribute_names.map(&:to_sym).each do |column_name|
add_column ::Page.table_name, column_name, Page::Translation.columns.detect{|c| c.name.to_sym == column_name}.type
end
end
end

View File

@ -0,0 +1,88 @@
class CreateSeoMeta < ActiveRecord::Migration
def self.up
create_table :seo_meta do |t|
t.integer :seo_meta_id
t.string :seo_meta_type
t.string :browser_title
t.string :meta_keywords
t.text :meta_description
t.timestamps
end
add_index :seo_meta, :id
add_index :seo_meta, [:seo_meta_id, :seo_meta_type]
# Grab the attributes of the records that currently exist
existing_translations = ::Page::Translation.all.map(&:attributes)
# Remove columns
::SeoMeta.attributes.keys.each do |field|
if ::Page::Translation.column_names.map(&:to_sym).include?(field)
remove_column ::Page::Translation.table_name, field
end
end
# Reset column information because otherwise the old columns will still exist.
::Page::Translation.reset_column_information
# Re-attach seo_meta
::Page::Translation.module_eval do
is_seo_meta
end
# Migrate data
existing_translations.each do |translation|
::Page::Translation.find(translation['id']).update_attributes(
::SeoMeta.attributes.keys.inject({}) {|attributes, name|
attributes.merge(name => translation[name.to_s])
}
)
end
# Reset column information again because otherwise the old columns will still exist.
::Page.reset_column_information
end
def self.down
# Grab the attributes of the records that currently exist
existing_translations = ::Page::Translation.all.map(&:attributes)
# Add columns back to your model
::SeoMeta.attributes.each do |field, field_type|
unless ::Page::Translation.column_names.map(&:to_sym).include?(field)
add_column ::Page::Translation.table_name, field, field_type
end
end
# Reset column information because otherwise the new columns won't exist yet.
::Page::Translation.reset_column_information
# Migrate data
existing_translations.each do |translation|
::Page::Translation.update_all(
::SeoMeta.attributes.keys.inject({}) {|attributes, name|
attributes.merge(name => translation[name.to_s])
}, :id => translation['id']
)
end
::SeoMeta.attributes.keys.each do |k|
::Page::Translation.module_eval %{
def #{k}
end
def #{k}=(*args)
end
}
end
# Reset column information again because otherwise the old columns will still exist.
::Page.reset_column_information
drop_table :seo_meta
end
end

View File

@ -0,0 +1,21 @@
class CreateRefinerycmsResourcesSchema < ActiveRecord::Migration
def self.up
create_table ::Resource.table_name, :force => true do |t|
t.string "file_mime_type"
t.string "file_name"
t.integer "file_size"
t.datetime "created_at"
t.datetime "updated_at"
t.string "file_uid"
t.string "file_ext"
end
end
def self.down
[::Resource].reject{|m|
!(defined?(m) and m.respond_to?(:table_name))
}.each do |model|
drop_table model.table_name
end
end
end

View File

@ -0,0 +1,54 @@
class CreateBlogStructure < ActiveRecord::Migration
def self.up
create_table :blog_posts, :id => true do |t|
t.string :title
t.text :body
t.boolean :draft
t.datetime :published_at
t.timestamps
end
add_index :blog_posts, :id
create_table :blog_comments, :id => true do |t|
t.integer :blog_post_id
t.boolean :spam
t.string :name
t.string :email
t.text :body
t.string :state
t.timestamps
end
add_index :blog_comments, :id
create_table :blog_categories, :id => true do |t|
t.string :title
t.timestamps
end
add_index :blog_categories, :id
create_table :blog_categories_blog_posts, :id => false do |t|
t.integer :blog_category_id
t.integer :blog_post_id
end
add_index :blog_categories_blog_posts, [:blog_category_id, :blog_post_id], :name => 'index_blog_categories_blog_posts_on_bc_and_bp'
load(Rails.root.join('db', 'seeds', 'refinerycms_blog.rb').to_s)
end
def self.down
UserPlugin.destroy_all({:name => "refinerycms_blog"})
Page.delete_all({:link_url => "/blog"})
drop_table :blog_posts
drop_table :blog_comments
drop_table :blog_categories
drop_table :blog_categories_blog_posts
end
end

View File

@ -0,0 +1,11 @@
class AddUserIdToBlogPosts < ActiveRecord::Migration
def self.up
add_column :blog_posts, :user_id, :integer
end
def self.down
remove_column :blog_posts, :user_id
end
end

216
spec/dummy/db/schema.rb Normal file
View File

@ -0,0 +1,216 @@
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20110601190333) do
create_table "blog_categories", :force => true do |t|
t.string "title"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "blog_categories", ["id"], :name => "index_blog_categories_on_id"
create_table "blog_categories_blog_posts", :id => false, :force => true do |t|
t.integer "blog_category_id"
t.integer "blog_post_id"
end
add_index "blog_categories_blog_posts", ["blog_category_id", "blog_post_id"], :name => "index_blog_categories_blog_posts_on_bc_and_bp"
create_table "blog_comments", :force => true do |t|
t.integer "blog_post_id"
t.boolean "spam"
t.string "name"
t.string "email"
t.text "body"
t.string "state"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "blog_comments", ["id"], :name => "index_blog_comments_on_id"
create_table "blog_posts", :force => true do |t|
t.string "title"
t.text "body"
t.boolean "draft"
t.datetime "published_at"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "user_id"
end
add_index "blog_posts", ["id"], :name => "index_blog_posts_on_id"
create_table "images", :force => true do |t|
t.string "image_mime_type"
t.string "image_name"
t.integer "image_size"
t.integer "image_width"
t.integer "image_height"
t.datetime "created_at"
t.datetime "updated_at"
t.string "image_uid"
t.string "image_ext"
end
create_table "page_part_translations", :force => true do |t|
t.integer "page_part_id"
t.string "locale"
t.text "body"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "page_part_translations", ["page_part_id"], :name => "index_page_part_translations_on_page_part_id"
create_table "page_parts", :force => true do |t|
t.integer "page_id"
t.string "title"
t.text "body"
t.integer "position"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "page_parts", ["id"], :name => "index_page_parts_on_id"
add_index "page_parts", ["page_id"], :name => "index_page_parts_on_page_id"
create_table "page_translations", :force => true do |t|
t.integer "page_id"
t.string "locale"
t.string "title"
t.string "custom_title"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "page_translations", ["page_id"], :name => "index_page_translations_on_page_id"
create_table "pages", :force => true do |t|
t.integer "parent_id"
t.integer "position"
t.string "path"
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "show_in_menu", :default => true
t.string "link_url"
t.string "menu_match"
t.boolean "deletable", :default => true
t.string "custom_title_type", :default => "none"
t.boolean "draft", :default => false
t.boolean "skip_to_first_child", :default => false
t.integer "lft"
t.integer "rgt"
t.integer "depth"
end
add_index "pages", ["depth"], :name => "index_pages_on_depth"
add_index "pages", ["id"], :name => "index_pages_on_id"
add_index "pages", ["lft"], :name => "index_pages_on_lft"
add_index "pages", ["parent_id"], :name => "index_pages_on_parent_id"
add_index "pages", ["rgt"], :name => "index_pages_on_rgt"
create_table "refinery_settings", :force => true do |t|
t.string "name"
t.text "value"
t.boolean "destroyable", :default => true
t.datetime "created_at"
t.datetime "updated_at"
t.string "scoping"
t.boolean "restricted", :default => false
t.string "callback_proc_as_string"
t.string "form_value_type"
end
add_index "refinery_settings", ["name"], :name => "index_refinery_settings_on_name"
create_table "resources", :force => true do |t|
t.string "file_mime_type"
t.string "file_name"
t.integer "file_size"
t.datetime "created_at"
t.datetime "updated_at"
t.string "file_uid"
t.string "file_ext"
end
create_table "roles", :force => true do |t|
t.string "title"
end
create_table "roles_users", :id => false, :force => true do |t|
t.integer "user_id"
t.integer "role_id"
end
add_index "roles_users", ["role_id", "user_id"], :name => "index_roles_users_on_role_id_and_user_id"
add_index "roles_users", ["user_id", "role_id"], :name => "index_roles_users_on_user_id_and_role_id"
create_table "seo_meta", :force => true do |t|
t.integer "seo_meta_id"
t.string "seo_meta_type"
t.string "browser_title"
t.string "meta_keywords"
t.text "meta_description"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "seo_meta", ["id"], :name => "index_seo_meta_on_id"
add_index "seo_meta", ["seo_meta_id", "seo_meta_type"], :name => "index_seo_meta_on_seo_meta_id_and_seo_meta_type"
create_table "slugs", :force => true do |t|
t.string "name"
t.integer "sluggable_id"
t.integer "sequence", :default => 1, :null => false
t.string "sluggable_type", :limit => 40
t.string "scope", :limit => 40
t.datetime "created_at"
t.string "locale"
end
add_index "slugs", ["locale"], :name => "index_slugs_on_locale"
add_index "slugs", ["name", "sluggable_type", "scope", "sequence"], :name => "index_slugs_on_n_s_s_and_s", :unique => true
add_index "slugs", ["sluggable_id"], :name => "index_slugs_on_sluggable_id"
create_table "user_plugins", :force => true do |t|
t.integer "user_id"
t.string "name"
t.integer "position"
end
add_index "user_plugins", ["name"], :name => "index_user_plugins_on_title"
add_index "user_plugins", ["user_id", "name"], :name => "index_unique_user_plugins", :unique => true
create_table "users", :force => true do |t|
t.string "username", :null => false
t.string "email", :null => false
t.string "encrypted_password", :null => false
t.string "persistence_token"
t.datetime "created_at"
t.datetime "updated_at"
t.string "perishable_token"
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
t.integer "sign_in_count"
t.string "remember_token"
t.string "reset_password_token"
t.datetime "remember_created_at"
end
add_index "users", ["id"], :name => "index_users_on_id"
end

5
spec/dummy/db/seeds.rb Normal file
View File

@ -0,0 +1,5 @@
# Refinery seeds
Dir[Rails.root.join('db', 'seeds', '*.rb').to_s].each do |file|
puts "Loading db/seeds/#{file.split(File::SEPARATOR).last}"
load(file)
end

View File

@ -0,0 +1,42 @@
page_position = -1
home_page = Page.create(:title => "Home",
:deletable => false,
:link_url => "/",
:position => (page_position += 1))
home_page.parts.create({
:title => "Body",
:body => "<p>Welcome to our site. This is just a place holder page while we gather our content.</p>",
:position => 0
})
home_page.parts.create({
:title => "Side Body",
:body => "<p>This is another block of content over here.</p>",
:position => 1
})
home_page_position = -1
page_not_found_page = home_page.children.create(:title => "Page not found",
:menu_match => "^/404$",
:show_in_menu => false,
:deletable => false,
:position => (home_page_position += 1))
page_not_found_page.parts.create({
:title => "Body",
:body => "<h2>Sorry, there was a problem...</h2><p>The page you requested was not found.</p><p><a href='/'>Return to the home page</a></p>",
:position => 0
})
about_us_page = Page.create(:title => "About",
:deletable => true,
:position => (page_position += 1))
about_us_page.parts.create({
:title => "Body",
:body => "<p>This is just a standard text page example. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin metus dolor, hendrerit sit amet, aliquet nec, posuere sed, purus. Nullam et velit iaculis odio sagittis placerat. Duis metus tellus, pellentesque ut, luctus id, egestas a, lorem. Praesent vitae mauris. Aliquam sed nulla. Sed id nunc vitae leo suscipit viverra. Proin at leo ut lacus consequat rhoncus. In hac habitasse platea dictumst. Nunc quis tortor sed libero hendrerit dapibus.\n\nInteger interdum purus id erat. Duis nec velit vitae dolor mattis euismod. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Suspendisse pellentesque dignissim lacus. Nulla semper euismod arcu. Suspendisse egestas, erat a consectetur dapibus, felis orci cursus eros, et sollicitudin purus urna et metus. Integer eget est sed nunc euismod vestibulum. Integer nulla dui, tristique in, euismod et, interdum imperdiet, enim. Mauris at lectus. Sed egestas tortor nec mi.</p>",
:position => 0
})
about_us_page.parts.create({
:title => "Side Body",
:body => "<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus fringilla nisi a elit. Duis ultricies orci ut arcu. Ut ac nibh. Duis blandit rhoncus magna. Pellentesque semper risus ut magna. Etiam pulvinar tellus eget diam. Morbi blandit. Donec pulvinar mauris at ligula. Sed pellentesque, ipsum id congue molestie, lectus risus egestas pede, ac viverra diam lacus ac urna. Aenean elit.</p>",
:position => 1
})

View File

@ -0,0 +1,16 @@
User.find(:all).each do |user|
user.plugins.create(:name => "refinerycms_blog",
:position => (user.plugins.maximum(:position) || -1) +1)
end
page = Page.create(
:title => "Blog",
:link_url => "/blog",
:deletable => false,
:position => ((Page.maximum(:position, :conditions => {:parent_id => nil}) || -1)+1),
:menu_match => "^/blogs?(\/|\/.+?|)$"
)
Page.default_parts.each do |default_page_part|
page.parts.create(:title => default_page_part, :body => nil)
end

View File

@ -0,0 +1,7 @@
// Use this to customize the wymeditor boot process
// Just mirror the options specified in boot_wym.js with the new options here.
// This will completely override anything specified in boot_wym.js for that key.
// e.g. skin: 'something_else'
var custom_wymeditor_boot_options = {
};

View File

@ -1,191 +0,0 @@
(function() {
// Technique from Juriy Zaytsev
// http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
function isEventSupported(eventName) {
var el = document.createElement('div');
eventName = 'on' + eventName;
var isSupported = (eventName in el);
if (!isSupported) {
el.setAttribute(eventName, 'return;');
isSupported = typeof el[eventName] == 'function';
}
el = null;
return isSupported;
}
function isForm(element) {
return Object.isElement(element) && element.nodeName.toUpperCase() == 'FORM'
}
function isInput(element) {
if (Object.isElement(element)) {
var name = element.nodeName.toUpperCase()
return name == 'INPUT' || name == 'SELECT' || name == 'TEXTAREA'
}
else return false
}
var submitBubbles = isEventSupported('submit'),
changeBubbles = isEventSupported('change')
if (!submitBubbles || !changeBubbles) {
// augment the Event.Handler class to observe custom events when needed
Event.Handler.prototype.initialize = Event.Handler.prototype.initialize.wrap(
function(init, element, eventName, selector, callback) {
init(element, eventName, selector, callback)
// is the handler being attached to an element that doesn't support this event?
if ( (!submitBubbles && this.eventName == 'submit' && !isForm(this.element)) ||
(!changeBubbles && this.eventName == 'change' && !isInput(this.element)) ) {
// "submit" => "emulated:submit"
this.eventName = 'emulated:' + this.eventName
}
}
)
}
if (!submitBubbles) {
// discover forms on the page by observing focus events which always bubble
document.on('focusin', 'form', function(focusEvent, form) {
// special handler for the real "submit" event (one-time operation)
if (!form.retrieve('emulated:submit')) {
form.on('submit', function(submitEvent) {
var emulated = form.fire('emulated:submit', submitEvent, true)
// if custom event received preventDefault, cancel the real one too
if (emulated.returnValue === false) submitEvent.preventDefault()
})
form.store('emulated:submit', true)
}
})
}
if (!changeBubbles) {
// discover form inputs on the page
document.on('focusin', 'input, select, texarea', function(focusEvent, input) {
// special handler for real "change" events
if (!input.retrieve('emulated:change')) {
input.on('change', function(changeEvent) {
input.fire('emulated:change', changeEvent, true)
})
input.store('emulated:change', true)
}
})
}
function handleRemote(element) {
var method, url, params;
var event = element.fire("ajax:before");
if (event.stopped) return false;
if (element.tagName.toLowerCase() === 'form') {
method = element.readAttribute('method') || 'post';
url = element.readAttribute('action');
params = element.serialize();
} else {
method = element.readAttribute('data-method') || 'get';
url = element.readAttribute('href');
params = {};
}
new Ajax.Request(url, {
method: method,
parameters: params,
evalScripts: true,
onComplete: function(request) { element.fire("ajax:complete", request); },
onSuccess: function(request) { element.fire("ajax:success", request); },
onFailure: function(request) { element.fire("ajax:failure", request); }
});
element.fire("ajax:after");
}
function handleMethod(element) {
var method = element.readAttribute('data-method'),
url = element.readAttribute('href'),
csrf_param = $$('meta[name=csrf-param]')[0],
csrf_token = $$('meta[name=csrf-token]')[0];
var form = new Element('form', { method: "POST", action: url, style: "display: none;" });
element.parentNode.insert(form);
if (method !== 'post') {
var field = new Element('input', { type: 'hidden', name: '_method', value: method });
form.insert(field);
}
if (csrf_param) {
var param = csrf_param.readAttribute('content'),
token = csrf_token.readAttribute('content'),
field = new Element('input', { type: 'hidden', name: param, value: token });
form.insert(field);
}
form.submit();
}
document.on("click", "*[data-confirm]", function(event, element) {
var message = element.readAttribute('data-confirm');
if (!confirm(message)) event.stop();
});
document.on("click", "a[data-remote]", function(event, element) {
if (event.stopped) return;
handleRemote(element);
event.stop();
});
document.on("click", "a[data-method]", function(event, element) {
if (event.stopped) return;
handleMethod(element);
event.stop();
});
document.on("submit", function(event) {
var element = event.findElement(),
message = element.readAttribute('data-confirm');
if (message && !confirm(message)) {
event.stop();
return false;
}
var inputs = element.select("input[type=submit][data-disable-with]");
inputs.each(function(input) {
input.disabled = true;
input.writeAttribute('data-original-value', input.value);
input.value = input.readAttribute('data-disable-with');
});
var element = event.findElement("form[data-remote]");
if (element) {
handleRemote(element);
event.stop();
}
});
document.on("ajax:after", "form", function(event, element) {
var inputs = element.select("input[type=submit][disabled=true][data-disable-with]");
inputs.each(function(input) {
input.value = input.readAttribute('data-original-value');
input.removeAttribute('data-original-value');
input.disabled = false;
});
});
Ajax.Responders.register({
onCreate: function(request) {
var csrf_meta_tag = $$('meta[name=csrf-token]')[0];
if (csrf_meta_tag) {
var header = 'X-CSRF-Token',
token = csrf_meta_tag.readAttribute('content');
if (!request.options.requestHeaders) {
request.options.requestHeaders = {};
}
request.options.requestHeaders[header] = token;
}
}
});
})();

View File

@ -0,0 +1,4 @@
/*
Override default refinery application CSS below.
Formatting applies to all frontend.
*/

View File

@ -0,0 +1,4 @@
/*
Override default refinery formatting below.
Formatting applies to backend WYSIWYG editors and all frontend.
*/

View File

@ -0,0 +1,4 @@
/*
Override default refinery homepage styles here.
These only apply to the homepage of your site.
*/

View File

@ -0,0 +1,4 @@
/*
Override default refinery 'theme' styles here.
These only apply when using custom WYMeditor CSS.
*/

View File

@ -1,8 +1,6 @@
require 'spec_helper'
describe "Navigation" do
include Capybara
describe "Rails project" do
it "should be a valid app" do
::Rails.application.should be_a(Dummy::Application)
end

View File

@ -1,7 +1,7 @@
require 'spec_helper'
describe Refinerycms-wordpress-import do
describe Refinery::WordPress do
it "should be valid" do
Refinerycms-wordpress-import.should be_a(Module)
Refinery::WordPress.should be_a(Module)
end
end

View File

@ -11,11 +11,6 @@ ActionMailer::Base.default_url_options[:host] = "test.com"
Rails.backtrace_cleaner.remove_silencers!
# Configure capybara for integration testing
require "capybara/rails"
Capybara.default_driver = :rack_test
Capybara.default_selector = :css
# Run any available migration
ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)