diff options
author | Phie <phie@phie.ovh> | 2019-10-28 16:53:13 +0300 |
---|---|---|
committer | Phie <phie@phie.ovh> | 2019-10-28 16:53:13 +0300 |
commit | 1c62a25216498e8a56314958dd4c4b9ca6d06ff2 (patch) | |
tree | ab38211b5e20184597d897ca2a1eb612a7b2f8f4 /templates | |
parent | ec28b87d8e6142125b958a569fe3c4d9c18130eb (diff) |
using appversion for cache
Diffstat (limited to 'templates')
-rwxr-xr-x | templates/index.php | 12 | ||||
-rwxr-xr-x | templates/settings.php | 8 | ||||
-rwxr-xr-x | templates/writer.php | 10 |
3 files changed, 22 insertions, 8 deletions
diff --git a/templates/index.php b/templates/index.php index 21786a8..14b0986 100755 --- a/templates/index.php +++ b/templates/index.php @@ -2,7 +2,9 @@ global $currentpath; global $root; global $fullscreen; +global $appVersion; $fullscreen = $_['carnet_display_fullscreen']; +$appVersion = $_['app_version']; $currentpath = __DIR__."/CarnetElectron/"; $root = \OCP\Util::linkToAbsolute("carnet","templates"); $file = file_get_contents($currentpath."index.html"); @@ -10,26 +12,30 @@ $root = parse_url($root, PHP_URL_PATH); $file = preg_replace_callback('/<link(.*?)href=\"(.*?\.css(?:\?.*?)?)"/s',function ($matches) { global $currentpath; - return "<link".$matches[1]."href=\"".$matches[2]."?mtime=".filemtime($currentpath.$matches[2])."\""; + global $appVersion; + return "<link".$matches[1]."href=\"".$matches[2]."?v=".$appVersion."\""; }, $file); $file = str_replace("href=\"","href=\"".$root."/CarnetElectron/",$file); $file = preg_replace_callback('/<script(.*?)src=\"(.*?\.js(?:\?.*?)?)"/s',function ($matches) { global $currentpath; global $fullscreen; + global $appVersion; + if($matches[2] === "libs/jquery.min.js" AND $fullscreen === "no") return "<script src=\"\""; - return "<script".$matches[1]."src=\"".$matches[2]."?mtime=".filemtime($currentpath.$matches[2])."\""; + return "<script".$matches[1]."src=\"".$matches[2]."?v=".$appVersion."\""; }, $file); // token is needed to pass the csfr check $file .= "<span style=\"display:none;\" id=\"token\">".$_['requesttoken']."</span>"; if($_['carnet_display_fullscreen']==="yes"){ + $file = str_replace('</head>', " <link rel=\"apple-touch-icon-precomposed\" href=\"".image_path('', 'favicon-touch.png')."\" /> <link rel=\"icon\" href=\"".image_path('', 'favicon.ico')."\"> <link rel=\"mask-icon\" sizes=\"any\" href=\"".image_path('', 'favicon-mask.svg')."\" color=\"".$theme->getColorPrimary()."\"> <link rel=\"manifest\" href=\"".image_path('', 'manifest.json')."\"> - <script src=\"compatibility/nextcloud/fullscreen.js?mtime=\"></script> + <script src=\"compatibility/nextcloud/fullscreen.js?v="+$appVersion+"\"></script> </head>", $file); if($_['nc_version']>=16) style("carnet","../templates/CarnetElectron/compatibility/nextcloud/nc16"); diff --git a/templates/settings.php b/templates/settings.php index 454b55b..bad4856 100755 --- a/templates/settings.php +++ b/templates/settings.php @@ -1,21 +1,25 @@ <?php global $fullscreen; +global $appVersion; $fullscreen = $_['carnet_display_fullscreen']; $currentpath = __DIR__."/CarnetElectron/"; +$appVersion = $_['app_version']; + $root = \OCP\Util::linkToAbsolute("carnet","templates"); $root = parse_url($root, PHP_URL_PATH); $file = file_get_contents($currentpath."settings.html"); $file = str_replace("href=\"","href=\"".$root."/CarnetElectron/",$file); $file = preg_replace_callback('/<script(.*?)src=\"(.*?\.js(?:\?.*?)?)"/s',function ($matches) { global $currentpath; + global $appVersion; if($matches[2] === "libs/jquery.min.js" AND $fullscreen === "no") return "<script src=\"\""; - return "<script".$matches[1]."src=\"".$matches[2]."?mtime=".filemtime($currentpath.$matches[2])."\""; + return "<script".$matches[1]."src=\"".$matches[2]."?v=".$appVersion."\""; }, $file); // token is needed to pass the csfr check $file .= "<span style=\"display:none;\" id=\"token\">".$_['requesttoken']."</span>"; if($_['carnet_display_fullscreen']==="yes"){ - $file .= "<script src=\"compatibility/nextcloud/fullscreen.js?mtime=\"></script>"; + $file .= "<script src=\"compatibility/nextcloud/fullscreen.js??v=".$appVersion."\"></script>"; if($_['nc_version']>=16) style("carnet","../templates/CarnetElectron/compatibility/nextcloud/nc16"); } diff --git a/templates/writer.php b/templates/writer.php index 18a22d1..e4b8fb0 100755 --- a/templates/writer.php +++ b/templates/writer.php @@ -1,6 +1,8 @@ <?php global $currentpath; global $root; +global $appVersion; +$appVersion = $_['app_version']; $currentpath = __DIR__."/CarnetElectron/"; $root = \OCP\Util::linkToAbsolute("carnet","templates"); $root = parse_url($root, PHP_URL_PATH); @@ -10,21 +12,23 @@ $file = file_get_contents($currentpath."reader/reader.html"); $file = preg_replace_callback('/<script(.*?)src=\"(.*?\.js(?:\?.*?)?)"/s',function ($matches) { global $currentpath; global $root; + global $appVersion; $src = str_replace("<!ROOTPATH>", $root."/CarnetElectron/", $matches[2]); $relativePath = str_replace("<!ROOTPATH>", "", $matches[2]); - return "<script".$matches[1]."src=\"".$src."?mtime=".filemtime($currentpath.$relativePath)."\""; + return "<script".$matches[1]."src=\"".$src."?v=".$appVersion."\""; }, $file); $file = preg_replace_callback('/<link(.*?)href=\"(.*?\.css(?:\?.*?)?)"/s',function ($matches) { global $currentpath; global $root; + global $appVersion; $src = str_replace("<!ROOTPATH>", $root."/CarnetElectron/", $matches[2]); $relativePath = str_replace("<!ROOTPATH>", "", $matches[2]); - return "<link".$matches[1]."href=\"".$src."?mtime=".filemtime($currentpath.$relativePath)."\""; + return "<link".$matches[1]."href=\"".$src."?v=".$appVersion."\""; }, $file); // token is needed to pass the csfr check $file .= "<span style=\"display:none;\" id=\"token\">".$_['requesttoken']."</span>"; -$file .= "<script src=\"".$root."/CarnetElectron/compatibility/nextcloud/fullscreen.js?mtime=\"></script>"; +$file .= "<script src=\"".$root."/CarnetElectron/compatibility/nextcloud/fullscreen.js?v=".$appVersion."\"></script>"; $file = str_replace("<!ROOTPATH>", $root."/CarnetElectron/", $file); $root = substr(__DIR__, strlen($_SERVER['DOCUMENT_ROOT'])); |