Skip to content

Commit

Permalink
Generated enrichments
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Engel committed Nov 9, 2010
1 parent 3ef2158 commit 7c59cfe
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/cms_content.rb
@@ -0,0 +1,2 @@
class CmsContent < ActiveRecord::Base
end
7 changes: 7 additions & 0 deletions app/models/translation.rb
@@ -0,0 +1,7 @@
class Translation < ActiveRecord::Base

def to_rich_cms_response(params)
{:value => value, :translations => Hash[*params[:derivative_keys].split(";").uniq.collect{|x| [x, x.t({:as => params[:editable_input_type]})]}.flatten]}
end

end
8 changes: 8 additions & 0 deletions app/models/user.rb
@@ -0,0 +1,8 @@
class User < ActiveRecord::Base

acts_as_authentic do |c|
c.login_field = :email
c.crypted_password_field = :crypted_password
end

end
11 changes: 11 additions & 0 deletions app/models/user_session.rb
@@ -0,0 +1,11 @@
class UserSession < Authlogic::Session::Base

authenticate_with User
generalize_credentials_error_messages true
params_key "user_credentials"

def to_key
new_record? ? nil : [self.send self.class.primary_key]
end

end
4 changes: 4 additions & 0 deletions config/initializers/enrichments.rb
@@ -0,0 +1,4 @@

Rich::Cms::Engine.authenticate(:authlogic, {:class_name => "User", :identifier => :email})
Rich::Cms::Engine.register(".cms_content", {:class_name => "CmsContent"})
Rich::I18n::Engine.enable_i18n_cms
25 changes: 25 additions & 0 deletions db/migrate/20101109015924_create_users.rb
@@ -0,0 +1,25 @@
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :name
t.string :email
t.string :crypted_password
t.string :password_salt
t.datetime :created_at
t.string :persistence_token , :default => "", :null => false
t.string :single_access_token, :default => "", :null => false
t.string :perishable_token , :default => "", :null => false
t.integer :login_count
t.datetime :last_request_at
t.datetime :current_login_at
t.datetime :last_login_at
t.timestamps
end

add_index :users, :email
end

def self.down
drop_table :users
end
end
15 changes: 15 additions & 0 deletions db/migrate/20101109015929_create_cms_contents.rb
@@ -0,0 +1,15 @@
class CreateCmsContents < ActiveRecord::Migration
def self.up
create_table :cms_contents do |t|
t.string :key
t.text :value
t.timestamps
end

add_index :cms_contents, :key
end

def self.down
drop_table :cms_contents
end
end
18 changes: 18 additions & 0 deletions db/migrate/20101109015932_create_translations.rb
@@ -0,0 +1,18 @@
class CreateTranslations < ActiveRecord::Migration
def self.up
create_table :translations do |t|
t.string :locale
t.string :key
t.text :value
t.boolean :is_proc, :default => false
t.timestamps
end

add_index :translations, :locale
add_index :translations, :key
end

def self.down
drop_table :translations
end
end
11 changes: 11 additions & 0 deletions test/fixtures/cms_contents.yml
@@ -0,0 +1,11 @@
# Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html

# This model initially had no columns defined. If you add columns to the
# model remove the '{}' from the fixture names and add the columns immediately
# below each fixture, per the syntax in the comments below
#
one: {}
# column: value
#
two: {}
# column: value
8 changes: 8 additions & 0 deletions test/unit/cms_content_test.rb
@@ -0,0 +1,8 @@
require 'test_helper'

class CmsContentTest < ActiveSupport::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end

0 comments on commit 7c59cfe

Please sign in to comment.