engine_room 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +10 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +159 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +44 -0
- data/Rakefile +30 -0
- data/TODO +3 -0
- data/app/controllers/engine_room/content_controller.rb +117 -0
- data/app/controllers/engine_room/fields_controller.rb +119 -0
- data/app/controllers/engine_room/models_controller.rb +89 -0
- data/app/controllers/engine_room/pages_controller.rb +17 -0
- data/app/controllers/engine_room/sections_controller.rb +74 -0
- data/app/controllers/engine_room/users_controller.rb +84 -0
- data/app/controllers/er_devise/passwords_controller.rb +6 -0
- data/app/controllers/er_devise/registrations_controller.rb +8 -0
- data/app/controllers/er_devise/sessions_controller.rb +6 -0
- data/app/helpers/engine_room/content_helper.rb +103 -0
- data/app/helpers/engine_room/models_helper.rb +21 -0
- data/app/models/field.rb +89 -0
- data/app/models/section.rb +68 -0
- data/app/models/user.rb +31 -0
- data/app/views/engine_room/content/_form.html.erb +13 -0
- data/app/views/engine_room/content/_overview.html.erb +28 -0
- data/app/views/engine_room/content/_sidebar.html.erb +14 -0
- data/app/views/engine_room/content/edit.html.erb +38 -0
- data/app/views/engine_room/content/index.html.erb +1 -0
- data/app/views/engine_room/content/new.html.erb +1 -0
- data/app/views/engine_room/content/overview.html.erb +3 -0
- data/app/views/engine_room/fields/_form.html.erb +57 -0
- data/app/views/engine_room/fields/edit.html.erb +1 -0
- data/app/views/engine_room/fields/new.html.erb +1 -0
- data/app/views/engine_room/models/_form.html.erb +0 -0
- data/app/views/engine_room/models/edit.html.erb +14 -0
- data/app/views/engine_room/models/index.html.erb +16 -0
- data/app/views/engine_room/models/new.html.erb +14 -0
- data/app/views/engine_room/models/overview.html.erb +14 -0
- data/app/views/engine_room/pages/dashboard.html.erb +1 -0
- data/app/views/engine_room/pages/settings.html.erb +1 -0
- data/app/views/engine_room/sections/_form.html.erb +34 -0
- data/app/views/engine_room/sections/_sidebar.html.erb +11 -0
- data/app/views/engine_room/sections/edit.html.erb +81 -0
- data/app/views/engine_room/sections/index.html.erb +3 -0
- data/app/views/engine_room/sections/new.html.erb +1 -0
- data/app/views/engine_room/users/_form.html.erb +47 -0
- data/app/views/engine_room/users/edit.html.erb +11 -0
- data/app/views/engine_room/users/index.html.erb +24 -0
- data/app/views/engine_room/users/new.html.erb +1 -0
- data/app/views/er_devise/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/er_devise/mailer/reset_password_instructions.html.erb +8 -0
- data/app/views/er_devise/mailer/unlock_instructions.html.erb +7 -0
- data/app/views/er_devise/passwords/edit.html.erb +16 -0
- data/app/views/er_devise/passwords/new.html.erb +13 -0
- data/app/views/er_devise/registrations/edit.html.erb +42 -0
- data/app/views/er_devise/registrations/new.html.erb +21 -0
- data/app/views/er_devise/sessions/new.html.erb +23 -0
- data/app/views/er_devise/shared/_links.erb +19 -0
- data/app/views/layouts/engine_room.html.erb +103 -0
- data/app/views/layouts/login.html.erb +71 -0
- data/app/views/shared/_content_layout_selector.html.erb +45 -0
- data/app/views/shared/_error_messages.html.erb +17 -0
- data/config/initializers/devise.rb +146 -0
- data/config/initializers/locale.rb +5 -0
- data/config/locales/devise.de.yml +42 -0
- data/config/locales/devise.en.yml +39 -0
- data/config/locales/engine_room.de.yml +33 -0
- data/config/locales/engine_room.en.yml +42 -0
- data/config/routes.rb +62 -0
- data/engine_room.gemspec +35 -0
- data/lib/engine_room.rb +17 -0
- data/lib/engine_room/action_controller/controller_methods.rb +21 -0
- data/lib/engine_room/action_view/view_methods.rb +8 -0
- data/lib/engine_room/active_record/record_methods.rb +18 -0
- data/lib/engine_room/crummy/custom_renderer.rb +63 -0
- data/lib/engine_room/engine.rb +40 -0
- data/lib/engine_room/railties/tasks.rake +6 -0
- data/lib/engine_room/version.rb +3 -0
- data/lib/generators/engine_room/create_image_generator.rb +26 -0
- data/lib/generators/engine_room/setup_generator.rb +30 -0
- data/lib/generators/engine_room/templates/001_devise_create_users.rb +28 -0
- data/lib/generators/engine_room/templates/002_create_sections.rb +16 -0
- data/lib/generators/engine_room/templates/003_create_fields.rb +18 -0
- data/lib/generators/engine_room/templates/004_create_images.rb +19 -0
- data/lib/generators/engine_room/templates/image.rb +4 -0
- data/lib/tasks/dummy.rake +45 -0
- data/lib/tasks/templates/migrate/050_create_dogs.rb +18 -0
- data/lib/tasks/templates/models/dog.rb +3 -0
- data/public/images/er/accept.png +0 -0
- data/public/images/er/add.png +0 -0
- data/public/images/er/add_small.png +0 -0
- data/public/images/er/ajax-loader.gif +0 -0
- data/public/images/er/attach.png +0 -0
- data/public/images/er/back_disabled.jpg +0 -0
- data/public/images/er/back_enabled.jpg +0 -0
- data/public/images/er/bg/header_gradient_center.jpg +0 -0
- data/public/images/er/bg/header_gradient_left.jpg +0 -0
- data/public/images/er/bg/header_gradient_right.jpg +0 -0
- data/public/images/er/cancel.png +0 -0
- data/public/images/er/cog.png +0 -0
- data/public/images/er/database_add.png +0 -0
- data/public/images/er/delete.png +0 -0
- data/public/images/er/delete_small.png +0 -0
- data/public/images/er/down_arrow.gif +0 -0
- data/public/images/er/down_arrow.png +0 -0
- data/public/images/er/email.png +0 -0
- data/public/images/er/exclamation.png +0 -0
- data/public/images/er/forward_disabled.jpg +0 -0
- data/public/images/er/forward_enabled.jpg +0 -0
- data/public/images/er/help.png +0 -0
- data/public/images/er/image_add.png +0 -0
- data/public/images/er/information.png +0 -0
- data/public/images/er/link.png +0 -0
- data/public/images/er/loader.gif +0 -0
- data/public/images/er/telephone.png +0 -0
- data/public/images/er/up_arrow.gif +0 -0
- data/public/images/er/up_arrow.png +0 -0
- data/public/images/er/user.png +0 -0
- data/public/images/er/wrench.png +0 -0
- data/public/images/er/zoom.png +0 -0
- data/public/javascripts/er/dd_belatedpng.js +328 -0
- data/public/javascripts/er/fancybox/blank.gif +0 -0
- data/public/javascripts/er/fancybox/fancy_close.png +0 -0
- data/public/javascripts/er/fancybox/fancy_loading.png +0 -0
- data/public/javascripts/er/fancybox/fancy_nav_left.png +0 -0
- data/public/javascripts/er/fancybox/fancy_nav_right.png +0 -0
- data/public/javascripts/er/fancybox/fancy_shadow_e.png +0 -0
- data/public/javascripts/er/fancybox/fancy_shadow_n.png +0 -0
- data/public/javascripts/er/fancybox/fancy_shadow_ne.png +0 -0
- data/public/javascripts/er/fancybox/fancy_shadow_nw.png +0 -0
- data/public/javascripts/er/fancybox/fancy_shadow_s.png +0 -0
- data/public/javascripts/er/fancybox/fancy_shadow_se.png +0 -0
- data/public/javascripts/er/fancybox/fancy_shadow_sw.png +0 -0
- data/public/javascripts/er/fancybox/fancy_shadow_w.png +0 -0
- data/public/javascripts/er/fancybox/fancy_title_left.png +0 -0
- data/public/javascripts/er/fancybox/fancy_title_main.png +0 -0
- data/public/javascripts/er/fancybox/fancy_title_over.png +0 -0
- data/public/javascripts/er/fancybox/fancy_title_right.png +0 -0
- data/public/javascripts/er/fancybox/fancybox-x.png +0 -0
- data/public/javascripts/er/fancybox/fancybox-y.png +0 -0
- data/public/javascripts/er/fancybox/fancybox.png +0 -0
- data/public/javascripts/er/fancybox/jquery.fancybox-1.3.4.css +359 -0
- data/public/javascripts/er/fancybox/jquery.fancybox-1.3.4.pack.js +46 -0
- data/public/javascripts/er/jquery-1.4.4.min.js +167 -0
- data/public/javascripts/er/jquery-ui-1.8.6.custom.min.js +477 -0
- data/public/javascripts/er/modernizr-1.5.min.js +28 -0
- data/public/javascripts/er/plugins.js +48 -0
- data/public/javascripts/er/rails.js +156 -0
- data/public/javascripts/er/script.js +50 -0
- data/public/stylesheets/.gitkeep +0 -0
- data/public/stylesheets/admin.css +417 -0
- data/public/stylesheets/boilerplate.css +264 -0
- data/public/stylesheets/handheld.css +7 -0
- data/public/stylesheets/login.css +125 -0
- data/public/stylesheets/skin.css +2 -0
- data/public/stylesheets/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/public/stylesheets/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/public/stylesheets/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/public/stylesheets/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/public/stylesheets/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/public/stylesheets/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/public/stylesheets/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/public/stylesheets/smoothness/jquery-ui-1.8.6.custom.css +479 -0
- data/spec/controllers/content_controller_spec.rb +132 -0
- data/spec/controllers/fields_controller_spec.rb +103 -0
- data/spec/controllers/models_controller_spec.rb +65 -0
- data/spec/controllers/pages_controller_spec.rb +40 -0
- data/spec/controllers/sections_controller_spec.rb +124 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +45 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +22 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +26 -0
- data/spec/dummy/config/environments/production.rb +49 -0
- data/spec/dummy/config/environments/test.rb +35 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +10 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +58 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +26 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/public/javascripts/application.js +2 -0
- data/spec/dummy/public/javascripts/controls.js +965 -0
- data/spec/dummy/public/javascripts/dragdrop.js +974 -0
- data/spec/dummy/public/javascripts/effects.js +1123 -0
- data/spec/dummy/public/javascripts/prototype.js +6001 -0
- data/spec/dummy/public/javascripts/rails.js +175 -0
- data/spec/dummy/public/stylesheets/.gitkeep +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/engine_room_spec.rb +7 -0
- data/spec/factories.rb +32 -0
- data/spec/integration/navigation_spec.rb +9 -0
- data/spec/models/dog_spec.rb +14 -0
- data/spec/models/field_spec.rb +74 -0
- data/spec/models/section_spec.rb +70 -0
- data/spec/models/user_spec.rb +77 -0
- data/spec/routing/models_routing_spec.rb +66 -0
- data/spec/spec_helper.rb +39 -0
- data/spec/support/devise.rb +3 -0
- metadata +492 -0
data/lib/engine_room.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
module EngineRoom
|
2
|
+
|
3
|
+
if defined? Rails
|
4
|
+
#Dir.glob(Rails.root.to_s + '/app/models/*.rb').each { |file| require file }
|
5
|
+
|
6
|
+
require 'engine_room/engine'
|
7
|
+
|
8
|
+
require 'devise'
|
9
|
+
require 'will_paginate'
|
10
|
+
require 'paperclip'
|
11
|
+
require 'crummy'
|
12
|
+
|
13
|
+
require 'engine_room/action_controller/controller_methods'
|
14
|
+
require 'engine_room/action_view/view_methods'
|
15
|
+
require 'engine_room/active_record/record_methods'
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module EngineRoom::ControllerMethods
|
2
|
+
|
3
|
+
def self.included(base)
|
4
|
+
base.module_eval do
|
5
|
+
helper_attr :current_user
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def current_user
|
10
|
+
current_er_devise_user
|
11
|
+
end
|
12
|
+
|
13
|
+
def authorize
|
14
|
+
unless current_er_devise_user.is_admin?
|
15
|
+
flash[:alert] = "Access denied"
|
16
|
+
redirect_to engine_room_root_url
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
ActionController::Base.send :include, EngineRoom::ControllerMethods
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module EngineRoom::RecordMethods
|
2
|
+
|
3
|
+
#def self.included(base)
|
4
|
+
# base.module_eval do
|
5
|
+
# helper_attr :current_user
|
6
|
+
# end
|
7
|
+
#end
|
8
|
+
|
9
|
+
#def current_user
|
10
|
+
# current_er_devise_user
|
11
|
+
#end
|
12
|
+
|
13
|
+
def object_to_boolean(value)
|
14
|
+
return [true, "true", 1, "1", "T", "t"].include?(value.class == String ? value.downcase : value)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
ActiveRecord::Base.send :include, EngineRoom::RecordMethods
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Crummy
|
4
|
+
class CustomRenderer
|
5
|
+
include ActionView::Helpers::UrlHelper
|
6
|
+
|
7
|
+
# Render the list of crumbs as either html or xml
|
8
|
+
#
|
9
|
+
# Takes 3 options:
|
10
|
+
# The output format. Can either be xml or html. Default :html
|
11
|
+
# :format => (:html|:xml)
|
12
|
+
# The seperator text. It does not assume you want spaces on either side so you must specify. Default +»+ for :html and +crumb+ for xml
|
13
|
+
# :seperator => string
|
14
|
+
# Render links in the output. Default +true+
|
15
|
+
# :link => boolean
|
16
|
+
#
|
17
|
+
# Examples:
|
18
|
+
# render_crumbs #=> <a href="/">Home</a> » <a href="/businesses">Businesses</a>
|
19
|
+
# render_crumbs :seperator => ' | ' #=> <a href="/">Home</a> | <a href="/businesses">Businesses</a>
|
20
|
+
# render_crumbs :format => :xml #=> <crumb href="/">Home</crumb><crumb href="/businesses">Businesses</crumb>
|
21
|
+
#
|
22
|
+
# The only argument is for the seperator text. It does not assume you want spaces on either side so you must specify. Defaults to +»+
|
23
|
+
#
|
24
|
+
# render_crumbs(" . ") #=> <a href="/">Home</a> . <a href="/businesses">Businesses</a>
|
25
|
+
#
|
26
|
+
def render_crumbs(crumbs, options = {})
|
27
|
+
options[:format] = :html if options[:format] == nil
|
28
|
+
if options[:seperator] == nil
|
29
|
+
options[:seperator] = " » " if options[:format] == :html
|
30
|
+
options[:seperator] = "crumb" if options[:format] == :xml
|
31
|
+
end
|
32
|
+
options[:links] = true if options[:links] == nil
|
33
|
+
case options[:format]
|
34
|
+
when :html
|
35
|
+
crumb_string = crumbs.collect do |crumb|
|
36
|
+
crumb_to_html crumb, crumbs.last==crumb ? false : options[:links]
|
37
|
+
#crumb_to_html crumb, options[:links]
|
38
|
+
end * options[:seperator]
|
39
|
+
crumb_string = crumb_string.html_safe if crumb_string.respond_to?(:html_safe)
|
40
|
+
crumb_string
|
41
|
+
when :xml
|
42
|
+
crumbs.collect do |crumb|
|
43
|
+
crumb_to_xml crumb, options[:links], options[:seperator]
|
44
|
+
end * ''
|
45
|
+
else
|
46
|
+
raise ArgumentError, "Unknown breadcrumb output format"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def crumb_to_html(crumb, links)
|
53
|
+
name, url = crumb
|
54
|
+
url && links ? link_to(name, url) : name
|
55
|
+
end
|
56
|
+
|
57
|
+
def crumb_to_xml(crumb, links, seperator)
|
58
|
+
name, url = crumb
|
59
|
+
url && links ? "<#{seperator} href=\"#{url}\">#{name}</#{seperator}>" : "<#{seperator}>#{name}</#{seperator}>"
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module EngineRoom
|
2
|
+
class Engine < Rails::Engine
|
3
|
+
|
4
|
+
config.mount_at = '/'
|
5
|
+
|
6
|
+
# Load rake tasks
|
7
|
+
rake_tasks do
|
8
|
+
#load File.join(File.dirname(__FILE__), 'rails/railties/tasks.rake')
|
9
|
+
load "engine_room/railties/tasks.rake"
|
10
|
+
end
|
11
|
+
|
12
|
+
# Check the gem config
|
13
|
+
initializer "check config" do |app|
|
14
|
+
# make sure mount_at ends with trailing slash
|
15
|
+
config.mount_at += '/' unless config.mount_at.last == '/'
|
16
|
+
end
|
17
|
+
|
18
|
+
initializer "static assets" do |app|
|
19
|
+
app.middleware.use ::ActionDispatch::Static, "#{root}/public"
|
20
|
+
# app.middleware.insert_after ActionDispatch::Static, ActionDispatch::Static, "#{root}/public"
|
21
|
+
end
|
22
|
+
|
23
|
+
# TODO: move override into external module (couldn't get it working)
|
24
|
+
# override paths for Devise after sign-in and sign-out
|
25
|
+
initializer 'override ActionController' do |app|
|
26
|
+
|
27
|
+
ActiveSupport.on_load(:action_controller) do
|
28
|
+
class ActionController::Base
|
29
|
+
def after_sign_in_path_for(resource)
|
30
|
+
engine_room_root_path
|
31
|
+
end
|
32
|
+
def after_sign_out_path_for(resource)
|
33
|
+
new_er_devise_user_session_path
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rails/generators/active_record'
|
2
|
+
|
3
|
+
module EngineRoom
|
4
|
+
module Generators
|
5
|
+
class CreateImageGenerator < Rails::Generators::Base
|
6
|
+
include Rails::Generators::Migration
|
7
|
+
|
8
|
+
def self.source_root
|
9
|
+
@source_root ||= File.join(File.dirname(__FILE__), 'templates')
|
10
|
+
end
|
11
|
+
|
12
|
+
def doit
|
13
|
+
puts "generating image model..."
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.next_migration_number(dirname)
|
17
|
+
ActiveRecord::Generators::Base.next_migration_number(dirname)
|
18
|
+
end
|
19
|
+
|
20
|
+
def copy_files
|
21
|
+
migration_template "004_create_images.rb", "db/migrate/create_images.rb"
|
22
|
+
copy_file "image.rb", "app/models/image.rb"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'rails/generators/active_record'
|
2
|
+
|
3
|
+
module EngineRoom
|
4
|
+
module Generators
|
5
|
+
class SetupGenerator < Rails::Generators::Base
|
6
|
+
include Rails::Generators::Migration
|
7
|
+
|
8
|
+
def self.source_root
|
9
|
+
@source_root ||= File.join(File.dirname(__FILE__), 'templates')
|
10
|
+
end
|
11
|
+
|
12
|
+
def doit
|
13
|
+
puts "generating setup..."
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.next_migration_number(dirname)
|
17
|
+
ActiveRecord::Generators::Base.next_migration_number(dirname)
|
18
|
+
end
|
19
|
+
|
20
|
+
def devise
|
21
|
+
migration_template "001_devise_create_users.rb", "db/migrate/devise_create_users.rb"
|
22
|
+
end
|
23
|
+
|
24
|
+
def setup
|
25
|
+
migration_template "002_create_sections.rb", "db/migrate/create_sections.rb"
|
26
|
+
migration_template "003_create_fields.rb", "db/migrate/create_fields.rb"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class DeviseCreateUsers < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table(:users) do |t|
|
4
|
+
t.string :username, :null => false
|
5
|
+
t.database_authenticatable :null => false
|
6
|
+
t.recoverable
|
7
|
+
t.rememberable
|
8
|
+
t.trackable
|
9
|
+
|
10
|
+
t.integer :is_admin, :default => 0
|
11
|
+
# t.confirmable
|
12
|
+
# t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
|
13
|
+
# t.token_authenticatable
|
14
|
+
|
15
|
+
|
16
|
+
t.timestamps
|
17
|
+
end
|
18
|
+
|
19
|
+
add_index :users, :email, :unique => true
|
20
|
+
add_index :users, :reset_password_token, :unique => true
|
21
|
+
# add_index :users, :confirmation_token, :unique => true
|
22
|
+
# add_index :users, :unlock_token, :unique => true
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.down
|
26
|
+
drop_table :users
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class CreateSections < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table(:sections) do |t|
|
4
|
+
t.string :name, :null => false
|
5
|
+
t.string :model_name, :null => false
|
6
|
+
t.string :view_type
|
7
|
+
t.string :condition
|
8
|
+
t.integer :sort_order
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.down
|
14
|
+
drop_table :sections
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class CreateFields < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table(:fields) do |t|
|
4
|
+
t.integer :section_id, :null => false
|
5
|
+
t.string :column, :null => false
|
6
|
+
t.string :field_type, :null => false
|
7
|
+
t.string :display_type, :null => false
|
8
|
+
t.text :options
|
9
|
+
t.text :help
|
10
|
+
t.integer :sort_order
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.down
|
16
|
+
drop_table :fields
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class CreateImages < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table(:images) do |t|
|
4
|
+
# todo: add foreign keys to belongs_to model
|
5
|
+
|
6
|
+
t.string :title
|
7
|
+
t.text :description
|
8
|
+
t.string :image_file_name # paperclip property
|
9
|
+
t.string :image_content_type # paperclip property
|
10
|
+
t.integer :image_file_size # paperclip property
|
11
|
+
t.datetime :image_updated_at # paperclip property
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.down
|
17
|
+
drop_table :images
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
namespace :dummy do
|
4
|
+
desc "Initialize basic dummy app - adds models and migrations"
|
5
|
+
task :init do
|
6
|
+
puts "copying migrations and models"
|
7
|
+
|
8
|
+
engine_root_path = File.expand_path('../../..', __FILE__)
|
9
|
+
|
10
|
+
migrate_source = File.join(File.dirname(__FILE__), 'templates', 'migrate')
|
11
|
+
migrate_target = File.join(engine_root_path, 'spec', 'dummy', 'db', 'migrate')
|
12
|
+
Dir.mkdir(migrate_target) unless File.directory?(migrate_target)
|
13
|
+
|
14
|
+
Dir.chdir(migrate_source)
|
15
|
+
Dir.glob("*.rb") do |file|
|
16
|
+
puts "copy file: #{file} ==> #{migrate_target}"
|
17
|
+
FileUtils.copy(file, migrate_target)
|
18
|
+
end
|
19
|
+
|
20
|
+
models_source = File.join(File.dirname(__FILE__), 'templates', 'models')
|
21
|
+
models_target = File.join(engine_root_path, 'spec', 'dummy', 'app', 'models')
|
22
|
+
Dir.mkdir(models_target) unless File.directory?(models_target)
|
23
|
+
|
24
|
+
Dir.chdir(models_source)
|
25
|
+
Dir.glob("*.rb") do |file|
|
26
|
+
puts "copy file: #{file} ==> #{models_target}"
|
27
|
+
FileUtils.copy(file, models_target)
|
28
|
+
end
|
29
|
+
|
30
|
+
# copy user migration (devise)
|
31
|
+
user_migrate = File.join(engine_root_path, "lib", "generators", "engine_room", "templates", "001_devise_create_users.rb")
|
32
|
+
puts "copy file: #{user_migrate} ==> #{models_target}"
|
33
|
+
FileUtils.copy(user_migrate, migrate_target)
|
34
|
+
|
35
|
+
section_migrate = File.join(engine_root_path, "lib", "generators", "engine_room", "templates", "002_create_sections.rb")
|
36
|
+
puts "copy file: #{section_migrate} ==> #{models_target}"
|
37
|
+
FileUtils.copy(section_migrate, migrate_target)
|
38
|
+
|
39
|
+
field_migrate = File.join(engine_root_path, "lib", "generators", "engine_room", "templates", "003_create_fields.rb")
|
40
|
+
puts "copy file: #{field_migrate} ==> #{models_target}"
|
41
|
+
FileUtils.copy(field_migrate, migrate_target)
|
42
|
+
|
43
|
+
puts "fin."
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class CreateDogs < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :dogs do |t|
|
4
|
+
t.string :name, :null => false
|
5
|
+
t.string :color, :null => true
|
6
|
+
t.text :description, :null => true
|
7
|
+
t.integer :fleas, :null => true
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
|
11
|
+
add_index :dogs, :name
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.down
|
15
|
+
drop_table :dogs
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|