mirror of
https://git.ari.lt/ari.lt/blog.ari.lt.git
synced 2025-02-04 09:39:25 +01:00
update @ Sun 17 Apr 17:06:42 EEST 2022
Signed-off-by: Ari Archer <ari.web.xyz@gmail.com>
This commit is contained in:
parent
d54ee81c2e
commit
f8fad2a213
2 changed files with 35 additions and 14 deletions
File diff suppressed because one or more lines are too long
30
scripts/blog
30
scripts/blog
|
@ -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,17 +302,19 @@ 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(
|
|
||||||
BLOG_HTML_TEMPLATE.format(
|
|
||||||
title=config["page-title"],
|
title=config["page-title"],
|
||||||
theme_type=config["colourscheme-type"],
|
theme_type=config["colourscheme-type"],
|
||||||
keywords=blog_meta["keywords"],
|
keywords=blog_meta["keywords"],
|
||||||
blog_description=f"Blog on {blog_time} -- {blog_title}",
|
blog_description=f"Blog on {blog_time} -- {blog_title}",
|
||||||
blog=blog_base_html,
|
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")
|
||||||
|
|
||||||
|
@ -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,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue