Add some tomes & fully move loading to JavaScript with embed API

This commit is contained in:
2025-06-24 18:17:54 +02:00
parent ba17124d05
commit ce68d160b9
30 changed files with 333 additions and 76 deletions

View File

@ -1,7 +1,10 @@
<header class="header">
<div class="container">
<h1 class="logo">
<a title="{{ site.name }}" href="{{ site.baseurl | append: '/' }}">{{ site.name }}</a>
<a title="Home" href="{{ site.baseurl | append: '/' }}">{{ site.name }}</a>
</h1>
<div style="float: right;">
<a href="{{ site.baseurl | append: '/info/' }}">Info</a>
</div>
</div>
</header>

View File

@ -9,7 +9,10 @@
"folder": {{ tome-folder | jsonify }},
"file": {{ tome.file | jsonify }},
"chapters": {{ tome.chapters | jsonify }},
"config": {{ site.extra | jsonify }},
{%- endif %}
"locale": {{ tome-lang | jsonify }},
"slug": {{ tome-id | jsonify }}
"slug": {{ tome-id | jsonify }},
"isbn": {{ tome.isbn | jsonify }},
"gbooks": {{ tome.gbooks | jsonify }}
}

View File

@ -7,6 +7,10 @@
{%- include tome-id tome=page -%}
{%- endcapture -%}
{%- assign this-id = this-id | split: '/' | first | strip -%}
{%- capture is-page -%}
{%- assign tokens = page.path | split: '/' -%}
{%- if tokens.size == 1 and page.path != 'index.html' -%}true{%- else -%}false{%- endif -%}
{%- endcapture -%}
{% if this-id == '' %}
<title>{{ site.name }} | {{ site.tagline }}</title>
<meta name="description" content="{{ site.description }}">
@ -24,6 +28,7 @@
<main class="content">
<section class="intro">
<div class="container">
{%- if is-page == 'false' -%}
{% if this-id == '' %}
<h2>About site</h2>
<p class="main">{{ site.description }}</p>
@ -42,8 +47,14 @@
{% include tome-info.html %}
{% endif %}
{% else %}
<h1>{{ page.title }}</h1>
<br />
{{ page.content | markdownify }}
{% endif %}
</div>
</section>
{%- if is-page == 'false' -%}
<section class="projects">
<div class="container">
<h2>Available tomes</h2>
@ -81,6 +92,7 @@
</ul>
</div>
</section>
{% endif %}
</main>
{% include footer.html %}
<script src="{{ '/assets/scripts/vendor/scrollreveal.min.js' | prepend: site.baseurl }}"></script>

View File

