diff --git a/README.md b/README.md index 921cd4c..20cec44 100644 --- a/README.md +++ b/README.md @@ -61,4 +61,8 @@ Some blogs might be hidden for a day or two if I'm working on it or just need to hide it to not show some stuff on the main page, though nobody is stopping you from using the static API, -it's located at [/blog.json](https://blog.ari-web.xyz/blog.json) +it's located at [/blog.json](https://blog.ari-web.xyz/blog.json), also if you're using +this API generally, this API is **extremely** large, so +I implemented cache validation, just cache it, +including the sha256 hash and validate it with +the [hash on the api](https://blog.ari-web.xyz/blog_json_hash.txt) diff --git a/blog_json_hash.txt b/blog_json_hash.txt new file mode 100644 index 0000000..097a13e --- /dev/null +++ b/blog_json_hash.txt @@ -0,0 +1 @@ +fe9cdebb971b9c7a0ec8da637eb91cde4663e5d871ea3ac7f107b1cd46413fac \ No newline at end of file diff --git a/scripts/blog b/scripts/blog index 6afea50..8581f36 100755 --- a/scripts/blog +++ b/scripts/blog @@ -2,6 +2,7 @@ # -*- coding: utf-8 -*- """Manage blogs""" +import hashlib import os import random import string @@ -651,6 +652,14 @@ def generate_metadata(config: Dict) -> Tuple[int, Dict]: manifest, ) + with open(DEFAULT_CONFIG_FILE, "rb") as blog_api_file: + log(f"Generating hash for {DEFAULT_CONFIG_FILE!r}") + + with open( + f"{DEFAULT_CONFIG_FILE.replace('.', '_')}_hash.txt", "w" + ) as blog_api_hash: + blog_api_hash.write(hashlib.sha256(blog_api_file.read()).hexdigest()) + return EXIT_OK, config