2022-10-31 19:32:08 +01:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
# frozen_string_literal: true
|
2023-03-11 13:31:37 +01:00
|
|
|
|
2022-11-05 03:26:03 +01:00
|
|
|
require "ryo"
|
2023-06-30 00:49:42 +02:00
|
|
|
require "nanoc-gzip"
|
2022-11-19 02:24:57 +01:00
|
|
|
require "nanoc-webpack"
|
2023-11-07 05:59:45 +01:00
|
|
|
require "nanoc-tidy"
|
2022-10-31 19:32:08 +01:00
|
|
|
|
2023-03-02 01:52:25 +01:00
|
|
|
locales = %w[ar en]
|
2023-03-12 20:45:17 +01:00
|
|
|
slugs = Ryo.from(
|
2022-11-05 03:26:03 +01:00
|
|
|
JSON.parse(
|
|
|
|
File.read(File.join(Dir.getwd, "src", "slugs.json"))
|
|
|
|
)
|
|
|
|
)
|
2023-03-11 22:41:22 +01:00
|
|
|
i18n = Ryo.from(
|
|
|
|
JSON.parse(
|
|
|
|
File.read(File.join(Dir.getwd, "src", "i18n.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
|
|
|
|
|
2023-03-11 13:27:31 +01:00
|
|
|
##
|
2023-03-11 14:45:12 +01:00
|
|
|
# Inline CSS / JSON rules
|
2023-03-10 20:36:52 +01:00
|
|
|
compile "/i18n.json" do
|
|
|
|
filter(:minify_json)
|
2023-03-11 13:27:31 +01:00
|
|
|
write(nil)
|
|
|
|
end
|
|
|
|
|
|
|
|
compile "/surahs.json" do
|
|
|
|
filter(:minify_json)
|
|
|
|
write(nil)
|
|
|
|
end
|
|
|
|
|
|
|
|
compile "/slugs.json" do
|
|
|
|
filter(:minify_json)
|
|
|
|
write(nil)
|
2023-03-10 20:36:52 +01:00
|
|
|
end
|
|
|
|
|
2023-10-13 06:13:03 +02:00
|
|
|
compile "/recitations.json" do
|
2023-07-21 17:30:47 +02:00
|
|
|
filter(:minify_json)
|
|
|
|
write(nil)
|
|
|
|
end
|
|
|
|
|
2023-07-12 01:14:58 +02:00
|
|
|
compile "/css/postman.scss" do
|
2023-03-11 14:45:12 +01:00
|
|
|
filter :sass, syntax: :scss, style: :compact
|
|
|
|
filter :rainpress
|
2023-07-12 01:14:58 +02:00
|
|
|
write("/css/postman.css")
|
2023-03-11 14:45:12 +01:00
|
|
|
end
|
|
|
|
|
2023-03-11 17:11:10 +01:00
|
|
|
##
|
|
|
|
# /sitemap.xml
|
|
|
|
compile "/sitemap.xml.erb" do
|
2023-03-12 20:45:17 +01:00
|
|
|
filter(:erb, locals: {locales:, slugs:})
|
2023-03-11 17:11:10 +01:00
|
|
|
filter(:strip)
|
|
|
|
write("/sitemap.xml")
|
|
|
|
end
|
|
|
|
|
2023-07-17 21:48:12 +02:00
|
|
|
##
|
|
|
|
# /robots.txt
|
|
|
|
compile "/robots.txt" do
|
|
|
|
write("/robots.txt")
|
|
|
|
end
|
|
|
|
|
2023-07-12 01:14:58 +02:00
|
|
|
##
|
|
|
|
# Require rules
|
2023-07-17 12:19:43 +02:00
|
|
|
require_rules "nanoc/rules/assets"
|
2023-10-08 10:02:01 +02:00
|
|
|
require_rules "nanoc/rules/redirect"
|
|
|
|
require_rules "nanoc/rules/random", {locales:, i18n:, slugs:}
|
|
|
|
require_rules "nanoc/rules/stream", {locales:, i18n:, slugs:}
|
|
|
|
require_rules "nanoc/rules/index", {locales:, i18n:}
|
2023-07-12 01:14:58 +02:00
|
|
|
|
2022-10-31 19:32:08 +01:00
|
|
|
##
|
2023-03-02 05:30:46 +01:00
|
|
|
# Defaults
|
2022-10-31 19:32:08 +01:00
|
|
|
compile("/**/*") { write(nil) }
|
2022-11-02 04:49:43 +01:00
|
|
|
layout("**/*", :erb)
|