@ -1,9 +1,9 @@
<!DOCTYPE html>
<html lang="{% include tome-lang tome=page %}">
<head>
{%- capture id %}{% include tome-id tome=page %}{%- endcapture -%}
{%- capture this-id %}{% include tome-id tome=page %}{%- endcapture -%}
{%- capture parent -%}{%- include tome-parent tome=page key='title' -%}{%- endcapture -%}
{%- capture title %}{% include tome-field tome=page field='title' %}{%- endcapture -%}
{%- capture folder %}{% include tome-field tome=page field='folder' %}{%- endcapture -%}
{%- capture cover %}{% include tome-cover tome=page %}{%- endcapture -%}
<title>{{ title }} | {{ site.name }}</title>
<meta name="author" content="{{ site.name }}">
@ -11,12 +11,7 @@
<meta name="keywords" content="{{ page.keywords }}">
<meta property="og:image" content="{{ cover }}">
{% include head.html %}
{% capture tome_json %}{% include tome.json tome=page full=true %}{% endcapture %}
{% capture embed %}{
"page": {{ tome_json }},
"extra": {{ site.extra | jsonify }}
}{% endcapture %}
<script type="application/json" id="tome">{{ tome_json }}</script>
<script type="application/json" id="tome">{% include tome.json tome=page full=true %}</script>
</head>
<body>
{% include header.html %}
@ -28,6 +23,11 @@
<h1>{{ title }}</h1>
<p>{{ page.subtitle }}</p>
{% if parent != '' %}
<span class="h2">Part of</span>
<a href="..">{{ parent }}</a>
{% endif %}
<span class="h2">Cover</span>
<img src="{{ cover }}" alt="Cover" style="max-height: 40vh; width: auto;" />
@ -51,11 +51,6 @@
</article>
<aside>
<ul>
<li>
<iframe src="{{ '/reader/' | prepend: site.baseurl }}#{{ embed | uri_escape | xml_escape }}"
style="width: 100%; height: 90vh; border: none;"
allow="fullscreen" allowfullscreen="allowfullscreen"></iframe>
</li>
<li>
<img src="{{ cover }}" alt="Cover" />
</li>
@ -69,20 +64,6 @@
<script src="{{ '/assets/scripts/vendor/scrollreveal.min.js' | prepend: site.baseurl }}"></script>
<script src="{{ '/assets/scripts/vendor/sticky-kit.min.js' | prepend: site.baseurl }}"></script>
<script src="{{ '/assets/scripts/project.js' | prepend: site.baseurl }}"></script>
<script>
{% if page.file %}
document.querySelector('article').innerHTML += '<span class="h2">Download tome</span><ul><li><button>{{ page.file }}</button></li></ul>';
document.querySelector('article button').addEventListener('click', function(){
location.href = '{{ site.extra.store }}/tomes/{% if folder != "" %}{{ id | split: "/" | first }}{% else %}{{ id }}{% endif %}/{% if folder != "" %}{{ folder }}/{% endif %}{{ page.file }}';
});
{% else if page.chapters %}
document.querySelector('article').innerHTML += '<span class="h2">Download chapters</span><ul>{% for chapter in page.chapters %}<li><button>{{ chapter }}</button></li>{% endfor %}</ul>';
document.querySelectorAll('article button').forEach(function(button){
button.addEventListener('click', function(){
location.href = '{{ site.extra.store }}/tomes/{{ id }}/{{ folder }}/' + button.textContent;
});
});
{% endif %}
</script>
<script src="{{ '/reader/autoload.js' | prepend: site.baseurl }}"></script>
</body>
</html>

View File

@ -0,0 +1,9 @@
---
layout: "index"
permalink: "/en/smells-like-green-spirit/"
webpage: "https://reader.decadencescans.com/manga/smells-like-green-spirit/"
title: "Smells Like Green Spirit"
folder: "en_decadence"
cover: "00000000_001000.jpg"
cover2: "00000000_009000.jpg"
---

View File

@ -0,0 +1,6 @@
---
title: "SIDE A"
cover: "00000000_001000.jpg"
folder: "en_decadence/1"
chapters: ["0_Chapter_1_-_Gree.cbz", "1_Chapter_2_-_A_Me.cbz", "2_Chapter_3_-_Pand.cbz", "3_Chapter_4_-_Para.cbz", "4_Chapter_5_-_Scen.cbz", "5_Chapter_6_-_Fami.cbz", "6_Chapter_7_-_Lust.cbz", "7_Chapter_8_-_Mask.cbz"]
---

View File

@ -0,0 +1,6 @@
---
title: "SIDE B"
cover: "00000000_009000.jpg"
folder: "en_decadence/2"
chapters: ["8_Chapter_9_-_Coll.cbz", "9_Chapter_10_-_The.cbz", "10_Chapter_11_-_Wh.cbz", "11_Chapter_12_-_Sp.cbz", "12_Chapter_13_-_Fr.cbz", "13_Chapter_14_-_Sm.cbz", "14_Chapter_14_5_-_.cbz"]
---

View File

@ -0,0 +1,13 @@
---
title: "Vol. 10"
subtitle: "Rematch"
date: "2019-06-04"
isbn: "1974712095, 9781974712090"
gbooks: "PKmZDwAAQBAJ"
folder: "en_viz/10"
chapters: ["99_Chap_80.cbz", "100_Chap_81.cbz", "101_Chap_82.cbz", "102_Chap_83.cbz", "103_Chap_84.cbz", "104_Chap_85.cbz", "105_Chap_86.cbz", "106_Chap_87.cbz", "107_Chap_88.cbz"]
cover: "-251518170_100000.png"
webpage: "https://www.viz.com/manga-books/manga/promised-neverland-volume-10/product/5925"
---
<p>With Lucass help, Emma is able to finally uncover the mystery of William Minerva. While their helper may no longer be alive, Emma now knows how to escape the world of demons. However, first they will need to escape Goldy Pond in one piece. And to do that, theyll have to take down some of the most powerful demons theyve ever come across!</p> -- VIZ Media

