From d1d31bb444697138409421020edee52ea9d07107 Mon Sep 17 00:00:00 2001 From: Eyal Gruss Date: Sat, 20 Jan 2024 17:24:00 +0200 Subject: [PATCH] optional issue subtitle (but just in hebrew) --- resen/pages.js | 70 +++++++++++++++++++++++++++---------------------- resen/style.css | 2 +- 2 files changed, 39 insertions(+), 33 deletions(-) diff --git a/resen/pages.js b/resen/pages.js index b35b650..c65ff9a 100644 --- a/resen/pages.js +++ b/resen/pages.js @@ -19,7 +19,7 @@ const pages = { const authors = { "oulipoh": { - "name": {"": "כתב עת מקוון ליצירה אילוצית וחישובית בעברית (בהקמה)", "en": "An online journal for constrained and computational creation in Hebrew (under construction)"}, + "name": {"": "כתב עת מקוון ליצירה אילוצית וחישובית בעברית", "en": "An online journal for constrained and computational creation in Hebrew"}, "mail": "eyalgruss+oulipoh@gmail.com", "github": "", "sponsors": "", @@ -68,28 +68,8 @@ const ui = { const default_rows_first = true const default_reorder_contents = true -const default_copyright_url = "https://creativecommons.org/licenses/by/4.0/" -const default_copyright_label = "(CC)(웃)" -const default_force_new_tab_for_mailto_tel = true -const default_new_tab_for_social = true -const default_new_tab_for_footer = true -const default_show_snippet = true -const default_show_author = true - -let author_pages_folder = '' -author_pages_folder = author_pages_folder.replace(/^[./]+|[./]+$/g, '') - -const social = { - "mail": {"url": "mailto:", "label": "✉"}, - "web": {"label": "🏠︎"}, - "twitter": {"url": "twitter.com", "label": "🐦"}, - "github": {"url": "github.com", "label": "🐱"}, - "sponsors": {"url": "github.com/sponsors", "label": "♥"}, - "paypal": {"url": "www.paypal.com/donate/?hosted_button_id=", "label": "💸"}, - "subscribe": {"url": "forms.gle", "label": "הרשמה לעדכונים"} -} - const kw_labels = { + 0: "אפס – מלחמה", "2d 3d": "רב־ממדי", "biblical": "תורני", "cipher": "צופן", @@ -112,12 +92,33 @@ const kw_labels = { "visual": "חזותי" } +const social = { + "mail": {"url": "mailto:", "label": "✉"}, + "web": {"label": "🏠︎"}, + "twitter": {"url": "twitter.com", "label": "🐦"}, + "github": {"url": "github.com", "label": "🐱"}, + "sponsors": {"url": "github.com/sponsors", "label": "♥"}, + "paypal": {"url": "www.paypal.com/donate/?hosted_button_id=", "label": "💸"}, + "subscribe": {"url": "forms.gle", "label": "הרשמה לעדכונים"} +} + const shortcuts = { "back": "Alt+Backspace", "next": "Alt+PageDown", "prev": "Alt+PageUp" } +const default_copyright_url = "https://creativecommons.org/licenses/by/4.0/" +const default_copyright_label = "(CC)(웃)" +const default_force_new_tab_for_mailto_tel = true +const default_new_tab_for_social = true +const default_new_tab_for_footer = true +const default_show_snippet = true +const default_show_author = true + +let author_pages_folder = '' +author_pages_folder = author_pages_folder.replace(/^[./]+|[./]+$/g, '') + function get_lang() { return location.search.slice(1) in ui ? location.search.slice(1) : Object.keys(ui)[0] @@ -128,7 +129,7 @@ const collator = Intl.Collator(document.documentElement.lang, {numeric: true}) function reorder(list_of_strings, lang='', labels=kw_labels) { - return [...new Set(list_of_strings)].map(String).sort((a, b) => {if (!lang) {a = labels[a] || a, b = labels[b] || b} return collator.compare(a, b)}) + return [...new Set(list_of_strings)].map(String).sort((a, b) => {const issues = !!b.match(/^\d+$/) - !!(a.match(/^\d+$/)); if (!lang) a = labels[a] ?? a, b = labels[b] ?? b; return issues || collator.compare(a, b)}) } @@ -386,6 +387,17 @@ function set_next_prev_page(page, next, prev, lang, url_kw) { } +function get_kw_label(kw, lang='') { + let label = lang ? kw : kw_labels[kw] ?? kw + if (kw.match(/^\d+$/)) { + if (!lang && !label.includes(' – ')) + label = kw + ' – ' + label + label = ui[lang].issue + ' ' + label + } + return label +} + + function make_header(reorder_contents=default_reorder_contents, new_tab_for_social=default_new_tab_for_social) { const page = get_page() const lang = get_lang() @@ -478,17 +490,11 @@ function make_header(reorder_contents=default_reorder_contents, new_tab_for_soci keywords.forEach((kw, button_index) => { button = document.createElement(page == '/' ? 'button' : 'a') button.id = 'kw_' + sanitize(kw) - let label = kw_labels[kw] || kw - if (kw.match(/^\d+$/)) - label = ui[lang].issue + ' ' + kw + const label = get_kw_label(kw, lang) let alt = '' if (trans) { - alt = kw - if (kw.match(/^\d+$/)) - alt = ui[alt_langs[0]].issue + ' ' + kw - else if (lang) - [label, alt] = [alt, label] + alt = get_kw_label(kw, alt_langs[0]) if (alt == label) alt = '' } @@ -506,7 +512,7 @@ function make_header(reorder_contents=default_reorder_contents, new_tab_for_soci }) if (page == '/') { button = document.createElement('button') - button.ariaLabel = 'אפס בחירות' + button.ariaLabel = 'אַפס בחירות' button.id = 'kw_x' button.innerHTML = 'X' button.onclick = () => div.querySelectorAll('.on').forEach(e => e.click()) diff --git a/resen/style.css b/resen/style.css index a9ecbd4..a773130 100644 --- a/resen/style.css +++ b/resen/style.css @@ -437,7 +437,7 @@ nav[dir=rtl] ~ footer > div { } .github, .paypal { - filter: invert(--invert); + filter: invert(var(--invert)); } h1, h2 {