From 652983c024e254bf290949a44526f0dd9986f6e6 Mon Sep 17 00:00:00 2001 From: Ari Archer Date: Wed, 26 Apr 2023 02:41:11 +0300 Subject: [PATCH] update @ Wed 26 Apr 02:41:11 EEST 2023 Signed-off-by: Ari Archer --- requirements.txt | 2 +- scripts/blog.py | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/requirements.txt b/requirements.txt index 56fbfc0..931e679 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,4 @@ pyfzf typing pymdown-extensions ujson - +readtime diff --git a/scripts/blog.py b/scripts/blog.py index 460d682..1f5912f 100755 --- a/scripts/blog.py +++ b/scripts/blog.py @@ -31,6 +31,7 @@ from markdown.inlinepatterns import InlineProcessor # type: ignore from markdown.treeprocessors import Treeprocessor # type: ignore from plumbum.commands.processes import ProcessExecutionError # type: ignore from pyfzf import FzfPrompt # type: ignore +from readtime import of_markdown as read_time_of_markdown # type: ignore __version__: int = 1 @@ -124,7 +125,10 @@ BLOG_MARKDOWN_TEMPLATE: str = """
skip - GMT + UTC + + + read home @@ -224,7 +228,7 @@ HOME_PAGE_HTML_TEMPLATE: str = f""" - last posted : GMT + last posted : UTC @@ -530,7 +534,7 @@ def new_blog(config: Dict[str, Any]) -> Tuple[int, Dict[str, Any]]: blog["keywords"] = html_escape(user_keywords) - blog["time"] = datetime.now().timestamp() + blog["time"] = datetime.utcnow().timestamp() config["blogs"][s_title] = blog return EXIT_OK, config @@ -601,11 +605,16 @@ def build(config: Dict[str, Any]) -> Tuple[int, Dict[str, Any]]: blog_title: str = html_escape(blog_meta["title"]) + # 150 wpm is quite slow, but im compensating for people who + # cant read that fast, especially with unprofessional people + # who write blog posts -- like me + blog_base_html: str = markdown( BLOG_MARKDOWN_TEMPLATE % ( blog_title, blog_time, + read_time_of_markdown(blog_meta["content"], 150).text, # type: ignore config["comment-url"], config["base-homepage"], config["git-url"], @@ -629,7 +638,7 @@ def build(config: Dict[str, Any]) -> Tuple[int, Dict[str, Any]]: keywords=blog_meta["keywords"].replace(" ", ", ") + ", " + ", ".join(config["default-keywords"]), - blog_description=f"blog post on {blog_time} GMT -- {blog_title}", + blog_description=f"blog post on {blog_time} UTC -- {blog_title}", blog_title=blog_title, blog=blog_base_html, author=config["full-name"],