Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/CarnetApp/CarnetNextcloud.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhie <phie@phie.ovh>2019-10-28 16:53:13 +0300
committerPhie <phie@phie.ovh>2019-10-28 16:53:13 +0300
commit1c62a25216498e8a56314958dd4c4b9ca6d06ff2 (patch)
treeab38211b5e20184597d897ca2a1eb612a7b2f8f4
parentec28b87d8e6142125b958a569fe3c4d9c18130eb (diff)
using appversion for cache
-rwxr-xr-xlib/Controller/PageController.php9
-rwxr-xr-xtemplates/index.php12
-rwxr-xr-xtemplates/settings.php8
-rwxr-xr-xtemplates/writer.php10
4 files changed, 30 insertions, 9 deletions
diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php
index c99b610..88c2cc5 100755
--- a/lib/Controller/PageController.php
+++ b/lib/Controller/PageController.php
@@ -1,6 +1,7 @@
<?php
namespace OCA\Carnet\Controller;
+use OCP\App;
use OCP\IRequest;
use OCP\AppFramework\Http\ContentSecurityPolicy;
use OCP\AppFramework\Http\TemplateResponse;
@@ -14,6 +15,7 @@ class PageController extends Controller {
parent::__construct($AppName, $request);
$this->userId = $UserId;
$this->config = $Config;
+ $this->$appName = $AppName;
}
/**
@@ -30,6 +32,7 @@ class PageController extends Controller {
$parameters = [
'nc_version' => \OCP\Util::getVersion()[0],
'carnet_display_fullscreen' => $this->config->getAppValue('carnet', 'carnetDisplayFullscreen', 'no'),
+ 'app_version' => App::getAppInfo($this->appName)['version'],
];
$response = new TemplateResponse($this->appName,"index",$parameters);
if($this->config->getAppValue('carnet', 'carnetDisplayFullscreen', 'no') === "yes")
@@ -46,7 +49,10 @@ class PageController extends Controller {
* @NoCSRFRequired
*/
public function writer() {
- $response = new TemplateResponse($this->appName,"writer");
+ $parameters = [
+ 'app_version' => App::getAppInfo($this->appName)['version'],
+ ];
+ $response = new TemplateResponse($this->appName,"writer",$parameters);
$policy = new ContentSecurityPolicy();
$policy->addAllowedMediaDomain('blob:');
if (method_exists($policy, "addAllowedWorkerSrcDomain")){
@@ -65,6 +71,7 @@ class PageController extends Controller {
public function settings() {
$parameters = [
'carnet_display_fullscreen' => $this->config->getAppValue('carnet', 'carnetDisplayFullscreen', 'no'),
+ 'app_version' => App::getAppInfo($this->appName)['version'],
];
$response = new TemplateResponse($this->appName,"settings", $parameters);
if($this->config->getAppValue('carnet', 'carnetDisplayFullscreen', 'no') === "yes")
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']));