mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
/-/ alternative URL for homepage, closes #2393
This commit is contained in:
parent
bf953628bb
commit
93067668fe
5 changed files with 33 additions and 1 deletions
|
|
@ -1476,6 +1476,8 @@ class Datasette:
|
|||
routes.append((regex, view))
|
||||
|
||||
add_route(IndexView.as_view(self), r"/(\.(?P<format>jsono?))?$")
|
||||
add_route(IndexView.as_view(self), r"/-/(\.(?P<format>jsono?))?$")
|
||||
add_route(permanent_redirect("/-/"), r"/-$")
|
||||
# TODO: /favicon.ico and /-/static/ deserve far-future cache expires
|
||||
add_route(favicon, "/favicon.ico")
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
{% block title %}{{ metadata.title or "Datasette" }}: {% for database in databases %}{{ database.name }}{% if not loop.last %}, {% endif %}{% endfor %}{% endblock %}
|
||||
|
||||
{% block extra_head %}
|
||||
{% if noindex %}<meta name="robots" content="noindex">{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block body_class %}index{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
|
|
|||
|
|
@ -152,8 +152,9 @@ class IndexView(BaseView):
|
|||
extra_links = await await_me_maybe(hook)
|
||||
if extra_links:
|
||||
homepage_actions.extend(extra_links)
|
||||
alternative_homepage = request.path == "/-/"
|
||||
return await self.render(
|
||||
["index.html"],
|
||||
["default:index.html" if alternative_homepage else "index.html"],
|
||||
request=request,
|
||||
context={
|
||||
"databases": databases,
|
||||
|
|
@ -166,5 +167,6 @@ class IndexView(BaseView):
|
|||
"top_homepage", self.ds, request
|
||||
),
|
||||
"homepage_actions": homepage_actions,
|
||||
"noindex": request.path == "/-/",
|
||||
},
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue