Added custom bootstrap CSS option

This commit is contained in:
Harvey Tindall 2020-05-17 15:22:50 +01:00
parent bb864ce46e
commit 91eae9a4ce
9 changed files with 249 additions and 11 deletions

View File

@ -104,4 +104,6 @@ invites =
emails =
; Path to the user policy template. Can be acquired with get-template.
user_template =
; Path to custom bootstrap.css
custom_css =

View File

@ -12,8 +12,8 @@
<meta name="msapplication-TileColor" content="#603cba">
<meta name="theme-color" content="#ffffff">
<title>Create Jellyfin Account</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<title>404</title>
<link rel="stylesheet" href="{{ css_href }}" integrity="{{ css_integrity }}" crossorigin="{{ css_crossorigin }}">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>

View File

@ -14,7 +14,7 @@
<meta name="theme-color" content="#ffffff">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<link rel="stylesheet" href="{{ css_href }}" integrity="{{ css_integrity }}" crossorigin="{{ css_crossorigin }}">
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>

View File

@ -12,7 +12,7 @@
<meta name="msapplication-TileColor" content="#603cba">
<meta name="theme-color" content="#ffffff">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<link rel="stylesheet" href="{{ css_href }}" integrity="{{ css_integrity }}" crossorigin="{{ css_crossorigin }}">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>

View File

@ -3,8 +3,8 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Create Jellyfin Account</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<title>Invalid Code</title>
<link rel="stylesheet" href="{{ css_href }}" integrity="{{ css_integrity }}" crossorigin="{{ css_crossorigin }}">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 49 KiB

View File

@ -1,7 +1,7 @@
import json
from pathlib import Path
from flask import Flask, send_from_directory, render_template
from __main__ import config, app, g
from __main__ import config, app, g, css
from __main__ import web_log as log
from jellyfin_accounts.web_api import checkInvite, validator
@ -9,6 +9,9 @@ from jellyfin_accounts.web_api import checkInvite, validator
@app.errorhandler(404)
def page_not_found(e):
return render_template('404.html',
css_href=css['href'],
css_integrity=css['integrity'],
css_crossorigin=css['crossorigin'],
contactMessage=config['ui']['contact_message']), 404
@ -16,6 +19,9 @@ def page_not_found(e):
def admin():
# return app.send_static_file('admin.html')
return render_template('admin.html',
css_href=css['href'],
css_integrity=css['integrity'],
css_crossorigin=css['crossorigin'],
contactMessage='',
email_enabled=config.getboolean(
'invite_emails', 'enabled'))
@ -26,6 +32,9 @@ def static_proxy(path):
if 'html' not in path:
return app.send_static_file(path)
return render_template('404.html',
css_href=css['href'],
css_integrity=css['integrity'],
css_crossorigin=css['crossorigin'],
contactMessage=config['ui']['contact_message']), 404
@ -45,6 +54,9 @@ def inviteProxy(path):
except KeyError:
email = ""
return render_template('form.html',
css_href=css['href'],
css_integrity=css['integrity'],
css_crossorigin=css['crossorigin'],
contactMessage=config['ui']['contact_message'],
helpMessage=config['ui']['help_message'],
successMessage=config['ui']['success_message'],
@ -59,4 +71,7 @@ def inviteProxy(path):
else:
log.debug('Attempted use of invalid invite')
return render_template('invalidCode.html',
css_href=css['href'],
css_integrity=css['integrity'],
css_crossorigin=css['crossorigin'],
contactMessage=config['ui']['contact_message'])

View File

@ -87,9 +87,34 @@ if args.port is not None:
for key in config['files']:
if config['files'][key] == '':
if key != 'custom_css':
log.debug(f'Using default {key}')
config['files'][key] = str(data_dir / (key + '.json'))
def default_css():
css = {}
css['href'] = "https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
css['integrity'] = "sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh"
css['crossorigin'] = "anonymous"
return css
css = {}
css = default_css()
if 'custom_css' in config['files']:
if config['files']['custom_css'] != '':
try:
shutil.copy(config['files']['custom_css'],
(local_dir / 'static' / 'bootstrap.css'))
log.debug('Loaded custom CSS')
css['href'] = '/bootstrap.css'
css['integrity'] = ''
css['crossorigin'] = ''
except FileNotFoundError:
log.error(f'Custom CSS {config["files"]["custom_css"]} not found, using default.')
if ('email_html' not in config['password_resets'] or
config['password_resets']['email_html'] == ''):
log.debug('Using default password reset email HTML template')
@ -110,7 +135,6 @@ if ('email_text' not in config['invite_emails'] or
config['invite_emails']['email_text'] = str(local_dir /
'invite-email.txt')
if args.get_policy:
import json
from jellyfin_accounts.jf_api import Jellyfin