From 0a46a4dea5e36771c47022396939b52164c5e070 Mon Sep 17 00:00:00 2001 From: manetta Date: Thu, 16 Sep 2021 18:37:23 +0200 Subject: [PATCH] pushing updates --- command-line/css/print.css | 180 ++++++++++++++++++++------- command-line/templates/template.html | 1 + command-line/update.py | 75 ++++++++++- web-interface/update.py | 74 +++++++++++ 4 files changed, 282 insertions(+), 48 deletions(-) diff --git a/command-line/css/print.css b/command-line/css/print.css index 18dd6ba..6526052 100644 --- a/command-line/css/print.css +++ b/command-line/css/print.css @@ -62,7 +62,12 @@ html, body{ } @page:right{ margin: 15mm 20mm 17mm 30mm; - +} +@page:left{ + margin: 15mm 30mm 17mm 20mm; +} +@page main:right{ + /* running header: contribution title (h2) */ @top-center{ content: string(contributiontitle); font-size: 8pt; @@ -70,69 +75,97 @@ html, body{ margin-top: 5mm; } } -@page:left{ - margin: 15mm 30mm 17mm 20mm; - +@page main:left{ + /* running header: section title (h1) */ @top-center{ - content: string(sectiontitle); + content: element(sectiontitle); font-size: 8pt; text-transform: uppercase; margin-top: 5mm; } } +@page section{ + background-color: lightyellow; + + @top-center{ + content: none; + } +} +@page introduction{ + /* exception running-header for the introduction */ + @top-center{ + content: element(introductiontitle); + } +} @page:first{ background-color: #b89ee6; - @top-left{ - content: ""; + @top-center{ + content: none; + } + @bottom-center{ + content: none; } +} +@page backcover{ + background-color: #b89ee6; + @top-center{ - content: ""; + content: none; } @bottom-center{ - content: ""; + content: none; } } @page nomarks{ - @top-left{ - content: ""; - } + @top-center{ - content: ""; + content: none; } @bottom-center{ - content: ""; + content: none; } } -@page:blank{ - @top-left{ - content: ""; - } +@page:blank{ + @top-center{ - content: ""; + content: none; } @bottom-center{ - content: ""; + content: none; } } /* sections */ div.section{ - page-break-before: right; + page: main; + /* force an extra blank page before each section ... */ + page-break-before: always; } + div.section.foreword_and_introduction{ + page: main; + /* reset this extra page break for the foreword + introduction section (does not work?) */ + page-break-before: none !important; + } + div.section h1{ + page: section; + /* ... and make sure that each section starts on the right */ + page-break-before: right; + } -/* sub-sections */ +/* sub-sections -- page flows */ +div.multi, +div.foreword, div.introduction, div.contribution{ page-break-before: right; } - div.introduction h1{ - display: none; + div.introduction{ + page: introduction; } -div.cover.second, -div.multi, -div.series{ +div.section.nomarks, +div.section.toc{ page: nomarks; } div.cover.second, @@ -143,13 +176,21 @@ div.series{ div.appendix{ page-break-before: always; } +div.backcover{ + page-break-before: always; + page: backcover; +} -div.cover{ +/* sub-sections -- lay-out rules */ + +div.cover, +div.backcover{ hyphens: none; margin: -10mm 0 0 10mm; } div.cover, - div.cover ul li{ + div.cover ul li, + div.backcover h2{ font-size: 17pt; font-family: "bitter_semi"; line-height: 1.4; @@ -169,6 +210,15 @@ div.cover{ div.cover.second ul li{ color: black; } + div.backcover{ + } + div.backcover h2{ + margin-left: 0; + } + div.backcover p{ + margin-bottom: 1em; + color: white; + } div.series{ font-size: var(--small-font-size); line-height: var(--small-line-height); @@ -181,18 +231,43 @@ div.series{ column-gap: 5mm; column-fill: auto; } -div.index{ + +/* Table of Contents */ +div.toc *{ + font-size: var(--font-size); } - div.index h3{ - margin: 1em 0 !important; + div.toc p:first-of-type{ + font-size: 17pt !important; + font-family: "bitter_semi"; + line-height: 1.4; + letter-spacing: 0.025em; + margin: -10mm 0 1em 10mm !important; + } + div.toc a::before{ + content: target-counter(attr(href url), page); + float: left; + margin-left: -3em; + } + div.toc p{ + margin-top: 1em; + } + div.toc ul{ + margin: 1em 0 0 3em; + /*page-break-inside: avoid;*/ + /*page-break-before: avoid;*/ } + div.toc ul li{ + margin-bottom: 0.5em; + } + div.introduction, div.contribution{ } - /* author names */ + div.introduction h1{ + display: none; + } div.contribution h2 + p > b{ font-weight: normal; - margin-left: var(--second-indent); } ol.references, ul /* This is tricky as it has no class, so these styles are applied to ALL ul elements */{ @@ -204,8 +279,9 @@ ul /* This is tricky as it has no class, so these styles are applied to ALL ul e margin: 0 1em; padding: 0; } + /* exceptions of columns */ div.cover ul, - div.index ul{ + div.toc ul{ columns: unset; } ul li{ @@ -213,23 +289,33 @@ ul /* This is tricky as it has no class, so these styles are applied to ALL ul e text-indent: -1em; } div.cover ul li, - div.index ul li{ + div.toc ul li{ text-indent: 0; } +div.item_index{ +} + div.item_index a::after{ + content: target-counter(attr(href), page); + float: right; + } /* general elements*/ h1{ - string-set: sectiontitle content(text); + /* section titles */ font-size: 37pt; line-height: 1.15; margin: 0; word-break: normal; hyphens: none; } + /* h1's are preceded by a */ + .running-header{ + position: running(sectiontitle); + } h2{ /* Contribution titles */ - string-set: contributiontitle content(text); + string-set: contributiontitle content(text) !important; /* using data attributes in HTML to save short versions of the title -- edited on the wiki */ font-family: "bitter_semi"; font-size: 16pt; line-height: 22pt; @@ -237,6 +323,10 @@ h2{ margin: 0 0 1em var(--second-indent); hyphens: none; } + div.foreword .running-header, + div.introduction .running-header{ + position: running(introductiontitle); + } h3{ /* Sub-headers + Notes/References sections + TOC headers*/ font-size: 100%; @@ -269,8 +359,13 @@ p{ margin: 0; padding: 0; } + /* all exceptions on the text-indent */ + div.toc p, + h2 + p, + h3 + p, div.series p, div.cover p, + div.backcover p, blockquote p{ text-indent: unset !important; } @@ -281,9 +376,9 @@ img{ position: relative; display: block; width: 115mm; /* estimation of the full text width */ - /*height: auto;*/ - max-height: 220mm; - margin: 0 0 1em 0; + height: auto; + max-height: 200mm; + margin: 1em 0 1em 0; } .thumb{ /* sometimes wrapper of img + image caption */ @@ -312,7 +407,7 @@ table{ sup{ line-height: 0; font-size: 7pt; - padding-left: 0.5mm; + padding-left: 0.15mm; } canvas{ position: absolute; @@ -344,3 +439,4 @@ a.external{ } } + diff --git a/command-line/templates/template.html b/command-line/templates/template.html index 23caff8..31309ad 100644 --- a/command-line/templates/template.html +++ b/command-line/templates/template.html @@ -6,6 +6,7 @@ +
diff --git a/command-line/update.py b/command-line/update.py index 55466a6..8c48392 100644 --- a/command-line/update.py +++ b/command-line/update.py @@ -80,14 +80,76 @@ def download_media(html, images, wiki): return html -def split_h2_header(html): +def insert_variable_geometry(html): + vg = """ +""" + html = html.replace("$multi", vg) + return html + +def add_item_inventory_links(html): """ html = string (HTML) - DOES NOT WORK YET! """ - pattern = '

.*?:.*?

' # split the h2 in two on the ":" - result = re.split(pattern, html) - # print(result[0]) + pattern = r'Item \d\d\d' + matches = re.findall(pattern, html) + index = {} + for match in matches: + number = match.replace('Item ', '').strip() + if not number in index: + index[number] = [] + count = 1 + else: + count = index[number][-1] + 1 + index[number].append(count) + item_id = f'{ number }-{ index[number][-1] }' + html = html.replace(match, f'Item { number }') + import json + print(json.dumps(index, indent=4)) return html def clean_up(html): @@ -113,7 +175,8 @@ def parse_page(pagename, wiki): images = data['parse']['images'] html = download_media(html, images, wiki) html = clean_up(html) - html = split_h2_header(html) + html = add_item_inventory_links(html) + # html = insert_variable_geometry(html) else: html = None diff --git a/web-interface/update.py b/web-interface/update.py index 7ada867..701318a 100644 --- a/web-interface/update.py +++ b/web-interface/update.py @@ -81,6 +81,78 @@ def download_media(html, images, wiki): return html +def insert_variable_geometry(html): + vg = """ +""" + html = html.replace("$multi", vg) + return html + +def add_item_inventory_links(html): + """ + html = string (HTML) + """ + pattern = r'Item \d\d\d' + matches = re.findall(pattern, html) + index = {} + for match in matches: + number = match.replace('Item ', '').strip() + if not number in index: + index[number] = [] + count = 1 + else: + count = index[number][-1] + 1 + index[number].append(count) + item_id = f'{ number }-{ index[number][-1] }' + html = html.replace(match, f'Item { number }') + import json + print(json.dumps(index, indent=4)) + return html + def clean_up(html): """ html = string (HTML) @@ -104,6 +176,8 @@ def parse_page(pagename, wiki): images = data['parse']['images'] html = download_media(html, images, wiki) html = clean_up(html) + html = add_item_inventory_links(html) + # html = insert_variable_geometry(html) else: html = None