mirror of
https://git.pleroma.social/pleroma/relay.git
synced 2024-11-24 15:31:08 +00:00
move stylesheet variables to separate file and re-enable cache
This commit is contained in:
parent
a0ee22406b
commit
e86a376f6e
|
@ -263,11 +263,12 @@ async def handle_response_headers(request: web.Request, handler: Coroutine) -> R
|
|||
resp = await handler(request)
|
||||
resp.headers['Server'] = 'ActivityRelay'
|
||||
|
||||
# if not request.app['dev'] and request.path.endswith(('.css', '.js')):
|
||||
# resp.headers['Cache-Control'] = 'public,max-age=2628000,immutable'
|
||||
if not request.app['dev'] and request.path.endswith(('.css', '.js')):
|
||||
# cache for 2 weeks
|
||||
resp.headers['Cache-Control'] = 'public,max-age=1209600,immutable'
|
||||
|
||||
# else:
|
||||
# resp.headers['Cache-Control'] = 'no-store'
|
||||
else:
|
||||
resp.headers['Cache-Control'] = 'no-store'
|
||||
|
||||
return resp
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
%title << {{config.name}}: {{page}}
|
||||
%meta(charset="UTF-8")
|
||||
%meta(name="viewport" content="width=device-width, initial-scale=1")
|
||||
%link(rel="stylesheet" type="text/css" href="/theme/{{theme_name}}.css")
|
||||
%link(rel="stylesheet" type="text/css" href="/style.css")
|
||||
-block head
|
||||
|
||||
|
|
|
@ -1,20 +1,3 @@
|
|||
:root {
|
||||
--text: {{theme["text"]}};
|
||||
--background: {{theme["background"]}};
|
||||
--primary: {{theme["primary"]}};
|
||||
--primary-hover: {{theme["primary-hover"]}};
|
||||
--section-background: {{theme["section-background"]}};
|
||||
--table-background: {{theme["table-background"]}};
|
||||
--border: {{theme["border"]}};
|
||||
--message-text: {{theme["message-text"]}};
|
||||
--message-background: {{theme["message-background"]}};
|
||||
--message-border: {{theme["message-border"]}};
|
||||
--error-text: {{theme["error-text"]}};
|
||||
--error-background: {{theme["error-background"]}};
|
||||
--error-border: {{theme["error-border"]}};
|
||||
--spacing: 10px;
|
||||
}
|
||||
|
||||
a {
|
||||
color: var(--primary);
|
||||
text-decoration: none;
|
||||
|
|
|
@ -44,7 +44,7 @@ class Template(Environment):
|
|||
'domain': self.app.config.domain,
|
||||
'version': __version__,
|
||||
'config': config,
|
||||
'theme': THEMES.get(config['theme'], THEMES['default']),
|
||||
'theme_name': config['theme'] or 'Default',
|
||||
**(context or {})
|
||||
}
|
||||
|
||||
|
|
|
@ -445,3 +445,18 @@ class StyleCss(View):
|
|||
async def get(self, request: Request) -> Response:
|
||||
data = self.template.render('style.css', self)
|
||||
return Response.new(data, ctype = 'css')
|
||||
|
||||
|
||||
@register_route('/theme/{theme}.css')
|
||||
class ThemeCss(View):
|
||||
async def get(self, request: Request, theme: str) -> Response:
|
||||
try:
|
||||
context = {
|
||||
'theme': THEMES[theme]
|
||||
}
|
||||
|
||||
except KeyError:
|
||||
return Response.new('Invalid theme', 404)
|
||||
|
||||
data = self.template.render('variables.css', self, **context)
|
||||
return Response.new(data, ctype = 'css')
|
||||
|
|
Loading…
Reference in a new issue