mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-16 09:34:39 +00:00
(theme) add support for custom theme.js hook
This commit is contained in:
parent
d82608e143
commit
6f2bd69847
@ -41,6 +41,12 @@ $di->set('view', function () use ($config) {
|
||||
'compiledPath' => $config->application->cacheDir,
|
||||
'compiledSeparator' => '_'
|
||||
));
|
||||
// register additional volt template functions
|
||||
$volt->getCompiler()->addFunction('javascript_include_when_exists', function($local_url) {
|
||||
$chk_path = "str_replace('/ui/','/usr/local/opnsense/www/',".$local_url.")";
|
||||
$js_tag = "'<script type=\"text/javascript\" src=\"'.$local_url.'\"></script>'";
|
||||
return "file_exists(".$chk_path.") ? ".$js_tag." :''";
|
||||
});
|
||||
|
||||
return $volt;
|
||||
},
|
||||
|
||||
@ -14,9 +14,10 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
|
||||
|
||||
<title>{{title|default("OPNsense") }}</title>
|
||||
{% set theme_name = ui_theme|default('opnsense') %}
|
||||
|
||||
<!-- include (theme) style -->
|
||||
<link href="/ui/themes/{{ui_theme|default('opnsense')}}/build/css/main.css" rel="stylesheet">
|
||||
<link href="/ui/themes/{{theme_name}}/build/css/main.css" rel="stylesheet">
|
||||
|
||||
<!-- TODO: move to theme style -->
|
||||
<style>
|
||||
@ -30,13 +31,13 @@
|
||||
</style>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link href="/ui/themes/{{ui_theme|default('opnsense')}}/build/images/favicon.png" rel="shortcut icon">
|
||||
<link href="/ui/themes/{{theme_name}}/build/images/favicon.png" rel="shortcut icon">
|
||||
|
||||
<!-- Stylesheet for fancy select/dropdown -->
|
||||
<link rel="stylesheet" type="text/css" href="/ui/themes/{{ui_theme|default('opnsense')}}/build/css/bootstrap-select.css">
|
||||
<link rel="stylesheet" type="text/css" href="/ui/themes/{{theme_name}}/build/css/bootstrap-select.css">
|
||||
|
||||
<!-- bootstrap dialog -->
|
||||
<link href="/ui/themes/{{ui_theme|default('opnsense')}}/build/css/bootstrap-dialog.css" rel="stylesheet" type="text/css" />
|
||||
<link href="/ui/themes/{{theme_name}}/build/css/bootstrap-dialog.css" rel="stylesheet" type="text/css" />
|
||||
|
||||
<!-- Font awesome -->
|
||||
<link rel="stylesheet" href="/ui/css/font-awesome.min.css">
|
||||
@ -179,6 +180,7 @@
|
||||
<script type="text/javascript" src="/ui/js/opnsense.js"></script>
|
||||
<script type="text/javascript" src="/ui/js/opnsense_ui.js"></script>
|
||||
<script type="text/javascript" src="/ui/js/opnsense_bootgrid_plugin.js"></script>
|
||||
{{javascript_include_when_exists('/ui/themes/' ~ theme_name ~ '/build/js/theme.js')}}
|
||||
|
||||
</head>
|
||||
<body>
|
||||
@ -187,8 +189,8 @@
|
||||
<div class="container-fluid">
|
||||
<div class="navbar-header">
|
||||
<a class="navbar-brand" href="/">
|
||||
<img class="brand-logo" src="/ui/themes/{{ui_theme|default('opnsense')}}/build/images/default-logo.png" height="30" alt="logo"/>
|
||||
<img class="brand-icon" src="/ui/themes/{{ui_theme|default('opnsense')}}/build/images/icon-logo.png" height="30" alt="icon"/>
|
||||
<img class="brand-logo" src="/ui/themes/{{theme_name}}/build/images/default-logo.png" height="30" alt="logo"/>
|
||||
<img class="brand-icon" src="/ui/themes/{{theme_name}}/build/images/icon-logo.png" height="30" alt="icon"/>
|
||||
</a>
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navigation">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
|
||||
@ -237,4 +237,9 @@ $pagetitle .= sprintf(' | %s.%s', $config['system']['hostname'], $config['system
|
||||
});
|
||||
//]]>
|
||||
</script>
|
||||
<?php
|
||||
if (file_exists("/usr/local/opnsense/www/themes/".$themename."/build/js/theme.js")):?>
|
||||
<script type="text/javascript" src="/ui/themes/<?=$themename?>/build/js/theme.js"></script>
|
||||
<?php
|
||||
endif;?>
|
||||
</head>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user