View File

@ -0,0 +1,13 @@
---
title: "Vol. 6"
subtitle: "B06-32"
date: "2018-10-02"
isbn: "1974706869, 9781974706860"
gbooks: "m2FuDwAAQBAJ"
folder: "en_viz/6"
chapters: ["63_Chap_44.cbz", "64_Chap_45.cbz", "65_Chap_46.cbz", "66_Chap_47.cbz", "67_Chap_48.cbz", "68_Chap_49.cbz", "69_Chap_50.cbz", "70_Chap_51.cbz", "71_Chap_52.cbz"]
cover: "-251518170_064000.png"
webpage: "https://www.viz.com/manga-books/manga/promised-neverland-volume-6/product/5681"
---
<p>The children have successfully escaped Grace Field House, but their troubles are just beginning. Now up against a dangerous natural world and their demon pursuers, Emma and Ray struggle to lead the children to safety. Just when the situation is at its most dire, a mysterious girl suddenly appears. Is she there to help, or is it a demonic trap...?</p> -- VIZ Media

View File

@ -0,0 +1,13 @@
---
title: "Vol. 7"
subtitle: "Decision"
date: "2018-12-04"
isbn: "1974708543, 9781974708543"
gbooks: "ZCt7DwAAQBAJ"
folder: "en_viz/7"
chapters: ["72_Chap_53.cbz", "73_Chap_54.cbz", "74_Chap_55.cbz", "75_Chap_56.cbz", "76_Chap_57.cbz", "77_Chap_58.cbz", "78_Chap_59.cbz", "79_Chap_60.cbz", "80_Chap_61.cbz"]
cover: "-251518170_073000.png"
webpage: "https://www.viz.com/manga-books/manga/promised-neverland-volume-7/product/5754"
---
<p>After learning the truth of the world they find themselves in, the orphans finally make their way out of the forest. With their improved survival skills, Emma, Ray and the other children arrive at the location laid out in Minervas hidden message. But awaiting them there is a new kind of challenge...</p> -- VIZ Media

View File

@ -0,0 +1,13 @@
---
title: "Vol. 8"
subtitle: "The Forbidden Game"
date: "2019-02-05"
isbn: "1974709787, 9781974709786"
gbooks: "feyEDwAAQBAJ"
folder: "en_viz/8"
chapters: ["81_Chap_62.cbz", "82_Chap_63.cbz", "83_Chap_64.cbz", "84_Chap_65.cbz", "85_Chap_66.cbz", "86_Chap_67.cbz", "87_Chap_68.cbz", "88_Chap_69.cbz", "89_Chap_70.cbz"]
cover: "-251518170_082000.png"
webpage: "https://www.viz.com/manga-books/manga/promised-neverland-volume-8/product/5818"
---
<p>With their guide working against them, Emma and Ray find themselves surrounded by deadly demons in an unfamiliar forest. Theyll have to learn how to fight quickly to have any hope of surviving and making their way to Goldy Pond. But what awaits them there...?</p> -- VIZ Media

View File

@ -0,0 +1,13 @@
---
title: "Vol. 9"
subtitle: "The Battle Begins"
date: "2019-04-02"
isbn: "1974710904, 9781974710904"
gbooks: "vUWNDwAAQBAJ"
folder: "en_viz/9"
chapters: ["90_Chap_71.cbz", "91_Chap_72.cbz", "92_Chap_73.cbz", "93_Chap_74.cbz", "94_Chap_75.cbz", "95_Chap_76.cbz", "96_Chap_77.cbz", "97_Chap_78.cbz", "98_Chap_79.cbz"]
cover: "-251518170_091000.png"
webpage: "https://www.viz.com/manga-books/manga/promised-neverland-volume-9/product/5875"
---
<p>The search for the mysterious Minerva has led Emma to a secret room within Goldy Pond. Heeding Minervas clues, Emma and the other children have successfully escaped Grace Field House and survived the dangerous terrain of the outside world. But when Emma opens the door to the truth, will Minervas secrets be everything shes been hoping for?</p> -- VIZ Media

