Skip to content

Commit

Permalink
fix path issues on some other servers
Browse files Browse the repository at this point in the history
  • Loading branch information
PhieF committed Oct 8, 2018
1 parent 6b67942 commit 418ef5c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
2 changes: 2 additions & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* The controller class has to be registered in the application.php file since
* it's instantiated in there
*/

$this->create('carnet_writer','/writer')->actionInclude('carnet/templates/writer.php');

return [
'routes' => [
Expand Down
15 changes: 7 additions & 8 deletions templates/writer.php
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
<?php
$currentpath = getcwd()."/";
$currentpath = __DIR__."/CarnetElectron/";
$root = \OCP\Util::linkToAbsolute("carnet","templates");

$file = file_get_contents($currentpath."CarnetElectron/reader/reader.html");
$file = str_replace("<!ROOTPATH>", "CarnetElectron/", $file);
$file = file_get_contents($currentpath."reader/reader.html");
$file = str_replace("<!ROOTPATH>", $root."/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("<!ROOTURL>", "CarnetElectron/", $file);
$file = str_replace("<!APIURL>", "../../../index.php/apps/carnet/", $file);


$urlGenerator = \OC::$server->getURLGenerator();
$file = str_replace("<!ROOTURL>", $root."/CarnetElectron/", $file);
$file = str_replace("<!APIURL>", $urlGenerator->linkToRouteAbsolute("carnet.page.index"), $file);
echo $file;

?>

0 comments on commit 418ef5c

Please sign in to comment.