mirror of
https://git.ari.lt/ari.lt/blog.ari.lt.git
synced 2025-02-04 09:39:25 +01:00
improve recents api
Signed-off-by: Ari Archer <ari.web.xyz@gmail.com>
This commit is contained in:
parent
14dfa32835
commit
faa6935be8
2 changed files with 16 additions and 2 deletions
|
@ -58,6 +58,7 @@
|
|||
"locale": "en_GB",
|
||||
"home-page-header": "my blogs",
|
||||
"comment-url": "\/c",
|
||||
"recents": 16,
|
||||
"blogs": {
|
||||
"new-blog-management-system-": {
|
||||
"title": "New blog management system!",
|
||||
|
@ -535,7 +536,7 @@
|
|||
},
|
||||
"ari-web-blog-api-change": {
|
||||
"title": "Ari-web blog API change",
|
||||
"content": "hello world\n\n[the blog api](\/blog.json) has changed, now i dont use base64 to encode, it was useless, i noticed\nnobody uses the api basically, but i want it to be available, so just notifying yall\nof the change, the reason i just changed it with no prior warning is because\nnobody uses it lol\n\nalso, a new api created -- [recents.json](\/recents.json) which has the most recent 5 blog posts as the\n`blog.json` api is extremely large lol, it also has [recents_json_hash.txt](\/recents_json_hash.txt)\n\nanyway, have fun i guess :)\n",
|
||||
"content": "hello world\n\n[the blog api](\/blog.json) has changed, now i dont use base64 to encode, it was useless, i noticed\nnobody uses the api basically, but i want it to be available, so just notifying yall\nof the change, the reason i just changed it with no prior warning is because\nnobody uses it lol\n\nalso, a new api created -- [recents.json](\/recents.json) which has the most recent 5 blog posts as the\n`blog.json` api is extremely large lol, it also has [recents_json_hash.txt](\/recents_json_hash.txt)\n\nkeep in mind `recents.json` only has summaries of blog posts, not full content, time\n( UNIX timestamp ) and the title, thats it\n\nanyway, have fun i guess :)\n",
|
||||
"time": 1680636542.575466,
|
||||
"keywords": "ari-web blog api change"
|
||||
}
|
||||
|
|
|
@ -78,6 +78,7 @@ DEFAULT_CONFIG: Dict[str, Any] = {
|
|||
"locale": "en_GB",
|
||||
"home-page-header": "my blogs",
|
||||
"comment-url": "/c",
|
||||
"recents": 16,
|
||||
"blogs": {},
|
||||
}
|
||||
DEFAULT_CONFIG_FILE: str = "blog.json"
|
||||
|
@ -880,7 +881,19 @@ def generate_metadata(config: Dict[str, Any]) -> Tuple[int, Dict[str, Any]]:
|
|||
|
||||
with open("recents.json", "w") as blog_recents:
|
||||
log(f"generating {blog_recents.name!r}", "GENERATE")
|
||||
ujson.dump(dict(tuple(config["blogs"].items())[-5:]), blog_recents)
|
||||
|
||||
recents: Dict[str, Any] = {}
|
||||
|
||||
for rid, recent in tuple(config["blogs"].items())[-(config["recents"]) :]:
|
||||
r: Dict[str, Any] = recent.copy()
|
||||
content: List[str] = r["content"].strip()[:196][::-1].split(maxsplit=1)
|
||||
|
||||
r["content"] = content[len(content) > 1][::-1]
|
||||
del r["keywords"]
|
||||
|
||||
recents[rid] = r
|
||||
|
||||
ujson.dump(recents, blog_recents)
|
||||
|
||||
for hashable in (DEFAULT_CONFIG_FILE, blog_recents.name):
|
||||
with open(hashable, "rb") as api_file:
|
||||
|
|
Loading…
Add table
Reference in a new issue