takahe/core/views.py

60 lines
1.7 KiB
Python
Raw Normal View History

2022-11-16 13:53:39 +00:00
from django.http import JsonResponse
from django.templatetags.static import static
from django.views.generic import TemplateView, View
2022-11-05 20:17:27 +00:00
2022-11-13 23:14:38 +00:00
from activities.views.timelines import Home
2022-11-05 20:17:27 +00:00
from users.models import Identity
def homepage(request):
if request.user.is_authenticated:
return Home.as_view()(request)
else:
return LoggedOutHomepage.as_view()(request)
class LoggedOutHomepage(TemplateView):
template_name = "index.html"
def get_context_data(self):
return {
2022-11-26 01:32:45 +00:00
"identities": Identity.objects.filter(
local=True,
discoverable=True,
).order_by("-created")[:20],
2022-11-05 20:17:27 +00:00
}
2022-11-16 13:53:39 +00:00
class AppManifest(View):
"""
Serves a PWA manifest file. This is a view as we want to drive some
items from settings.
"""
def get(self, request):
return JsonResponse(
{
"$schema": "https://json.schemastore.org/web-manifest-combined.json",
"name": "Takahē",
"short_name": "Takahē",
"start_url": "/",
"display": "standalone",
"background_color": "#26323c",
"theme_color": "#26323c",
"description": "An ActivityPub server",
"icons": [
{
"src": static("img/icon-128.png"),
"sizes": "128x128",
"type": "image/png",
},
{
"src": static("img/icon-1024.png"),
"sizes": "1024x1024",
"type": "image/png",
},
],
}
)