al-quran.reflectslight.io/Rules

74 lines
1.7 KiB
Text
Raw Normal View History

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
require "ryo"
2024-03-17 01:31:06 +01:00
require "ryo/json"
2023-06-30 00:49:42 +02:00
require "nanoc-gzip"
require "nanoc-webpack"
require "nanoc-tidy"
2024-05-02 15:14:04 +02:00
2024-03-17 01:31:06 +01:00
##
2024-06-14 22:12:39 +02:00
# Configuration
locales = %w[ar fa en]
2024-03-17 01:31:06 +01:00
json_dir = File.join(Dir.getwd, "src", "json")
2024-06-14 22:12:39 +02:00
name_by_id = Ryo.from_json(path: File.join(json_dir, "nameById.json"))
tdata = Ryo.from_json(path: File.join(json_dir, "t.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-04-29 15:40:00 +02:00
2024-05-14 21:07:57 +02:00
##
# DSL extensions
Nanoc::RuleDSL::CompilationRuleContext.prepend(Nanoc::RuleDSL::Filter)
Nanoc::RuleDSL::CompilerDSL.prepend(Nanoc::RuleDSL::RequireRules)
2024-04-29 15:40:00 +02:00
##
2024-06-14 22:12:39 +02:00
# Plugins
Nanoc::Webpack
.default_argv
.replace([*Nanoc::Webpack.default_argv, "--config", "webpack.#{buildenv}.js"].uniq)
2024-04-29 15:40:00 +02:00
Nanoc::Tidy
.default_argv
.replace([*Nanoc::Tidy.default_argv, "--config", "webpack.#{buildenv}.js"].uniq)
##
2024-06-14 22:12:39 +02:00
# See packages/typescript/postman
compile "/css/vendor/postman.scss" do
2023-03-11 14:45:12 +01:00
filter :sass, syntax: :scss, style: :compact
filter :rainpress
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
2024-05-02 16:29:46 +02:00
##
# /json/durations/*/*.json
passthrough "/json/durations/*.json"
2024-05-02 16:29:46 +02:00
2023-07-12 01:14:58 +02:00
##
2024-06-14 22:12:39 +02:00
# Require rules
2023-07-17 12:19:43 +02:00
require_rules "nanoc/rules/assets"
2024-06-15 04:31:39 +02:00
require_rules "nanoc/rules/redirect", {locales:, tidy:}
require_rules "nanoc/rules/random", {locales:, tdata:, tidy:}
require_rules "nanoc/rules/stream", {locales:, tdata:, name_by_id:, tidy:}
require_rules "nanoc/rules/index", {locales:, tdata:, tidy:}
2023-07-12 01:14:58 +02:00
2022-10-31 19:32:08 +01:00
##
2024-06-14 22:12:39 +02:00
# Catch-all
2022-10-31 19:32:08 +01:00
compile("/**/*") { write(nil) }
2022-11-02 04:49:43 +01:00
layout("**/*", :erb)