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
|
|
|
##
|
|
|
|
# requires
|
2022-11-05 03:26:03 +01:00
|
|
|
require "ryo"
|
2024-03-17 01:31:06 +01:00
|
|
|
require "ryo/json"
|
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
|
|
|
|
|
|
|
##
|
|
|
|
# DSL extensions
|
2024-05-02 14:58:30 +02:00
|
|
|
Nanoc::RuleDSL::CompilationRuleContext.prepend(Nanoc::RuleDSL::Filter)
|
2024-05-02 15:14:04 +02:00
|
|
|
Nanoc::RuleDSL::CompilerDSL.prepend(Nanoc::RuleDSL::RequireRules)
|
2022-10-31 19:32:08 +01:00
|
|
|
|
2024-03-17 01:31:06 +01:00
|
|
|
##
|
2024-05-02 15:14:04 +02:00
|
|
|
# variables
|
2024-03-17 01:31:06 +01:00
|
|
|
locales = %w[ar en]
|
|
|
|
json_dir = File.join(Dir.getwd, "src", "json")
|
|
|
|
name_by_id = Ryo.from_json_file("#{json_dir}/nameById.json")
|
2024-05-01 03:41:01 +02:00
|
|
|
tdata = Ryo.from_json_file("#{json_dir}/t.json")
|
|
|
|
buildenv = ENV["buildenv"] || "development"
|
2024-04-29 15:40:00 +02:00
|
|
|
|
|
|
|
##
|
2024-05-02 15:14:04 +02:00
|
|
|
# plugins
|
2024-04-26 01:36:34 +02:00
|
|
|
Nanoc::Webpack
|
|
|
|
.default_argv
|
|
|
|
.concat ["--config", "webpack.#{buildenv}.js"]
|
2024-04-29 15:40:00 +02:00
|
|
|
Nanoc::Tidy
|
|
|
|
.default_argv
|
|
|
|
.concat ["-upper"]
|
2024-02-18 13:24:54 +01:00
|
|
|
|
2023-03-11 13:27:31 +01:00
|
|
|
##
|
2024-05-02 15:14:04 +02:00
|
|
|
# see packages/typescript/postman
|
2024-04-30 05:28:52 +02:00
|
|
|
compile "/css/vendor/postman.scss" do
|
2023-03-11 14:45:12 +01:00
|
|
|
filter :sass, syntax: :scss, style: :compact
|
|
|
|
filter :rainpress
|
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 14:58:30 +02:00
|
|
|
filter Proc.new { _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-05-02 15:14:04 +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"
|
2024-03-17 01:31:06 +01:00
|
|
|
require_rules "nanoc/rules/random", {locales:}
|
2024-05-01 03:41:01 +02:00
|
|
|
require_rules "nanoc/rules/stream", {locales:, tdata:, name_by_id:}
|
|
|
|
require_rules "nanoc/rules/index", {locales:, tdata:}
|
2023-07-12 01:14:58 +02:00
|
|
|
|
2022-10-31 19:32:08 +01:00
|
|
|
##
|
2024-05-02 15:14:04 +02:00
|
|
|
# defaults
|
2022-10-31 19:32:08 +01:00
|
|
|
compile("/**/*") { write(nil) }
|
2022-11-02 04:49:43 +01:00
|
|
|
layout("**/*", :erb)
|