View File

@ -0,0 +1,12 @@
---
title: "01"
date: "2015-06-16"
isbn: "1421584794, 9781421584799"
gbooks: "PQPCCQAAQBAJ"
cover: "-251518170_001000.png"
folder: "en_viz/1"
chapters: ["0_Chap_1.cbz", "1_Chap_2.cbz", "2_Chap_3.cbz", "3_Chap_4.cbz", "4_Chap_5.cbz"]
webpage: "https://www.viz.com/manga-books/manga/welcome-to-the-n-h-k-volume-1/product/4625"
---
<p>Twenty-something-year-old Satou, a college dropout and aficionado of anime porn, knows a little secret--or at least he thinks he does! Believe it or not, he has stumbled upon an incredible conspiracy created by the Japanese Broadcasting Company NHK. But despite fighting the good fight, Satou has become an unemployed Hikikomori--a shut-in who as withdrawn from the world...</p> <p>One day, he meets Misaki, a mysterious young girl who invites him to join her special "project". Slowly Satou comes out of his reclusive shell, and his hilarious journey begins: filled with mistaken identity; panty shots; Lolita complexes--and an ultimate quest to create the greatest hentai game ever!</p> -- VIZ Media

View File

@ -0,0 +1,12 @@
---
title: "02"
date: "2015-06-30"
isbn: "1421584921, 9781421584928"
gbooks: "WSzdCQAAQBAJ"
cover: "-251518170_006000.png"
folder: "en_viz/2"
chapters: ["5_Chap_6.cbz", "6_Chap_7.cbz", "7_Chap_8.cbz", "8_Chap_9.cbz", "9_Chap_10.cbz"]
webpage: "https://www.viz.com/manga-books/manga/welcome-to-the-n-h-k-volume-2/product/4626"
---
<p>Surrounded by turmoil and tragedy, Satou and Misaki are drawn closer to each other, and the timing couldn't be better. Satou's mother pays him a visit as Misaki comes over to pose as his "girlfriend." But will the facade hold up under her scrutiny? Later, Satou is upset by the fact that most of his problems involve women, and he and Yamazaki share their frustration. Misaki is worried that Satou is heading down a path of destruction. Can she save him before it is too late--or is it already too late?</p> -- VIZ Media

View File

@ -0,0 +1,12 @@
---
title: "03"
date: "2015-07-28"
isbn: "1421585634, 9781421585635"
gbooks: "rx0tCgAAQBAJ"
cover: "-251518170_011000.png"
folder: "en_viz/3"
chapters: ["10_Chap_11.cbz", "11_Chap_12.cbz", "12_Chap_13.cbz", "13_Chap_14.cbz", "14_Chap_15.cbz"]
webpage: "https://www.viz.com/manga-books/manga/welcome-to-the-n-h-k-volume-3/product/4627"
---
<p>Satou may have survived his mom and the urge to put an end to it all, but now he's taking his battle online! When Satou gets caught up in the MMORPG craze, will hours of play help him escape his shell...or send him deeper into desperation? Misaki is there to lend a hand but there are some forces out there that even she can't beat--like the scamming company that's determined to bring Satou down...and Misaki with him!</p> -- VIZ Media

View File

@ -0,0 +1,12 @@
---
title: "04"
date: "2015-08-25"
isbn: "1421586185, 9781421586182"
gbooks: "1XBZCgAAQBAJ"
folder: "en_viz/4"
chapters: ["15_Chap_16.cbz", "16_Chap_17.cbz", "17_Chap_18.cbz", "18_Chap_19.cbz", "19_Chap_20.cbz"]
cover: "-251518170_016000.png"
webpage: "https://www.viz.com/manga-books/manga/welcome-to-the-n-h-k-volume-4/product/4628"
---
<p>Satou and Yamazaki have hit rock bottom in their creativity. To get out of his slump, Satou goes on a date with the newly married Kashiwa-senpai. But an envious and jealous Misaki lurks in the shadows, patiently waiting for her chance to strike revenge. Satou will need more than creative inspiration in order to survive Misaki's devious scheme!</p> -- VIZ Media

View File

