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
|
|
|
|
|
|
|
LOCALES = %w[ar en]
|
2022-11-05 03:26:03 +01:00
|
|
|
SURAH_ID_TO_SLUG = Ryo.from(
|
|
|
|
JSON.parse(
|
|
|
|
File.read(File.join(Dir.getwd, "src", "slugs.json"))
|
|
|
|
)
|
|
|
|
)
|
2022-10-31 19:32:08 +01:00
|
|
|
|
|
|
|
##
|
2022-11-05 03:26:03 +01:00
|
|
|
# Root path (/)
|
2023-01-08 16:29:32 +01:00
|
|
|
# Locale path (/en/, /ar/)
|
2022-11-06 00:48:59 +01:00
|
|
|
# Redirects to a random surah no
|
2023-01-08 16:29:32 +01:00
|
|
|
compile "/html/RandomRedirect.html.erb" do
|
2022-11-19 23:23:48 +01:00
|
|
|
filter(:erb)
|
2022-11-02 02:36:57 +01:00
|
|
|
write("/index.html")
|
2023-01-08 16:29:32 +01:00
|
|
|
LOCALES.each { write "/#{_1}/index.html" }
|
2022-11-02 02:36:57 +01:00
|
|
|
end
|
|
|
|
|
2022-10-31 19:32:08 +01:00
|
|
|
##
|
|
|
|
# /<locale>/<surahno>/surah.json
|
2022-11-06 00:48:59 +01:00
|
|
|
# Provides the JSON for a given surah no
|
2022-11-12 18:35:26 +01:00
|
|
|
compile "/*/*/surah.json" do
|
|
|
|
write(item.identifier.to_s)
|
|
|
|
if File.size(item.raw_filename) > (1024 * 10)
|
|
|
|
filter :gzip_text
|
|
|
|
write("#{item.identifier}.gz")
|
|
|
|
end
|
2022-10-31 19:32:08 +01:00
|
|
|
end
|
|
|
|
|
2022-11-05 03:26:03 +01:00
|
|
|
##
|
|
|
|
# /<locale>/<surahno>/index.html
|
2022-11-06 00:48:59 +01:00
|
|
|
# Redirects to a slug URL (eg /en/al-fatihah/)
|
2022-11-06 09:32:07 +01:00
|
|
|
compile "/html/redirect-to-surah-slug.html.erb" do
|
2022-11-19 23:23:48 +01:00
|
|
|
filter(:erb)
|
2022-11-05 03:26:03 +01:00
|
|
|
1.upto(114) do |surahno|
|
|
|
|
LOCALES.each { write(File.join("/", _1, surahno.to_s, "index.html")) }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# /<locale>/surah_slug>/index.html
|
2022-11-06 00:48:59 +01:00
|
|
|
# For reading a given surah
|
2022-11-05 03:26:03 +01:00
|
|
|
Ryo.each(SURAH_ID_TO_SLUG) do |surah_id, slug|
|
|
|
|
LOCALES.each do |locale|
|
2022-11-06 09:32:07 +01:00
|
|
|
compile "/html/TheSurahPage.html.erb", rep: "/#{locale}/#{slug}/index.html" do
|
2022-11-05 03:26:03 +01:00
|
|
|
filter :erb, locals: {locale: locale, surah_id: surah_id}
|
|
|
|
write "/#{locale}/#{slug}/index.html"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-10-31 19:32:08 +01:00
|
|
|
##
|
2023-02-27 02:04:55 +01:00
|
|
|
# TheSurahPage
|
2022-10-31 19:32:08 +01:00
|
|
|
compile "/js/pages/TheSurahPage.tsx" do
|
2023-01-08 09:10:04 +01:00
|
|
|
filter :webpack, depend_on: ["/js/components", "/js/lib/[!WebPackage]/", "/js/hooks"]
|
2023-02-27 02:04:55 +01:00
|
|
|
write "/js/pages/TheSurahPage.js"
|
2022-11-11 00:41:22 +01:00
|
|
|
filter :gzip_text
|
2023-02-27 02:04:55 +01:00
|
|
|
write "/js/pages/TheSurahPage.js.gz"
|
2022-10-31 19:32:08 +01:00
|
|
|
end
|
|
|
|
|
2022-11-12 22:55:53 +01:00
|
|
|
compile "/js/pages/TheSurahPage/package.ts" do
|
2023-01-08 09:10:04 +01:00
|
|
|
filter :webpack, depend_on: "/js/lib/WebPackage"
|
2022-11-12 22:55:53 +01:00
|
|
|
write "/js/pages/TheSurahPage/package.js"
|
|
|
|
end
|
|
|
|
|
2023-02-27 02:04:55 +01:00
|
|
|
compile "/css/pages/TheSurahPage.scss" do
|
|
|
|
filter :sass, syntax: :scss, style: :compact
|
|
|
|
filter :rainpress
|
|
|
|
write("/css/pages/TheSurahPage.css")
|
|
|
|
end
|
|
|
|
|
2022-11-06 10:45:30 +01:00
|
|
|
##
|
2023-01-08 16:29:32 +01:00
|
|
|
# /js/pages/RandomRedirect.js
|
|
|
|
compile "/js/pages/RandomRedirect.ts" do
|
2022-11-18 03:34:46 +01:00
|
|
|
filter :webpack
|
2023-01-08 16:29:32 +01:00
|
|
|
write "/js/pages/RandomRedirect.js"
|
2022-11-06 10:45:30 +01:00
|
|
|
end
|
|
|
|
|
2022-11-06 10:51:28 +01:00
|
|
|
##
|
|
|
|
# /js/pages/redirect-to-surah-slug.js
|
|
|
|
compile "/js/pages/redirect-to-surah-slug.ts" do
|
2022-11-18 03:34:46 +01:00
|
|
|
filter :webpack
|
2022-11-06 10:51:28 +01:00
|
|
|
write "/js/pages/redirect-to-surah-slug.js"
|
|
|
|
end
|
|
|
|
|
2022-10-31 19:32:08 +01:00
|
|
|
##
|
|
|
|
# CSS
|
|
|
|
|
|
|
|
##
|
|
|
|
# Fonts
|
|
|
|
compile "/fonts/*" do
|
|
|
|
write(item.identifier.to_s)
|
2022-11-11 00:41:22 +01:00
|
|
|
filter :gzip_binary
|
|
|
|
write("#{item.identifier}.gz")
|
2022-10-31 19:32:08 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
##
|
|
|
|
# Images
|
2022-11-11 00:41:22 +01:00
|
|
|
compile "/images/*.svg" do
|
2022-10-31 19:32:08 +01:00
|
|
|
write(item.identifier.to_s)
|
2022-11-11 00:41:22 +01:00
|
|
|
filter :gzip_binary
|
|
|
|
write("#{item.identifier}.gz")
|
2022-10-31 19:32:08 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
compile("/**/*") { write(nil) }
|
2022-11-02 04:49:43 +01:00
|
|
|
layout("**/*", :erb)
|