2022-10-31 19:32:08 +01:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
# frozen_string_literal: true
|
2023-03-11 13:31:37 +01:00
|
|
|
|
2024-05-02 15:26:25 +02:00
|
|
|
##
|
2024-06-14 22:12:39 +02:00
|
|
|
# Requires
|
2022-11-05 03:26:03 +01:00
|
|
|
require "ryo"
|
2024-03-17 01:31:06 +01:00
|
|
|
require "ryo/json"
|
2024-06-20 22:34:33 +02:00
|
|
|
require "ryo/yaml"
|
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"
|
2024-05-02 15:14:04 +02:00
|
|
|
|
2024-06-22 04:27:45 +02:00
|
|
|
##
|
|
|
|
# Extensions
|
2024-06-22 04:43:31 +02:00
|
|
|
[Nanoc::RuleDSL::CompilationRuleContext, Nanoc::RuleDSL::CompilerDSL].each { _1.prepend(Utils) }
|
2024-06-22 04:27:45 +02:00
|
|
|
Nanoc::RuleDSL::CompilationRuleContext.prepend(Nanoc::Extension::AnonymousFilter)
|
|
|
|
Nanoc::RuleDSL::CompilerDSL.prepend(Nanoc::Extension::RequireRules)
|
|
|
|
|
2024-03-17 01:31:06 +01:00
|
|
|
##
|
2024-06-22 04:03:51 +02:00
|
|
|
# Locals
|
2024-05-19 21:48:09 +02:00
|
|
|
locales = %w[ar fa en]
|
2024-06-22 04:27:45 +02:00
|
|
|
name_by_id = Ryo.from_json(path: File.join(dirs.content, "json", "nameById.json"))
|
|
|
|
tdata = Ryo.from_json(path: File.join(dirs.content, "json", "t.json"))
|
2024-08-13 21:59:59 +02:00
|
|
|
surahs = Ryo.from_json(path: File.join(dirs.content, "json", "surahs.json"))
|
2024-06-15 04:32:55 +02:00
|
|
|
tidy = `which tidy || which tidy5`.chomp
|
2024-06-14 22:12:39 +02:00
|
|
|
buildenv = ENV["buildenv"] || "development"
|
2024-08-22 20:39:55 +02:00
|
|
|
etcdir = File.join(__dir__, "etc")
|
2024-08-30 15:16:42 +02:00
|
|
|
globals = {buildenv:, locales:, tidy:, tdata:, surahs:, name_by_id:}
|
2024-04-29 15:40:00 +02:00
|
|
|
|
|
|
|
##
|
2024-08-22 20:39:55 +02:00
|
|
|
# Filters
|
2024-04-29 15:40:00 +02:00
|
|
|
Nanoc::Tidy
|
|
|
|
.default_argv
|
2024-06-22 06:06:21 +02:00
|
|
|
.replace([*Nanoc::Tidy.default_argv, "-upper"].uniq)
|
2024-02-18 13:24:54 +01:00
|
|
|
|
2023-03-11 13:27:31 +01:00
|
|
|
##
|
2024-06-14 22:12:39 +02:00
|
|
|
# See packages/typescript/postman
|
2024-07-23 04:50:29 +02:00
|
|
|
compile "/css/vendor/postman.css" do
|
2024-04-30 05:28:52 +02:00
|
|
|
write("/css/vendor/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
|
2024-03-17 01:31:06 +01:00
|
|
|
filter(:erb, locals: {locales:, name_by_id:})
|
2024-05-02 15:46:40 +02:00
|
|
|
filter proc { _1.each_line.reject { |s| s.strip.empty? }.join }
|
2023-03-11 17:11:10 +01:00
|
|
|
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
|
|
|
##
|
2024-06-22 04:03:51 +02:00
|
|
|
# Rules
|
2024-08-30 15:16:42 +02:00
|
|
|
passthrough "/json/durations/*.json"
|
|
|
|
require_rules "nanoc/rules/assets", globals
|
|
|
|
require_rules "nanoc/rules/redirect", globals
|
|
|
|
require_rules "nanoc/rules/random", globals
|
|
|
|
require_rules "nanoc/rules/surah-stream", globals
|
|
|
|
require_rules "nanoc/rules/surah-index", globals
|
2023-07-12 01:14:58 +02:00
|
|
|
|
2024-08-30 15:16:42 +02:00
|
|
|
compile "/js/main/vendor.ts" do
|
|
|
|
filter :webpack,
|
|
|
|
argv: %w[--config etc/webpack.vendor.js]
|
|
|
|
write("/js/main/vendor.js")
|
|
|
|
end
|
2022-10-31 19:32:08 +01:00
|
|
|
compile("/**/*") { write(nil) }
|
2022-11-02 04:49:43 +01:00
|
|
|
layout("**/*", :erb)
|