mirror of
https://git.ari.lt/ari.lt/blog.ari.lt.git
synced 2025-02-04 09:39:25 +01:00
update @ Thu 2 Feb 15:57:41 EET 2023
Signed-off-by: Ari Archer <ari.web.xyz@gmail.com>
This commit is contained in:
parent
c8d7b2563d
commit
c8e10f487b
2 changed files with 55 additions and 5 deletions
|
@ -555,6 +555,13 @@
|
||||||
"version": 1,
|
"version": 1,
|
||||||
"time": 1675084012.897419,
|
"time": 1675084012.897419,
|
||||||
"keywords": "trans transgender transfem fem woman transwoman transgirl lgbt psychologist psychology mental health happiness comingout out closet lithuania"
|
"keywords": "trans transgender transfem fem woman transwoman transgirl lgbt psychologist psychology mental health happiness comingout out closet lithuania"
|
||||||
|
},
|
||||||
|
"doml-2-2023-02-02": {
|
||||||
|
"title": "RE9NTCAjMiAtLSAyMDIzLzAyLzAy",
|
||||||
|
"content": "aGVsbG8gd29ybGQKCnRvZGF5IHdhcyBraW5kYSBjb29sLCBpIGxpdGVyYWxseSB3YXNudCBhdCBzY2hvb2wgYW5kIHdhcyBqdXN0IHByb2dyYW1taW5nIGZvciA1IGhvdXJzLAphbHRob3VnaCBpdHMgbm90IHdoYXQgeW91IHRoaW5rIGl0IGlzLCBtb3N0IGxpa2VseQoKdG9kYXkgaSB3ZW50IHRvIGEgcHJvZ3JhbW1pbmcgb2x5bXBpYyBhZ2FpbiwgdGhlIGNvdW50cnkgcGFydCwgcGFydCAxLCBhbHRob3VnaCBpIGRvbnQKdGhpbmsgaWxsIGdvIHRvIHRoZSBmaW5hbGUsIHJlYXNvbiBiZWluZyBpIGdvdCBgMzUgLyAzMDBgIHBvaW50cywgaWsgaXQgc291bmRzIGhvcnJpYmxlLApiZWNhdXNlIGl0IGlzLCBpdHMgYDExLig2KSAlYCBidXQgcGVyIGF2ZXJhZ2UgaSBmZWVsIGxpa2UgaSBkaWQgb2theSBpZywsLCwgaSBtZWFuLCBpIGdvdAptb3JlIHBvaW50cyB0aGFuIGFub3RoZXIgZ3V5IGZvciBzdXJlLCB0aG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pcmVkIHRvIGRvIG11Y2ggcm4gdGJoLCBpIHJlYWxseSB3YW50ZWQgdG8gc2hhcmUgd2hhdCBpCmRpZCB0b2RheSwgZXZlbiB0aG91Z2ggaXQgaXNudCBtdWNoIGZvciBub3cgYXQgbGVhc3QsIGFmdGVyIHRoaXMgaW0gcHJvYmFibHkgZ29pbmcgb24gYSB3YWxrLAptYXliZSB0byBteSBncmFuZG1hLCB3ZWxsIHNlZSwgc28geWUKCmhhdmUgYSBuaWNlIGRheSA8Mwo=",
|
||||||
|
"version": 1,
|
||||||
|
"time": 1675346248.689833,
|
||||||
|
"keywords": "doml web programming day of my life 2023 2023\/02\/02"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -9,6 +9,7 @@ import string
|
||||||
import sys
|
import sys
|
||||||
import xml.etree.ElementTree as etree
|
import xml.etree.ElementTree as etree
|
||||||
from base64 import b64decode, b64encode
|
from base64 import b64decode, b64encode
|
||||||
|
from collections.abc import Collection
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from glob import iglob
|
from glob import iglob
|
||||||
from html import escape as html_escape
|
from html import escape as html_escape
|
||||||
|
@ -18,7 +19,7 @@ from shutil import rmtree
|
||||||
from tempfile import gettempdir
|
from tempfile import gettempdir
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from timeit import default_timer as code_timer
|
from timeit import default_timer as code_timer
|
||||||
from typing import Any, Callable, Dict, Iterable, List, Optional, Set, Tuple
|
from typing import Any, Callable, Dict, List, Optional, Set, Tuple
|
||||||
from warnings import filterwarnings as filter_warnings
|
from warnings import filterwarnings as filter_warnings
|
||||||
|
|
||||||
import ujson # type: ignore
|
import ujson # type: ignore
|
||||||
|
@ -81,6 +82,35 @@ DEFAULT_CONFIG: Dict[str, Any] = {
|
||||||
DEFAULT_CONFIG_FILE: str = "blog.json"
|
DEFAULT_CONFIG_FILE: str = "blog.json"
|
||||||
HISTORY_FILE: str = ".blog_history"
|
HISTORY_FILE: str = ".blog_history"
|
||||||
BLOG_VERSION: int = 1
|
BLOG_VERSION: int = 1
|
||||||
|
CONTEXT_WORDS: Tuple[str, ...] = (
|
||||||
|
"the",
|
||||||
|
"a",
|
||||||
|
"about",
|
||||||
|
"etc",
|
||||||
|
"on",
|
||||||
|
"at",
|
||||||
|
"in",
|
||||||
|
"by",
|
||||||
|
"its",
|
||||||
|
"i",
|
||||||
|
"to",
|
||||||
|
"my",
|
||||||
|
"of",
|
||||||
|
"between",
|
||||||
|
"because",
|
||||||
|
"of",
|
||||||
|
"or",
|
||||||
|
"how",
|
||||||
|
"to",
|
||||||
|
"begin",
|
||||||
|
"is",
|
||||||
|
"this",
|
||||||
|
"person",
|
||||||
|
"important",
|
||||||
|
"homework",
|
||||||
|
"and",
|
||||||
|
"cause",
|
||||||
|
)
|
||||||
|
|
||||||
BLOG_MARKDOWN_TEMPLATE: str = """<header role="group">
|
BLOG_MARKDOWN_TEMPLATE: str = """<header role="group">
|
||||||
<h1 role="heading" aria-level="1">%s</h1>
|
<h1 role="heading" aria-level="1">%s</h1>
|
||||||
|
@ -222,7 +252,20 @@ HOME_PAGE_HTML_TEMPLATE: str = f"""<!DOCTYPE html>
|
||||||
</html>"""
|
</html>"""
|
||||||
|
|
||||||
|
|
||||||
def sanitise_title(title: str, titleset: Iterable[str], _nosep: bool = False) -> str:
|
def remove_basic_punct(s: str) -> str:
|
||||||
|
return "".join(c for c in s if c not in "'\"()[]{}:;.,?!=#")
|
||||||
|
|
||||||
|
|
||||||
|
def sanitise_title(
|
||||||
|
title: str, titleset: Collection[str], /, nosep: bool = False
|
||||||
|
) -> str:
|
||||||
|
title = " ".join(
|
||||||
|
[
|
||||||
|
w
|
||||||
|
for w in remove_basic_punct(title).lower().split()
|
||||||
|
if w not in CONTEXT_WORDS
|
||||||
|
][:8]
|
||||||
|
)
|
||||||
_title: str = ""
|
_title: str = ""
|
||||||
|
|
||||||
for char in title:
|
for char in title:
|
||||||
|
@ -234,13 +277,13 @@ def sanitise_title(title: str, titleset: Iterable[str], _nosep: bool = False) ->
|
||||||
else ""
|
else ""
|
||||||
)
|
)
|
||||||
|
|
||||||
_title = _title.lower().rstrip("-")
|
_title = _title.rstrip("-")
|
||||||
|
|
||||||
return (
|
return (
|
||||||
_title
|
_title
|
||||||
if _title not in titleset and _title.strip()
|
if _title not in titleset and _title.strip()
|
||||||
else sanitise_title(
|
else sanitise_title(
|
||||||
_title + ("" if _nosep else "-") + random.choice(string.digits),
|
_title + ("" if nosep else "-") + random.choice(string.digits),
|
||||||
titleset,
|
titleset,
|
||||||
True,
|
True,
|
||||||
)
|
)
|
||||||
|
@ -439,7 +482,7 @@ def new_blog(config: Dict[str, Any]) -> Tuple[int, Dict[str, Any]]:
|
||||||
us_title: str = title
|
us_title: str = title
|
||||||
s_title: str = sanitise_title(us_title, config["blogs"])
|
s_title: str = sanitise_title(us_title, config["blogs"])
|
||||||
else:
|
else:
|
||||||
raise RuntimeError("Unreachable")
|
return EXIT_ERR, config
|
||||||
|
|
||||||
blog: Dict[str, Any] = {
|
blog: Dict[str, Any] = {
|
||||||
"title": b64encode(us_title.encode()).decode(),
|
"title": b64encode(us_title.encode()).decode(),
|
||||||
|
|
Loading…
Add table
Reference in a new issue