content updates
|
|
@ -1,109 +0,0 @@
|
|||
class asciiTextFill extends Paged.Handler {
|
||||
constructor(chunker, polisher, caller) {
|
||||
super(chunker, polisher, caller);
|
||||
}
|
||||
|
||||
afterRendered(pages) {
|
||||
const PAD = 4;
|
||||
|
||||
/* ── 1. Mesurer charW et lineH avec une pre cachée ── */
|
||||
const probe = document.createElement('pre');
|
||||
probe.style.cssText = [
|
||||
'position:absolute', 'visibility:hidden', 'top:0', 'left:0',
|
||||
'font-family:"Courier New",monospace', 'font-size:9pt',
|
||||
'line-height:1.5', 'white-space:pre'
|
||||
].join(';');
|
||||
// 10 lignes de 100 tirets → mesure fiable
|
||||
probe.textContent = Array(10).fill('-'.repeat(100)).join('\n');
|
||||
document.body.appendChild(probe);
|
||||
const pr = probe.getBoundingClientRect();
|
||||
const charW = pr.width / 200;
|
||||
const lineH = pr.height / 20;
|
||||
document.body.removeChild(probe);
|
||||
|
||||
/* ── 2. COLS = nb de caractères par ligne dans la zone imprimable ── */
|
||||
const COLS = Math.floor(pages[0].width / charW);
|
||||
// const COLS = pages[0].width;
|
||||
const DASH = '-'.repeat(COLS);
|
||||
|
||||
/* ── 3. makeBox centré dans COLS ── */
|
||||
function makeBox(lines) {
|
||||
const maxLen = Math.max(...lines.map(l => l.length));
|
||||
const innerW = maxLen + PAD * 2;
|
||||
const border = '|' + '-'.repeat(innerW) + '|';
|
||||
const empty = ' '.repeat(innerW + 2);
|
||||
const rows = lines.map(l =>
|
||||
' '.repeat(PAD) + l + ' '.repeat(innerW - PAD - l.length)
|
||||
);
|
||||
const offset = Math.max(0, Math.floor((COLS - (innerW + 2)) / 2));
|
||||
const sp = ' '.repeat(offset);
|
||||
return [sp + border, sp + empty, ...rows.map(r => sp + r), sp + empty, sp + border].join('\n');
|
||||
}
|
||||
|
||||
/* ── 4. Titre : vider SEULEMENT #chapter-title ── */
|
||||
const titleEl = document.getElementById('chapter-title');
|
||||
const titleLines = Array.from(titleEl.querySelectorAll('h2, h3'))
|
||||
.map(n => n.textContent.trim()).filter(Boolean);
|
||||
if (titleLines.length) {
|
||||
const pre = document.createElement('pre');
|
||||
pre.textContent = titleEl.innerHTML = ''; // vide le div
|
||||
pre.textContent = makeBox(titleLines);
|
||||
titleEl.appendChild(pre);
|
||||
}
|
||||
|
||||
/* ── 5. Bio : vider SEULEMENT #biographie ── */
|
||||
const bioEl = document.getElementById('biographie');
|
||||
const bioText = Array.from(bioEl.querySelectorAll('p'))
|
||||
.map(p => p.textContent.trim()).join(' ');
|
||||
const bioInnerW = COLS - 50; // place pour les | |
|
||||
|
||||
if (bioText) {
|
||||
// word-wrap manuel
|
||||
const wrapped = [];
|
||||
let cur = '';
|
||||
bioText.split(/\s+/).forEach(w => {
|
||||
const test = cur ? cur + ' ' + w : w;
|
||||
if (test.length <= bioInnerW) { cur = test; }
|
||||
else { if (cur) wrapped.push(cur); cur = w; }
|
||||
});
|
||||
if (cur) wrapped.push(cur);
|
||||
|
||||
const border = '|' + '-'.repeat(bioInnerW) + '|';
|
||||
// const bioRows = wrapped.map(l => '|' + l + ' '.repeat(bioInnerW - l.length) + '|');
|
||||
const pre = document.createElement('pre');
|
||||
// pre.textContent = [border, ...bioRows, border].join('\n');
|
||||
// const bioRows = wrapped.map(l => '|' + l + ' '.repeat(bioInnerW - l.length) + '|');
|
||||
pre.textContent = border + '\n\n' + wrapped + '\n\n' + border;
|
||||
bioEl.innerHTML = '';
|
||||
bioEl.appendChild(pre);
|
||||
}
|
||||
|
||||
/* ── 6. Calculer l'espace dispo et remplir les fills ── */
|
||||
// Hauteur intérieure de la page (après padding CSS)
|
||||
const totalH = pages[0].height;
|
||||
|
||||
// Hauteur réelle des blocs de contenu après génération
|
||||
const fixedH = titleEl.offsetHeight + bioEl.offsetHeight;
|
||||
|
||||
// Espace à distribuer entre les 3 fills
|
||||
const spare = Math.max(0, totalH - fixedH);
|
||||
|
||||
// Répartition : 1/3 haut, 1/3 milieu, 1/3 bas
|
||||
// (modifie ces ratios pour décaler le contenu verticalement)
|
||||
const ratios = [1/3, 1/3, 1/3];
|
||||
const ids = ['fill-top', 'fill-mid', 'fill-bottom'];
|
||||
|
||||
ids.forEach((id, i) => {
|
||||
const el = document.getElementById(id);
|
||||
const h = spare * ratios[i];
|
||||
const n = Math.max(0, Math.floor(h / lineH));
|
||||
el.textContent = Array(n).fill(DASH).join('\n');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Paged.registerHandlers(asciiTextFill);
|
||||
|
||||
|
||||
|
||||
|
|
@ -6,6 +6,10 @@ Author: Jean-Noël Lafargue
|
|||
|
||||
----
|
||||
|
||||
Typeof: essai
|
||||
|
||||
----
|
||||
|
||||
Cover: - file://a8u2rj1e35diuqs4
|
||||
|
||||
----
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 247 KiB |
|
|
@ -1,13 +0,0 @@
|
|||
Caption:
|
||||
|
||||
----
|
||||
|
||||
Alt:
|
||||
|
||||
----
|
||||
|
||||
Uuid: h6hivgu4wmsnxgmv
|
||||
|
||||
----
|
||||
|
||||
Template: blocks/image
|
||||
|
Before Width: | Height: | Size: 151 KiB |
|
|
@ -1,13 +0,0 @@
|
|||
Caption:
|
||||
|
||||
----
|
||||
|
||||
Alt:
|
||||
|
||||
----
|
||||
|
||||
Uuid: 4n4xodebzjizqzuw
|
||||
|
||||
----
|
||||
|
||||
Template: blocks/image
|
||||
|
Before Width: | Height: | Size: 331 KiB |
|
|
@ -1,13 +0,0 @@
|
|||
Caption:
|
||||
|
||||
----
|
||||
|
||||
Alt:
|
||||
|
||||
----
|
||||
|
||||
Uuid: jkixi1ufyzyzarjy
|
||||
|
||||
----
|
||||
|
||||
Template: blocks/image
|
||||
|
Before Width: | Height: | Size: 446 KiB |
|
|
@ -1,13 +0,0 @@
|
|||
Caption:
|
||||
|
||||
----
|
||||
|
||||
Alt:
|
||||
|
||||
----
|
||||
|
||||
Uuid: 5anwxl3z2yr7robi
|
||||
|
||||
----
|
||||
|
||||
Template: blocks/image
|
||||
|
Before Width: | Height: | Size: 194 KiB |
|
|
@ -1,13 +0,0 @@
|
|||
Caption:
|
||||
|
||||
----
|
||||
|
||||
Alt:
|
||||
|
||||
----
|
||||
|
||||
Uuid: e2pj5gz9tfcnwvce
|
||||
|
||||
----
|
||||
|
||||
Template: blocks/image
|
||||
|
Before Width: | Height: | Size: 427 KiB |
|
|
@ -1,13 +0,0 @@
|
|||
Caption:
|
||||
|
||||
----
|
||||
|
||||
Alt:
|
||||
|
||||
----
|
||||
|
||||
Uuid: eegq1akt2uyogeqo
|
||||
|
||||
----
|
||||
|
||||
Template: blocks/image
|
||||
|
Before Width: | Height: | Size: 952 KiB |
|
|
@ -1,13 +0,0 @@
|
|||
Caption:
|
||||
|
||||
----
|
||||
|
||||
Alt:
|
||||
|
||||
----
|
||||
|
||||
Uuid: iyoongpzjh6mfsdi
|
||||
|
||||
----
|
||||
|
||||
Template: blocks/image
|
||||
|
Before Width: | Height: | Size: 586 KiB |
|
|
@ -1,13 +0,0 @@
|
|||
Caption:
|
||||
|
||||
----
|
||||
|
||||
Alt:
|
||||
|
||||
----
|
||||
|
||||
Uuid: evyyg9thzpd49rqy
|
||||
|
||||
----
|
||||
|
||||
Template: blocks/image
|
||||
|
Before Width: | Height: | Size: 896 KiB |
|
|
@ -1,13 +0,0 @@
|
|||
Caption:
|
||||
|
||||
----
|
||||
|
||||
Alt:
|
||||
|
||||
----
|
||||
|
||||
Uuid: lzcmbx0pq6tjgc3p
|
||||
|
||||
----
|
||||
|
||||
Template: blocks/image
|
||||
|
|
@ -11,12 +11,21 @@ columns:
|
|||
label: Auteur·ice
|
||||
type: text
|
||||
width: 1/2
|
||||
typeof:
|
||||
label: Type
|
||||
type: select
|
||||
default: essai
|
||||
options:
|
||||
- essai
|
||||
- portfolio
|
||||
- entretien
|
||||
width: 1/2
|
||||
cover:
|
||||
label: Image de couverture
|
||||
type: files
|
||||
multiple: false
|
||||
chapeau:
|
||||
label: Chapeau
|
||||
bio:
|
||||
label: Biographie de l’auteur·ice
|
||||
type: writer
|
||||
text:
|
||||
label: Contenu
|
||||
|
|
|
|||
|
|
@ -1,49 +0,0 @@
|
|||
<?php snippet('head') ?>
|
||||
|
||||
|
||||
<?php $sizes = "(min-width: 1200px) 25vw,
|
||||
(min-width: 900px) 33vw,
|
||||
(min-width: 600px) 50vw,
|
||||
100vw";
|
||||
?>
|
||||
|
||||
<header id="interface-header" w3-include-html="assets/pagedjs/interface.html"></header>
|
||||
|
||||
<div id="render-book"></div>
|
||||
|
||||
<template id="book-content">
|
||||
<section class="cover">
|
||||
<h1><?= $site->title()->html()?></h1>
|
||||
</section>
|
||||
<section class="toc">
|
||||
<h2>Sommaire</h2>
|
||||
<article id="table-of-contents"></article>
|
||||
</section>
|
||||
|
||||
<?php foreach($site->index()->filterBy('intendedTemplate', 'chapitre') as $chapitre):?>
|
||||
<section class="chapter">
|
||||
<div class="chapter-title">
|
||||
<!-- REMPLISSAGE HAUT -->
|
||||
<div class="ascii-fill fill-top"></div>
|
||||
<h2><?= $chapitre->title()->html()->smartypants() ?></h2>
|
||||
<h3><?= $chapitre->author()->html()->smartypants() ?></h3>
|
||||
<!-- REMPLISSAGE BAS -->
|
||||
<div class="ascii-fill fill-mid"></div>
|
||||
<div class="biographie" id="biographie">
|
||||
<p>Biographie Nus adit pressit et rem dolor ratibus. Ut atem et res ab id ut est lit, iscia cum que am verum sapici dolestorpora placeat laborit asinctate omnihilis aspelen dicatusam voluptae eum ipsandit undempos aut et laceptati omniminveris quam sim qui corem harum qui invenihita volorer sperumquas el mi, tectota tesequu ntioneserit, corem qui as earchit ipis di cum litios pro conse perspel ipsae eturi unt, sundae enimus aut ut endero cumquam faccatem duci quo quatqua meturion event fuga. Et volore videndia solorro runtis doluptas rem netum aborporaepro te quos raes at. Haritas sim quam, soluptate venem quam, earum vendunte omnisi ad endebisqui opta vel magnam conseditas eicia ditibearum rem explabo.</p>
|
||||
</div>
|
||||
<!-- REMPLISSAGE BAS FINAL -->
|
||||
<div class="ascii-fill fill-bottom"></div>
|
||||
</div>
|
||||
|
||||
<div class="chapeau"><?= $chapitre->chapeau()->kt()->smartypants() ?></div>
|
||||
<?php foreach ($chapitre->text()->toBlocks() as $block): ?>
|
||||
<div id="<?= $block->id() ?>" class="block block-type-<?= $block->type() ?>">
|
||||
<?= $block ?>
|
||||
</div>
|
||||
<?php endforeach ?>
|
||||
</section>
|
||||
<?php endforeach;?>
|
||||
</template>
|
||||
|
||||
<?php snippet('footer');?>
|
||||
|
|
@ -41,8 +41,6 @@
|
|||
<div class="ascii-fill fill-bottom"></div>
|
||||
</div>
|
||||
|
||||
<div class="chapeau"><?= $chapitre->chapeau()->kt()->smartypants() ?></div>
|
||||
|
||||
<div class="chapter-content">
|
||||
<?php foreach ($chapitre->text()->toBlocks() as $block): ?>
|
||||
<div id="<?= $block->id() ?>" class="block block-type-<?= $block->type() ?>">
|
||||
|
|
|
|||