total rewrite of the blogging system

Signed-off-by: Ari Archer <ari.web.xyz@gmail.com>
This commit is contained in:
Ari Archer 2023-08-29 10:27:14 +03:00
parent 09553e441e
commit dd29749b5a
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: A50D5B4B599AF8A2
10 changed files with 3263 additions and 1609 deletions

2740
blog.json

File diff suppressed because one or more lines are too long

View file

@ -1,12 +0,0 @@
# blog completion -*- shell-script -*-
_blog() {
local cur
_init_completion -s || return
COMPREPLY=($(compgen -W "help new build ls\
rm edit defcfg clean metadata static css" -- "$cur"))
} && complete -F _blog -o bashdefault -o default blog
# ex: filetype=sh

View file

@ -181,41 +181,27 @@ blockquote * {
color: var(--clr-blockquote-fg); color: var(--clr-blockquote-fg);
} }
*[data-pl] { *[h] > a {
padding-top: 0.06em;
padding-bottom: 0.06em;
margin-top: 0.5em;
margin-bottom: 0.5em;
}
*[data-pl] * {
display: inline;
font-size: inherit !important;
}
*[data-pl] > a {
padding-right: 0.3em;
opacity: 0.3; opacity: 0.3;
-webkit-transition: opacity 0.1s ease-in-out; -webkit-transition: opacity 0.1s ease-in-out;
-o-transition: opacity 0.1s ease-in-out; -o-transition: opacity 0.1s ease-in-out;
transition: opacity 0.1s ease-in-out; transition: opacity 0.1s ease-in-out;
} }
*[data-pl]:hover > a, *[h]:hover > a,
*[data-pl]:focus > a { *[h]:focus > a {
opacity: 0.6; opacity: 0.6;
} }
*[data-pl] > a:hover, *[h] > a:hover,
*[data-pl] > a:focus { *[h] > a:focus {
opacity: 1; opacity: 1;
} }
@media only screen and (max-width: 1200px) { @media only screen and (max-width: 1200px) {
*[data-pl] > a, *[h] > a,
*[data-pl]:hover > a, *[h]:hover > a,
*[data-pl]:focus > a { *[h]:focus > a {
opacity: 1; opacity: 1;
} }
} }
@ -271,7 +257,7 @@ nav img {
-ms-overflow-style: initial !important; -ms-overflow-style: initial !important;
} }
*[data-pl] > a { a {
opacity: 1; opacity: 1;
} }
} }

View file

@ -1,5 +1,5 @@
[build] [build]
command = "python3 ./scripts/blog.py static && rm -rf ./scripts/ ./completions/" command = "python3 ./scripts/blog.py static && rm -rf ./scripts/"
[[redirects]] [[redirects]]
from = "/git/*" from = "/git/*"
@ -13,18 +13,6 @@
status = 200 status = 200
force = true force = true
[[redirects]]
from = "/robots.txt"
to = "https://ari-web.xyz/robots.txt"
status = 200
force = true
[[redirects]]
from = "/sitemap.xml"
to = "https://ari-web.xyz/sitemap.xml"
status = 200
force = true
[[redirects]] [[redirects]]
from = "/blogs/:blog" from = "/blogs/:blog"
to = "https://legacy.blog.ari-web.xyz/blogs/:blog" to = "https://legacy.blog.ari-web.xyz/blogs/:blog"

View file

@ -12,3 +12,10 @@ stubPath = "src/stubs"
typeCheckingMode = "strict" typeCheckingMode = "strict"
useLibraryCodeForTypes = true useLibraryCodeForTypes = true
reportMissingTypeStubs = true reportMissingTypeStubs = true
[tool.mypy]
exclude = [
"^venv/.*",
"^node_modules/.*",
"^__pycache__/.*",
]

3
requirements-extra.txt Normal file
View file

@ -0,0 +1,3 @@
pyfzf
rebelai
requests

View file

@ -1,9 +1,5 @@
css-html-js-minify css-html-js-minify
datetime mistune
markdown
plumbum
pyfzf
typing typing
pymdown-extensions
ujson
readtime readtime
unidecode

File diff suppressed because it is too large Load diff

42
scripts/migrate.py Normal file
View file

@ -0,0 +1,42 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""migrates from v1 to v2"""
import json
from warnings import filterwarnings as filter_warnings
def t(data: str) -> str:
return data[:196] + ("" if len(data) < 196 else " ...")
def main() -> int:
"""entry / main function"""
with open("a.json", "r") as f: # old v1 blog
posts = json.load(f)["blogs"]
with open("blog.json", "r") as f:
blog = json.load(f)
for slug, post in posts.items():
blog["posts"][slug] = {
"title": post["title"],
"description": t(post["content"][:196]),
"content": post["content"],
"keywords": post["keywords"].split(),
"created": post["time"],
}
with open("blog.json", "w") as f:
json.dump(blog, f, indent=4)
return 0
if __name__ == "__main__":
assert main.__annotations__.get("return") is int, "main() should return an integer"
filter_warnings("error", category=Warning)
raise SystemExit(main())

View file

@ -1,3 +1,8 @@
[flake8] [tox]
max-line-length = 200 envlist = py38
[flake8]
max-line-length = 160
[pycodestyle]
max-line-length = 160