Populate surah via info.json

This commit is contained in:
0x1eef 2024-05-14 23:08:04 -03:00
parent 5a59e999b3
commit 82cb7e81e0
4 changed files with 15 additions and 11 deletions

1
.gitignore vendored
View file

@ -4,6 +4,7 @@
/packages/typescript/**/dist/ /packages/typescript/**/dist/
/rake/tasks/deploy.rake /rake/tasks/deploy.rake
/.gems/ /.gems/
/submodules/quran-json/
/crash.log /crash.log
node_modules/ node_modules/
*.core *.core

View file

@ -5,7 +5,7 @@
# Contains rules for the the surah stream available # Contains rules for the the surah stream available
# at /<locale>/<name>/, /<locale>/<id>/ # at /<locale>/<name>/, /<locale>/<id>/
compile "/json/*/*/surah.json" do compile "/json/*/*/{surah,info}.json" do
write(item.identifier.to_s) write(item.identifier.to_s)
if File.size(item.raw_filename) > (1024 * 10) if File.size(item.raw_filename) > (1024 * 10)
filter :gzip filter :gzip

View file

@ -13,7 +13,8 @@ import postman, { item } from "postman";
item.css("/css/main/surah-stream.css"), item.css("/css/main/surah-stream.css"),
item.font("Kanit Regular", "url(/fonts/kanit-regular.ttf)"), item.font("Kanit Regular", "url(/fonts/kanit-regular.ttf)"),
item.font("Mada Regular", "url(/fonts/mada-regular.ttf"), item.font("Mada Regular", "url(/fonts/mada-regular.ttf"),
item.json(`/json/${locale}/${surahId}/surah.json`, { className: "surah" }), item.json(`/json/${locale}/${surahId}/info.json`, { className: "json surahinfo" }),
item.json(`/json/${locale}/${surahId}/surah.json`, { className: "json surah" }),
item.progress((percent: number) => { item.progress((percent: number) => {
progressBar.value = percent; progressBar.value = percent;
progressNumber.innerText = `${percent.toFixed(0)}%`; progressNumber.innerText = `${percent.toFixed(0)}%`;

View file

@ -1,4 +1,4 @@
import { Surah, Ayah, TSurah, TLocale } from "Quran"; import { Surah, Ayah, TAyat, TSurah, TLocale } from "Quran";
import React from "react"; import React from "react";
import ReactDOM from "react-dom/client"; import ReactDOM from "react-dom/client";
import { T } from "~/lib/t"; import { T } from "~/lib/t";
@ -12,18 +12,20 @@ import { SurahStream } from "~/components/SurahStream";
/* /*
* Configure an instance of Surah * Configure an instance of Surah
*/ */
const node1: HTMLScriptElement = document.querySelector("script.surah")!; const node1: HTMLScriptElement = document.querySelector(".json.surahinfo")!;
const node2: HTMLScriptElement = document.querySelector(".json.durations")!; const node2: HTMLScriptElement = document.querySelector(".json.surah")!;
const blob1: [TSurah, [number, string]] = JSON.parse(node1.innerText)!; const node3: HTMLScriptElement = document.querySelector(".json.durations")!;
const blob2: Array<[number, number]> = JSON.parse(node2.innerText)!; const blob1: TSurah = JSON.parse(node1.innerText)!;
const surah = new Surah(blob1[0]); const blob2: [number, string][] = JSON.parse(node2.innerText)!;
for (let i = 1; i < blob1.length; i++) { const blob3: [number, number][] = JSON.parse(node3.innerText)!;
const [id, body] = blob1[i] as [number, string]; const surah = new Surah(blob1);
for (let i = 0; i < blob2.length; i++) {
const [id, body] = blob2[i] as [number, string];
surah.ayat.push(new Ayah({ id, body })); surah.ayat.push(new Ayah({ id, body }));
} }
for (let i = 0; i < surah.ayat.length; i++) { for (let i = 0; i < surah.ayat.length; i++) {
const ayah = surah.ayat[i]; const ayah = surah.ayat[i];
const [, ms] = blob2[i]; const [, ms] = blob3[i];
ayah.ms = ms * 1000; ayah.ms = ms * 1000;
} }