geminispace.info

gemini search engine
git clone https://git.clttr.info/geminispace.info.git
Log (Feed) | Files | Refs (Tags) | README | LICENSE

commit b39154af7ead9bbc40a875ab94a9cdab850ba183
parent c9d588e7e168dbc785d9ce5fa52c34b20a8da817
Author: Natalie Pendragon <natpen@natpen.net>
Date:   Tue, 12 May 2020 08:46:14 -0400

[serve] Add news feature

Diffstat:
Mgus/serve.py | 44+++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 43 insertions(+), 1 deletion(-)

diff --git a/gus/serve.py b/gus/serve.py @@ -71,6 +71,39 @@ def _render_known_hosts(): return d +def _render_news(): + d = [ + "", + "# GUS News", + ] + news_items = [ + { + "date": "2020-05-12", + "content": "Added Known Hosts and News, both of which you can find on the GUS homepage.", + }, + { + "date": "2020-05-11", + "content": "Added Index Statistics feature, which you can find on the GUS homepage.", + }, + { + "date": "2020-05-09", + "content": "Added ability to search and filter by content type. Documentation for this feature can be found on the about page! I'm really excited about this update, because it will allow users to do things like search for all the music in Geminispace, or search for all the downloadable epub content. Unsurprisingly, most of the current content is either `text/gemini` or `text/plain`, but there is still a smattering of other interesting content types already in existence in Geminispace.", + }, + { + "date": "2020-03-04", + "content": "Added search suggestions. When a search returns with no results, GUS will now attempt to find some lexicographically similar search suggestions that would yield results. Hopefully this will help ameliorate both typos in queries, as well as the slight paucity of content in these early days of Gemini.", + }, + { + "date": "2020-02-21", + "content": "Updated GUS indexing to respect robots.txt. Documentation for this feature can be found on the about page.", + }, + ] + news_items.sort(key=lambda item: item["date"], reverse=True) + for item in news_items: + d.extend(["", "## {}".format(item["date"]), item["content"]]) + return d + + @app.route("") def index(request): data = _render_header() @@ -78,7 +111,8 @@ def index(request): "=> /about About GUS", "=> /statistics GUS Statistics", "=> /known-hosts Known Gemini Hosts", - "=> gemini://gemini.circumlunar.space Gemini Project information" + "=> /news GUS News", + "=> gemini://gemini.circumlunar.space Gemini Project information", ]) data.extend(_render_footer()) return Response(Status.SUCCESS, "text/gemini", "\n".join(data)) @@ -141,6 +175,14 @@ def index(request): return Response(Status.SUCCESS, "text/gemini", "\n".join(data)) +@app.route("/news") +def index(request): + data = _render_header() + data.extend(_render_news()) + data.extend(_render_footer()) + return Response(Status.SUCCESS, "text/gemini", "\n".join(data)) + + def _search_index(query): query = MultifieldParser(["content", "url", "prompt"], ix.schema).parse(query) results = searcher.search(query)