forked from zquestz/bitcoincash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Rakefile
67 lines (60 loc) · 2.47 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
require 'bundler'
Bundler.setup
require 'erb'
require 'fileutils'
require 'i18n'
require "i18n/backend/fallbacks"
require 'digest'
namespace :docker do
desc "build docker images"
task :build => ['css:minify', 'js:minify', 'translations:build'] do
puts "Building bitcoincash docker image"
puts `docker build -t bitcoincash .`
end
end
namespace :css do
desc "minify css files"
task :minify do
puts `juicer merge html/css/deps.css html/css/bootstrap.css html/css/stack-interface.css html/css/socicon.css --force`
puts `juicer merge html/css/theme.css html/css/custom.css --force`
puts `juicer merge html/css/custom.css --force`
end
end
namespace :js do
desc "minify js files"
task :minify do
puts `juicer merge html/js/jquery.easing.1.3.js --force`
puts `juicer merge html/js/scripts.js html/js/main.js --force`
puts `juicer merge html/js/ticker.js --force`
end
end
namespace :translations do
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
I18n.load_path = Dir['./translations/*.yml']
I18n.default_locale = :en
desc "build translated html files"
task :build do
puts "Building bitcoincash translated html files"
nginx_template = File.read('views/nginx.conf.erb')
nginx_renderer = ERB.new(nginx_template)
File.write(File.join('.', 'nginx.conf'), nginx_renderer.result())
graphics_template = File.read('views/graphics.html.erb')
graphics_renderer = ERB.new(graphics_template, nil, '-')
FileUtils.mkdir_p(File.join('.', 'html', 'graphics'))
template = File.read('views/index.html.erb')
renderer = ERB.new(template, nil, '-')
I18n.available_locales.sort.each do |locale|
puts "Building #{locale}"
I18n.locale = locale
File.write(File.join('.', 'html', "index.#{locale}.html"), renderer.result())
File.write(File.join('.', 'html', 'index.html'), renderer.result()) if locale == :en
FileUtils.mkdir_p(File.join('.', 'html', 'graphics'))
FileUtils.mkdir_p(File.join('.', 'html', locale.to_s.downcase, 'graphics'))
File.write(File.join('.', 'html', 'graphics', "index.#{locale}.html"), graphics_renderer.result())
File.write(File.join('.', 'html', 'graphics', 'index.html'), renderer.result()) if locale == :en
File.write(File.join('.', 'html', locale.to_s.downcase, 'index.html'), renderer.result())
File.write(File.join('.', 'html', locale.to_s.downcase, 'graphics', 'index.html'), graphics_renderer.result())
end
end
end
task :default => 'docker:build'