@ -0,0 +1,12 @@
---
title: "05"
date: "2015-09-29"
isbn: "1421586924, 9781421586922"
gbooks: "7oqICgAAQBAJ"
folder: "en_viz/5"
chapters: ["20_Chap_21.cbz", "21_Chap_22.cbz", "22_Chap_23.cbz", "23_Chap_24.cbz", "24_Chap_25.cbz"]
cover: "-251518170_021000.png"
webpage: "https://www.viz.com/manga-books/manga/welcome-to-the-n-h-k-volume-5/product/4629"
---
<p>After going to a bath house under the influence of some shady drugs from Yamazaki, Satou spirals out of control and completely loses his mind! With conspiracy theories and paranoia getting the best of him, he's quickly admitted to a hospital and then sent to live with his parents. Will moving back home set Satou on the path to normalcy, or will the lack of privacy cause some unexpected...problems?</p> -- VIZ Media

View File

@ -0,0 +1,12 @@
---
title: "06"
date: "2015-10-27"
isbn: "1421587599, 9781421587592"
gbooks: "Yv-qCgAAQBAJ"
folder: "en_viz/6"
chapters: ["25_Chap_26.cbz", "26_Chap_27.cbz", "27_Chap_28.cbz", "28_Chap_29.cbz", "29_Chap_30.cbz"]
cover: "-251518170_026000.png"
webpage: "https://www.viz.com/manga-books/manga/welcome-to-the-n-h-k-volume-6/product/4630"
---
<p>Satou's hallucinations of an Angel-Misaki are getting worse! Having run away from home, he now turns to arcades and pachinko bars for relief. But he soon learns that these are expensive habits, and that his escapism comes at a cost he might not be willing to pay. Feeling alone, with no one to turn to, especially now that Yamazaki's got his own girl problems, Satou is at an all-time low. Where will he turn? Fates are intertwined and secrets revealed in this, the next volume of Welcome to the N.H.K.!</p> -- VIZ Media

View File

@ -0,0 +1,12 @@
---
title: "07"
date: "2015-11-24"
isbn: "1421588498, 9781421588490"
gbooks: "VkbpCgAAQBAJ"
folder: "en_viz/7"
chapters: ["30_Chap_31.cbz", "31_Chap_32.cbz", "32_Chap_33.cbz", "33_Chap_34.cbz", "34_Chap_35.cbz"]
cover: "-251518170_031000.png"
webpage: "https://www.viz.com/manga-books/manga/welcome-to-the-n-h-k-volume-7/product/4632"
---
<p>With his life in total disarray, Satou opts for the most sensible solution: have an affair with Kashiwa-senpai! However, whether or not he can go through with it will depend on various factors out of his control. Meanwhile, the relationship between Shirou and Misaki may be getting serious. Or is it all another one of Misaki's tricks?!</p> -- VIZ Media

View File

@ -0,0 +1,12 @@
---
title: "08"
date: "2015-12-29"
isbn: "142158901X, 9781421589015"
gbooks: "ZNohCwAAQBAJ"
folder: "en_viz/8"
chapters: ["35_Chap_36.cbz", "36_Chap_37.cbz", "37_Chap_38.cbz", "38_Chap_39.cbz", "39_Chap_40.cbz"]
cover: "-251518170_036000.png"
webpage: "https://www.viz.com/manga-books/manga/welcome-to-the-n-h-k-volume-8/product/4631"
---
<p>Satou vowed to fight the evil organization known as N.H.K. and save the future from eroticism, violence, and drugs. Instead, he has become a delusional shut-in and lost the only girl that ever offered him love. Surely, this is rock bottom.</p> <p>But from the bottom there's nowhere to go but up...and higher. So Yamazaki plants a garden of illegal herbs to inspire a revolutionary otaku uprising. Will it be enough to return Misaki to Satou or Satou to the real world? Can any plot save Mita House and its hikikomori inhabitants?</p> -- VIZ Media

View File

@ -0,0 +1,11 @@
---
layout: "index"
permalink: "/en/welcome-to-the-nhk-manga/"
webpage: "https://www.viz.com/welcome-to-the-n-h-k"
title: "Welcome to the N.H.K. (Manga)"
authors: "Tatsuhiko Takimoto"
publisher: "VIZ Media"
folder: "en_viz"
cover: "-251518170_001000.png"
cover2: "-251518170_036000.png"
---

