Group locals onto 'context'
This commit is contained in:
parent
0aee18baf7
commit
0e5b8db6bf
8 changed files with 29 additions and 38 deletions
3
Rules
3
Rules
|
@ -21,6 +21,7 @@ Nanoc::RuleDSL::CompilerDSL.prepend(Nanoc::Extension::RequireRules)
|
||||||
locales = %w[ar fa en]
|
locales = %w[ar fa en]
|
||||||
name_by_id = Ryo.from_json(path: File.join(dirs.content, "json", "nameById.json"))
|
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"))
|
tdata = Ryo.from_json(path: File.join(dirs.content, "json", "t.json"))
|
||||||
|
surahs = Ryo.from_json(path: File.join(dirs.content, "json", "surahs.json"))
|
||||||
tidy = `which tidy || which tidy5`.chomp
|
tidy = `which tidy || which tidy5`.chomp
|
||||||
buildenv = ENV["buildenv"] || "development"
|
buildenv = ENV["buildenv"] || "development"
|
||||||
|
|
||||||
|
@ -62,7 +63,7 @@ passthrough "/json/durations/*.json"
|
||||||
require_rules "nanoc/rules/assets"
|
require_rules "nanoc/rules/assets"
|
||||||
require_rules "nanoc/rules/redirect", {locales:, tidy:}
|
require_rules "nanoc/rules/redirect", {locales:, tidy:}
|
||||||
require_rules "nanoc/rules/random", {locales:, tdata:, tidy:}
|
require_rules "nanoc/rules/random", {locales:, tdata:, tidy:}
|
||||||
require_rules "nanoc/rules/surah-stream", {locales:, tdata:, name_by_id:, tidy:}
|
require_rules "nanoc/rules/surah-stream", {locales:, tdata:, surahs:, name_by_id:, tidy:}
|
||||||
require_rules "nanoc/rules/surah-index", {locales:, tdata:, tidy:}
|
require_rules "nanoc/rules/surah-index", {locales:, tdata:, tidy:}
|
||||||
|
|
||||||
##
|
##
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
|
|
||||||
locales.each do |locale|
|
locales.each do |locale|
|
||||||
compile "/html/main/random.html.erb", rep: "random/#{locale}" do
|
compile "/html/main/random.html.erb", rep: "random/#{locale}" do
|
||||||
context = Ryo.from({filename: "random.html.erb", dir: tdata[locale].dir, locale:, locales:})
|
context = Ryo.from({dir: tdata[locale].dir, locale:, locales:})
|
||||||
filter(:erb, locals: {locale:, locales:, dir: context.dir, context:})
|
filter(:erb, locals: {context:})
|
||||||
filter(:tidy, exe: tidy)
|
filter(:tidy, exe: tidy)
|
||||||
write("/#{locale}/random/index.html")
|
write("/#{locale}/random/index.html")
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,8 +7,8 @@
|
||||||
|
|
||||||
locales.each do |locale|
|
locales.each do |locale|
|
||||||
compile "/html/main/surah-index.html.erb", rep: "/#{locale}/surah/index" do
|
compile "/html/main/surah-index.html.erb", rep: "/#{locale}/surah/index" do
|
||||||
context = Ryo.from(filename: "surah-index.html.erb", dir: tdata[locale].dir, locale:, locales:)
|
context = Ryo.from(dir: tdata[locale].dir, locale:, locales:)
|
||||||
filter(:erb, {locals: {locale:, locales:, dir: context.dir, context:}})
|
filter(:erb, {locals: {context:}})
|
||||||
filter(:tidy, exe: tidy)
|
filter(:tidy, exe: tidy)
|
||||||
write "/#{locale}/index.html"
|
write "/#{locale}/index.html"
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,19 +15,9 @@ end
|
||||||
|
|
||||||
Ryo.each(name_by_id) do |id, slug|
|
Ryo.each(name_by_id) do |id, slug|
|
||||||
write_file = ->(locale, pathname:) do
|
write_file = ->(locale, pathname:) do
|
||||||
name = tdata[locale].surahs.names[id.to_i - 1]
|
surah = surahs[locale][id.to_i - 1]
|
||||||
context = Ryo.from(
|
context = Ryo.from(locale:, locales:, surah:, dir: tdata[locale].dir)
|
||||||
filename: "surah-stream.html.erb",
|
filter(:erb, locals: {context:})
|
||||||
locale:,
|
|
||||||
locales:,
|
|
||||||
surah: {id:, name:, slug:},
|
|
||||||
dir: tdata[locale].dir
|
|
||||||
)
|
|
||||||
locals = {
|
|
||||||
locale: context.locale, locales: context.locales,
|
|
||||||
surah: context.surah, dir: context.dir, context:
|
|
||||||
}
|
|
||||||
filter(:erb, locals:)
|
|
||||||
filter(:tidy, exe: tidy)
|
filter(:tidy, exe: tidy)
|
||||||
write "/#{locale}/#{pathname}/index.html"
|
write "/#{locale}/#{pathname}/index.html"
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,15 +1,15 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="<%= locale %>" dir="<%= dir %>">
|
<html lang="<%= context.locale %>" dir="<%= context.dir %>">
|
||||||
<head>
|
<head>
|
||||||
<title><%= t(locale, "TheNobleQuran") %></title>
|
<title><%= t(context.locale, "TheNobleQuran") %></title>
|
||||||
<meta name="description" content="<%= t(locale, 'meta.random.description') %>">
|
<meta name="description" content="<%= t(context.locale, 'meta.random.description') %>">
|
||||||
<%= erb("_version.html.erb") %>
|
<%= erb("_version.html.erb") %>
|
||||||
<%= erb("_opengraph.html.erb", {file: "random.html.erb", context:}) %>
|
<%= erb("_opengraph.html.erb", {file: "random.html.erb", context:}) %>
|
||||||
<link
|
<link
|
||||||
rel="canonical"
|
rel="canonical"
|
||||||
href="<%= base_url %>/<%= locale %>/random/"
|
href="<%= base_url %>/<%= context.locale %>/random/"
|
||||||
/>
|
/>
|
||||||
<% locales.each do |locale| %>
|
<% context.locales.each do |locale| %>
|
||||||
<link
|
<link
|
||||||
rel="alternate"
|
rel="alternate"
|
||||||
href="<%= base_url %>/<%= locale %>/random/"
|
href="<%= base_url %>/<%= locale %>/random/"
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="<%= locale %>" dir="<%= dir %>">
|
<html lang="<%= context.locale %>" dir="<%= context.dir %>">
|
||||||
<head>
|
<head>
|
||||||
<title><%= t(locale, "TheNobleQuran") %></title>
|
<title><%= t(context.locale, "TheNobleQuran") %></title>
|
||||||
<%= inline_css('/css/vendor/postman.css') %>
|
<%= inline_css('/css/vendor/postman.css') %>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="description" content="<%= t(locale, 'meta.index.description') %>">
|
<meta name="description" content="<%= t(context.locale, 'meta.index.description') %>">
|
||||||
<%= erb("_version.html.erb") %>
|
<%= erb("_version.html.erb") %>
|
||||||
<%= erb("_opengraph.html.erb", {file: "surah-index.html.erb", context:}) %>
|
<%= erb("_opengraph.html.erb", {file: "surah-index.html.erb", context:}) %>
|
||||||
<link
|
<link
|
||||||
rel="canonical"
|
rel="canonical"
|
||||||
href="<%= base_url %>/<%= locale %>/"
|
href="<%= base_url %>/<%= context.locale %>/"
|
||||||
/>
|
/>
|
||||||
<% locales.each do |locale| %>
|
<% context.locales.each do |locale| %>
|
||||||
<link rel="alternate"
|
<link rel="alternate"
|
||||||
href="<%= base_url %>/<%= locale %>/"
|
href="<%= base_url %>/<%= locale %>/"
|
||||||
hreflang="<%= locale %>" />
|
hreflang="<%= locale %>" />
|
||||||
|
@ -20,7 +20,7 @@
|
||||||
<%= erb("_favicon.html.erb") %>
|
<%= erb("_favicon.html.erb") %>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<%= erb("_postman.html.erb", {locale:, dir:}) %>
|
<%= erb("_postman.html.erb", {locale: context.locale, dir: context.dir}) %>
|
||||||
<div class="root h-full"></div>
|
<div class="root h-full"></div>
|
||||||
<script src="/js/loaders/surah-index-loader.js?v=<%= commit %>"></script>
|
<script src="/js/loaders/surah-index-loader.js?v=<%= commit %>"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="<%= locale %>" dir="<%= dir %>">
|
<html lang="<%= context.locale %>" dir="<%= context.dir %>">
|
||||||
<head>
|
<head>
|
||||||
<title><%= surah.name %></title>
|
<title><%= context.surah.name %></title>
|
||||||
<%= inline_css('/css/vendor/postman.css') %>
|
<%= inline_css('/css/vendor/postman.css') %>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="description" content="<%= t(locale, 'meta.stream.description') %>">
|
<meta name="description" content="<%= t(context.locale, 'meta.stream.description') %>">
|
||||||
<%= erb("_version.html.erb") %>
|
<%= erb("_version.html.erb") %>
|
||||||
<%= erb("_opengraph.html.erb", {file: "stream-stream.html.erb", context:}) %>
|
<%= erb("_opengraph.html.erb", {file: "stream-stream.html.erb", context:}) %>
|
||||||
<link
|
<link
|
||||||
rel="canonical"
|
rel="canonical"
|
||||||
href="<%= base_url %>/<%= locale %>/<%= surah.urlName %>/"
|
href="<%= base_url %>/<%= context.locale %>/<%= context.surah.urlName %>/"
|
||||||
/>
|
/>
|
||||||
<% locales.each do |locale| %>
|
<% context.locales.each do |locale| %>
|
||||||
<link rel="alternate"
|
<link rel="alternate"
|
||||||
href="<%= base_url %>/<%= locale %>/<%= surah.urlName %>/"
|
href="<%= base_url %>/<%= locale %>/<%= context.surah.urlName %>/"
|
||||||
hreflang="<%= locale %>" />
|
hreflang="<%= locale %>" />
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= erb("_favicon.html.erb") %>
|
<%= erb("_favicon.html.erb") %>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<%= erb("_postman.html.erb", {locale:, dir:}) %>
|
<%= erb("_postman.html.erb", {locale: context.locale, dir: context.dir}) %>
|
||||||
<div class="root"
|
<div class="root"
|
||||||
data-surah-id="<%= surah.id %>"
|
data-surah-id="<%= context.surah.id %>"
|
||||||
data-audio-base-url="<%= audio_base_url %>">
|
data-audio-base-url="<%= audio_base_url %>">
|
||||||
</div>
|
</div>
|
||||||
<script src="/js/loaders/surah-stream-loader.js?v=<%= commit %>"></script>
|
<script src="/js/loaders/surah-stream-loader.js?v=<%= commit %>"></script>
|
||||||
|
|
|
@ -2741,4 +2741,4 @@
|
||||||
"translitName": "An-Nas"
|
"translitName": "An-Nas"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue