Class: Radiant::Setup
- Inherits:
-
Object
- Object
- Radiant::Setup
- Extended by:
- Forwardable
- Defined in:
- lib/radiant/setup.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Class Method Summary collapse
Instance Method Summary collapse
- #bootstrap(config) ⇒ Object
- #create_admin_user(name, username, password) ⇒ Object
- #load_database_template(filename) ⇒ Object
- #load_default_configuration ⇒ Object
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
15 16 17 |
# File 'lib/radiant/setup.rb', line 15 def config @config end |
Class Method Details
.bootstrap(config) ⇒ Object
8 9 10 11 12 |
# File 'lib/radiant/setup.rb', line 8 def bootstrap(config) setup = new setup.bootstrap(config) setup end |
Instance Method Details
#bootstrap(config) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/radiant/setup.rb', line 17 def bootstrap(config) @config = config @admin = create_admin_user(config[:admin_name], config[:admin_username], config[:admin_password]) UserActionObserver.current_user = @admin load_default_configuration load_database_template(config[:database_template]) announce "Finished." announce "Don't forget to run your update task to copy any public assets for your template.\n\n" announce "For example, run 'rake radiant:extensions:site_templates:update'." end |
#create_admin_user(name, username, password) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/radiant/setup.rb', line 28 def create_admin_user(name, username, password) unless name and username and password announce "Create the admin user (press enter for defaults)." name = prompt_for_admin_name unless name username = prompt_for_admin_username unless username password = prompt_for_admin_password unless password end attributes = { :name => name, :login => username, :password => password, :password_confirmation => password, :admin => true } admin = User.find_by_login(username) admin = User.new unless admin admin.update_attributes(attributes) admin end |
#load_database_template(filename) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/radiant/setup.rb', line 61 def load_database_template(filename) template = nil if filename name = find_template_in_path(filename) unless name announce "Invalid template name: #{filename}" filename = nil else template = load_template_file(name) end end unless filename templates = find_and_load_templates("#{Rails.root}/db/templates/*.yml") choose do || .header = "\nSelect a database template" .prompt = "[1-#{templates.size}]: " .select_by = :index templates.each { |t| .choice(t['name']) { template = t } } end end create_records(template) end |
#load_default_configuration ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/radiant/setup.rb', line 48 def load_default_configuration feedback "\nInitializing configuration" do step { Radiant::Config['admin.title' ] = 'Radiant CMS' } step { Radiant::Config['admin.subtitle'] = 'Publishing for Small Teams' } step { Radiant::Config['defaults.page.parts' ] = 'body, extended' } step { Radiant::Config['defaults.page.status' ] = 'draft' } step { Radiant::Config['defaults.page.filter' ] = nil } step { Radiant::Config['defaults.page.fields'] = 'Keywords, Description' } step { Radiant::Config['session_timeout'] = 2.weeks } step { Radiant::Config['default_locale'] = 'en' } end end |