View File

@ -1,5 +1,5 @@
---
title: "Matematica: Algebra lineare"
title: "Matematica: Algebra lineare (Vol. 10)"
authors: "Shin Takahashi, Iroha Inoue"
date: 2016-12-02
isbn: "8883715756, 9788883715754"

View File

@ -1,5 +1,5 @@
---
title: "Regressione: Analisi statistica dei dati"
title: "Regressione: Analisi statistica dei dati (Vol. 11)"
authors: "Shin Takahashi"
date: 2016-12-09
isbn: "8883715748, 9788883715747"

View File

@ -1,5 +1,5 @@
---
title: "Anatomia"
title: "Anatomia (Vol. 12)"
authors: "Etsuro Tanaka, Keiko Koyama"
date: 2016-12-16
isbn: "888371573X, 9788883715730"

View File

@ -1,5 +1,5 @@
---
title: "Elettromagnetismo"
title: "Elettromagnetismo (Vol. 8)"
authors: "Kazuhiro Fujitaki"
publisher: "Gedi (Gruppo Editoriale)"
date: 2016-11-18

View File

@ -1,5 +1,5 @@
---
title: "Biochimica"
title: "Biochimica (Vol. 9)"
authors: "Masaharu Takemura"
date: 2016-11-25
isbn: "8883715764, 9788883715761"

13
info.md Normal file
View File

@ -0,0 +1,13 @@
---
layout: "index"
title: "Info"
---
More information about the project can be found on the GitHub repository, linked below. We welcome all open-source contributions, from library additions to technical improvements.
---
We also provide APIs for use of our library in your own website or application, completely for free.
* Embed reader (IFrame): `/reader/#/{locale}/{tome}/[volume]`
* List of the entire library: `GET` [`/tomes.json`](../tomes.json)

34
reader/autoload.js Normal file
View File

@ -0,0 +1,34 @@
---
---
(function(){
var articleEl = document.querySelector('main article');
var asideEl = document.querySelector('main aside ul');
var json = document.querySelector('script[type="application/json"][id="tome"]').innerHTML;
var tome = JSON.parse(json);
var id = (tome.folder ? tome.slug.split('/')[0] : tome.slug);
if (tome.file) {
articleEl.innerHTML += '<span class="h2">Download tome</span><ul><li><button>' + tome.file + '</button></li></ul>';
articleEl.querySelector('button').addEventListener('click', function(){
location.href = tome.config.store + '/tomes/' + id + '/' + tome.folder + '/' + tome.file;
});
} else if (tome.chapters) {
var chapters = '';
tome.chapters.forEach(function(chapter){
chapters += '<li><button>' + chapter + '</button></li>';
});
articleEl.innerHTML += '<span class="h2">Download chapters</span><ul>' + chapters + '</ul>';
articleEl.querySelectorAll('button').forEach(function(button){
button.addEventListener('click', function(){
location.href = tome.config.store + '/tomes/' + id + '/' + tome.folder + '/' + button.textContent;
});
});
}
asideEl.insertBefore(Object.assign(document.createElement('li'), {
innerHTML: '<iframe src="{{ "/reader/" | prepend: site.baseurl }}#' + encodeURIComponent(json) + '" style="width: 100%; height: 90vh; border: none; position: relative; z-index: 1;" allow="fullscreen" allowfullscreen="allowfullscreen"></iframe>',
}), asideEl.children[0]);
})();

View File

