al-quran.reflectslight.io/Rules

108 lines
2.3 KiB
Text
Raw Normal View History

2022-10-31 19:32:08 +01:00
#!/usr/bin/env ruby
# frozen_string_literal: true
require "ryo"
require "nanoc-gunzip"
2022-10-31 19:32:08 +01:00
LOCALES = %w[ar en]
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
##
# Root path (/)
2022-11-06 00:48:59 +01:00
# Redirects to a random surah no
compile "/html/redirect-to-random-surah.html" do
2022-11-02 02:36:57 +01:00
write("/index.html")
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
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
##
# /<locale>/<surahno>/index.html
2022-11-06 00:48:59 +01:00
# Redirects to a slug URL (eg /en/al-fatihah/)
compile "/html/redirect-to-surah-slug.html.erb" do
filter :erb
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
Ryo.each(SURAH_ID_TO_SLUG) do |surah_id, slug|
LOCALES.each do |locale|
compile "/html/TheSurahPage.html.erb", rep: "/#{locale}/#{slug}/index.html" do
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
##
2022-11-02 02:36:57 +01:00
# /js/pages/surah.js
2022-10-31 19:32:08 +01:00
compile "/js/pages/TheSurahPage.tsx" do
filter :webpack
2022-10-31 19:32:08 +01:00
write "/js/pages/surah.js"
filter :gzip_text
write "/js/pages/surah.js.gz"
2022-10-31 19:32:08 +01:00
end
compile "/js/pages/TheSurahPage/package.ts" do
filter :webpack
write "/js/pages/TheSurahPage/package.js"
end
##
# /js/pages/redirect-to-random-surah.js
compile "/js/pages/redirect-to-random-surah.ts" do
filter :webpack
write "/js/pages/redirect-to-random-surah.js"
end
##
# /js/pages/redirect-to-surah-slug.js
compile "/js/pages/redirect-to-surah-slug.ts" do
filter :webpack
write "/js/pages/redirect-to-surah-slug.js"
end
2022-10-31 19:32:08 +01:00
##
# CSS
compile("/css/_*.scss") { write(nil) }
compile "/css/*.scss" do
filter :sass, syntax: :scss, style: :compact
filter :rainpress
write item.identifier.without_ext + ".css"
end
##
# Fonts
compile "/fonts/*" do
write(item.identifier.to_s)
filter :gzip_binary
write("#{item.identifier}.gz")
2022-10-31 19:32:08 +01:00
end
##
# Images
compile "/images/*.svg" do
2022-10-31 19:32:08 +01:00
write(item.identifier.to_s)
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)