install_generator 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/USAGE +0 -0
- data/install_generator-0.0.1.gem +0 -0
- data/install_generator.gemspec +18 -0
- data/install_generator.rb +54 -0
- data/templates/INSTALL +22 -0
- data/templates/LICENSE +10 -0
- data/templates/README +12 -0
- data/templates/controllers/install_controller.rb +143 -0
- data/templates/helpers/install_helper.rb +28 -0
- data/templates/lang/en.yml +42 -0
- data/templates/lang/ro.yml +42 -0
- data/templates/models/database.rb +104 -0
- data/templates/models/mail_server.rb +59 -0
- data/templates/models/site_config.rb +36 -0
- data/templates/test/unit/database_test.rb +126 -0
- data/templates/test/unit/mail_server_test.rb +73 -0
- data/templates/test/unit/site_config_test.rb +41 -0
- data/templates/views/install/_db_form.rhtml +40 -0
- data/templates/views/install/_mail_form.rhtml +21 -0
- data/templates/views/install/_site_settings_form.rhtml +20 -0
- data/templates/views/install/config_mail.rhtml +6 -0
- data/templates/views/install/confirm_options.rhtml +75 -0
- data/templates/views/install/read_site_settings.rhtml +10 -0
- data/templates/views/install/save_options.rhtml +2 -0
- data/templates/views/install/select_db.rhtml +16 -0
- data/templates/views/install/select_language.rhtml +4 -0
- data/templates/views/install/show_authentication_options.rhtml +10 -0
- data/templates/views/install/show_db_options.rhtml +7 -0
- data/templates/views/install/welcome.rhtml +14 -0
- data/templates/views/layouts/install.rhtml +20 -0
- metadata +99 -0
data/USAGE
ADDED
File without changes
|
File without changes
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
SPEC = Gem::Specification.new do |spec|
|
3
|
+
spec.name="install_generator"
|
4
|
+
spec.version="0.0.1"
|
5
|
+
spec.author="Eugen Minciu"
|
6
|
+
spec.email="minciue@gmail.com"
|
7
|
+
spec.homepage="http://www.tufat.com/oslink.php"
|
8
|
+
spec.platform=Gem::Platform::RUBY
|
9
|
+
spec.summary="Generates a web-based installer for Ruby on Rails applications"
|
10
|
+
spec.files = Dir.glob("./**/*")
|
11
|
+
spec.files.each do |f|
|
12
|
+
spec.files.delete(f) if ( f.include?(".svn") || f=="install_generator.gemspec" )
|
13
|
+
end
|
14
|
+
spec.require_path="."
|
15
|
+
spec.test_files= Dir.glob("templates/test/**/*rb")
|
16
|
+
spec.has_rdoc=true
|
17
|
+
spec.add_dependency "rails", ">= 1.0"
|
18
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
class InstallGenerator < Rails::Generator::NamedBase
|
2
|
+
def manifest
|
3
|
+
record do |m|
|
4
|
+
|
5
|
+
#Controller
|
6
|
+
m.template "controllers/install_controller.rb", "app/controllers/#{file_name}_controller.rb", :collision => :ask
|
7
|
+
|
8
|
+
#Models
|
9
|
+
m.file "models/database.rb", "app/models/database.rb", :collision => :ask
|
10
|
+
m.file "models/mail_server.rb", "app/models/mail_server.rb", :collision => :ask
|
11
|
+
m.file "models/site_config.rb", "app/models/site_config.rb", :collision => :ask
|
12
|
+
|
13
|
+
#Helpers
|
14
|
+
m.template "helpers/install_helper.rb", "app/helpers/#{file_name}_helper.rb", :collision => :ask
|
15
|
+
|
16
|
+
#Tests
|
17
|
+
m.file "test/unit/database_test.rb", "test/unit/database_test.rb", :collision => :ask
|
18
|
+
m.file "test/unit/mail_server_test.rb", "test/unit/mail_server_test.rb", :collision => :ask
|
19
|
+
m.file "test/unit/site_config_test.rb", "test/unit/site_config_test.rb", :collision => :ask
|
20
|
+
|
21
|
+
#Views
|
22
|
+
m.directory "app/views/#{file_name}"
|
23
|
+
m.file "views/install/confirm_options.rhtml", "app/views/#{file_name}/confirm_options.rhtml", :collision => :ask
|
24
|
+
m.file "views/install/config_mail.rhtml", "app/views/#{file_name}/config_mail.rhtml", :collision => :ask
|
25
|
+
m.file "views/install/select_db.rhtml", "app/views/#{file_name}/select_db.rhtml", :collision => :ask
|
26
|
+
m.file "views/install/show_authentication_options.rhtml", "app/views/#{file_name}/show_authentication_options.rhtml", :collision => :ask
|
27
|
+
m.file "views/install/show_db_options.rhtml", "app/views/#{file_name}/show_db_options.rhtml", :collision => :ask
|
28
|
+
m.file "views/install/welcome.rhtml", "app/views/#{file_name}/welcome.rhtml", :collision => :ask
|
29
|
+
m.file "views/install/select_language.rhtml", "app/views/#{file_name}/select_language.rhtml", :collision => :ask
|
30
|
+
m.file "views/install/read_site_settings.rhtml", "app/views/#{file_name}/read_site_settings.rhtml", :collision => :ask
|
31
|
+
m.file "views/install/save_options.rhtml", "app/views/#{file_name}/save_options.rhtml", :collision => :ask
|
32
|
+
|
33
|
+
# Partials
|
34
|
+
m.file "views/install/_db_form.rhtml", "app/views/#{file_name}/_db_form.rhtml", :collision => :ask
|
35
|
+
m.file "views/install/_mail_form.rhtml", "app/views/#{file_name}/_mail_form.rhtml", :collision => :ask
|
36
|
+
m.file "views/install/_site_settings_form.rhtml", "app/views/#{file_name}/_site_settings_form.rhtml", :collision => :ask
|
37
|
+
|
38
|
+
#Layouts
|
39
|
+
m.file "views/layouts/install.rhtml", "app/views/layouts/#{file_name}.rhtml", :collision => :ask
|
40
|
+
|
41
|
+
#Languages
|
42
|
+
m.directory "lang"
|
43
|
+
m.file "lang/en.yml", "lang/en.yml", :collision => :ask
|
44
|
+
m.file "lang/ro.yml", "lang/ro.yml", :collision => :ask
|
45
|
+
|
46
|
+
#Extra files
|
47
|
+
m.file "LICENSE", "doc/LICENSE_FOR_INSTALL_GENERATOR", :collision => :ask
|
48
|
+
m.file "INSTALL", "doc/INSTALL_FOR_INSTALL_GENERATOR", :collision => :ask
|
49
|
+
m.file "README", "doc/README_FOR_INSTALL_GENERATOR", :collision => :ask
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
data/templates/INSTALL
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
To set up the install generator for your rails application you must do the following:
|
2
|
+
|
3
|
+
1) Install the GLoc plugin for your Ruby on Rails application
|
4
|
+
$ ruby script/plugin source svn://rubyforge.org//var/svn/gloc
|
5
|
+
$ ruby script/plugin install gloc
|
6
|
+
|
7
|
+
2) Add the following lines to your config/environment.rb (for GLoc)
|
8
|
+
GLoc.set_config :default_language => :en
|
9
|
+
GLoc.clear_strings_except :en, :ro
|
10
|
+
GLoc.set_kcode
|
11
|
+
GLoc.load_localized_strings
|
12
|
+
|
13
|
+
3) Install the Settings plugin for your Ruby on Rails application
|
14
|
+
Don't bother to generate the settings migration or migrate the database
|
15
|
+
That will be done by the installer at the end automatically
|
16
|
+
|
17
|
+
$ ruby script/plugin source http://beautifulpixel.textdriven.com/svn/plugins/settings
|
18
|
+
$ ruby script/plugin install settings
|
19
|
+
|
20
|
+
4) Install the installer generator and add it to your application
|
21
|
+
# gem install --remote install_generator
|
22
|
+
$ ruby script/generate install
|
data/templates/LICENSE
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
Copyright (c) 2006, Eugen Minciu
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
5
|
+
|
6
|
+
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
7
|
+
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
8
|
+
* Neither the name of Eugen Minciu nor the names of his contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
9
|
+
|
10
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/templates/README
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
This is a generator for a web-based online installer for Ruby On Rails applications, similar to what many PHP applications out there have today.
|
2
|
+
|
3
|
+
The code it generates is somewhat similar to what you'd get from a scaffold generator. You'll probably be changing it a lot but it should still provide you with what you need to get started, and all the functionality should be present.
|
4
|
+
|
5
|
+
It's distributed under the BSD License, please see the LICENSE file for additional information.
|
6
|
+
|
7
|
+
Features:
|
8
|
+
The forms it creates rely on the use of AJAX to only display fields that are relevant to your options.
|
9
|
+
Allows you to set up your database, your mail server and your site's main settings through an easy to use interface
|
10
|
+
Is fully internationalized, allowing you to select the language in which you wish to install the application.
|
11
|
+
|
12
|
+
Please direct any spam or useful mail to minciue@gmail.com ;)
|
@@ -0,0 +1,143 @@
|
|
1
|
+
class <%= class_name %>Controller < ApplicationController
|
2
|
+
model :database, :mail_server, :site_config
|
3
|
+
before_filter :redirect_to_license, :except => [ :index, :welcome, :agree_to_license, :select_language]
|
4
|
+
before_filter :set_installer_lang
|
5
|
+
|
6
|
+
# Set up a hash of languages to insert in the initial form
|
7
|
+
def select_language
|
8
|
+
@forward_action=:welcome
|
9
|
+
@langs=Hash.new
|
10
|
+
GLoc.valid_languages.each do |current_lang|
|
11
|
+
@langs[ll(current_lang,:language_name)] = current_lang
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# Welcome dialog. Present LICENSE from doc/LICENSE file (adding <br /> s)
|
16
|
+
def welcome
|
17
|
+
@back_action = :select_language
|
18
|
+
@forward_action = :agree_to_license
|
19
|
+
# the filter has already set the language to English (default)
|
20
|
+
# so let's change that
|
21
|
+
begin
|
22
|
+
f=File.new("doc/LICENSE")
|
23
|
+
@license=f.read()
|
24
|
+
rescue
|
25
|
+
@license=l(:no_license)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# When the user agrees to the license he is taken to this page, where
|
30
|
+
# the fact that he accepted the license is recorded in his session hash
|
31
|
+
def agree_to_license
|
32
|
+
session[:license_agreed]=true
|
33
|
+
redirect_to :action => 'select_db'
|
34
|
+
end
|
35
|
+
|
36
|
+
# Main database selection dialog
|
37
|
+
def select_db
|
38
|
+
@back_action = :welcome
|
39
|
+
@forward_action = :config_mail
|
40
|
+
end
|
41
|
+
|
42
|
+
# Create a new database object for the appropriate database type
|
43
|
+
# Fill out an AJAX-delivered form with the appropriate data from the said object.
|
44
|
+
def show_db_options
|
45
|
+
@db=Database.new
|
46
|
+
@db.set_default(params[:db_adapter])
|
47
|
+
render :layout => false
|
48
|
+
end
|
49
|
+
|
50
|
+
# Configure the ActionMailer settings
|
51
|
+
def config_mail
|
52
|
+
@back_action = :select_db
|
53
|
+
@forward_action = :read_site_settings
|
54
|
+
@db=load_db
|
55
|
+
redirect_to_form(:select_db) unless @db.valid?
|
56
|
+
end
|
57
|
+
|
58
|
+
# Show authentication options for the mail setup
|
59
|
+
def show_authentication_options
|
60
|
+
@auth=params[:mail_authentication]
|
61
|
+
render :layout => false
|
62
|
+
end
|
63
|
+
|
64
|
+
# Read the main settings for the site
|
65
|
+
def read_site_settings
|
66
|
+
@back_action = :config_mail
|
67
|
+
@forward_action = :confirm_options
|
68
|
+
@mail = load_mailserver
|
69
|
+
redirect_to_form(:config_mail) unless @mail.valid?
|
70
|
+
end
|
71
|
+
|
72
|
+
# Save database options directly to 'config/database.yml' through YAML.dump
|
73
|
+
#
|
74
|
+
# The user is returned to the configuration page with an error message
|
75
|
+
# if there is an error in opening the file or saving it
|
76
|
+
def confirm_options
|
77
|
+
@back_action = :read_site_settings
|
78
|
+
@forward_action = :save_options
|
79
|
+
@db = load_db
|
80
|
+
@mail = load_mailserver
|
81
|
+
|
82
|
+
@site = load_site_settings
|
83
|
+
redirect_to_form(:read_site_settings) unless @site.valid?
|
84
|
+
end
|
85
|
+
|
86
|
+
# Save the configuration options
|
87
|
+
# Databases migrations are automatically performed
|
88
|
+
def save_options
|
89
|
+
@db.save
|
90
|
+
@mail.save
|
91
|
+
@site.save
|
92
|
+
Settings.installed=true
|
93
|
+
end
|
94
|
+
|
95
|
+
# Index (points to welcome)
|
96
|
+
def index
|
97
|
+
select_language
|
98
|
+
render :action => :select_language
|
99
|
+
end
|
100
|
+
|
101
|
+
private
|
102
|
+
|
103
|
+
# Load a mailserver object from the session data
|
104
|
+
def load_mailserver
|
105
|
+
session[:mail] = params[:mail] if params[:mail]
|
106
|
+
MailServer.new(session[:mail])
|
107
|
+
end
|
108
|
+
|
109
|
+
def load_site_settings
|
110
|
+
session[:site]=params[:site] if params[:site]
|
111
|
+
SiteConfig.new(session[:site])
|
112
|
+
end
|
113
|
+
|
114
|
+
# Load a database object from the session data
|
115
|
+
def load_db
|
116
|
+
session[:database]=params[:database] if @params[:database]
|
117
|
+
Database.new(session[:database])
|
118
|
+
end
|
119
|
+
|
120
|
+
# Redirect back to a form unless all the required parts of the form were completed
|
121
|
+
def redirect_to_form(form)
|
122
|
+
flash[:notice]=l(:not_all_fields_completed)
|
123
|
+
redirect_to :action => form
|
124
|
+
end
|
125
|
+
|
126
|
+
# Redirect to the license page unless the license was agreed to
|
127
|
+
def redirect_to_license
|
128
|
+
begin
|
129
|
+
flash[:notice]=l(:must_agree_to_license)
|
130
|
+
redirect_to :action => 'index'
|
131
|
+
end unless session[:license_agreed]==true
|
132
|
+
end
|
133
|
+
|
134
|
+
def set_installer_lang
|
135
|
+
if params[:language] then
|
136
|
+
if params[:language][:name] then
|
137
|
+
session[:language]=params[:language][:name]
|
138
|
+
end
|
139
|
+
end
|
140
|
+
set_language session[:language]
|
141
|
+
end
|
142
|
+
|
143
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module <%= class_name %>Helper
|
2
|
+
def cute_db_name(string)
|
3
|
+
case string
|
4
|
+
when "mysql"
|
5
|
+
return "MySQL"
|
6
|
+
when "postgresql"
|
7
|
+
return "PostgreSQL"
|
8
|
+
when "oci"
|
9
|
+
return "Oracle"
|
10
|
+
when "sqlite"
|
11
|
+
return "SQLite"
|
12
|
+
when "sqlserver"
|
13
|
+
return "Microsoft SQL Server"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_br(str)
|
18
|
+
str.gsub("\n","<br />\n")
|
19
|
+
end
|
20
|
+
|
21
|
+
def back_link
|
22
|
+
link_to l(:back), :action => @back_action
|
23
|
+
end
|
24
|
+
|
25
|
+
def forward_link
|
26
|
+
link_to l(:forward), :action => @forward_action
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
language_name: English
|
2
|
+
no_license: No license specified. Please add your license in doc/LICENSE
|
3
|
+
not_all_fields_completed: Not all required fields were completed.
|
4
|
+
must_agree_to_license: You must agree to the license first.
|
5
|
+
not_specified: is not specified
|
6
|
+
not_valid_number: is not a valid number
|
7
|
+
installer_default_title: Installation
|
8
|
+
forward: Forward
|
9
|
+
here_is_an_overview: Here is an overview of the configuration you have selected for your site.
|
10
|
+
if_not_satisfied: If you are not satisfied with your settings you may return and change them.
|
11
|
+
db_configuration: Database Configuration
|
12
|
+
type: Type
|
13
|
+
name: Name
|
14
|
+
address: Address
|
15
|
+
username: Username
|
16
|
+
password: Password
|
17
|
+
port: Port
|
18
|
+
file: File
|
19
|
+
mail_configuration: Mail Server Configuration
|
20
|
+
domain: Domain
|
21
|
+
back: Back
|
22
|
+
fill_database_options: Please fill in database options
|
23
|
+
enter_mail_configuration: Please enter your mail server configuration
|
24
|
+
authentication: Authentication Method
|
25
|
+
select_db_type: Select your database type
|
26
|
+
none: None
|
27
|
+
project_information_and_license: Insert information about your project and its license here.
|
28
|
+
proceed_if_you_agree: You may proceed only if you agree to this license.
|
29
|
+
i_agree: I Agree
|
30
|
+
enter_site_information: Please complete the following information about your site
|
31
|
+
title: Title
|
32
|
+
admin_username: Administrator's username
|
33
|
+
admin_name: Administrator's name
|
34
|
+
admin_email: Administrator's email
|
35
|
+
admin_password: Administrator's password
|
36
|
+
description: Description
|
37
|
+
site_information: Site information
|
38
|
+
congratulation_settings_saved: Congratulations, your settings have been sucessfully saved!
|
39
|
+
dont_match: Don't Match
|
40
|
+
confirmation_password: Password (confirm)
|
41
|
+
admin_confirmation_password: Administrator's password (confirmation)
|
42
|
+
title: Title
|
@@ -0,0 +1,42 @@
|
|
1
|
+
language_name: Românã
|
2
|
+
no_license: Nici o licenţã nu a fost specificatã. Vã rugãm sã adãugaţi licenţa dumneavoastrã in doc/LICENSE
|
3
|
+
not_all_fields_completed: Nu toate câmpurile necesare au fost completate.
|
4
|
+
must_agree_to_license: Trebuie sã acceptaţi licenţa iniţial.
|
5
|
+
not_specified: nu este specificat(ã)
|
6
|
+
not_valid_number: nu este un numãr valid
|
7
|
+
installer_default_title: Instalare
|
8
|
+
forward: Înainte
|
9
|
+
here_is_an_overview: Iatã configuraţia pe care aţi selectat-o pentru situl dumneavoastra.
|
10
|
+
if_not_satisfied: Dacã nu sunteţi mulţumit(ă) de opţiunile selectate, vã puteţi întoarce pentru a le modifica.
|
11
|
+
db_configuration: Configuraţia bazei de date
|
12
|
+
type: Tip
|
13
|
+
name: Nume
|
14
|
+
address: Adresã
|
15
|
+
username: Utilizator
|
16
|
+
password: Parolã
|
17
|
+
port: Port
|
18
|
+
file: Fişier
|
19
|
+
mail_configuration: Configuraţia serverului de mail
|
20
|
+
domain: Domeniu
|
21
|
+
back: Înapoi
|
22
|
+
fill_database_options: Vã rugãm sã completaţi opţiunile referitoare la baza de date
|
23
|
+
enter_mail_configuration: Vã rugãm sã introduceţi configuraţia serverului dumneavoastrã de mail
|
24
|
+
authentication: Metodã de autentificare
|
25
|
+
select_db_type: Selectaţi tipul bazei de date
|
26
|
+
none: Nici unul(una)
|
27
|
+
project_information_and_license: Introduceţi informaţii despre proiectul dumneavoastrã şi licenţa acestuia aici.
|
28
|
+
proceed_if_you_agree: Puteţi continua doar dacã sunteţi de acord cu aceastã licenţã.
|
29
|
+
i_agree: Sunt de acord
|
30
|
+
enter_site_information: Vã rugãm sã introduceţi urmãtoarele informaţii despre situl dumneavoastra
|
31
|
+
title: Titlu
|
32
|
+
admin_username: Utilizatorul administratorului
|
33
|
+
admin_name: Numele administratorului
|
34
|
+
admin_email: Adresa de email a administratorului
|
35
|
+
admin_password: Parola administratorului
|
36
|
+
description: Descriere
|
37
|
+
site_information: Informaţii despre sit
|
38
|
+
congratulations_settings_saved: Felicitãri, opţiunile dumneavoastrã au fost salvate cu succes!
|
39
|
+
dont_match: Nu se potrivesc
|
40
|
+
confirmation_password: Parola (confirmare)
|
41
|
+
admin_confirmation_password: Parola administratorului (confirmare)
|
42
|
+
title: Titlu
|
@@ -0,0 +1,104 @@
|
|
1
|
+
class Database < ActiveRecord::Base
|
2
|
+
attr_accessor :adapter, :database, :host, :username, :password, :confirmation_password, :port, :dbfile
|
3
|
+
# The following definitions are required for validation because this model
|
4
|
+
# Does not have an associated table present in the database
|
5
|
+
def self.columns() @columns ||= []; end
|
6
|
+
def self.column(name, sql_type = nil, default = nil, null = true)
|
7
|
+
columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
|
8
|
+
end
|
9
|
+
column :adapter, :string
|
10
|
+
column :database, :string
|
11
|
+
column :host, :string
|
12
|
+
column :username, :string
|
13
|
+
column :password, :string
|
14
|
+
column :confirmation_password, :string
|
15
|
+
column :port, :string # PostgreSQL can use a filename as a port argument (and often does)
|
16
|
+
column :dbfile, :string
|
17
|
+
|
18
|
+
# These are the supported database adapters
|
19
|
+
# Based on these, the installer will generate a form that only has the appropriate boxes to edit
|
20
|
+
ADAPTERS = [
|
21
|
+
[ "MySQL", 'mysql'],
|
22
|
+
[ "PostgreSQL", 'postgresql'],
|
23
|
+
[ "SQLite", 'sqlite'],
|
24
|
+
[ "Oracle", 'oci'],
|
25
|
+
[ "Microsoft SQL Server", 'sqlserver']
|
26
|
+
].freeze
|
27
|
+
|
28
|
+
# Set some sensible defaults from values
|
29
|
+
# If for some fields, defaults aren't set and they remain nil, those fields won't appear in the form
|
30
|
+
def set_default(adapter)
|
31
|
+
@adapter=adapter
|
32
|
+
case @adapter
|
33
|
+
when "mysql"
|
34
|
+
@database=""
|
35
|
+
@host="localhost"
|
36
|
+
@username="root"
|
37
|
+
@port=3306
|
38
|
+
@password=""
|
39
|
+
@confirmation_password=""
|
40
|
+
when "postgresql"
|
41
|
+
@database=""
|
42
|
+
@host="localhost"
|
43
|
+
@username="root"
|
44
|
+
@port=5432
|
45
|
+
@password=""
|
46
|
+
@confirmation_password=""
|
47
|
+
when "oci"
|
48
|
+
@host=""
|
49
|
+
@username=""
|
50
|
+
@password=""
|
51
|
+
@confirmation_password=""
|
52
|
+
when "sqlserver"
|
53
|
+
@database=""
|
54
|
+
@host="localhost"
|
55
|
+
@username="sa"
|
56
|
+
@password=""
|
57
|
+
@confirmation_password=""
|
58
|
+
when "sqlite"
|
59
|
+
@dbfile=""
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# Save the database configuration in 'config/database.yml' or some other user supplied value
|
64
|
+
# Properly handles the event of an unwritable file.
|
65
|
+
def save(file='config/database.yml')
|
66
|
+
@databases=Hash.new()
|
67
|
+
@production=Hash.new()
|
68
|
+
|
69
|
+
@production['adapter']=@adapter if @adapter
|
70
|
+
@production['database']=@database if @database
|
71
|
+
@production['username']=@username if @username
|
72
|
+
@production['password']=@password if @password
|
73
|
+
@production['host']=@host if @host
|
74
|
+
@production['port']=@port if @port
|
75
|
+
@production['dbfile']=@dbfile if @dbfile
|
76
|
+
|
77
|
+
@databases['production']=@production
|
78
|
+
# TODO : only have the next line execute if we're in a development environment
|
79
|
+
@databases['development']='production'
|
80
|
+
|
81
|
+
begin
|
82
|
+
File.open(file, 'w') do |out|
|
83
|
+
YAML.dump(@databases,out)
|
84
|
+
end
|
85
|
+
rescue
|
86
|
+
flash[:notice]="Unable to save the configuration.\n<br />"
|
87
|
+
flash[:notice]+=" Make sure you have write permissions for the file '#{file}'"
|
88
|
+
redirect_to :action => "select_db"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
protected
|
93
|
+
# Validation for the AJAX-generated form which lets you specify database details
|
94
|
+
# if a certain item is nil this is not seen as an error, the said item was not in the form
|
95
|
+
def validate
|
96
|
+
erorrs.add(:adapter, l(:not_specified)) if @adapter == ""
|
97
|
+
errors.add(:database, l(:not_specified)) if @database == ""
|
98
|
+
errors.add(:password, l(:dont_match)) if @password != @confirmation_password
|
99
|
+
errors.add(:host, l(:not_specified)) if @host == ""
|
100
|
+
errors.add(:username, l(:not_specified)) if @username == ""
|
101
|
+
errors.add(:port, l(:not_specified)) if @port == ""
|
102
|
+
errors.add(:dbfile, l(:not_specified)) if @dbfile == ""
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
class MailServer < ActiveRecord::Base
|
2
|
+
attr_accessor :address, :port, :domain, :authentication, :username, :password, :confirmation_password
|
3
|
+
# The following definitions are required for validation because this model
|
4
|
+
# Does not have an associated table present in the database
|
5
|
+
def self.columns() @columns ||= []; end
|
6
|
+
def self.column(name, sql_type = nil, default = nil, null = true)
|
7
|
+
columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
|
8
|
+
end
|
9
|
+
|
10
|
+
column :address, :string
|
11
|
+
column :port, :integer
|
12
|
+
column :domain, :string
|
13
|
+
column :authentication, :string
|
14
|
+
column :username, :string
|
15
|
+
column :password, :string
|
16
|
+
column :confirmation_password, :string
|
17
|
+
|
18
|
+
validates_presence_of :address, :port, :domain
|
19
|
+
|
20
|
+
# These are the authentication methods Rails supports
|
21
|
+
AUTHENTICATION_METHODS = [
|
22
|
+
[ "None", 'none' ],
|
23
|
+
[ "Plain", 'plain' ],
|
24
|
+
[ "Login", 'login' ],
|
25
|
+
[ "CRAM-MD5", 'cram_md5']
|
26
|
+
]
|
27
|
+
|
28
|
+
def save
|
29
|
+
if (@authentication != 'none') then
|
30
|
+
@hash = {
|
31
|
+
:adapter => @adapter,
|
32
|
+
:port => @port,
|
33
|
+
:domain => @domain,
|
34
|
+
:authentication => @authentication,
|
35
|
+
:username => @username,
|
36
|
+
:password => @password
|
37
|
+
}
|
38
|
+
else
|
39
|
+
@hash = {
|
40
|
+
:adapter => @adapter,
|
41
|
+
:port => @port,
|
42
|
+
:domain => @domain,
|
43
|
+
:authentication => @authentication
|
44
|
+
}
|
45
|
+
end
|
46
|
+
return @hash
|
47
|
+
end
|
48
|
+
|
49
|
+
protected
|
50
|
+
|
51
|
+
def validate
|
52
|
+
errors.add(@port, l(:not_valid_number)) if (@port.to_i <0 || @port.to_i >65535)
|
53
|
+
if (@authentication != 'none') then
|
54
|
+
errors.add(:username, l(:not_specified)) if @username == "" || @username == nil
|
55
|
+
errors.add(:password, l(:dont_match)) if @password != @confirmation_password
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
class SiteConfig < ActiveRecord::Base
|
2
|
+
attr_accessor :title, :admin_username, :admin_name, :admin_password, :admin_confirmation_password, :admin_email, :description
|
3
|
+
|
4
|
+
# The following definitions are required for validation because this model
|
5
|
+
# Does not have an associated table present in the database
|
6
|
+
def self.columns() @columns ||= []; end
|
7
|
+
def self.column(name, sql_type = nil, default = nil, null = true)
|
8
|
+
columns << ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, sql_type.to_s, null)
|
9
|
+
end
|
10
|
+
|
11
|
+
column :title, :string
|
12
|
+
column :admin_username, :string
|
13
|
+
column :admin_name, :string
|
14
|
+
column :admin_password, :string
|
15
|
+
column :admin_confirmation_password, :string
|
16
|
+
column :admin_email, :string
|
17
|
+
column :description, :text
|
18
|
+
|
19
|
+
validates_presence_of :title, :admin_username, :admin_name, :admin_password, :admin_confirmation_password, :admin_email, :description
|
20
|
+
|
21
|
+
# Save the options. This requires the settings plugin to be installed
|
22
|
+
def save
|
23
|
+
system("ruby script/generate settings_migration")
|
24
|
+
system("rake db:migrate")
|
25
|
+
Settings.title=@title
|
26
|
+
Settings.admin_username=@admin_username
|
27
|
+
Settings.admin_name=@admin_name
|
28
|
+
Settings.admin_password=@admin_password
|
29
|
+
Settings.admin_email=@admin_email
|
30
|
+
Settings.description=@description
|
31
|
+
end
|
32
|
+
|
33
|
+
def validate
|
34
|
+
errors.add(:admin_password, l(:dont_match)) if @admin_password != @admin_confirmation_password
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
class DatabaseTest < Test::Unit::TestCase
|
3
|
+
def setup
|
4
|
+
@db=Database.new
|
5
|
+
@mysql_db=Database.new
|
6
|
+
@postgresql_db=Database.new
|
7
|
+
@sqlite_db=Database.new
|
8
|
+
@oracle_db=Database.new
|
9
|
+
@sqlserver_db=Database.new
|
10
|
+
|
11
|
+
@databases=[@mysql_db,@postgresql_db,@sqlite_db,@oracle_db,@sqlserver_db]
|
12
|
+
@databases_except_sqlite=[@mysql_db,@postgresql_db,@oracle_db,@sqlserver_db]
|
13
|
+
|
14
|
+
@mysql_db.set_default('mysql')
|
15
|
+
@postgresql_db.set_default('postgresql')
|
16
|
+
@sqlite_db.set_default('sqlite')
|
17
|
+
@oracle_db.set_default('oci')
|
18
|
+
@sqlserver_db.set_default('sqlserver')
|
19
|
+
end
|
20
|
+
|
21
|
+
# Tests that the values set through set_default yield an invalid product
|
22
|
+
#
|
23
|
+
# This should be the case, as the user is expected to fill in at least
|
24
|
+
# a database name or database file
|
25
|
+
def test_invalid_defaults
|
26
|
+
for i in @databases do
|
27
|
+
assert(!(i.valid?))
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# Check if they pass once you fill in the required field
|
32
|
+
# (or dbfile for sqlite)
|
33
|
+
def test_valid_with_database_field
|
34
|
+
@sqlite_db.dbfile='test'
|
35
|
+
for i in @databases do
|
36
|
+
i.database='test' unless i == @sqlite_db
|
37
|
+
|
38
|
+
assert (i.valid?) unless i== @oracle_db
|
39
|
+
# Oracle fails
|
40
|
+
# All fields must be completed for Oracle, there are no defaults
|
41
|
+
assert(!(i.valid?)) if i==@oracle_db
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# A separate test for Oracle which has no defaults for multiple fields
|
46
|
+
#
|
47
|
+
# The reason for this is that the configuration heavily depends on the
|
48
|
+
# version of Oracle DB server you use
|
49
|
+
def test_oracle_valid
|
50
|
+
@oracle_db.database = 'test'
|
51
|
+
@oracle_db.host = 'localhost'
|
52
|
+
@oracle_db.username = 'test'
|
53
|
+
|
54
|
+
assert @oracle_db.valid?
|
55
|
+
end
|
56
|
+
|
57
|
+
# Test if the database objects pass if different values are registered for
|
58
|
+
# their password and confirmation_password fields (except for SQLite )
|
59
|
+
def test_different_passwords_invalid
|
60
|
+
@oracle_db.host='localhost'
|
61
|
+
@oracle_db.username='test'
|
62
|
+
|
63
|
+
for i in @databases_except_sqlite do
|
64
|
+
i.database='test'
|
65
|
+
i.password='test1'
|
66
|
+
i.confirmation_password='test2'
|
67
|
+
assert (!(i.valid?))
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
# This tests that databases do not pass validation unless they have a
|
73
|
+
# host field. This of course, doesn't apply for SQLite
|
74
|
+
def test_invalid_if_missing_host
|
75
|
+
@oracle_db.username='test'
|
76
|
+
for i in @databases_except_sqlite do
|
77
|
+
i.database='test'
|
78
|
+
i.host=''
|
79
|
+
assert(!(i.valid?))
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
|
84
|
+
#Test that databases without a username don't pass (except for SQLite)
|
85
|
+
def test_invalid_if_missing_username
|
86
|
+
@oracle_db.host='test'
|
87
|
+
for i in @databases_except_sqlite do
|
88
|
+
i.database='test'
|
89
|
+
i.username=''
|
90
|
+
assert(!(i.valid?))
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# For MySQL and PostgreSQL check that databases do not work without
|
95
|
+
# specifying a port number
|
96
|
+
def test_invalid_if_missing_port
|
97
|
+
for i in [@mysql_db, @postgresql_db] do
|
98
|
+
i.database='test'
|
99
|
+
i.port=''
|
100
|
+
assert (!(i.valid?))
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
# Test that save works properly by loading from a saved test file and
|
105
|
+
# comparing the fields with the initial values.
|
106
|
+
#
|
107
|
+
# This test is only written for an example MySQL database.
|
108
|
+
# If anyone finds an example where this doesn't work let me know.
|
109
|
+
def test_save
|
110
|
+
@mysql_db.database='test'
|
111
|
+
@mysql_db.save('test_file')
|
112
|
+
File.open('test_file') do |yo|
|
113
|
+
mysql_db_from_test_file=YAML::load(yo)
|
114
|
+
@test_mysql_db=mysql_db_from_test_file['production']
|
115
|
+
end
|
116
|
+
assert @mysql_db.adapter==@test_mysql_db['adapter']
|
117
|
+
assert @mysql_db.database==@test_mysql_db['database']
|
118
|
+
assert @mysql_db.username==@test_mysql_db['username']
|
119
|
+
assert @mysql_db.password==@test_mysql_db['password']
|
120
|
+
assert @mysql_db.host==@test_mysql_db['host']
|
121
|
+
assert @mysql_db.port==@test_mysql_db['port']
|
122
|
+
assert @mysql_db.dbfile==@test_mysql_db['dbfile']
|
123
|
+
FileUtils.rm('test_file')
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
class MailServerTest < Test::Unit::TestCase
|
3
|
+
def setup
|
4
|
+
@unauthenticated=MailServer.new
|
5
|
+
@plain=MailServer.new
|
6
|
+
@login=MailServer.new
|
7
|
+
@cram_md5=MailServer.new
|
8
|
+
|
9
|
+
@all_methods=[@unauthenticated,@plain,@login,@cram_md5]
|
10
|
+
@authenticated=[@plain,@login,@cram_md5]
|
11
|
+
|
12
|
+
for i in @all_methods
|
13
|
+
i.address='localhost'
|
14
|
+
i.port=25
|
15
|
+
i.domain=''
|
16
|
+
end
|
17
|
+
|
18
|
+
@unauthenticated.authentication='none'
|
19
|
+
@plain.authentication='plain'
|
20
|
+
@login.authentication='login'
|
21
|
+
@cram_md5.authentication='cram_md5'
|
22
|
+
end
|
23
|
+
|
24
|
+
# First we test that default options don't pass
|
25
|
+
# They don't pass because there's no domain field specified
|
26
|
+
def test_defaults
|
27
|
+
for i in @all_methods
|
28
|
+
assert (!(i.valid?))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# We then test that if we add a domain field only the
|
33
|
+
# setup where the mail server doesn't need any authentication passes
|
34
|
+
def test_defaults_with_domain_specified
|
35
|
+
for i in @all_methods do
|
36
|
+
i.domain='localdomain'
|
37
|
+
assert(!(i.valid?)) unless i==@unauthenticated
|
38
|
+
end
|
39
|
+
assert @unauthenticated.valid?
|
40
|
+
end
|
41
|
+
|
42
|
+
# Now we check that properly completed mail server options where authentication is in use do indeed pass
|
43
|
+
def test_authenticated_with_all_completed_fields_pass
|
44
|
+
for i in @authenticated do
|
45
|
+
i.domain='localdomain'
|
46
|
+
i.username='test'
|
47
|
+
i.password='test'
|
48
|
+
i.confirmation_password='test'
|
49
|
+
assert i.valid?
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Just what the test's name says
|
54
|
+
def test_different_password_fields_fail
|
55
|
+
for i in @authenticated do
|
56
|
+
i.domain='localdomain'
|
57
|
+
i.username='test'
|
58
|
+
i.password='test'
|
59
|
+
i.confirmation_password='test2'
|
60
|
+
assert (!(i.valid?))
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# Test that the saved results are appropriate
|
65
|
+
def test_save
|
66
|
+
@x=Hash.new
|
67
|
+
@x=@unauthenticated.save
|
68
|
+
assert @x[:authentication]==@unauthenticated.authentication
|
69
|
+
assert @x[:port]==@unauthenticated.port
|
70
|
+
assert @x[:domain]==@unauthenticated.domain
|
71
|
+
assert @x[:authentication]==@unauthenticated.authentication
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
class SiteConfigTest < Test::Unit::TestCase
|
3
|
+
def setup
|
4
|
+
@site=SiteConfig.new
|
5
|
+
end
|
6
|
+
|
7
|
+
# Test that default values do not pass
|
8
|
+
def test_default_doesnt_pass
|
9
|
+
@site.title='test'
|
10
|
+
@site.admin_username='admin'
|
11
|
+
assert(!(@site.valid?))
|
12
|
+
end
|
13
|
+
|
14
|
+
# Test that if all fields are completed but the supplied
|
15
|
+
# passwords are different, the configuration is not valid
|
16
|
+
def test_different_passwords_dont_pass
|
17
|
+
@site.title=@site.admin_username=@site.admin_name=@site.admin_email=@site.description='test'
|
18
|
+
@site.admin_password='test1'
|
19
|
+
@site.admin_confirmation_password='test2'
|
20
|
+
assert(!(@site.valid?))
|
21
|
+
end
|
22
|
+
|
23
|
+
# test that properly configured fields provide a valid result
|
24
|
+
def test_all_completed_fields_pass_with_identical_passwords
|
25
|
+
@site.title=@site.admin_username=@site.admin_name=@site.admin_email=@site.description=@site.admin_password=@site.admin_confirmation_password='test'
|
26
|
+
assert @site.valid?
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_save
|
30
|
+
@site.title=@site.admin_username=@site.admin_name=@site.admin_email=@site.description=@site.admin_password=@site.admin_confirmation_password='test'
|
31
|
+
@site.save
|
32
|
+
assert Settings.title == @site.title
|
33
|
+
assert Settings.admin_username == @site.admin_username
|
34
|
+
assert Settings.admin_name == @site.admin_name
|
35
|
+
assert Settings.admin_email == @site.admin_email
|
36
|
+
assert Settings.description == @site.description
|
37
|
+
assert Settings.admin_password == @site.admin_password
|
38
|
+
assert Settings.admin_confirmation_password = @site.admin_confirmation_password
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
<% begin -%>
|
2
|
+
<%= l(:fill_database_options) %>: <br />
|
3
|
+
<% end if @db.adapter!="" -%>
|
4
|
+
|
5
|
+
<% begin -%>
|
6
|
+
<%= l(:name) %>:
|
7
|
+
<%= text_field :database, :database, :value => @db.database %><br />
|
8
|
+
<% end if @db.database -%>
|
9
|
+
|
10
|
+
<% begin -%>
|
11
|
+
<%= l(:address) %>:
|
12
|
+
<%= text_field :database, :host, :value => @db.host %><br />
|
13
|
+
<% end if @db.host -%>
|
14
|
+
|
15
|
+
<% begin -%>
|
16
|
+
<%= l(:username) %>:
|
17
|
+
<%= text_field :database, :username, :value => @db.username %><br />
|
18
|
+
<% end if @db.username -%>
|
19
|
+
|
20
|
+
<% begin -%>
|
21
|
+
<%= l(:password) %>:
|
22
|
+
<%= password_field :database, :password %><br />
|
23
|
+
|
24
|
+
<%= l(:confirmation_password) %>:
|
25
|
+
<%= password_field :database, :confirmation_password %><br />
|
26
|
+
<% end if @db.password -%>
|
27
|
+
|
28
|
+
<% begin -%>
|
29
|
+
<%= l(:port) %>:
|
30
|
+
<%= text_field :database, :port, :value => @db.port %><br />
|
31
|
+
<% end if @db.port -%>
|
32
|
+
|
33
|
+
<% begin -%>
|
34
|
+
<%= l(:file) %>:
|
35
|
+
<%= text_field :database, :dbfile, :value => @db.dbfile %><br />
|
36
|
+
<% end if @db.dbfile-%>
|
37
|
+
|
38
|
+
<% begin -%>
|
39
|
+
<%= hidden_field 'database','adapter', :value => @db.adapter %>
|
40
|
+
<% end if @db.adapter -%>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<%= l(:enter_mail_configuration) %><br />
|
2
|
+
|
3
|
+
<%= l(:address) %>:
|
4
|
+
<%= text_field :mail, :address, :value => 'localhost' %><br />
|
5
|
+
|
6
|
+
<%= l(:port) %>:
|
7
|
+
<%= text_field :mail, :port, :value => 25 %><br />
|
8
|
+
|
9
|
+
<%= l(:domain) %>:
|
10
|
+
<%= text_field :mail, :domain %><br />
|
11
|
+
|
12
|
+
<%= l(:authentication) %>:
|
13
|
+
<%= select('mail', 'authentication', MailServer::AUTHENTICATION_METHODS) %> <br />
|
14
|
+
|
15
|
+
<%= observe_field('mail_authentication',
|
16
|
+
:url => { :action => :show_authentication_options },
|
17
|
+
:update => 'authentication_form', :with => 'mail_authentication')
|
18
|
+
%>
|
19
|
+
|
20
|
+
<div id="authentication_form">
|
21
|
+
</div>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<%= l(:title) %>:
|
2
|
+
<%= text_field :site, :title, :value => l(:title) %><br />
|
3
|
+
|
4
|
+
<%= l(:admin_username) %>:
|
5
|
+
<%= text_field :site, :admin_username, :value => 'admin' %><br />
|
6
|
+
|
7
|
+
<%= l(:admin_name) %>:
|
8
|
+
<%= text_field :site, :admin_name %><br />
|
9
|
+
|
10
|
+
<%= l(:admin_password) %>:
|
11
|
+
<%= password_field :site, :admin_password %><br />
|
12
|
+
|
13
|
+
<%= l(:admin_confirmation_password) %>:
|
14
|
+
<%= password_field :site, :admin_confirmation_password %><br />
|
15
|
+
|
16
|
+
<%= l(:admin_email) %>:
|
17
|
+
<%= text_field :site, :admin_email %><br />
|
18
|
+
|
19
|
+
<%= l(:description) %>:<br />
|
20
|
+
<%= text_area :site, :description %><br />
|
@@ -0,0 +1,75 @@
|
|
1
|
+
<p>
|
2
|
+
<%= l(:here_is_an_overview) %>
|
3
|
+
</p>
|
4
|
+
|
5
|
+
<p>
|
6
|
+
<%= l(:if_not_satisfied) %> <br />
|
7
|
+
</p>
|
8
|
+
|
9
|
+
<div>
|
10
|
+
<p>
|
11
|
+
<%= l(:db_configuration) %>:<br />
|
12
|
+
<% begin -%>
|
13
|
+
<%= l(:type) %>: <%= cute_db_name(@db.adapter) %><br />
|
14
|
+
<% end if @db.adapter!="" -%>
|
15
|
+
|
16
|
+
<% begin -%>
|
17
|
+
<%= l(:name) %>: <%= @db.database %><br />
|
18
|
+
<% end if @db.database -%>
|
19
|
+
|
20
|
+
<% begin -%>
|
21
|
+
<%= l(:address) %>: <%= @db.host %> <br />
|
22
|
+
<% end if @db.host %>
|
23
|
+
|
24
|
+
<% begin -%>
|
25
|
+
<%= l(:username) %>: <%= @db.username %> <br />
|
26
|
+
<% end if @db.username -%>
|
27
|
+
|
28
|
+
<% begin -%>
|
29
|
+
<%= l(:password) %>: <%= '*' * @db.password.length %><br />
|
30
|
+
<% end if @db.password -%>
|
31
|
+
|
32
|
+
<% begin -%>
|
33
|
+
<%= l(:port) %>: <%= @db.port %> <br />
|
34
|
+
<% end if @db.port -%>
|
35
|
+
|
36
|
+
<% begin -%>
|
37
|
+
<%= l(:file) %>: <%= @db.dbfile %> <br />
|
38
|
+
<% end if @db.dbfile -%>
|
39
|
+
</p>
|
40
|
+
</div>
|
41
|
+
|
42
|
+
<hr />
|
43
|
+
|
44
|
+
<div>
|
45
|
+
<p>
|
46
|
+
<%= l(:mail_configuration)%>: <br />
|
47
|
+
<%= l(:address) %>: <%= @mail.address %><br />
|
48
|
+
<%= l(:port) %>: <%= @mail.port %><br />
|
49
|
+
<%= l(:domain) %>: <%= @mail.domain %><br />
|
50
|
+
<% begin -%>
|
51
|
+
<%= l(:username) %>: <%= @mail.username %><br />
|
52
|
+
<%= l(:password) %>: <%= '*' * @mail.password.length %>
|
53
|
+
<% end if @mail.authentication != 'none' -%>
|
54
|
+
</p>
|
55
|
+
</div>
|
56
|
+
|
57
|
+
<hr />
|
58
|
+
|
59
|
+
<div>
|
60
|
+
<p>
|
61
|
+
<%= l(:site_information)%>: <br />
|
62
|
+
<%= l(:title) %>: <%= @site.title %><br />
|
63
|
+
<%= l(:admin_username) %>: <%= @site.admin_username %><br />
|
64
|
+
<%= l(:admin_name) %>: <%= @site.admin_name %><br />
|
65
|
+
<%= l(:admin_password) %>: <%= '*' * @site.admin_password.length %><br />
|
66
|
+
<%= l(:admin_email) %>: <%= @site.admin_email %><br />
|
67
|
+
<%= l(:description) %>: <br />
|
68
|
+
<p>
|
69
|
+
<%= add_br(@site.description) %>
|
70
|
+
</p>
|
71
|
+
</p>
|
72
|
+
</div>
|
73
|
+
|
74
|
+
<%= back_link %>
|
75
|
+
<%= forward_link %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<%= l(:select_db_type) %>
|
2
|
+
|
3
|
+
<%=
|
4
|
+
#TODO i18n this
|
5
|
+
options = [ ["Select database type", ""]] + Database::ADAPTERS
|
6
|
+
select('db','adapter',options)
|
7
|
+
%>
|
8
|
+
|
9
|
+
<%=
|
10
|
+
observe_field('db_adapter', :url => { :action => :show_db_options }, :update => 'database_form', :with => 'db_adapter')
|
11
|
+
%>
|
12
|
+
|
13
|
+
<div id="database_form">
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<%= back_link %>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<% begin -%>
|
2
|
+
<%= l(:username) %>:
|
3
|
+
<%= text_field :mail, :username %><br />
|
4
|
+
|
5
|
+
<%= l(:password) %>:
|
6
|
+
<%= password_field :mail, :password %><br />
|
7
|
+
|
8
|
+
<%= l(:confirmation_password) %>:
|
9
|
+
<%= password_field :mail, :password %><br />
|
10
|
+
<% end if (@auth != 'none') -%>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE html
|
3
|
+
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
4
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
5
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
6
|
+
<head>
|
7
|
+
<title><%= l(:installer_default_title) %></title>
|
8
|
+
<%= javascript_include_tag "prototype" %>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<% if (@flash[:notice]) then -%>
|
12
|
+
<%= flash[:notice] %><br />
|
13
|
+
<% end -%>
|
14
|
+
|
15
|
+
<div>
|
16
|
+
<%= @content_for_layout %>
|
17
|
+
</div>
|
18
|
+
</body>
|
19
|
+
</html>
|
20
|
+
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.0
|
3
|
+
specification_version: 1
|
4
|
+
name: install_generator
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.0.1
|
7
|
+
date: 2006-07-28 00:00:00 +03:00
|
8
|
+
summary: Generates a web-based installer for Ruby on Rails applications
|
9
|
+
require_paths:
|
10
|
+
- .
|
11
|
+
email: minciue@gmail.com
|
12
|
+
homepage: http://www.tufat.com/oslink.php
|
13
|
+
rubyforge_project:
|
14
|
+
description:
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Eugen Minciu
|
31
|
+
files:
|
32
|
+
- ./USAGE
|
33
|
+
- ./install_generator-0.0.1.gem
|
34
|
+
- ./install_generator.rb
|
35
|
+
- ./install_generator.gemspec
|
36
|
+
- ./templates
|
37
|
+
- ./templates/lib
|
38
|
+
- ./templates/lang
|
39
|
+
- ./templates/test
|
40
|
+
- ./templates/LICENSE
|
41
|
+
- ./templates/views
|
42
|
+
- ./templates/README
|
43
|
+
- ./templates/migrate
|
44
|
+
- ./templates/controllers
|
45
|
+
- ./templates/models
|
46
|
+
- ./templates/helpers
|
47
|
+
- ./templates/INSTALL
|
48
|
+
- ./templates/lang/en.yml
|
49
|
+
- ./templates/lang/ro.yml
|
50
|
+
- ./templates/test/unit
|
51
|
+
- ./templates/test/functional
|
52
|
+
- ./templates/test/fixtures
|
53
|
+
- ./templates/test/unit/site_config_test.rb
|
54
|
+
- ./templates/test/unit/database_test.rb
|
55
|
+
- ./templates/test/unit/mail_server_test.rb
|
56
|
+
- ./templates/views/layouts
|
57
|
+
- ./templates/views/install
|
58
|
+
- ./templates/views/layouts/install.rhtml
|
59
|
+
- ./templates/views/install/show_db_options.rhtml
|
60
|
+
- ./templates/views/install/select_db.rhtml
|
61
|
+
- ./templates/views/install/show_authentication_options.rhtml
|
62
|
+
- ./templates/views/install/config_mail.rhtml
|
63
|
+
- ./templates/views/install/_site_settings_form.rhtml
|
64
|
+
- ./templates/views/install/save_options.rhtml
|
65
|
+
- ./templates/views/install/select_language.rhtml
|
66
|
+
- ./templates/views/install/welcome.rhtml
|
67
|
+
- ./templates/views/install/_db_form.rhtml
|
68
|
+
- ./templates/views/install/confirm_options.rhtml
|
69
|
+
- ./templates/views/install/read_site_settings.rhtml
|
70
|
+
- ./templates/views/install/_mail_form.rhtml
|
71
|
+
- ./templates/controllers/install_controller.rb
|
72
|
+
- ./templates/models/database.rb
|
73
|
+
- ./templates/models/site_config.rb
|
74
|
+
- ./templates/models/mail_server.rb
|
75
|
+
- ./templates/helpers/install_helper.rb
|
76
|
+
test_files:
|
77
|
+
- templates/test/unit/site_config_test.rb
|
78
|
+
- templates/test/unit/database_test.rb
|
79
|
+
- templates/test/unit/mail_server_test.rb
|
80
|
+
rdoc_options: []
|
81
|
+
|
82
|
+
extra_rdoc_files: []
|
83
|
+
|
84
|
+
executables: []
|
85
|
+
|
86
|
+
extensions: []
|
87
|
+
|
88
|
+
requirements: []
|
89
|
+
|
90
|
+
dependencies:
|
91
|
+
- !ruby/object:Gem::Dependency
|
92
|
+
name: rails
|
93
|
+
version_requirement:
|
94
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: "1.0"
|
99
|
+
version:
|