-
Notifications
You must be signed in to change notification settings - Fork 0
/
hooks.py
36 lines (32 loc) · 1.19 KB
/
hooks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import os
from plugins.customstyling import plugin_settings, models
from utils.function_cache import cache
@cache(900)
def inject_css(context):
request = context['request']
html = ''
if request.journal:
cross_journal_stylesheets = models.CrossJournalStylesheet.objects.filter(
journals=request.journal,
)
for stylesheet in cross_journal_stylesheets:
html += '<link href="{}" rel="stylesheet">\n'.format(
os.path.join(plugin_settings.CSS_MEDIA_PATH, 'press', stylesheet.stylesheet_name)
)
html += '<link href="{}" rel="stylesheet">\n'.format(
os.path.join(plugin_settings.CSS_MEDIA_PATH, str(request.journal.pk), 'custom.css')
)
elif request.repository:
html += '<link href="{}" rel="stylesheet">\n'.format(
os.path.join(
plugin_settings.CSS_MEDIA_PATH,
'repositories',
str(request.repository.pk),
'custom.css',
)
)
else:
html += '<link href="{}" rel="stylesheet">\n'.format(
os.path.join(plugin_settings.CSS_MEDIA_PATH, 'press', 'custom.css')
)
return html