48 lines
1.8 KiB
Python
48 lines
1.8 KiB
Python
import re
|
|
|
|
THEME_REPO_URL = "https://git.falkenthal.me/falkenthal/pretix-falkenthal-theme"
|
|
|
|
control_files = [
|
|
'/pretix/src/pretix/control/templates/pretixcontrol/base.html',
|
|
'/pretix/src/pretix/control/templates/pretixcontrol/auth/base.html',
|
|
]
|
|
|
|
footer_Html = (
|
|
f' · <a href="{THEME_REPO_URL}" target="_blank" rel="noopener">'
|
|
f'Theme-Plugin (Quellcode)</a></footer>'
|
|
)
|
|
|
|
for p in control_files:
|
|
with open(p, 'r', encoding='utf-8') as f:
|
|
c = f.read()
|
|
c = re.sub(r'<link[^>]*rel=[\"\'](shortcut )?icon[\"\'][^>]*>', '', c, flags=re.I)
|
|
if '/static/whitelabel/control.css' not in c:
|
|
c = c.replace(
|
|
'</head>',
|
|
'<link rel="icon" type="image/svg+xml" href="/static/whitelabel/favicon.svg?v=7">'
|
|
'<link rel="shortcut icon" href="/static/whitelabel/favicon.svg?v=7">'
|
|
'<link rel="stylesheet" type="text/css" href="/static/whitelabel/control.css?v=7"></head>'
|
|
)
|
|
if THEME_REPO_URL not in c:
|
|
c = c.replace('</footer>', footer_Html)
|
|
with open(p, 'w', encoding='utf-8') as f:
|
|
f.write(c)
|
|
|
|
presale_file = '/pretix/src/pretix/presale/templates/pretixpresale/base.html'
|
|
with open(presale_file, 'r', encoding='utf-8') as f:
|
|
c = f.read()
|
|
c = re.sub(r'<link[^>]*rel=[\"\'](shortcut )?icon[\"\'][^>]*>', '', c, flags=re.I)
|
|
if '/static/whitelabel/presale.css' not in c:
|
|
c = c.replace(
|
|
'</head>',
|
|
'<link rel="icon" type="image/svg+xml" href="/static/whitelabel/favicon.svg?v=7">'
|
|
'<link rel="shortcut icon" href="/static/whitelabel/favicon.svg?v=7">'
|
|
'<link rel="stylesheet" type="text/css" href="/static/whitelabel/presale.css?v=7"></head>'
|
|
)
|
|
if THEME_REPO_URL not in c:
|
|
c = c.replace('</footer>', footer_Html)
|
|
with open(presale_file, 'w', encoding='utf-8') as f:
|
|
f.write(c)
|
|
|
|
print("Pretix templates patched successfully (v1.7.3).")
|