nearly at the finish line, mostly got to tidy up kitaab some more. maybe fix up the header??

This commit is contained in:
Anish Lakhwara 2022-02-09 01:12:28 +10:00
parent ef7a0c7812
commit 328fe29f4d
6 changed files with 206 additions and 14 deletions

View file

@ -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;
}
}
}

View file

@ -2,6 +2,7 @@ from jinja2 import Environment, FileSystemLoader
import argparse import argparse
import glob import glob
import os import os
import random
import platform import platform
import re import re
import shutil import shutil
@ -212,7 +213,7 @@ def fix_wiki_links(page, path):
captured_group = match.group(groupNum + 1) captured_group = match.group(groupNum + 1)
link_elem = captured_group.split("|") link_elem = captured_group.split("|")
if len(link_elem) > 1: if len(link_elem) > 1:
full_url = "<a href='" + build_url + link_elem[0].strip() + ".html' >" + link_elem[0].strip() + "</a>" full_url = "<a href='" + build_url + link_elem[0].strip() + ".html' >" + link_elem[1].strip() + "</a>"
else: else:
if config.flat_build: if config.flat_build:
full_url = "<a href='" + build_url + link_elem[0].strip() + ".html' >" + link_elem[0].strip() + "</a>" full_url = "<a href='" + build_url + link_elem[0].strip() + ".html' >" + link_elem[0].strip() + "</a>"
@ -253,15 +254,41 @@ def remove_date(page):
return 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): def get_date(page):
try: try:
textContent = page.splitlines() regex = r"%date [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}"
date = textContent[2] match = re.findall(regex, page)[0].strip('%date')
if '%date' in date: return match
textContent.strip('%date')
date = str(datetime.strptime(textContent, '%y%m%d-%H%M'))
return date
return None
except: except:
#print(f"Could not parse date") #print(f"Could not parse date")
return None return None
@ -292,6 +319,7 @@ def create_entries(pages):
markdown_text = open(page, 'r').read() markdown_text = open(page, 'r').read()
markdown_text = parse_headings(markdown_text) markdown_text = parse_headings(markdown_text)
markdown_text = replace_generated(markdown_text)
markdown_text = style_iframes(markdown_text) markdown_text = style_iframes(markdown_text)
markdown_text = fix_images_urls(markdown_text) markdown_text = fix_images_urls(markdown_text)
markdown_text = fix_wiki_links(markdown_text, path["folder"]) markdown_text = fix_wiki_links(markdown_text, path["folder"])
@ -312,7 +340,7 @@ def create_entries(pages):
if date: if date:
tempPage['date'] = date tempPage['date'] = date
else: else:
tempPage['date'] = path['iso_date'] tempPage['date'] = path['iso_date'][:-3]
tempPage['title'] = fix_amp(title) tempPage['title'] = fix_amp(title)
tempPage['pageContent'] = pageContent tempPage['pageContent'] = pageContent
tempPage['tags'] = tags tempPage['tags'] = tags

View file

@ -7,16 +7,18 @@ from os import listdir, mkdir, path, remove
import shutil import shutil
import random import random
import json import json
import shared.TagHelper as TagHelper
import convert import convert
from icecream import ic from icecream import ic
import sys
sys.path.append("../")
from shared.censor import privateList from shared.censor import privateList
from shared import TagHelper
## TODO: generalize based on headings(?) in index.wiki ## TODO: generalize based on headings(?) in index.wiki
censor = privateList censor = privateList
# TODO put this in config too... # 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 = ... #TODO create = ...
def loadNetwork(path='network.json'): def loadNetwork(path='network.json'):

View file

@ -19,7 +19,7 @@
{% endif %} {% endif %}
{% endif %} {% endif %}
</h3> </h3>
<p style='position:absolute;bottom:0;margin-left:29em'>{{entry['date'].split(' ')[0]}}</p> <p style='position:absolute;bottom:0;margin-left:29em'>{{entry['date']}}</p>
</div> </div>
{% for page in entry['tags'].split(' ') %} {% for page in entry['tags'].split(' ') %}
<a href="{{page}}_index.html"> <a href="{{page}}_index.html">

View file

@ -45,7 +45,7 @@ media="screen" title="no title" charset="utf-8">
<body class="flow-large container"> <body class="flow-large container">
<header> <header>
<a href="home.html" aria-label="{{config.name_of_site}}">{{config.name_of_site}}</a> <a style='display:flex;padding-top:10px' href="home.html" aria-label="{{config.name_of_site}}">{{config.name_of_site}}</a>
</header> </header>
<main> <main>
{{ page_navigation }} {{ page_navigation }}