2022-10-31 19:32:08 +01:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
# frozen_string_literal: true
|
2022-11-05 03:26:03 +01:00
|
|
|
require "ryo"
|
2022-11-12 17:28:26 +01:00
|
|
|
require "nanoc-gunzip"
|
2022-11-19 02:24:57 +01:00
|
|
|
require "nanoc-webpack"
|
2022-10-31 19:32:08 +01:00
|
|
|
|
2023-03-02 01:52:25 +01:00
|
|
|
locales = %w[ar en]
|
|
|
|
surah_id_to_name = Ryo.from(
|
2022-11-05 03:26:03 +01:00
|
|
|
JSON.parse(
|
|
|
|
File.read(File.join(Dir.getwd, "src", "slugs.json"))
|
|
|
|
)
|
|
|
|
)
|
2022-10-31 19:32:08 +01:00
|
|
|
|
2023-03-02 01:52:25 +01:00
|
|
|
def require_rules(rules, locals = {}, target = binding)
|
|
|
|
locals.each { target.local_variable_set(_1, _2) }
|
|
|
|
path = File.join(Dir.getwd, rules)
|
|
|
|
target.eval(
|
|
|
|
if File.readable?(path)
|
|
|
|
File.read(path)
|
|
|
|
elsif File.readable?("#{path}.rb")
|
|
|
|
File.read("#{path}.rb")
|
|
|
|
elsif File.readable?("#{path}.rules")
|
|
|
|
File.read("#{path}.rules")
|
|
|
|
else
|
|
|
|
raise LoadError, "#{path} is not readable"
|
2022-11-05 03:26:03 +01:00
|
|
|
end
|
2023-03-02 01:52:25 +01:00
|
|
|
)
|
2022-11-06 10:51:28 +01:00
|
|
|
end
|
|
|
|
|
2022-10-31 19:32:08 +01:00
|
|
|
##
|
2023-03-02 01:52:25 +01:00
|
|
|
# Require rules
|
|
|
|
require_rules "rules/pages/RandomRedirect", {locales:, surah_id_to_name:}
|
|
|
|
require_rules "rules/pages/TheSurahPage", {locales:, surah_id_to_name:}
|
|
|
|
require_rules "rules/assets"
|
2022-10-31 19:32:08 +01:00
|
|
|
|
|
|
|
##
|
2023-03-02 01:52:25 +01:00
|
|
|
# Default rules
|
2022-10-31 19:32:08 +01:00
|
|
|
compile("/**/*") { write(nil) }
|
2022-11-02 04:49:43 +01:00
|
|
|
layout("**/*", :erb)
|