Fix
This commit is contained in:
parent
e776ce48b8
commit
797d09de7c
|
@ -897,7 +897,7 @@ class translations
|
|||
}
|
||||
}
|
||||
}
|
||||
$webpack_manifest_path = realpath("resources/dist/manifest.json");
|
||||
$webpack_manifest_path = realpath("resources/dist/assets-manifest.json");
|
||||
function init_class($enableDebugger=true, $headers=true)
|
||||
{
|
||||
global $tools, $database, $user, $crud, $translations, $debugbar;
|
||||
|
|
|
@ -16,11 +16,11 @@ function show_error_page($error=null, $error_message=null, $error_message_advanc
|
|||
}
|
||||
}
|
||||
$webpack_manifest = json_decode(
|
||||
file_get_contents(isset($webpack_manifest_path) ? $webpack_manifest_path : realpath("resources/dist/manifest.json")),
|
||||
file_get_contents(isset($webpack_manifest_path) ? $webpack_manifest_path : realpath("resources/dist/assets-manifest.json")),
|
||||
true
|
||||
);
|
||||
$main_script_url = "resources/dist/".$webpack_manifest["main.js"];
|
||||
$game_script_url = "resources/dist/".$webpack_manifest["games.js"];
|
||||
$main_script_url = "resources/dist/".$webpack_manifest["main.js"]["src"];
|
||||
$game_script_url = "resources/dist/".$webpack_manifest["games.js"]["src"];
|
||||
|
||||
$error_templates = [
|
||||
<<<EOT
|
||||
|
|
|
@ -90,7 +90,17 @@ module.exports = {
|
|||
{ from: "node_modules/leaflet/dist/images", to: ".", noErrorOnMissing: true }
|
||||
],
|
||||
}),
|
||||
new WebpackAssetsManifest()
|
||||
new WebpackAssetsManifest({
|
||||
writeToDisk: true,
|
||||
integrity: true,
|
||||
customize(entry) {
|
||||
allowed_entries = ["main.js", "maps.js", "players.js", "games.js"]
|
||||
if (entry.key.startsWith('fonts') || allowed_entries.includes(entry.key)) {
|
||||
return entry;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
})
|
||||
],
|
||||
optimization: {
|
||||
mergeDuplicateChunks: true
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
/*{% endif %}*/
|
||||
</script>
|
||||
{% endif %}
|
||||
<script src="{{ urlsoftware }}/resources/dist/{{ resource('main.js') }}"></script>
|
||||
{{ script('main.js') }}
|
||||
<script>$.fn.loading.defaults.message = "{{ 'Loading...'|t }}";</script>
|
||||
{% endblock %}
|
||||
{% if enable_debug_bar %}{{ debug_bar_head|raw }}{% endif %}
|
||||
|
|
|
@ -93,7 +93,7 @@
|
|||
<div id="results"></div>
|
||||
</div>
|
||||
<input type="hidden" name="place" value="" />
|
||||
<script src="{{ urlsoftware }}/resources/dist/{{ resource('maps.js') }}" onload="allertaJS.maps.loadMap();"></script>
|
||||
{{ script('maps.js', 'allertaJS.maps.loadMap();') }}
|
||||
{% else %}
|
||||
<div class="form-group">
|
||||
<label>{{ 'Service place'|t }}</label>
|
||||
|
|
|
@ -77,7 +77,7 @@
|
|||
<div id="results"></div>
|
||||
</div>
|
||||
<input type="hidden" name="place" value="" />
|
||||
<script src="{{ urlsoftware }}/resources/dist/{{ resource('maps.js') }}" onload="allertaJS.maps.loadMap();"></script>
|
||||
{{ script('maps.js', 'allertaJS.maps.loadMap();') }}
|
||||
{% else %}
|
||||
<div class="form-group">
|
||||
<label for="place">{{ 'Training place'|t }}</label>
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
let playerScript = document.createElement("script");
|
||||
playerScript.setAttribute("src", "{{ urlsoftware }}/resources/dist/{{ resource('players.js') }}");
|
||||
playerScript.setAttribute("async", "false");
|
||||
playerScript.onload = () => {
|
||||
playerScript.onload = function() {
|
||||
console.log("player script loaded");
|
||||
var sound = new Howl({
|
||||
src: ['{{ urlsoftware }}/resources/sounds/{{ error_sound }}'],
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<script src="{{ urlsoftware }}/resources/dist/{{ resource('maps.js') }}"></script>
|
||||
{{ script('maps.js') }}
|
||||
<br>
|
||||
<img alt="VVF" src="./resources/images/owner.png" width="150"
|
||||
style="display: block; margin-left: auto; margin-right: auto;">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<script src="{{ urlsoftware }}/resources/dist/{{ resource('maps.js') }}"></script>
|
||||
{{ script('maps.js') }}
|
||||
<br>
|
||||
<img alt="VVF" src="./resources/images/owner.png" width="150"
|
||||
style="display: block; margin-left: auto; margin-right: auto;">
|
||||
|
|
|
@ -12,9 +12,11 @@ if(!is_null($debugbar)){
|
|||
$enable_debugbar = false;
|
||||
}
|
||||
|
||||
$url_software = $database->get_option("web_url");
|
||||
|
||||
p_start("Load Twig");
|
||||
$webpack_manifest = json_decode(
|
||||
file_get_contents(realpath("resources/dist/manifest.json")),
|
||||
file_get_contents(realpath("resources/dist/assets-manifest.json")),
|
||||
true
|
||||
);
|
||||
try {
|
||||
|
@ -55,11 +57,27 @@ $twig->addFunction($function_username);
|
|||
$function_resource = new \Twig\TwigFunction(
|
||||
'resource', function ($file) {
|
||||
global $webpack_manifest;
|
||||
return $webpack_manifest[$file];
|
||||
return $webpack_manifest[$file]["src"];
|
||||
}
|
||||
);
|
||||
$twig->addFunction($function_resource);
|
||||
|
||||
$function_script = new \Twig\TwigFunction(
|
||||
'script', function ($file, $onLoad=false) {
|
||||
global $url_software, $webpack_manifest;
|
||||
$script_url = $url_software . "/resources/dist/" . $webpack_manifest[$file]["src"];
|
||||
$script_integrity = $webpack_manifest[$file]["integrity"];
|
||||
|
||||
$script_tag = "<script src='{$script_url}' integrity='{$script_integrity}' crossorigin='anonymous'";
|
||||
if($onLoad){
|
||||
$script_tag .= " onload='{$onLoad}'";
|
||||
}
|
||||
$script_tag .= "></script>";
|
||||
return $script_tag;
|
||||
}, ['is_safe' => ['html']]
|
||||
);
|
||||
$twig->addFunction($function_script);
|
||||
|
||||
$filter_minimize = new \Twig\TwigFilter(
|
||||
'minimize', function ($content) {
|
||||
if(isset($_REQUEST["skip_minify"])){
|
||||
|
@ -78,7 +96,7 @@ p_stop();
|
|||
$template = null;
|
||||
function loadtemplate($templatename, $data, $requirelogin=true)
|
||||
{
|
||||
global $database, $user, $twig, $template, $enable_debugbar, $debugbarRenderer;
|
||||
global $url_software, $database, $user, $twig, $template, $enable_debugbar, $debugbarRenderer;
|
||||
p_start("Render Twig template");
|
||||
if($requirelogin) {
|
||||
$user->requirelogin();
|
||||
|
@ -90,7 +108,7 @@ function loadtemplate($templatename, $data, $requirelogin=true)
|
|||
$data['debug_bar_head'] = $enable_debugbar ? $debugbarRenderer->renderHead() : "";
|
||||
$data['debug_bar'] = $enable_debugbar ? $debugbarRenderer->render() : "";
|
||||
$data['owner'] = $database->get_option("owner");
|
||||
$data['urlsoftware'] = $database->get_option("web_url");
|
||||
$data['urlsoftware'] = $url_software;
|
||||
$data['user'] = $user->info();
|
||||
$data['show_menu'] = !isset($_REQUEST["hide_menu"]);
|
||||
$data['show_footer'] = !isset($_REQUEST["hide_footer"]);
|
||||
|
|
Loading…
Reference in New Issue