contao 0.6.1 → 0.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/contao/generators/application.rb +1 -0
- data/lib/contao/generators/base.rb +2 -0
- data/lib/contao/generators/contao_initializer.rb +1 -1
- data/lib/contao/generators/localconfig.rb +29 -0
- data/lib/contao/templates/contao_initializer.rb.erb +2 -2
- data/lib/contao/version.rb +1 -1
- data/lib/tasks/contao.rake +5 -14
- data/spec/lib/contao/generators/contao_initializer_spec.rb +1 -1
- data/spec/lib/contao/generators/localconfig_spec.rb +47 -0
- data/spec/support/filesystem_mock.rb +82 -0
- data/spec/support/stub_rails.rb +12 -0
- metadata +5 -2
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'contao/generators/base'
|
2
|
+
|
3
|
+
module TechnoGate
|
4
|
+
module Contao
|
5
|
+
module Generators
|
6
|
+
class Localconfig < Base
|
7
|
+
class LocalconfigRequired < RuntimeError; end
|
8
|
+
|
9
|
+
def generate
|
10
|
+
require_localconfig
|
11
|
+
|
12
|
+
config = Contao::Application.config
|
13
|
+
File.open localconfig_path, 'w' do |f|
|
14
|
+
f.write ERB.new(File.read(options[:template]), nil, '-').result(binding)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
protected
|
19
|
+
def require_localconfig
|
20
|
+
raise LocalconfigRequired unless options[:template]
|
21
|
+
end
|
22
|
+
|
23
|
+
def localconfig_path
|
24
|
+
Pathname.new(Rails.public_path).join 'system/config/localconfig.php'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -21,7 +21,7 @@ module ContaoTemplate
|
|
21
21
|
|
22
22
|
# Enable SMTP ?
|
23
23
|
config.contao.smtp.enabled = <%= config.smtp_enabled %>
|
24
|
-
|
24
|
+
<%- if config.smtp_enabled %>
|
25
25
|
# SMTP Host
|
26
26
|
config.contao.smtp.host = '<%= config.smtp_host %>'
|
27
27
|
|
@@ -36,6 +36,6 @@ module ContaoTemplate
|
|
36
36
|
|
37
37
|
# SMTP Port
|
38
38
|
config.contao.smtp.port = <%= config.smtp_port %>
|
39
|
-
|
39
|
+
<%- end %>
|
40
40
|
end
|
41
41
|
end
|
data/lib/contao/version.rb
CHANGED
data/lib/tasks/contao.rake
CHANGED
@@ -96,21 +96,12 @@ namespace :contao do
|
|
96
96
|
|
97
97
|
desc "Generate the localconfig.php"
|
98
98
|
task :generate_localconfig => :environment do
|
99
|
-
require '
|
100
|
-
config = Rails.application.config.contao.dup
|
99
|
+
require 'contao/generators/localconfig'
|
101
100
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
config.db_password = config.global.mysql.pass
|
107
|
-
config.db_database = config.application_name
|
108
|
-
|
109
|
-
localconfig_template = Rails.root.join 'config/examples/localconfig.php.erb'
|
110
|
-
localconfig_path = public_path.join 'system/config/localconfig.php'
|
111
|
-
|
112
|
-
localconfig = ERB.new(File.read(localconfig_template), nil, '-').result(binding)
|
113
|
-
File.open(localconfig_path, 'w') {|f| f.write localconfig }
|
101
|
+
TechnoGate::Contao::Generators::Localconfig.new(
|
102
|
+
path: Rails.root,
|
103
|
+
template: Rails.root.join('config/examples/localconfig.php.erb'),
|
104
|
+
).generate
|
114
105
|
|
115
106
|
TechnoGate::Contao::Notifier.notify 'The configuration file localconfig.php was generated successfully.'
|
116
107
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'contao/generators/localconfig'
|
3
|
+
|
4
|
+
module TechnoGate
|
5
|
+
module Contao
|
6
|
+
module Generators
|
7
|
+
describe Localconfig, :fakefs => true do
|
8
|
+
let(:klass) { Localconfig }
|
9
|
+
|
10
|
+
subject {
|
11
|
+
klass.new path: @path, template: @template
|
12
|
+
}
|
13
|
+
|
14
|
+
before :each do
|
15
|
+
@path = '/root/my_awesome_project'
|
16
|
+
@template = "#{@path}/config/examples/localconfig.php.erb"
|
17
|
+
|
18
|
+
stub_filesystem! :global_config => {
|
19
|
+
'mysql' => {
|
20
|
+
'host' => 'localhost',
|
21
|
+
'user' => 'myuser',
|
22
|
+
'pass' => 'mypass',
|
23
|
+
'port' => 3306,
|
24
|
+
},
|
25
|
+
}
|
26
|
+
|
27
|
+
Contao::Application.send :load_global_config!
|
28
|
+
end
|
29
|
+
|
30
|
+
it_should_behave_like 'Generator'
|
31
|
+
|
32
|
+
describe '#generate' do
|
33
|
+
it 'should require a template' do
|
34
|
+
expect do
|
35
|
+
klass.new(path: @path).generate
|
36
|
+
end.to raise_error Localconfig::LocalconfigRequired
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should generate a localconfig file' do
|
40
|
+
subject.generate
|
41
|
+
File.exists?('/root/my_awesome_project/public/system/config/localconfig.php').should be_true
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -3,12 +3,14 @@ def stub_filesystem!(options = {})
|
|
3
3
|
|
4
4
|
'/root/my_awesome_project/config',
|
5
5
|
'/root/my_awesome_project/config/initializers',
|
6
|
+
'/root/my_awesome_project/config/examples',
|
6
7
|
'/root/my_awesome_project/app/assets/javascripts',
|
7
8
|
'/root/my_awesome_project/app/assets/stylesheets',
|
8
9
|
'/root/my_awesome_project/app/assets/images',
|
9
10
|
'/root/my_awesome_project/contao/non_existing_folder',
|
10
11
|
'/root/my_awesome_project/contao/system/modules/some_extension',
|
11
12
|
'/root/my_awesome_project/public/resources',
|
13
|
+
'/root/my_awesome_project/public/system/config',
|
12
14
|
'/root/my_awesome_project/public/system/modules/frontend',
|
13
15
|
'/root/my_awesome_project/vendor/assets/javascripts',
|
14
16
|
'/tmp',
|
@@ -22,6 +24,86 @@ def stub_filesystem!(options = {})
|
|
22
24
|
|
23
25
|
stub_global_config_file!(options[:global_config] || {})
|
24
26
|
stub_config_application!(options[:application_name])
|
27
|
+
stub_localconfig!
|
28
|
+
end
|
29
|
+
|
30
|
+
def stub_localconfig!
|
31
|
+
localconfig_path = '/root/my_awesome_project/config/examples/localconfig.php.erb'
|
32
|
+
File.open localconfig_path, 'w' do |f|
|
33
|
+
f.write <<-EOS
|
34
|
+
<?php if (!defined('TL_ROOT')) die('You cannot access this file directly!');
|
35
|
+
|
36
|
+
/**
|
37
|
+
* Contao Open Source CMS
|
38
|
+
* Copyright (C) 2005-2011 Leo Feyer
|
39
|
+
*
|
40
|
+
* Formerly known as TYPOlight Open Source CMS.
|
41
|
+
*
|
42
|
+
* This program is free software: you can redistribute it and/or
|
43
|
+
* modify it under the terms of the GNU Lesser General Public
|
44
|
+
* License as published by the Free Software Foundation, either
|
45
|
+
* version 3 of the License, or (at your option) any later version.
|
46
|
+
*
|
47
|
+
* This program is distributed in the hope that it will be useful,
|
48
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
49
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
50
|
+
* Lesser General Public License for more details.
|
51
|
+
*
|
52
|
+
* You should have received a copy of the GNU Lesser General Public
|
53
|
+
* License along with this program. If not, please visit the Free
|
54
|
+
* Software Foundation website at <http://www.gnu.org/licenses/>.
|
55
|
+
*
|
56
|
+
* PHP version 5
|
57
|
+
* @copyright Leo Feyer 2005-2011
|
58
|
+
* @author Leo Feyer <http://www.contao.org>
|
59
|
+
* @package Config
|
60
|
+
* @license LGPL
|
61
|
+
* @filesource
|
62
|
+
*/
|
63
|
+
|
64
|
+
### INSTALL SCRIPT START ###
|
65
|
+
$GLOBALS['TL_CONFIG']['websitePath'] = '';
|
66
|
+
$GLOBALS['TL_CONFIG']['licenseAccepted'] = true;
|
67
|
+
$GLOBALS['TL_CONFIG']['installPassword'] = '<%= config.install_password %>';
|
68
|
+
$GLOBALS['TL_CONFIG']['installCount'] = 0;
|
69
|
+
$GLOBALS['TL_CONFIG']['encryptionKey'] = '<%= config.encryption_key %>';
|
70
|
+
<% if config.db_server_app == 'mysql' -%>
|
71
|
+
$GLOBALS['TL_CONFIG']['dbDriver'] = 'MySQL';
|
72
|
+
<% end -%>
|
73
|
+
$GLOBALS['TL_CONFIG']['dbHost'] = '<%= config.db_hostname || 'localhost' %>';
|
74
|
+
$GLOBALS['TL_CONFIG']['dbPort'] = <%= config.db_port || 3306 %>;
|
75
|
+
$GLOBALS['TL_CONFIG']['dbUser'] = '<%= config.db_username %>';
|
76
|
+
$GLOBALS['TL_CONFIG']['dbPass'] = '<%= config.db_password %>';
|
77
|
+
$GLOBALS['TL_CONFIG']['dbDatabase'] = '<%= config.db_database %>';
|
78
|
+
$GLOBALS['TL_CONFIG']['dbPconnect'] = false;
|
79
|
+
$GLOBALS['TL_CONFIG']['dbCharset'] = 'UTF8';
|
80
|
+
$GLOBALS['TL_CONFIG']['adminEmail'] = '<%= config.admin_email %>';
|
81
|
+
$GLOBALS['TL_CONFIG']['cron_weekly'] = 201126;
|
82
|
+
$GLOBALS['TL_CONFIG']['latestVersion'] = '2.11.3';
|
83
|
+
$GLOBALS['TL_CONFIG']['cron_daily'] = 20110701;
|
84
|
+
$GLOBALS['TL_CONFIG']['timeZone'] = '<%= config.time_zone %>';
|
85
|
+
$GLOBALS['TL_CONFIG']['rewriteURL'] = true;
|
86
|
+
$GLOBALS['TL_CONFIG']['allowedTags'] = '<a><abbr><acronym><address><area><article><aside><b><big><blockquote><br><base><bdo><button><caption><cite><code><col><colgroup><dd><del><div><dfn><dl><dt><em><figure><figcaption><form><fieldset><footer><header><hr><h1><h2><h3><h4><h5><h6><i><iframe><img><input><ins><label><legend><li><link><map><nav><object><ol><optgroup><option><p><pre><param><q><section><select><small><span><strong><sub><sup><style><table><tbody><td><textarea><tfoot><th><thead><tr><tt><u><ul>';
|
87
|
+
<% if config.smtp.enabled -%>
|
88
|
+
$GLOBALS['TL_CONFIG']['useSMTP'] = true;
|
89
|
+
$GLOBALS['TL_CONFIG']['smtpHost'] = '<%= config.smtp.host %>';
|
90
|
+
$GLOBALS['TL_CONFIG']['smtpUser'] = '<%= config.smtp.user %>';
|
91
|
+
$GLOBALS['TL_CONFIG']['smtpPass'] = '<%= config.smtp.pass %>';
|
92
|
+
<% end -%>
|
93
|
+
<% if config.smtp.ssl -%>
|
94
|
+
$GLOBALS['TL_CONFIG']['smtpEnc'] = 'ssl';
|
95
|
+
$GLOBALS['TL_CONFIG']['smtpPort'] = <%= config.smtp.port || 465 %>;
|
96
|
+
<% end -%>
|
97
|
+
<% unless Rails.env.production? -%>
|
98
|
+
$GLOBALS['TL_CONFIG']['cacheMode'] = 'none';
|
99
|
+
$GLOBALS['TL_CONFIG']['displayErrors'] = true;
|
100
|
+
$GLOBALS['TL_CONFIG']['disableRefererCheck'] = true;
|
101
|
+
<% end -%>
|
102
|
+
### INSTALL SCRIPT STOP ###
|
103
|
+
|
104
|
+
?>
|
105
|
+
EOS
|
106
|
+
end
|
25
107
|
end
|
26
108
|
|
27
109
|
def stub_global_config_file!(config = {})
|
data/spec/support/stub_rails.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: contao
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -166,6 +166,7 @@ files:
|
|
166
166
|
- lib/contao/generators/base.rb
|
167
167
|
- lib/contao/generators/config.rb
|
168
168
|
- lib/contao/generators/contao_initializer.rb
|
169
|
+
- lib/contao/generators/localconfig.rb
|
169
170
|
- lib/contao/notifier.rb
|
170
171
|
- lib/contao/password.rb
|
171
172
|
- lib/contao/railties.rb
|
@@ -181,6 +182,7 @@ files:
|
|
181
182
|
- spec/lib/contao/generators/base_spec.rb
|
182
183
|
- spec/lib/contao/generators/config_spec.rb
|
183
184
|
- spec/lib/contao/generators/contao_initializer_spec.rb
|
185
|
+
- spec/lib/contao/generators/localconfig_spec.rb
|
184
186
|
- spec/lib/contao/notifier_spec.rb
|
185
187
|
- spec/lib/contao/password_spec.rb
|
186
188
|
- spec/spec_helper.rb
|
@@ -209,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
211
|
version: '0'
|
210
212
|
segments:
|
211
213
|
- 0
|
212
|
-
hash:
|
214
|
+
hash: 775829207634762625
|
213
215
|
requirements: []
|
214
216
|
rubyforge_project:
|
215
217
|
rubygems_version: 1.8.23
|
@@ -227,6 +229,7 @@ test_files:
|
|
227
229
|
- spec/lib/contao/generators/base_spec.rb
|
228
230
|
- spec/lib/contao/generators/config_spec.rb
|
229
231
|
- spec/lib/contao/generators/contao_initializer_spec.rb
|
232
|
+
- spec/lib/contao/generators/localconfig_spec.rb
|
230
233
|
- spec/lib/contao/notifier_spec.rb
|
231
234
|
- spec/lib/contao/password_spec.rb
|
232
235
|
- spec/spec_helper.rb
|