diff --git a/src/kitaab-public/asset/header.css b/src/kitaab-public/asset/header.css new file mode 100644 index 0000000..cc8098f --- /dev/null +++ b/src/kitaab-public/asset/header.css @@ -0,0 +1,162 @@ +@define-mixin menu { + position: absolute; + background: var(--background); + box-shadow: var(--shadow); + color: white; + border: 2px solid; + margin: 0; + padding: 10px; + list-style: none; + z-index: 99; +} + +.header { + display: flex; + flex-direction: column; + position: relative; + + @media print { + display: none; + } + + &__inner { + display: flex; + align-items: center; + justify-content: space-between; + } + + &__logo { + display: flex; + flex: 1; + + &:after { + content: ''; + background: repeating-linear-gradient(90deg, var(--accent), var(--accent) 2px, transparent 0, transparent 10px); + display: block; + width: 100%; + right: 10px; + } + + a { + flex: 0 0 auto; + max-width: 100%; + text-decoration: none; + } + } + + .menu { + --shadow-color: color-mod(var(--background) a(80%)); + --shadow: 0 10px var(--shadow-color), -10px 10px var(--shadow-color), 10px 10px var(--shadow-color); + margin: 20px 1px; + + @media (--phone) { + @mixin menu; + top: 50px; + right: 0; + } + + &__inner { + display: flex; + flex-wrap: wrap; + list-style: none; + margin: 0; + padding: 0; + + &--desktop { + @media (--phone) { + display: none; + } + } + + &--mobile { + display: none; + + @media (--phone) { + display: block; + } + } + + li { + &:not(:last-of-type) { + margin-right: 20px; + margin-bottom: 10px; + flex: 0 0 auto; + } + } + + @media (--phone) { + flex-direction: column; + align-items: flex-start; + padding: 0; + + li { + margin: 0; + padding: 5px; + } + } + } + + &__sub-inner { + position: relative; + list-style: none; + padding: 0; + margin: 0; + + &:not(:only-child) { + margin-left: 20px; + } + + &-more { + @mixin menu; + top: 35px; + left: 0; + + &-trigger { + color: var(--accent); + user-select: none; + cursor: pointer; + } + + li { + margin: 0; + padding: 5px; + white-space: nowrap; + } + } + } + + .spacer { + flex-grow: 1; + } + + .language-selector { + position: relative; + list-style: none; + margin: 0; + + &-current { + list-style-type: none; + display: flex; + flex-direction: row; + color: var(--accent); + cursor: pointer; + margin: 0; + } + + &__more { + @mixin menu; + top: 35px; + right: 0; + } + } + + &-trigger { + color: var(--accent); + border: 2px solid; + margin-left: 10px; + height: 100%; + padding: 3px 8px; + position: relative; + } + } +} diff --git a/src/kitaab-public/asset/main.css b/src/kitaab-public/asset/main.css index 21d7112..af9897d 100644 --- a/src/kitaab-public/asset/main.css +++ b/src/kitaab-public/asset/main.css @@ -291,4 +291,4 @@ ul>*+* { --article-shadow: #333; --link: var(--purple-light-transparent); } -} */ \ No newline at end of file +} */ diff --git a/src/kitaab-public/build/build.py b/src/kitaab-public/build/build.py index 9313ea4..0420ccb 100644 --- a/src/kitaab-public/build/build.py +++ b/src/kitaab-public/build/build.py @@ -2,6 +2,7 @@ from jinja2 import Environment, FileSystemLoader import argparse import glob import os +import random import platform import re import shutil @@ -212,7 +213,7 @@ def fix_wiki_links(page, path): captured_group = match.group(groupNum + 1) link_elem = captured_group.split("|") if len(link_elem) > 1: - full_url = "" + link_elem[0].strip() + "" + full_url = "" + link_elem[1].strip() + "" else: if config.flat_build: full_url = "" + link_elem[0].strip() + "" @@ -253,15 +254,41 @@ def remove_date(page): return page +def replacement_function(replace): + replace = replace.group() + replace = replace.strip('@<>') + if replace == 'name-generation': + # TODO gross hardcoded + lines = [] + with open('raw/210124-0033.wiki') as f: + lines = f.readlines() + lines = lines[-2:] + line1 = lines[0].split(',') + line2 = lines[1].split(',') + line1len = len(line1) + line2len = len(line2) + first = line1[random.randrange(line1len)] + second = line2[random.randrange(line2len)] + return first + ' ' + second + + +def replace_generated(page): + #try: + page = re.sub(r'@<[A-Za-z- ]*>', + replacement_function, + page) + return page + #except Exception as e: + # print(e) + # print(f"Could not replace generated in {page}") + # return page + + def get_date(page): try: - textContent = page.splitlines() - date = textContent[2] - if '%date' in date: - textContent.strip('%date') - date = str(datetime.strptime(textContent, '%y%m%d-%H%M')) - return date - return None + regex = r"%date [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}" + match = re.findall(regex, page)[0].strip('%date') + return match except: #print(f"Could not parse date") return None @@ -292,6 +319,7 @@ def create_entries(pages): markdown_text = open(page, 'r').read() markdown_text = parse_headings(markdown_text) + markdown_text = replace_generated(markdown_text) markdown_text = style_iframes(markdown_text) markdown_text = fix_images_urls(markdown_text) markdown_text = fix_wiki_links(markdown_text, path["folder"]) @@ -312,7 +340,7 @@ def create_entries(pages): if date: tempPage['date'] = date else: - tempPage['date'] = path['iso_date'] + tempPage['date'] = path['iso_date'][:-3] tempPage['title'] = fix_amp(title) tempPage['pageContent'] = pageContent tempPage['tags'] = tags diff --git a/src/kitaab-public/grab/makePublic.py b/src/kitaab-public/grab/makePublic.py index 1250522..aec7fe8 100644 --- a/src/kitaab-public/grab/makePublic.py +++ b/src/kitaab-public/grab/makePublic.py @@ -7,16 +7,18 @@ from os import listdir, mkdir, path, remove import shutil import random import json -import shared.TagHelper as TagHelper import convert from icecream import ic +import sys +sys.path.append("../") from shared.censor import privateList +from shared import TagHelper ## TODO: generalize based on headings(?) in index.wiki censor = privateList # TODO put this in config too... -filter = ["dream", "gratitude", "review", "jrnl", "piracy", "work", "job", "debt", "people", "priv", "threatdefence"] +filter = ["dream", "gratitude", "review", "jrnl", "work", "job", "debt", "people", "priv", "threatdefence", "info"] #TODO create = ... def loadNetwork(path='network.json'): diff --git a/src/kitaab-public/partial/list.html b/src/kitaab-public/partial/list.html index 5ab8463..6987cd2 100644 --- a/src/kitaab-public/partial/list.html +++ b/src/kitaab-public/partial/list.html @@ -19,7 +19,7 @@ {% endif %} {% endif %} -
{{entry['date'].split(' ')[0]}}
+{{entry['date']}}
{% for page in entry['tags'].split(' ') %} diff --git a/src/kitaab-public/partial/main.html b/src/kitaab-public/partial/main.html index afb5442..fcb39e7 100644 --- a/src/kitaab-public/partial/main.html +++ b/src/kitaab-public/partial/main.html @@ -45,7 +45,7 @@ media="screen" title="no title" charset="utf-8">