2019-07-30 21:29:24 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-25 16:20:18 +00:00
|
|
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
2018-03-25 17:30:42 +00:00
|
|
|
|
|
|
|
namespace :settings do
|
|
|
|
task :environment do
|
|
|
|
require File.expand_path('../../config/environment.rb', File.dirname(__FILE__))
|
|
|
|
end
|
|
|
|
|
2019-07-30 21:29:24 +00:00
|
|
|
desc 'show settings'
|
|
|
|
task show: :environment do
|
2018-03-25 17:30:42 +00:00
|
|
|
require 'pp'
|
|
|
|
pp Settings.to_hash
|
|
|
|
end
|
|
|
|
|
2019-07-30 21:29:24 +00:00
|
|
|
task generate_json: :environment do
|
|
|
|
cdn_url = URI(Settings.cdn.url)
|
2018-03-25 17:30:42 +00:00
|
|
|
cdn_url = cdn_url.to_s
|
2019-07-30 21:29:24 +00:00
|
|
|
if Settings.button_config&.url
|
|
|
|
cdn_url = URI(Settings.button_config.url).to_s
|
2018-07-24 21:32:27 +00:00
|
|
|
end
|
2019-07-30 21:29:24 +00:00
|
|
|
c = { button: { url: cdn_url, css: "#{cdn_url}/css/donate-button.v2.css" } }
|
2018-03-25 17:30:42 +00:00
|
|
|
open(File.expand_path('config/settings.json', Rails.root), 'w') do |f|
|
|
|
|
f.write(c.to_json)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-07-30 21:29:24 +00:00
|
|
|
task combine_translations: 'i18n:js:export' do
|
2018-03-25 17:30:42 +00:00
|
|
|
js_root = File.expand_path('public/javascripts', Rails.root)
|
2019-07-30 21:29:24 +00:00
|
|
|
# i18n = File.read(File.join(js_root, 'i18n.js'))
|
2018-03-25 17:30:42 +00:00
|
|
|
translations = File.read(File.join(js_root, 'translations.js'))
|
|
|
|
open(File.join(js_root, '_final.js'), 'w') do |f|
|
|
|
|
f.write("const I18n = require('i18n-js');\n" + translations + "\n window.I18n = I18n")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|