mirror of
https://git.ari.lt/ari.lt/blog.ari.lt.git
synced 2025-02-04 17:49:24 +01:00
switch back to css-html-js-minify
Signed-off-by: Ari Archer <ari.web.xyz@gmail.com>
This commit is contained in:
parent
5338b1ab02
commit
21b2928918
4 changed files with 17 additions and 28 deletions
|
@ -1,5 +1,4 @@
|
||||||
htmlmin
|
css-html-js-minify
|
||||||
rcssmin
|
|
||||||
mistune
|
mistune
|
||||||
typing
|
typing
|
||||||
readtime
|
readtime
|
||||||
|
|
4
robots.txt
Normal file
4
robots.txt
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
User-agent: *
|
||||||
|
Disallow: /content/*
|
||||||
|
Allow: *
|
||||||
|
Sitemap: https://blog.ari-web.xyz/sitemap.xml
|
|
@ -24,13 +24,13 @@ from threading import Thread
|
||||||
from timeit import default_timer as code_timer
|
from timeit import default_timer as code_timer
|
||||||
from warnings import filterwarnings as filter_warnings
|
from warnings import filterwarnings as filter_warnings
|
||||||
|
|
||||||
import htmlmin
|
|
||||||
import mistune
|
import mistune
|
||||||
import mistune.core
|
import mistune.core
|
||||||
import mistune.inline_parser
|
import mistune.inline_parser
|
||||||
import mistune.plugins
|
import mistune.plugins
|
||||||
import rcssmin # type: ignore
|
|
||||||
import unidecode
|
import unidecode
|
||||||
|
from css_html_js_minify import html_minify # type: ignore
|
||||||
|
from css_html_js_minify import process_single_css_file # type: ignore
|
||||||
from readtime import of_markdown as read_time_of_markdown # type: ignore
|
from readtime import of_markdown as read_time_of_markdown # type: ignore
|
||||||
|
|
||||||
__version__: typing.Final[int] = 2
|
__version__: typing.Final[int] = 2
|
||||||
|
@ -557,24 +557,6 @@ def read_post(path: str) -> str:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
def process_css(code: str) -> str:
|
|
||||||
return rcssmin.cssmin(code) # type: ignore
|
|
||||||
|
|
||||||
|
|
||||||
def process_css_from_file(file: str) -> str:
|
|
||||||
with open(file, "r") as css:
|
|
||||||
return process_css(css.read())
|
|
||||||
|
|
||||||
|
|
||||||
def process_css_file(file: str, out: str) -> None:
|
|
||||||
with open(out, "w") as css:
|
|
||||||
css.write(process_css_from_file(file))
|
|
||||||
|
|
||||||
|
|
||||||
def min_html(code: str) -> str:
|
|
||||||
return htmlmin.minify(code, True, True, True, True, True, True, True)
|
|
||||||
|
|
||||||
|
|
||||||
# markdown
|
# markdown
|
||||||
|
|
||||||
TITLE_LINKS_RE: typing.Final[str] = r"<#:[^>]+?>"
|
TITLE_LINKS_RE: typing.Final[str] = r"<#:[^>]+?>"
|
||||||
|
@ -882,10 +864,12 @@ def build(config: dict[str, typing.Any]) -> int:
|
||||||
post_crit_css: str = ""
|
post_crit_css: str = ""
|
||||||
|
|
||||||
if os.path.isfile(critp := f"{config['assets-dir']}/critical.css"):
|
if os.path.isfile(critp := f"{config['assets-dir']}/critical.css"):
|
||||||
crit_css = process_css_from_file(critp)
|
with open(critp, "r") as fp:
|
||||||
|
crit_css = fp.read()
|
||||||
|
|
||||||
if os.path.isfile(critp := f"{config['assets-dir']}/post_critical.css"):
|
if os.path.isfile(critp := f"{config['assets-dir']}/post_critical.css"):
|
||||||
post_crit_css = process_css_from_file(critp)
|
with open(critp, "r") as fp:
|
||||||
|
post_crit_css = fp.read()
|
||||||
|
|
||||||
def build_post(slug: str, post: dict[str, typing.Any]) -> None:
|
def build_post(slug: str, post: dict[str, typing.Any]) -> None:
|
||||||
ct: float = ctimer()
|
ct: float = ctimer()
|
||||||
|
@ -895,7 +879,7 @@ def build(config: dict[str, typing.Any]) -> int:
|
||||||
|
|
||||||
with open(f"{post_dir}/index.html", "w") as html:
|
with open(f"{post_dir}/index.html", "w") as html:
|
||||||
html.write(
|
html.write(
|
||||||
min_html(
|
html_minify(
|
||||||
POST_TEMPLATE.format(
|
POST_TEMPLATE.format(
|
||||||
lang=lang,
|
lang=lang,
|
||||||
keywords=html_escape(
|
keywords=html_escape(
|
||||||
|
@ -952,7 +936,7 @@ def build(config: dict[str, typing.Any]) -> int:
|
||||||
|
|
||||||
with open("index.html", "w") as index:
|
with open("index.html", "w") as index:
|
||||||
index.write(
|
index.write(
|
||||||
min_html(
|
html_minify(
|
||||||
INDEX_TEMPLATE.format( # type: ignore
|
INDEX_TEMPLATE.format( # type: ignore
|
||||||
lang=lang,
|
lang=lang,
|
||||||
keywords=html_escape(", ".join(config["blog-keywords"])),
|
keywords=html_escape(", ".join(config["blog-keywords"])),
|
||||||
|
@ -1014,7 +998,7 @@ def css(config: dict[str, typing.Any]) -> int:
|
||||||
|
|
||||||
if os.path.isfile(styles := f"{config['assets-dir']}/styles.css"):
|
if os.path.isfile(styles := f"{config['assets-dir']}/styles.css"):
|
||||||
lnew(f"minifying {styles!r}")
|
lnew(f"minifying {styles!r}")
|
||||||
_thread(process_css_file, styles, f"{config['assets-dir']}/styles.min.css") # type: ignore
|
_thread(process_single_css_file, styles, f"{config['assets-dir']}/styles.min.css") # type: ignore
|
||||||
|
|
||||||
if os.path.isdir(fonts := f"{config['assets-dir']}/fonts"):
|
if os.path.isdir(fonts := f"{config['assets-dir']}/fonts"):
|
||||||
log(f"minifying fonts in {fonts!r}")
|
log(f"minifying fonts in {fonts!r}")
|
||||||
|
@ -1023,7 +1007,7 @@ def css(config: dict[str, typing.Any]) -> int:
|
||||||
if fcss.endswith(".min.css"):
|
if fcss.endswith(".min.css"):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
_thread(process_css_file, fcss, f"{os.path.splitext(fcss)[0]}.min.css") # type: ignore
|
_thread(process_single_css_file, fcss, f"{os.path.splitext(fcss)[0]}.min.css") # type: ignore
|
||||||
|
|
||||||
for t in ts:
|
for t in ts:
|
||||||
t.join()
|
t.join()
|
||||||
|
|
2
sitemap.xml
Normal file
2
sitemap.xml
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue