commit 0161ae462a27645f9720aa03c9321b2da8398d73
parent 61f7f7e33fe57460ff8d55cd6199b16d3e95b655
Author: Natalie Pendragon <natpen@natpen.net>
Date: Sat, 9 May 2020 13:35:08 -0400
[serve] Put index generation date in footer
Diffstat:
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
@@ -48,6 +48,5 @@ as this guide to [mailing list etiquette](https://man.sr.ht/lists.sr.ht/etiquett
type of construct in the Gemini spec now, so I should probably
add a TODO to refactor the extract_gemini_links function to
exclude any links found within such a block.
-- **put index creation date on results page**
- **add user-facing documentation on searching by content type**
- **track freshness of content**
diff --git a/gus/serve.py b/gus/serve.py
@@ -2,7 +2,9 @@
A gemini search engine frontend.
"""
import asyncio
+from datetime import datetime
import math
+import os
import sys
import jetforce
@@ -26,7 +28,9 @@ def _render_header():
def _render_footer():
return [
"",
- "=> /add-seed See any missing results? Let GUS know your gemini URL exists."
+ "=> /add-seed See any missing results? Let GUS know your gemini URL exists.",
+ "",
+ "Index generation date: {:%Y-%m-%d}".format(index_modification_time)
]
@@ -73,6 +77,10 @@ def _search_index(query):
)
+def _get_index_modification_time():
+ return datetime.fromtimestamp(os.path.getmtime("index"))
+
+
def _get_search_suggestions(query):
suggestions = []
corrector = searcher.corrector("content")
@@ -178,6 +186,8 @@ def main():
)
global ix
ix = open_dir("index")
+ global index_modification_time
+ index_modification_time = _get_index_modification_time()
global searcher
with ix.searcher() as searcher:
asyncio.run(server.run())