mirror of
https://git.pleroma.social/pleroma/relay.git
synced 2024-11-22 22:48:00 +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'",
|
"connect-src 'self'",
|
||||||
"img-src 'self'",
|
"img-src 'self'",
|
||||||
"object-src 'none'",
|
"object-src 'none'",
|
||||||
"frame-ancestors 'none'"
|
"frame-ancestors 'none'",
|
||||||
|
f"manifest-src 'self' https://{request.app.config.domain}"
|
||||||
]
|
]
|
||||||
|
|
||||||
return '; '.join(data) + ';'
|
return '; '.join(data) + ';'
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
%meta(name="viewport" content="width=device-width, initial-scale=1")
|
%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="/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="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)
|
%script(type="application/javascript" src="/static/api.js" nonce="{{view.request['hash']}}", defer)
|
||||||
-block head
|
-block head
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,8 @@ MIMETYPES = {
|
||||||
'css': 'text/css',
|
'css': 'text/css',
|
||||||
'html': 'text/html',
|
'html': 'text/html',
|
||||||
'json': 'application/json',
|
'json': 'application/json',
|
||||||
'text': 'text/plain'
|
'text': 'text/plain',
|
||||||
|
'webmanifest': 'application/manifest+json'
|
||||||
}
|
}
|
||||||
|
|
||||||
NODEINFO_NS = {
|
NODEINFO_NS = {
|
||||||
|
|
|
@ -210,11 +210,27 @@ class AdminConfig(View):
|
||||||
return Response.new(data, ctype = 'html')
|
return Response.new(data, ctype = 'html')
|
||||||
|
|
||||||
|
|
||||||
@register_route('/style.css')
|
@register_route('/manifest.json')
|
||||||
class StyleCss(View):
|
class ManifestJson(View):
|
||||||
async def get(self, request: Request) -> Response:
|
async def get(self, request: Request) -> Response:
|
||||||
data = self.template.render('style.css', self)
|
with self.database.session(False) as conn:
|
||||||
return Response.new(data, ctype = 'css')
|
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')
|
@register_route('/theme/{theme}.css')
|
||||||
|
|
Loading…
Reference in a new issue