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-08-17 18:05:24 +0300
committerPhie <phie@phie.ovh>2019-08-17 18:05:24 +0300
commit5e4a3a27430ab49517b365e120ca7bc2253eb2de (patch)
treeebc3966e0a931431edc46c91fb74e98184c77329 /templates
parentb0c8de086f72791512b4776dc03eda46834c6750 (diff)
real fullscreen without loading all of nextcloud stuff
Diffstat (limited to 'templates')
-rwxr-xr-xtemplates/index.php10
-rwxr-xr-xtemplates/settings.php35
-rwxr-xr-xtemplates/writer.php4
3 files changed, 32 insertions, 17 deletions
diff --git a/templates/index.php b/templates/index.php
index c64887e..957b7e2 100755
--- a/templates/index.php
+++ b/templates/index.php
@@ -1,6 +1,8 @@
<?php
global $currentpath;
global $root;
+global $fullscreen;
+$fullscreen = $_['carnet_display_fullscreen'];
$currentpath = __DIR__."/CarnetElectron/";
$root = \OCP\Util::linkToAbsolute("carnet","templates");
$file = file_get_contents($currentpath."index.html");
@@ -14,13 +16,15 @@ $file = str_replace("href=\"","href=\"".$root."/CarnetElectron/",$file);
$file = preg_replace_callback('/<script(.*?)src=\"(.*?\.js(?:\?.*?)?)"/s',function ($matches) {
global $currentpath;
- if($matches[2] === "libs/jquery.min.js")
+ global $fullscreen;
+ 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])."\"";
}, $file);
-
+// token is needed to pass the csfr check
+$file .= "<span style=\"display:none;\" id=\"token\">".$_['requesttoken']."</span>";
if($_['carnet_display_fullscreen']==="yes"){
- script("carnet","../templates/CarnetElectron/compatibility/nextcloud/browser_fullscreen");
+ $file .= "<script src=\"compatibility/nextcloud/fullscreen.js?mtime=\"></script>";
if($_['nc_version']>=16)
style("carnet","../templates/CarnetElectron/compatibility/nextcloud/nc16");
}
diff --git a/templates/settings.php b/templates/settings.php
index eec7a7d..454b55b 100755
--- a/templates/settings.php
+++ b/templates/settings.php
@@ -1,23 +1,32 @@
<?php
-
+global $fullscreen;
+$fullscreen = $_['carnet_display_fullscreen'];
$currentpath = __DIR__."/CarnetElectron/";
$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);
-
-preg_match_all('/<script.*?src=\"(.*?\.js(?:\?.*?)?)"/si', $file, $matches, PREG_PATTERN_ORDER);
-for ($i = 0; $i < count($matches[1]); $i++) {
- if($matches[1][$i] === "libs/jquery.min.js")
- continue;
- script("carnet","../templates/CarnetElectron/".substr($matches[1][$i],0,-3));
+$file = preg_replace_callback('/<script(.*?)src=\"(.*?\.js(?:\?.*?)?)"/s',function ($matches) {
+ global $currentpath;
+ 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])."\"";
+}, $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>";
+ if($_['nc_version']>=16)
+ style("carnet","../templates/CarnetElectron/compatibility/nextcloud/nc16");
}
-if($_['carnet_display_fullscreen']==="yes")
- script("carnet","../templates/CarnetElectron/compatibility/nextcloud/browser_fullscreen");
-$file = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $file);
-$file = str_replace("src=\"","defer src=\"".$root."/CarnetElectron/",$file);
+else if($_['nc_version']>=14)
+ style("carnet","../templates/CarnetElectron/compatibility/nextcloud/nc14-header");
+$nonce = "";
+if (method_exists(\OC::$server, "getContentSecurityPolicyNonceManager")){
+ $nonce = \OC::$server->getContentSecurityPolicyNonceManager()->getNonce();
+}
+$file = str_replace("src=\"","defer nonce='".$nonce."' src=\"".$root."/CarnetElectron/",$file);
echo $file;
echo "<span style=\"display:none;\" id=\"root-url\">".$root."/CarnetElectron/</span>";
+echo "<span style=\"display:none;\" id=\"logout-token\">".urlencode(\OCP\Util::callRegister())."</span>";
?>
diff --git a/templates/writer.php b/templates/writer.php
index c4f90c4..56eec7a 100755
--- a/templates/writer.php
+++ b/templates/writer.php
@@ -22,9 +22,11 @@ $file = preg_replace_callback('/<link(.*?)href=\"(.*?\.css(?:\?.*?)?)"/s',functi
$relativePath = str_replace("<!ROOTPATH>", "", $matches[2]);
return "<link".$matches[1]."href=\"".$src."?mtime=".filemtime($currentpath.$relativePath)."\"";
}, $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 = str_replace("<!ROOTPATH>", $root."/CarnetElectron/", $file);
-
$root = substr(__DIR__, strlen($_SERVER['DOCUMENT_ROOT']));
$urlGenerator = \OC::$server->getURLGenerator();
$file = str_replace("<!ROOTURL>", $root."/CarnetElectron/", $file);