@ -9,53 +9,69 @@ p { margin: 1em; }
<body>
<noscript><p>This application requires JavaScript.</p></noscript>
<script>
(function(data){
(function(payload){
document.body.innerHTML = '';
var page = data.page, extra = data.extra;
var readers = {
villain: extra.store + "/Villain-gh-pages/#/reader?src=",
// villain: "../Villain-gh-pages/#/reader?src=",
// villain: "https://villain.js.org/#/reader?src=",
foliate: extra.store + "/foliate-js-main/reader.html?url=",
// foliate: "../foliate-js-main/reader.html?url=",
// foliate: "https://johnfactotum.github.io/foliate-js/reader.html?url=",
};
if (page.chapters) {
document.body.innerHTML +=
'<style>iframe{ height: calc(100% - 32px); }</style>' +
'<div style="height: 32px; background-color: darkgray; padding-left: 4px; padding-right: 4px;"><label><select style="margin: 4px;"></select></label></div>';
}
document.body.innerHTML += '<iframe allow="fullscreen" allowfullscreen="allowfullscreen"></iframe>';
// if (runtime === readers.foliate) {
// document.body.innerHTML += '<button style="position: absolute; top: 8px; right: 48px; font-size: large;" onclick="document.body.requestFullscreen();">↔</button>';
// }
if (page.file) {
displayVolume(page.file);
} else if (page.chapters) {
var select = document.body.querySelector('select');
page.chapters.forEach(function(chapter){
select.appendChild(Object.assign(document.createElement('option'), { textContent: chapter }));
if (payload[0] === '/') {
fetch('../' + payload).then(function(res){
res.text().then(function(html){
var dom = (new DOMParser()).parseFromString(html, 'text/html');
var json = dom.querySelector('script[type="application/json"][id="tome"]').innerHTML;
load(json);
});
});
select.addEventListener('change', function(){
displayVolume(select.value);
});
displayVolume(select.value);
} else {
return document.body.innerHTML += '<p>No online reading available for this tome, please check downloads.</p>';
load(payload);
}
function displayVolume(file) {
var ext = file.split('.').slice(-1)[0];
var runtime = {
cbz: readers.villain,
}[ext] || readers.foliate;
document.querySelector('iframe').src = runtime + extra.store + '/tomes/' + (page.folder ? page.slug.split('/')[0] : page.slug) + '/' + (page.folder ? page.folder + '/' : '') + file;
function load(json) {
var tome = JSON.parse(json);
var store = tome.config.store;
var readers = {
villain: store + "/Villain-gh-pages/#/reader?src=",
// villain: "../Villain-gh-pages/#/reader?src=",
// villain: "https://villain.js.org/#/reader?src=",
foliate: store + "/foliate-js-main/reader.html?url=",
// foliate: "../foliate-js-main/reader.html?url=",
// foliate: "https://johnfactotum.github.io/foliate-js/reader.html?url=",
};
if (tome.chapters) {
document.body.innerHTML +=
'<style>iframe{ height: calc(100% - 32px); }</style>' +
'<div style="height: 32px; background-color: darkgray; padding-left: 4px; padding-right: 4px;"><label><select style="margin: 4px;"></select></label></div>';
}
document.body.innerHTML += '<iframe allow="fullscreen" allowfullscreen="allowfullscreen"></iframe>';
// if (runtime === readers.foliate) {
// document.body.innerHTML += '<button style="position: absolute; top: 8px; right: 48px; font-size: large;" onclick="document.body.requestFullscreen();">↔</button>';
// }
if (tome.file) {
displayVolume(tome.file);
} else if (tome.chapters) {
var select = document.body.querySelector('select');
tome.chapters.forEach(function(chapter){
select.appendChild(Object.assign(document.createElement('option'), { textContent: chapter }));
});
select.addEventListener('change', function(){
displayVolume(select.value);
});
displayVolume(select.value);
} else {
return document.body.innerHTML += '<p>No online reading available for this tome, please check downloads.</p>';
}
function displayVolume(file) {
var ext = file.split('.').slice(-1)[0];
var runtime = {
cbz: readers.villain,
}[ext] || readers.foliate;
document.querySelector('iframe').src = runtime + store + '/tomes/' + (tome.folder ? tome.slug.split('/')[0] : tome.slug) + '/' + tome.folder + '/' + file;
}
}
})(JSON.parse(decodeURIComponent(location.hash.slice(1))));
})(decodeURIComponent(location.hash.slice(1)).trim());
</script>
</body>
</html>

View File

@ -1,14 +1,16 @@
---
---
[
{%- assign first = true -%}
{%- for tome in site.tomes -%}
{%- capture tome-id -%}
{%- include tome-id tome=tome -%}
{%- endcapture -%}
{%- assign parts = tome-id | split: '/' -%}
{%- if parts[1] != 'index' -%}
{%- unless first -%},{%- endunless -%}
{%- assign first = false -%}
{% include tome.json %}
{%- unless forloop.last %},{% endunless -%}
{%- endif -%}
{%- endfor -%}
]