mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 11:36:44 +00:00
Custom splash screen (#3499)
* Adds support for custom splash screen * Add option to config template file
This commit is contained in:
parent
af0c6b957d
commit
b0ad326daa
@ -265,6 +265,20 @@ def getLogoImage(as_file=False, custom=True):
|
|||||||
return getStaticUrl('img/inventree.png')
|
return getStaticUrl('img/inventree.png')
|
||||||
|
|
||||||
|
|
||||||
|
def getSplashScren(custom=True):
|
||||||
|
"""Return the InvenTree splash screen, or a custom splash if available"""
|
||||||
|
|
||||||
|
static_storage = StaticFilesStorage()
|
||||||
|
|
||||||
|
if custom and settings.CUSTOM_SPLASH:
|
||||||
|
|
||||||
|
if static_storage.exists(settings.CUSTOM_SPLASH):
|
||||||
|
return static_storage.url(settings.CUSTOM_SPLASH)
|
||||||
|
|
||||||
|
# No custom splash screen
|
||||||
|
return static_storage.url("img/inventree_splash.jpg")
|
||||||
|
|
||||||
|
|
||||||
def TestIfImageURL(url):
|
def TestIfImageURL(url):
|
||||||
"""Test if an image URL (or filename) looks like a valid image format.
|
"""Test if an image URL (or filename) looks like a valid image format.
|
||||||
|
|
||||||
|
@ -820,7 +820,7 @@ PLUGIN_FILE_CHECKED = False # Was the plugin file checked?
|
|||||||
# User interface customization values
|
# User interface customization values
|
||||||
CUSTOMIZE = get_setting('INVENTREE_CUSTOMIZE', 'customize', {})
|
CUSTOMIZE = get_setting('INVENTREE_CUSTOMIZE', 'customize', {})
|
||||||
|
|
||||||
CUSTOM_LOGO = get_setting('INVENTREE_CUSTOM_LOGO', 'customize.logo', None)
|
static_storage = StaticFilesStorage()
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Check for the existence of a 'custom logo' file:
|
Check for the existence of a 'custom logo' file:
|
||||||
@ -828,9 +828,9 @@ Check for the existence of a 'custom logo' file:
|
|||||||
- Check the 'media' directory (legacy)
|
- Check the 'media' directory (legacy)
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if CUSTOM_LOGO:
|
CUSTOM_LOGO = get_setting('INVENTREE_CUSTOM_LOGO', 'customize.logo', None)
|
||||||
static_storage = StaticFilesStorage()
|
|
||||||
|
|
||||||
|
if CUSTOM_LOGO:
|
||||||
if static_storage.exists(CUSTOM_LOGO):
|
if static_storage.exists(CUSTOM_LOGO):
|
||||||
logger.info(f"Loading custom logo from static directory: {CUSTOM_LOGO}")
|
logger.info(f"Loading custom logo from static directory: {CUSTOM_LOGO}")
|
||||||
elif default_storage.exists(CUSTOM_LOGO):
|
elif default_storage.exists(CUSTOM_LOGO):
|
||||||
@ -839,8 +839,18 @@ if CUSTOM_LOGO:
|
|||||||
logger.warning(f"The custom logo file '{CUSTOM_LOGO}' could not be found in the static or media directories")
|
logger.warning(f"The custom logo file '{CUSTOM_LOGO}' could not be found in the static or media directories")
|
||||||
CUSTOM_LOGO = False
|
CUSTOM_LOGO = False
|
||||||
|
|
||||||
|
# Check for a custom splash screen
|
||||||
|
CUSTOM_SPLASH = get_setting('INVENTREE_CUSTOM_SPLASH', 'customize.splash', None)
|
||||||
|
|
||||||
|
if CUSTOM_SPLASH:
|
||||||
|
if static_storage.exists(CUSTOM_SPLASH):
|
||||||
|
logger.info(f"Loading custom splash screen from static directory: {CUSTOM_SPLASH}")
|
||||||
|
else:
|
||||||
|
logger.warning(f"The custom splash screen '{CUSTOM_SPLASH}' could not be found in the static directory")
|
||||||
|
CUSTOM_SPLASH = False
|
||||||
|
|
||||||
if DEBUG:
|
if DEBUG:
|
||||||
logger.info("InvenTree running with DEBUG enabled")
|
logger.info("InvenTree running with DEBUG enabled")
|
||||||
|
|
||||||
logger.debug(f"MEDIA_ROOT: '{MEDIA_ROOT}'")
|
logger.info(f"MEDIA_ROOT: '{MEDIA_ROOT}'")
|
||||||
logger.debug(f"STATIC_ROOT: '{STATIC_ROOT}'")
|
logger.info(f"STATIC_ROOT: '{STATIC_ROOT}'")
|
||||||
|
@ -19,8 +19,8 @@ main {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.login-screen {
|
.login-screen {
|
||||||
background: url(/static/img/paper_splash.jpg) no-repeat center fixed;
|
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
|
background-position: center;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
font-family: 'Numans', sans-serif;
|
font-family: 'Numans', sans-serif;
|
||||||
color: #eee;
|
color: #eee;
|
||||||
|
Before Width: | Height: | Size: 461 KiB After Width: | Height: | Size: 461 KiB |
@ -188,5 +188,6 @@ remote_login_header: REMOTE_USER
|
|||||||
# login_message: InvenTree demo instance - <a href='https://inventree.readthedocs.io/en/latest/demo/'> Click here for login details</a>
|
# login_message: InvenTree demo instance - <a href='https://inventree.readthedocs.io/en/latest/demo/'> Click here for login details</a>
|
||||||
# navbar_message: <h6>InvenTree demo mode <a href='https://inventree.readthedocs.io/en/latest/demo/'><span class='fas fa-info-circle'></span></a></h6>
|
# navbar_message: <h6>InvenTree demo mode <a href='https://inventree.readthedocs.io/en/latest/demo/'><span class='fas fa-info-circle'></span></a></h6>
|
||||||
# logo: logo.png
|
# logo: logo.png
|
||||||
|
# splash: splash_screen.jpg
|
||||||
# hide_admin_link: true
|
# hide_admin_link: true
|
||||||
# hide_password_reset: true
|
# hide_password_reset: true
|
||||||
|
@ -195,7 +195,7 @@ def inventree_title(*args, **kwargs):
|
|||||||
|
|
||||||
@register.simple_tag()
|
@register.simple_tag()
|
||||||
def inventree_logo(**kwargs):
|
def inventree_logo(**kwargs):
|
||||||
"""Return the InvenTree logo, *or* a custom logo if the user has uploaded one.
|
"""Return the InvenTree logo, *or* a custom logo if the user has provided one.
|
||||||
|
|
||||||
Returns a path to an image file, which can be rendered in the web interface
|
Returns a path to an image file, which can be rendered in the web interface
|
||||||
"""
|
"""
|
||||||
@ -203,6 +203,13 @@ def inventree_logo(**kwargs):
|
|||||||
return InvenTree.helpers.getLogoImage(**kwargs)
|
return InvenTree.helpers.getLogoImage(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
@register.simple_tag()
|
||||||
|
def inventree_splash(**kwargs):
|
||||||
|
"""Return the URL for the InvenTree splash screen, *or* a custom screen if the user has provided one."""
|
||||||
|
|
||||||
|
return InvenTree.helpers.getSplashScren(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
@register.simple_tag()
|
@register.simple_tag()
|
||||||
def inventree_base_url(*args, **kwargs):
|
def inventree_base_url(*args, **kwargs):
|
||||||
"""Return the INVENTREE_BASE_URL setting."""
|
"""Return the INVENTREE_BASE_URL setting."""
|
||||||
|
@ -49,10 +49,8 @@
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class='login-screen'>
|
<body class='login-screen' style='background: url({% inventree_splash %}); background-size: cover;'>
|
||||||
<!--
|
|
||||||
Background Image Attribution: https://unsplash.com/photos/Ixvv3YZkd7w
|
|
||||||
-->
|
|
||||||
<div class='container-fluid'>
|
<div class='container-fluid'>
|
||||||
<div class='notification-area' id='alerts'>
|
<div class='notification-area' id='alerts'>
|
||||||
<!-- Div for displayed alerts -->
|
<!-- Div for displayed alerts -->
|
||||||
|
Loading…
x
Reference in New Issue
Block a user