mirror of
https://git.pleroma.social/pleroma/relay.git
synced 2024-12-23 03:31:07 +00:00
add web manifest to frontend
This commit is contained in:
parent
ec7e254740
commit
beb9d9c3e5
|
@ -44,7 +44,8 @@ def get_csp(request: web.Request) -> str:
|
|||
"connect-src 'self'",
|
||||
"img-src 'self'",
|
||||
"object-src 'none'",
|
||||
"frame-ancestors 'none'"
|
||||
"frame-ancestors 'none'",
|
||||
f"manifest-src 'self' https://{request.app.config.domain}"
|
||||
]
|
||||
|
||||
return '; '.join(data) + ';'
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
%meta(name="viewport" content="width=device-width, initial-scale=1")
|
||||
%link(rel="stylesheet" type="text/css" href="/theme/{{config.theme}}.css" nonce="{{view.request['hash']}}" class="theme")
|
||||
%link(rel="stylesheet" type="text/css" href="/static/style.css" nonce="{{view.request['hash']}}")
|
||||
%link(rel="manifest" href="/manifest.json")
|
||||
%script(type="application/javascript" src="/static/api.js" nonce="{{view.request['hash']}}", defer)
|
||||
-block head
|
||||
|
||||
|
|
|
@ -38,7 +38,8 @@ MIMETYPES = {
|
|||
'css': 'text/css',
|
||||
'html': 'text/html',
|
||||
'json': 'application/json',
|
||||
'text': 'text/plain'
|
||||
'text': 'text/plain',
|
||||
'webmanifest': 'application/manifest+json'
|
||||
}
|
||||
|
||||
NODEINFO_NS = {
|
||||
|
|
|
@ -210,11 +210,27 @@ class AdminConfig(View):
|
|||
return Response.new(data, ctype = 'html')
|
||||
|
||||
|
||||
@register_route('/style.css')
|
||||
class StyleCss(View):
|
||||
@register_route('/manifest.json')
|
||||
class ManifestJson(View):
|
||||
async def get(self, request: Request) -> Response:
|
||||
data = self.template.render('style.css', self)
|
||||
return Response.new(data, ctype = 'css')
|
||||
with self.database.session(False) as conn:
|
||||
config = conn.get_config_all()
|
||||
theme = THEMES[config.theme]
|
||||
|
||||
data = {
|
||||
'background_color': theme['background'],
|
||||
'categories': ['activitypub'],
|
||||
'description': 'Message relay for the ActivityPub network',
|
||||
'display': 'standalone',
|
||||
'name': config['name'],
|
||||
'orientation': 'portrait',
|
||||
'scope': f"https://{self.config.domain}/",
|
||||
'short_name': 'ActivityRelay',
|
||||
'start_url': f"https://{self.config.domain}/",
|
||||
'theme_color': theme['primary']
|
||||
}
|
||||
|
||||
return Response.new(data, ctype = 'webmanifest')
|
||||
|
||||
|
||||
@register_route('/theme/{theme}.css')
|
||||
|
|
Loading…
Reference in a new issue