Compare commits

..

2 commits

Author SHA1 Message Date
Izalia Mae 36d2ae733c Merge branch 'dev' into 'master'
Draft: 0.3.0

See merge request pleroma/relay!57
2024-03-04 20:33:45 +00:00
Izalia Mae e86a376f6e move stylesheet variables to separate file and re-enable cache 2024-03-04 15:29:08 -05:00
5 changed files with 22 additions and 22 deletions

View file

@ -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

View file

@ -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

View file

@ -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;

View file

@ -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 {})
}

View file

@ -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')