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