contao 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +10 -0
- data/contao.gemspec +33 -0
- data/lib/contao/application.rb +66 -0
- data/lib/contao/coffeescript_compiler.rb +50 -0
- data/lib/contao/compiler.rb +104 -0
- data/lib/contao/javascript_compiler.rb +62 -0
- data/lib/contao/notifier.rb +24 -0
- data/lib/contao/stylesheet_compiler.rb +45 -0
- data/lib/contao/tasks/assets.rake +23 -0
- data/lib/contao/tasks/contao.rake +101 -0
- data/lib/contao/tasks/jasmine.rake +8 -0
- data/lib/contao/tasks/whitespace.rake +13 -0
- data/lib/contao/version.rb +3 -0
- data/lib/contao.rb +66 -0
- data/lib/guard/assets.rb +98 -0
- data/lib/monkey_patches/compass/urls.rb +81 -0
- data/lib/monkey_patches.rb +1 -0
- data/spec/lib/contao/application_spec.rb +92 -0
- data/spec/lib/contao/coffeescript_compiler_spec.rb +78 -0
- data/spec/lib/contao/javascript_compiler_spec.rb +91 -0
- data/spec/lib/contao/notifier_spec.rb +50 -0
- data/spec/lib/contao/stylesheet_compiler_spec.rb +117 -0
- data/spec/lib/contao_spec.rb +64 -0
- data/spec/lib/guard/assets_spec.rb +245 -0
- data/spec/spec_helper.rb +42 -0
- data/spec/support/compiler_shared_examples.rb +210 -0
- data/spec/support/filesystem_mock.rb +20 -0
- data/spec/support/singleton_shared_example.rb +17 -0
- metadata +289 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Wael Nasreddine
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Contao
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'contao'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install contao
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/contao.gemspec
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/contao/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Wael Nasreddine"]
|
6
|
+
gem.email = ["wael.nasreddine@gmail.com"]
|
7
|
+
gem.description = %q{Contao Integration with Compass, Sass, Coffee-script, Rake, Guard with asset pre-compiler and asset-manifest generator}
|
8
|
+
gem.summary = gem.description
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "contao"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Contao::VERSION
|
17
|
+
|
18
|
+
# Runtime dependencies
|
19
|
+
gem.add_dependency 'rake'
|
20
|
+
gem.add_dependency 'compass'
|
21
|
+
gem.add_dependency 'oily_png'
|
22
|
+
gem.add_dependency 'uglifier'
|
23
|
+
gem.add_dependency 'activesupport'
|
24
|
+
gem.add_dependency 'guard'
|
25
|
+
gem.add_dependency 'json'
|
26
|
+
gem.add_dependency 'parseconfig'
|
27
|
+
gem.add_dependency 'highline'
|
28
|
+
gem.add_dependency 'coffee-script'
|
29
|
+
|
30
|
+
# Development dependencies
|
31
|
+
gem.add_development_dependency 'rspec'
|
32
|
+
gem.add_development_dependency 'fakefs'
|
33
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module TechnoGate
|
2
|
+
module Contao
|
3
|
+
class Application < OpenStruct
|
4
|
+
include Singleton
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
super
|
8
|
+
self.config = OpenStruct.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.configure(&block)
|
12
|
+
instance.instance_eval(&block)
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.config
|
16
|
+
instance.config
|
17
|
+
end
|
18
|
+
|
19
|
+
def linkify
|
20
|
+
exhaustive_list_of_files_to_link(
|
21
|
+
Contao.expandify(Application.config.contao_path),
|
22
|
+
Contao.expandify(Application.config.contao_public_path)
|
23
|
+
).each do |list|
|
24
|
+
FileUtils.ln_s list[0], list[1]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.linkify
|
29
|
+
instance.linkify
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.load_tasks
|
33
|
+
Dir["#{File.expand_path '../tasks', __FILE__}/**/*.rake"].each {|f| load f}
|
34
|
+
end
|
35
|
+
|
36
|
+
def name
|
37
|
+
File.basename TechnoGate::Contao.root
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.name
|
41
|
+
instance.name
|
42
|
+
end
|
43
|
+
|
44
|
+
protected
|
45
|
+
|
46
|
+
# Return an array of arrays of files to link
|
47
|
+
#
|
48
|
+
# @param [String] Absolute path to folder from which to link
|
49
|
+
# @param [String] Absolute path to folder to which to link
|
50
|
+
# @return [Array]
|
51
|
+
def exhaustive_list_of_files_to_link(from, to)
|
52
|
+
files = []
|
53
|
+
Dir["#{from}/*"].each do |f|
|
54
|
+
file = "#{to}/#{File.basename f}"
|
55
|
+
if File.exists? file
|
56
|
+
exhaustive_list_of_files_to_link(f, file).each { |f| files << f }
|
57
|
+
else
|
58
|
+
files << [f, file]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
files
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'coffee_script'
|
2
|
+
require 'contao/compiler'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
module TechnoGate
|
6
|
+
module Contao
|
7
|
+
class CoffeescriptCompiler < Compiler
|
8
|
+
|
9
|
+
def initialize(options = {})
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
def clean
|
14
|
+
FileUtils.rm_rf compiled_javascript_path.to_s if File.exists?(compiled_javascript_path)
|
15
|
+
|
16
|
+
super
|
17
|
+
end
|
18
|
+
|
19
|
+
protected
|
20
|
+
|
21
|
+
# Compile assets
|
22
|
+
#
|
23
|
+
# This method compiled coffeescripts from
|
24
|
+
# Application.config.javascripts_path into
|
25
|
+
# Contao.root.join('tmp/compiled_javascript')
|
26
|
+
def compile_assets
|
27
|
+
Application.config.javascripts_path.each do |src_path|
|
28
|
+
Dir["#{Contao.expandify(src_path)}/**/*.coffee"].sort.each do |file|
|
29
|
+
dest = compute_destination_filename(src_path, file)
|
30
|
+
FileUtils.mkdir_p File.dirname(dest)
|
31
|
+
File.open(dest, 'w') do |f|
|
32
|
+
f.write ::CoffeeScript.compile(File.read(file))
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def compute_destination_filename(src_path, file)
|
39
|
+
dest = "#{compiled_javascript_path}/#{src_path.gsub('/', '_')}/"
|
40
|
+
dest << file.gsub(/.*#{Regexp.escape src_path}\//, '').gsub(/\.coffee$/, '')
|
41
|
+
dest << '.js' unless File.extname(dest) == '.js'
|
42
|
+
dest
|
43
|
+
end
|
44
|
+
|
45
|
+
def compiled_javascript_path
|
46
|
+
Contao.expandify("tmp/compiled_javascript")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
require 'active_support/core_ext/string/inflections'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module TechnoGate
|
5
|
+
module Contao
|
6
|
+
class Compiler
|
7
|
+
attr_accessor :options
|
8
|
+
|
9
|
+
def initialize(options = {})
|
10
|
+
@options = options
|
11
|
+
@manifest_path = assets_public_path.join('manifest.json')
|
12
|
+
end
|
13
|
+
|
14
|
+
# Compile assets
|
15
|
+
def compile
|
16
|
+
prepare_folders
|
17
|
+
compile_assets
|
18
|
+
create_hashed_assets if Contao.env == :production
|
19
|
+
generate_manifest
|
20
|
+
notify
|
21
|
+
|
22
|
+
self
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.compile
|
26
|
+
new.compile
|
27
|
+
end
|
28
|
+
|
29
|
+
def clean
|
30
|
+
FileUtils.rm_rf Contao.expandify(Application.config.assets_public_path)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.clean
|
34
|
+
new.clean
|
35
|
+
end
|
36
|
+
|
37
|
+
protected
|
38
|
+
def assets_public_path
|
39
|
+
Contao.expandify(Contao::Application.config.assets_public_path)
|
40
|
+
end
|
41
|
+
|
42
|
+
# Prepare folders
|
43
|
+
def prepare_folders
|
44
|
+
FileUtils.mkdir_p assets_public_path
|
45
|
+
end
|
46
|
+
|
47
|
+
def compile_assets
|
48
|
+
end
|
49
|
+
|
50
|
+
def create_hashed_assets
|
51
|
+
end
|
52
|
+
|
53
|
+
def notify
|
54
|
+
klass_name = self.class.to_s.split('::').last
|
55
|
+
|
56
|
+
Notifier.notify("#{klass_name.underscore.humanize} finished successfully.", title: klass_name)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Create a diges for a given file
|
60
|
+
#
|
61
|
+
# This method creates a digested file for a given file path
|
62
|
+
#
|
63
|
+
# @param [Pathname | String] file_path
|
64
|
+
def create_digest_for_file(file_path)
|
65
|
+
digest = Digest::MD5.hexdigest File.read(file_path)
|
66
|
+
digested_file_path = "#{file_path.to_s.chomp(File.extname(file_path))}-#{digest}#{File.extname(file_path)}"
|
67
|
+
FileUtils.cp file_path, digested_file_path
|
68
|
+
|
69
|
+
digested_file_path
|
70
|
+
end
|
71
|
+
|
72
|
+
# This method generates a manifest of all generated files
|
73
|
+
# so it can be parsed and processed by the PHP application
|
74
|
+
#
|
75
|
+
# This method is expected to be overridden
|
76
|
+
def generate_manifest
|
77
|
+
end
|
78
|
+
|
79
|
+
def generate_manifest_for(key, extension)
|
80
|
+
manifest = JSON.parse(File.read(@manifest_path)) rescue {}
|
81
|
+
manifest[key] = []
|
82
|
+
|
83
|
+
all_files = Dir["#{assets_public_path}/**/*.#{extension}"]
|
84
|
+
digested_files = all_files.select {|f| f =~ /^.+-[0-9a-f]{32}\.#{extension}$/}
|
85
|
+
non_digested_files = all_files - digested_files
|
86
|
+
|
87
|
+
if Contao.env == :production
|
88
|
+
files = digested_files
|
89
|
+
else
|
90
|
+
files = non_digested_files
|
91
|
+
end
|
92
|
+
|
93
|
+
files.each do |file|
|
94
|
+
file.slice! "#{assets_public_path}/"
|
95
|
+
manifest[key] << file
|
96
|
+
end
|
97
|
+
|
98
|
+
File.open(@manifest_path, 'w') do |f|
|
99
|
+
f.write(manifest.to_json)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'contao/compiler'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'uglifier'
|
4
|
+
|
5
|
+
module TechnoGate
|
6
|
+
module Contao
|
7
|
+
class JavascriptCompiler < Compiler
|
8
|
+
|
9
|
+
def initialize(options = {})
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
protected
|
14
|
+
|
15
|
+
# Compile assets
|
16
|
+
#
|
17
|
+
# This method compiles javascripts from
|
18
|
+
# Application.config.javascripts_path into
|
19
|
+
# Application.config.assets_public_path/application.js and it uglifies
|
20
|
+
# only if the environment is equal to :production
|
21
|
+
def compile_assets
|
22
|
+
tmp_app_js = Contao.root.join('tmp/application.js')
|
23
|
+
FileUtils.mkdir_p File.dirname(tmp_app_js)
|
24
|
+
|
25
|
+
File.open(tmp_app_js, 'w') do |compressed|
|
26
|
+
javascripts_path.each do |src_path|
|
27
|
+
Dir["#{Contao.expandify(src_path)}/**/*.js"].sort.each do |f|
|
28
|
+
if TechnoGate::Contao.env == :production
|
29
|
+
compressed.write(Uglifier.new.compile(File.read(f)))
|
30
|
+
else
|
31
|
+
compressed.write("// #{f}\n")
|
32
|
+
compressed.write(File.read(f))
|
33
|
+
compressed.write("\n")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
FileUtils.mv tmp_app_js, application_js_path
|
40
|
+
end
|
41
|
+
|
42
|
+
def javascripts_path
|
43
|
+
Application.config.javascripts_path.map do |path|
|
44
|
+
["tmp/compiled_javascript/#{path.gsub('/', '_')}", path]
|
45
|
+
end.flatten
|
46
|
+
end
|
47
|
+
|
48
|
+
# This function creates a hashed version of the assets
|
49
|
+
def create_hashed_assets
|
50
|
+
create_digest_for_file(Contao.expandify(Contao::Application.config.assets_public_path).join("application.js"))
|
51
|
+
end
|
52
|
+
|
53
|
+
def application_js_path
|
54
|
+
Contao.expandify(Application.config.assets_public_path).join("application.js")
|
55
|
+
end
|
56
|
+
|
57
|
+
def generate_manifest
|
58
|
+
generate_manifest_for("javascripts", "js")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'singleton'
|
2
|
+
require 'guard'
|
3
|
+
|
4
|
+
module TechnoGate
|
5
|
+
module Contao
|
6
|
+
class Notifier
|
7
|
+
include Singleton
|
8
|
+
|
9
|
+
def notify(message, options = {})
|
10
|
+
if ::Guard::UI.send(:color_enabled?)
|
11
|
+
message = "\e[0;34mContao>>\e[0m \e[0;32m#{message}\e[0m"
|
12
|
+
else
|
13
|
+
message = "Contao>> #{message}"
|
14
|
+
end
|
15
|
+
|
16
|
+
::Guard::UI.info(message, options)
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.notify(*args, &block)
|
20
|
+
instance.notify(*args, &block)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'contao/compiler'
|
2
|
+
require 'compass'
|
3
|
+
require 'compass/commands'
|
4
|
+
|
5
|
+
module TechnoGate
|
6
|
+
module Contao
|
7
|
+
class StylesheetCompiler < Compiler
|
8
|
+
|
9
|
+
def initialize(options = {})
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
def clean
|
14
|
+
@cleaner ||= Compass::Commands::CleanProject.new(
|
15
|
+
Contao.root,
|
16
|
+
configuration_file: Contao.root.join('config', 'compass.rb')
|
17
|
+
)
|
18
|
+
|
19
|
+
@cleaner.execute
|
20
|
+
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
protected
|
25
|
+
def compile_assets
|
26
|
+
@updater ||= Compass::Commands::UpdateProject.new(
|
27
|
+
Contao.root,
|
28
|
+
configuration_file: Contao.root.join('config', 'compass.rb')
|
29
|
+
)
|
30
|
+
|
31
|
+
@updater.execute
|
32
|
+
end
|
33
|
+
|
34
|
+
def create_hashed_assets
|
35
|
+
Dir["#{Contao.expandify(Contao::Application.config.assets_public_path)}/**/*.css"].each do |file|
|
36
|
+
create_digest_for_file Pathname(file).expand_path
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def generate_manifest
|
41
|
+
generate_manifest_for("stylesheets", "css")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
namespace :assets do
|
2
|
+
desc "Compile javascript"
|
3
|
+
task :javascript do
|
4
|
+
TechnoGate::Contao::CoffeescriptCompiler.compile
|
5
|
+
TechnoGate::Contao::CoffeescriptCompiler.compile
|
6
|
+
TechnoGate::Contao::JavascriptCompiler.compile
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "Compile stylesheet"
|
10
|
+
task :stylesheet do
|
11
|
+
TechnoGate::Contao::StylesheetCompiler.compile
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "Clean assets"
|
15
|
+
task :clean do
|
16
|
+
TechnoGate::Contao::StylesheetCompiler.clean
|
17
|
+
TechnoGate::Contao::CoffeescriptCompiler.clean
|
18
|
+
TechnoGate::Contao::JavascriptCompiler.clean
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "Precompile assets"
|
22
|
+
task :precompile => [:clean, :stylesheet, :javascript]
|
23
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
require 'highline'
|
2
|
+
|
3
|
+
def ask(what, options = {})
|
4
|
+
default = options[:default]
|
5
|
+
validate = options[:validate] || /(y(es)?)|(no?)|(a(bort)?|\n)/i
|
6
|
+
echo = (options[:echo].nil?) ? true : options[:echo]
|
7
|
+
|
8
|
+
ui = HighLine.new
|
9
|
+
ui.ask("#{what}? ") do |q|
|
10
|
+
q.overwrite = false
|
11
|
+
q.default = default
|
12
|
+
q.validate = validate
|
13
|
+
q.responses[:not_valid] = what
|
14
|
+
unless echo
|
15
|
+
q.echo = "*"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
namespace :contao do
|
21
|
+
desc "Link all contao files"
|
22
|
+
task :bootstrap do
|
23
|
+
public = TechnoGate::Contao.expandify(TechnoGate::Contao::Application.config.contao_public_path)
|
24
|
+
|
25
|
+
TechnoGate::Contao::Application.linkify
|
26
|
+
|
27
|
+
FileUtils.mkdir_p public.join('system/logs')
|
28
|
+
File.open(public.join('sitemap.xml'), 'w') {|f| f.write ''}
|
29
|
+
|
30
|
+
Rake::Task['contao:fix_permissions'].invoke
|
31
|
+
Rake::Task['contao:generate_localconfig'].invoke
|
32
|
+
Rake::Task['contao:generate_htaccess'].invoke
|
33
|
+
Rake::Task['assets:precompile'].invoke
|
34
|
+
|
35
|
+
TechnoGate::Contao::Notifier.notify("The contao folder has been bootstraped, Good Luck.", title: "Contao Bootstrap")
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "Fix permissions"
|
39
|
+
task :fix_permissions do
|
40
|
+
require 'fileutils'
|
41
|
+
|
42
|
+
public = TechnoGate::Contao.expandify(TechnoGate::Contao::Application.config.contao_public_path)
|
43
|
+
paths = [
|
44
|
+
'system/html',
|
45
|
+
'system/logs',
|
46
|
+
'system/scripts',
|
47
|
+
'system/tmp',
|
48
|
+
'system/cache',
|
49
|
+
].map {|p| public.join p}.reject {|p| !File.exists? p}
|
50
|
+
|
51
|
+
FileUtils.chmod 0777, paths
|
52
|
+
|
53
|
+
Dir["#{public}/system/modules/efg/**/*"].each do |f|
|
54
|
+
if File.directory?(f)
|
55
|
+
FileUtils.chmod 0777, f
|
56
|
+
else
|
57
|
+
FileUtils.chmod 0666, f
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
FileUtils.chmod 0666, public.join('sitemap.xml')
|
62
|
+
|
63
|
+
TechnoGate::Contao::Notifier.notify("The contao folder's permissions has been fixed.", title: "Contao Bootstrap")
|
64
|
+
end
|
65
|
+
|
66
|
+
desc "Generate the localconfig.php"
|
67
|
+
task :generate_localconfig do
|
68
|
+
require 'parseconfig'
|
69
|
+
|
70
|
+
my_cnf_path = File.expand_path("#{ENV['HOME']}/.my.cnf")
|
71
|
+
localconfig_template = TechnoGate::Contao.expandify('config/examples/localconfig.php.erb')
|
72
|
+
localconfig_path = TechnoGate::Contao.expandify(TechnoGate::Contao::Application.config.contao_public_path).join('system/config/localconfig.php')
|
73
|
+
|
74
|
+
if File.exists?(my_cnf_path)
|
75
|
+
my_cnf = ParseConfig.new(my_cnf_path)
|
76
|
+
mysql_host = my_cnf.params['client']['host']
|
77
|
+
mysql_user = my_cnf.params['client']['user']
|
78
|
+
mysql_password = my_cnf.params['client']['password']
|
79
|
+
else
|
80
|
+
puts "Please add these details to #{my_cnf_path}"
|
81
|
+
mysql_host = ask("What host is mysql running on", default: 'localhost', validate: /.+/)
|
82
|
+
mysql_user = ask("What user to use with mysql", validate: /.+/)
|
83
|
+
mysql_password = ask("What is the user's password", validate: /.+/, echo: false)
|
84
|
+
end
|
85
|
+
mysql_database = TechnoGate::Contao::Application.name
|
86
|
+
contao_env = TechnoGate::Contao.env
|
87
|
+
|
88
|
+
localconfig = ERB.new(File.read(localconfig_template)).result(binding)
|
89
|
+
File.open(localconfig_path, 'w') {|f| f.write localconfig }
|
90
|
+
|
91
|
+
TechnoGate::Contao::Notifier.notify("The configuration file localconfig.php was generated successfully.", title: "Contao Bootstrap")
|
92
|
+
end
|
93
|
+
|
94
|
+
desc "Generate the htaccess file"
|
95
|
+
task :generate_htaccess do
|
96
|
+
public = TechnoGate::Contao.expandify(TechnoGate::Contao::Application.config.contao_public_path)
|
97
|
+
FileUtils.cp public.join('.htaccess.default'), public.join('.htaccess')
|
98
|
+
|
99
|
+
TechnoGate::Contao::Notifier.notify("The .htaccess was successfully generated.", title: "Contao Bootstrap")
|
100
|
+
end
|
101
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Taken from RefineryCMD
|
2
|
+
# https://github.com/resolve/refinerycms/blob/master/core/lib/tasks/refinery.rake
|
3
|
+
desc 'Removes trailing whitespace across the entire application.'
|
4
|
+
task :whitespace do
|
5
|
+
require 'rbconfig'
|
6
|
+
if RbConfig::CONFIG['host_os'] =~ /linux/
|
7
|
+
sh %{find . -name '*.*rb' -o -name '*.*php' -o -name '*.*coffee' -o -name '*.*sass' -exec sed -i 's/\t/ /g' {} \\; -exec sed -i 's/ *$//g' {} \\; }
|
8
|
+
elsif RbConfig::CONFIG['host_os'] =~ /darwin/
|
9
|
+
sh %{find . -name '*.*rb' -o -name '*.*php' -o -name '*.*coffee' -o -name '*.*sass' -exec sed -i '' 's/\t/ /g' {} \\; -exec sed -i '' 's/ *$//g' {} \\; }
|
10
|
+
else
|
11
|
+
puts "This doesn't work on systems other than OSX or Linux. Please use a custom whitespace tool for your platform '#{RbConfig::CONFIG["host_os"]}'."
|
12
|
+
end
|
13
|
+
end
|