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>2018-10-05 14:30:42 +0300
committerPhie <phie@phie.ovh>2018-10-05 14:30:42 +0300
commitdc652534ee38806aef43f0262f77355f9610d3ac (patch)
tree09e8d708f7abb7474d398d480ecdba77f3e0aa86 /templates
parentf9c00d120c86b221c82102aeead6db841d1d8e78 (diff)
fix snap
Diffstat (limited to 'templates')
-rwxr-xr-xtemplates/index.php10
-rwxr-xr-xtemplates/settings.php11
-rwxr-xr-xtemplates/writer.php8
3 files changed, 15 insertions, 14 deletions
diff --git a/templates/index.php b/templates/index.php
index ab828e7..9386b1a 100755
--- a/templates/index.php
+++ b/templates/index.php
@@ -1,10 +1,13 @@
<?php
-$currentpath = substr(get_defined_vars()["file"],strlen(getcwd())+1, -strlen("index.php"))."/CarnetElectron/";
-
+$currentpath = substr(get_defined_vars()["file"],0, -strlen("index.php"))."/CarnetElectron/";
+$root = substr(__DIR__, strlen($_SERVER['DOCUMENT_ROOT']));
+if (strpos(__DIR__, '/snap/') !== false) {
+ $root = "/extra-apps/carnet/templates";
+}
$file = file_get_contents($currentpath."index.html");
//
-$file = str_replace("href=\"","href=\"".substr(__DIR__, strlen($_SERVER['DOCUMENT_ROOT']))."/CarnetElectron/",$file);
+$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++) {
@@ -17,7 +20,6 @@ else {
style("carnet","../templates/CarnetElectron/compatibility/nextcloud/nc14-header");
}
$file = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $file);
-$root = substr(__DIR__, strlen($_SERVER['DOCUMENT_ROOT']));
$file = str_replace("src=\"","defer src=\"".$root."/CarnetElectron/",$file);
echo $file;
echo "<span style=\"display:none;\" id=\"root-url\">".$root."/CarnetElectron/</span>";
diff --git a/templates/settings.php b/templates/settings.php
index 8ec0045..85b53c0 100755
--- a/templates/settings.php
+++ b/templates/settings.php
@@ -1,10 +1,14 @@
<?php
-$currentpath = substr(get_defined_vars()["file"],strlen(getcwd())+1, -strlen("settings.php"))."/CarnetElectron/";
+$currentpath = substr(get_defined_vars()["file"],0, -strlen("settings.php"))."/CarnetElectron/";
+$root = substr(__DIR__, strlen($_SERVER['DOCUMENT_ROOT']));
+if (strpos(__DIR__, '/snap/') !== false) {
+ $root = "/extra-apps/carnet/templates";
+}
$file = file_get_contents($currentpath."settings/index.html");
//
-$file = str_replace("href=\"","href=\"".substr(__DIR__, strlen($_SERVER['DOCUMENT_ROOT']))."/CarnetElectron/",$file);
+$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++) {
@@ -13,8 +17,7 @@ for ($i = 0; $i < count($matches[1]); $i++) {
if($_['carnet_display_fullscreen']==="yes")
script("carnet","../templates/CarnetElectron/compatibility/nextcloud/browser_fullscreen");
$file = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $file);
-$root = substr(__DIR__, strlen($_SERVER['DOCUMENT_ROOT']));
$file = str_replace("src=\"","defer src=\"".$root."/CarnetElectron/",$file);
echo $file;
echo "<span style=\"display:none;\" id=\"root-url\">".$root."/CarnetElectron/</span>";
-?> \ No newline at end of file
+?>
diff --git a/templates/writer.php b/templates/writer.php
index 8240d25..6716318 100755
--- a/templates/writer.php
+++ b/templates/writer.php
@@ -2,19 +2,15 @@
$currentpath = getcwd()."/CarnetElectron/";
$file = file_get_contents($currentpath."reader/reader.html");
-//
-$file = str_replace("href=\"","href=\"".substr(__DIR__, strlen($_SERVER['DOCUMENT_ROOT']))."/CarnetElectron/",$file);
-$file = str_replace("<!ROOTPATH>", "", $file);
+$file = str_replace("<!ROOTPATH>", "CarnetElectron/", $file);
$file = preg_replace_callback('/<script(.*?)src=\"(.*?\.js(?:\?.*?)?)"/s',function ($matches) {
global $currentpath;
return "<script".$matches[1]."src=\"".$matches[2]."?mtime=".filemtime($currentpath.$matches[2])."\"";
}, $file);
$root = substr(__DIR__, strlen($_SERVER['DOCUMENT_ROOT']));
-$file = str_replace("src=\"","defer src=\"".$root."/CarnetElectron/",$file);
-
-$file = str_replace("<!ROOTURL>", $root."/CarnetElectron/", $file);
+$file = str_replace("<!ROOTURL>", "CarnetElectron/", $file);
$file = str_replace("<!APIURL>", "../../../index.php/apps/carnet/", $file);