Fix meta tags and disable adding feeds

This commit is contained in:
Joakim Hellsén 2024-02-19 07:40:04 +01:00
commit 4c41dda244
3 changed files with 31 additions and 8 deletions

View file

@ -21,6 +21,10 @@ class IndexView(View):
context = { context = {
"db_size": get_db_size(), "db_size": get_db_size(),
"amount_of_feeds": Feed.objects.count(), "amount_of_feeds": Feed.objects.count(),
"description": "FeedVault allows users to archive and search their favorite web feeds.",
"keywords": "feed, rss, atom, archive, rss list",
"author": "TheLovinator",
"canonical": "https://feedvault.se/",
} }
return HttpResponse(content=template.render(context=context, request=request)) return HttpResponse(content=template.render(context=context, request=request))
@ -37,7 +41,17 @@ class FeedView(View):
feed = get_object_or_404(Feed, id=feed_id) feed = get_object_or_404(Feed, id=feed_id)
entries = Entry.objects.filter(feed=feed).order_by("-created_parsed")[:100] entries = Entry.objects.filter(feed=feed).order_by("-created_parsed")[:100]
context = {"feed": feed, "entries": entries, "db_size": get_db_size(), "amount_of_feeds": Feed.objects.count()} context = {
"feed": feed,
"entries": entries,
"db_size": get_db_size(),
"amount_of_feeds": Feed.objects.count(),
"description": f"Archive of {feed.href}",
"keywords": "feed, rss, atom, archive, rss list",
"author": f"{feed.author_detail.name if feed.author_detail else "FeedVault"}",
"canonical": f"https://feedvault.se/feed/{feed_id}/",
}
return render(request, "feed.html", context) return render(request, "feed.html", context)
@ -54,6 +68,10 @@ class FeedsView(ListView):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
context["db_size"] = get_db_size() context["db_size"] = get_db_size()
context["amount_of_feeds"] = Feed.objects.count() context["amount_of_feeds"] = Feed.objects.count()
context["description"] = "Archive of all feeds"
context["keywords"] = "feed, rss, atom, archive, rss list"
context["author"] = "TheLovinator"
context["canonical"] = "https://feedvault.se/feeds/"
return context return context
@ -66,11 +84,19 @@ class AddView(View):
context = { context = {
"db_size": get_db_size(), "db_size": get_db_size(),
"amount_of_feeds": Feed.objects.count(), "amount_of_feeds": Feed.objects.count(),
"description": "FeedVault allows users to archive and search their favorite web feeds.",
"keywords": "feed, rss, atom, archive, rss list",
"author": "TheLovinator",
"canonical": "https://feedvault.se/",
} }
return HttpResponse(content=template.render(context=context, request=request)) return HttpResponse(content=template.render(context=context, request=request))
def post(self, request: HttpRequest) -> HttpResponse: def post(self, request: HttpRequest) -> HttpResponse:
"""Add a feed.""" """Add a feed."""
# Temporary turn off the /add page.
return HttpResponse(content="Not available", status=404)
urls: str | None = request.POST.get("urls", None) urls: str | None = request.POST.get("urls", None)
if not urls: if not urls:
return HttpResponse(content="No urls", status=400) return HttpResponse(content="No urls", status=400)

View file

@ -16,9 +16,6 @@ BASE_DIR: Path = Path(__file__).resolve().parent.parent
# The secret key is used for cryptographic signing, and should be set to a unique, unpredictable value. # The secret key is used for cryptographic signing, and should be set to a unique, unpredictable value.
SECRET_KEY: str = os.getenv("SECRET_KEY", default="") SECRET_KEY: str = os.getenv("SECRET_KEY", default="")
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = [] ALLOWED_HOSTS = []
INSTALLED_APPS = [ INSTALLED_APPS = [

View file

@ -3,10 +3,10 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="%s" /> {% if description %}<meta name="description" content="{{ description }}" />{% endif %}
<meta name="keywords" content="%s" /> {% if keywords %}<meta name="keywords" content="{{ keywords }}" />{% endif %}
<meta name="author" content="%s" /> {% if author %}<meta name="author" content="{{ author }}" />{% endif %}
<link rel="canonical" href="%s" /> {% if canonical %}<link rel="canonical" href="{{ canonical }}" />{% endif %}
{% if title %} {% if title %}
<title>{{ title }}</title> <title>{{ title }}</title>
{% else %} {% else %}