update @ Sun 17 Apr 17:06:42 EEST 2022

Signed-off-by: Ari Archer <ari.web.xyz@gmail.com>
This commit is contained in:
Ari Archer 2022-04-17 17:06:42 +03:00
parent d54ee81c2e
commit f8fad2a213
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
2 changed files with 35 additions and 14 deletions

File diff suppressed because one or more lines are too long

View file

@ -2,7 +2,6 @@
# -*- coding: utf-8 -*-
"""Manage blogs"""
import hashlib
import json
import os
import random
@ -213,6 +212,7 @@ def new_blog(config: Dict) -> Tuple[int, Dict]:
"version": BLOG_VERSION,
"time": 0.0,
"keywords": "",
"minimise": True,
}
file: str = f"/tmp/{s_title}.md"
@ -238,6 +238,8 @@ def new_blog(config: Dict) -> Tuple[int, Dict]:
user_keywords + " " + " ".join(config["default-keywords"])
)
blog["minimise"] = (iinput("Minimise blog? (Y/n)") + "y").lower()[0] == "y"
blog["time"] = datetime.now().timestamp()
config["blogs"][s_title] = blog
@ -300,17 +302,19 @@ def build(config: Dict) -> Tuple[int, Dict]:
extensions=config["py-markdown-extensions"],
)
blog_html.write(
html_minify(
BLOG_HTML_TEMPLATE.format(
blog_html_full: str = BLOG_HTML_TEMPLATE.format(
title=config["page-title"],
theme_type=config["colourscheme-type"],
keywords=blog_meta["keywords"],
blog_description=f"Blog on {blog_time} -- {blog_title}",
blog=blog_base_html,
)
)
)
if blog_meta["minimise"]:
log(f"Minifying {blog_name!r} HTML")
blog_html_full = html_minify(blog_html_full)
blog_html.write(blog_html_full)
log(f"Finished building blog {blog_name!r}", "BUILD")
@ -447,10 +451,24 @@ def edit_content(blog: str, config: Dict) -> int:
return EXIT_OK
def edit_minimise(blog: str, config: Dict) -> int:
minimise: bool = config["blogs"][blog]["minimise"]
config["blogs"][blog]["minimise"] = (
iinput(
f"Minimise this blog's HTML? [{minimise}] (y/n)", "y" if minimise else "n"
)
+ "y"
)[0] == "y"
return EXIT_OK
EDIT_HOOKS: Dict = {
"title": edit_title,
"keywords": edit_keywords,
"content": edit_content,
"minimise": edit_minimise,
}