]> _ Git - fluidbook-toolbox.git/commitdiff
wip #5661 @3
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 19 Dec 2022 20:11:29 +0000 (21:11 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 19 Dec 2022 20:11:29 +0000 (21:11 +0100)
27 files changed:
app/Console/Commands/FluidbookPackage.php [new file with mode: 0644]
app/Fluidbook/Links.php
app/Fluidbook/Packager/Base.php
app/Fluidbook/Packager/ChromeOS.php
app/Fluidbook/Packager/MacOS.php
app/Fluidbook/Packager/OfflineHTML.php
app/Fluidbook/Packager/Online.php
app/Fluidbook/Packager/Precompiled.php
app/Fluidbook/Packager/Scorm.php
app/Fluidbook/Packager/Sharepoint.php
app/Fluidbook/Packager/USBKey.php
app/Fluidbook/Packager/WindowsEXE.php
app/Fluidbook/Packager/WindowsInstaller.php
app/Fluidbook/Packager/WindowsZIP.php
app/Jobs/FluidbookCompiler.php
app/Models/FluidbookPublication.php
resources/fluidbookpublication/packager/_ffmpeg/libffmpeg.dylib [new file with mode: 0644]
resources/fluidbookpublication/packager/_ffmpeg/windows-x32-ffmpeg.dll [new file with mode: 0644]
resources/fluidbookpublication/packager/_ffmpeg/windows-x64-ffmpeg.dll [new file with mode: 0644]
resources/fluidbookpublication/packager/autorun-html.inf [new file with mode: 0644]
resources/fluidbookpublication/packager/autorun.inf [new file with mode: 0644]
resources/fluidbookpublication/packager/fluidbook.ico [new file with mode: 0644]
resources/fluidbookpublication/packager/html-silent.nsi [new file with mode: 0644]
resources/fluidbookpublication/packager/html.inf [new file with mode: 0644]
resources/fluidbookpublication/packager/html.nsi [new file with mode: 0644]
resources/fluidbookpublication/packager/hybrid.html [new file with mode: 0644]
resources/fluidbookpublication/packager/script.nsi [new file with mode: 0644]

diff --git a/app/Console/Commands/FluidbookPackage.php b/app/Console/Commands/FluidbookPackage.php
new file mode 100644 (file)
index 0000000..135a5f6
--- /dev/null
@@ -0,0 +1,21 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Fluidbook\Packager\Base;
+use Cubist\Backpack\Console\Commands\CubistCommand;
+
+class FluidbookPackage extends CubistCommand
+{
+    protected $signature = 'fluidbook:package {id} {type} {--zip}';
+    protected $description = 'Compile a fluidbook';
+
+    /**
+     * @throws \Exception
+     */
+    public function handle()
+    {
+        $packager = Base::package($this->argument('id'), $this->argument('type'), $this->option('zip', false));
+        $packager->handle();
+    }
+}
index 77d41167af271015c3e6957d259b590a772a6102..e63e59307263a1a80820fc630f43d7971a6b30d4 100644 (file)
@@ -5,6 +5,7 @@ namespace App\Fluidbook;
 use App\Models\User;
 use App\Util\wsDAOBook;
 use App\Util\wsDocument;
+use Cubist\Util\ArrayUtil;
 use Cubist\Util\Files\Files;
 use Cubist\Util\Str;
 use Fluidbook\Tools\Links\Link;
@@ -157,14 +158,17 @@ class Links
         }
 
         $r = json_decode(gzdecode(file_get_contents($file)), true);
+
         $links = self::_UID($r['links']);
         $rulers = self::_UID($r['rulers']);
+
         if (can('fluidbook-publication:links:edit-animations')) {
             $links = Link::decryptLinks($links);
-        }else{
+        } else {
             $links = Link::encryptLinks($links);
         }
 
+
         self::_correctImageSpecialLinks($links);
     }
 
index 84795095505c81d5e989be5134c9a7aa7c1ee22c..b6cd67f48808b1b661f66be4d1a5007c37f9661d 100644 (file)
@@ -2,7 +2,11 @@
 
 namespace App\Fluidbook\Packager;
 
+use App\Jobs\FluidbookCompiler;
+use App\Models\FluidbookPublication;
+use App\Models\FluidbookTheme;
 use Cubist\Util\CommandLine;
+use Cubist\Util\Files\Files;
 use Cubist\Util\PHP;
 use Cubist\Util\Text;
 
@@ -11,57 +15,60 @@ class Base extends \App\Jobs\Base
 
     protected $dir;
     protected $vdir;
+
+    /**
+     * @var FluidbookPublication
+     */
     public $book;
-    protected $pages;
+    /** @var FluidbookTheme */
     protected $theme;
-    protected $version;
+    protected $scormVariant = false;
     protected $book_id;
     protected $themeRoot;
-    protected $daoBook;
     protected $zip;
     protected $workingDir;
-    protected $whole = true;
     protected $_clean = true;
     protected $_compileOnConstruct = false;
     public $cleanOnDestruct = true;
 
-    const COMPILE_ASSETS = '/application/resources/fluidbookpublication/packager/';
-
-    public static function package($book_id, $version, $zip = true, $cleanOnDestruct = true, $options = [])
-    {
-        global $packager;
-
-        PHP::neverStop();
-
-        if ($version === 'html') {
-            $packager = new Online($book_id, null, true, $options);
-        } else if ($version === 'scorm') {
-            $packager = new SCORM($book_id, null, true, $options);
-        } else if ($version === 'sharepoint') {
-            $packager = new Sharepoint($book_id, null, true, $options);
-        } elseif ($version === 'win_html') {
-            $packager = new OfflineHTML($book_id, null, true, $options);
-        } else if ($version === 'win_exe_html') {
-            $packager = new WindowsZIP($book_id, $options);
-        } else if ($version === 'mac_exe_html') {
-            $packager = new MacOS($book_id, $options);
-        } else if ($version === 'win_ins_html') {
-            $packager = new WindowsInstaller($book_id, $options);
-        } else if ($version === 'win_inss_html') {
-            $packager = new WindowsEXE($book_id, $options);
-        } else if ($version === 'win_cd_html') {
-            $packager = new USBKey($book_id, $options);
-        } else if ($version === 'precompiled') {
-            $packager = new Precompiled($book_id, null, true, $options);
-        } else if ($version === 'chromeos') {
-            $packager = new ChromeOS($book_id, null, true, $options);
+    public $zipPackage = true;
+
+    public $type = 'base';
+
+
+    public static function package($book_id, $type, $zipPackage = true, $cleanOnDestruct = true, $options = [])
+    {
+        if ($type === 'html') {
+            $packager = new Online($book_id, null, $options);
+        } else if ($type === 'scorm') {
+            $packager = new SCORM($book_id, null, $options);
+        } else if ($type === 'sharepoint') {
+            $packager = new Sharepoint($book_id, null, $options);
+        } elseif ($type === 'win_html') {
+            $packager = new OfflineHTML($book_id, null, $options);
+        } else if ($type === 'win_exe_html') {
+            $packager = new WindowsZIP($book_id, null, $options);
+        } else if ($type === 'mac_exe_html') {
+            $packager = new MacOS($book_id, null, $options);
+        } else if ($type === 'win_ins_html') {
+            $packager = new WindowsInstaller($book_id, null, $options);
+        } else if ($type === 'win_inss_html') {
+            $packager = new WindowsEXE($book_id, null, $options);
+        } else if ($type === 'win_cd_html') {
+            $packager = new USBKey($book_id, null, $options);
+        } else if ($type === 'precompiled') {
+            $packager = new Precompiled($book_id, null, $options);
+        } else if ($type === 'chromeos') {
+            $packager = new ChromeOS($book_id, null, $options);
         }
         $packager->cleanOnDestruct = $packager->cleanOnDestruct && $cleanOnDestruct;
+        $packager->zipPackage = $zipPackage;
 
-        return $packager->makePackage($zip);
+        return $packager;
     }
 
-    public function __construct($book_id, $vdir = null, $whole = true, $options = [])
+
+    public function __construct($book_id, $vdir = null, $options = [])
     {
 
         $this->_clean = (null === $vdir);
@@ -69,27 +76,18 @@ class Base extends \App\Jobs\Base
         $this->book_id = $book_id;
 
         $this->vdir = $vdir;
-        $this->dir = ROOT . '/fluidbook/packager/' . $book_id . '/';
-        $this->whole = $whole;
+        $this->dir = Files::mkdir($this->packager_path('/' . $book_id));
 
-        if (!file_exists($this->dir)) {
-            mkdir($this->dir, 0777, true);
-        }
-
-        $this->book = $this->daoBook->selectById($book_id);
+        $this->book = FluidbookPublication::find($book_id);
         $forceCompile = false;
         if (count($options)) {
             $options['forceCompileOnDownload'] = true;
         }
         foreach ($options as $k => $v) {
-            $this->book->parametres->$k = $v;
+            $this->book->getSettings()->set($k, $v);
         }
 
-        $this->pages = $this->daoBook->getPagesOfBook($book_id, false);
-
-        $daoTheme = new wsDAOTheme($core->con);
-        $this->theme = $daoTheme->getThemeOfBook($book_id, true);
-        $this->themeRoot = WS_THEMES . '/' . $this->theme->theme_id . '/';
+        $this->theme = $this->book->getTheme();
 
         $this->workingDir = $this->book->getAssetDir();
 
@@ -98,10 +96,27 @@ class Base extends \App\Jobs\Base
         }
     }
 
+    public function handle()
+    {
+        PHP::neverStop();
+        $this->makePackage($this->zipPackage);
+    }
+
+    protected function packager_path($path = '')
+    {
+        return protected_path('/fluidbookpublication/packager/' . ltrim($path, '/'));
+    }
+
+
+    protected function resource_path($path)
+    {
+        return resource_path('/fluidbookpublication/packager/' . ltrim($path, '/'));
+    }
 
     protected function compile($forceCompile = false)
     {
-        $this->daoBook->compile($this->book_id, '2', false, $this->book->parametres->forceCompileOnDownload || $forceCompile, false, $this->book);
+        $compiler = new FluidbookCompiler($this->book, $this->scormVariant);
+        $compiler->handle();
     }
 
     protected function preparePackage()
@@ -126,87 +141,35 @@ class Base extends \App\Jobs\Base
         return $res;
     }
 
-    protected function copyFluidbookFiles()
-    {
-        // Copie du FB vers un rĂ©pertoire temporaire
-        $cp = new CommandLine('cp');
-        $cp->setArg('R');
-        $cp->setArg('p');
-        $cp->setArg(null, WS_BOOKS . '/final/' . $this->book->book_id . '/*');
-        $cp->setArg(null, $this->vdir);
-        $cp->execute();
-    }
-
-    protected function copyOtherFiles($files)
-    {
-        foreach ($files as $source => $dest) {
-            if (is_int($source)) {
-                $source = $dest;
-            }
-
-            $s = WS_COMPILE_ASSETS . '/' . $source;
-            if (is_file($s) && !file_exists($this->vdir . $dest)) {
-                $this->copy($s, $this->vdir . $dest);
-            } else if (is_dir($s)) {
-                $cp = new CommandLine('cp');
-                $cp->setArg('R');
-                $cp->setArg('p');
-                $cp->setArg(null, $s);
-                $cp->setArg(null, $this->vdir);
-                $cp->execute();
-
-                $mv = new CommandLine('mv');
-                $mv->setArg($this->vdir . '/' . $source);
-                $mv->setArg($this->vdir . '/' . $dest);
-                $mv->execute();
-            }
-        }
-    }
 
     protected function getBaseFile()
     {
-        return $this->version . '-' . date('Ymdhis') . '-' . $this->escapeTitle();
+        return $this->type . '-' . date('Ymdhis') . '-' . $this->escapeTitle();
     }
 
     protected function escapeTitle()
     {
-        $res = Text::str2URL($this->book->parametres->title);
+        $res = Text::str2URL($this->book->title);
         if ($res == '') {
             $res = 'fluidbook';
         }
         return $res;
     }
 
-    protected function getRelativeBase()
-    {
-        return '/packager/download/' . $this->getBaseFile();
-    }
-
-    protected function getURLBase($ext = '')
-    {
-        $res = '/fluidbook' . $this->getRelativeBase();
-        if ($ext != '') {
-            $res .= '.' . $ext;
-        }
-        return $res;
-    }
 
     protected function getPathBase($ext = '')
     {
-        $res = WS_FILES . $this->getRelativeBase();
+        $res = '/download/' . $this->getBaseFile();
         if ($ext != '') {
             $res .= '.' . $ext;
         }
 
-        return $res;
+        return $this->packager_path($res);
     }
 
     protected function zip($zipfile = null)
     {
-        if (!$this->whole) {
-            return;
-        }
-        $url = $this->getURLBase('zip');
+        Files::mkdir($this->packager_path('download'));
         $final = $this->getPathBase('zip');
         $rename = false;
         if (is_null($zipfile)) {
@@ -227,64 +190,32 @@ class Base extends \App\Jobs\Base
             $zip->setArg(null, '.');
             $zip->setManualArg('-x "*/\.*"');
             $zip->execute();
-            $zip->debug();
-        }
-
-        if (!file_exists(WS_FILES . '/packager/download')) {
-            mkdir(WS_FILES . '/packager/download', 0777, true);
         }
 
         if ($rename) {
             rename($zipfile, $final);
         }
-        return $url;
+        return $final;
     }
 
     public function getFinalPackageDir()
     {
-        $dir = $this->vdir;
-        $dir .= '/m/';
-        return $dir;
+        return $this->vdir;
     }
 
     protected function initTempDir()
     {
         if (is_null($this->vdir)) {
-            $this->vdir = $this->dir . $this->version . '/';
-        }
-        $this->cleanVdir();
-        if (!file_exists($this->vdir . '/data')) {
-            mkdir($this->vdir . '/data', 0777, true);
+            $this->vdir = $this->dir . $this->type . '/';
         }
     }
 
-    protected function cleanVdir()
-    {
-        if (!$this->_clean) {
-            return;
-        }
-        if (file_exists($this->vdir)) {
-            // Suppression du rĂ©pertoire si il existe
-            $rm = new CommandLine('rm');
-            $rm->setArg('r');
-            $rm->setArg('f');
-            $rm->setArg(null, $this->vdir);
-            $rm->execute();
-        }
-    }
 
     protected function postPackage()
     {
 
     }
 
-    public function __destruct()
-    {
-        if ($this->whole && $this->cleanOnDestruct) {
-            $this->cleanVdir();
-        }
-    }
-
     public function copy($source, $dest)
     {
         if (!file_exists($source)) {
index 7347dbb734306167f455737a9e0463d0c9d5b5e5..cafdabbcfd55b20b41102983ddacab6a9e6f7a60 100644 (file)
@@ -6,12 +6,9 @@ use Cubist\Util\CommandLine;
 
 class ChromeOS extends Online
 {
-    public function __construct($book_id, $vdir = null, $whole = true, $options = [])
-    {
-        parent::__construct($book_id, $vdir, $whole, $options);
-        $this->version = 'chromeos';
-        $this->cleanOnDestruct = true;
-    }
+
+    public $type='chormeos';
+    public $cleanOnDestruct=true;
 
     protected function preparePackage()
     {
index afff8cc28d6a0ee370094670613f7addebdc0299..1dcab8f2f7dddfdf900100af70bbe4115271c8c3 100644 (file)
@@ -1,5 +1,7 @@
 <?php
+
 namespace App\Fluidbook\Packager;
+
 use Cubist\Util\CommandLine;
 
 class MacOS extends OfflineHTML
@@ -8,12 +10,7 @@ class MacOS extends OfflineHTML
     protected $nwversion = '0.49.2';
     protected $node_platform = 'mac';
     protected $exenameMaxlength = 28;
-
-    public function __construct($book_id, $options = [])
-    {
-        parent::__construct($book_id, $options);
-        $this->version = 'mac_exe_html';
-    }
+    public $type = 'mac_exe_html';
 
     public function makePackage($zip)
     {
@@ -65,8 +62,8 @@ class MacOS extends OfflineHTML
         $cl->debug();
 
         $this->replaceFFMpeg();
-        if(!file_exists($this->getAppPath())){
-            die('Error while building mac app : '.$cl->commande.' // '.$cl->output);
+        if (!file_exists($this->getAppPath())) {
+            die('Error while building mac app : ' . $cl->commande . ' // ' . $cl->output);
         }
 
         $this->signApp();
index 22ff130cfcd9abf6d2185fe6a99216f48d1bccf5..8744fe99a063e8fc8163f3e6b547d5ed05c5bcda 100644 (file)
@@ -2,13 +2,16 @@
 
 namespace App\Fluidbook\Packager;
 
-class OfflineHTML extends Online {
-       protected $_allowNetworking = 'internal';
+class OfflineHTML extends Online
+{
+    protected $_allowNetworking = 'internal';
+    public $type = 'win_html';
 
-       protected function copyFluidbookFiles() {
-               parent::copyFluidbookFiles();
-               unlink($this->vdir . '/index.swf');
-               unlink($this->vdir . '/player.swf');
-               copy(WS_COMPILE_ASSETS . '/offline.swf', $this->vdir . '/index.swf');
-       }
+    protected function copyFluidbookFiles()
+    {
+        parent::copyFluidbookFiles();
+        unlink($this->vdir . '/index.swf');
+        unlink($this->vdir . '/player.swf');
+        copy(WS_COMPILE_ASSETS . '/offline.swf', $this->vdir . '/index.swf');
+    }
 }
index b81c3743998eb4a92410e8aa4973872e3a7f5afa..45ffc844233f7200159466fcaaa69a14850cbd69 100644 (file)
 
 namespace App\Fluidbook\Packager;
 
+use App\Jobs\FluidbookCompiler;
+use App\Models\FluidbookPublication;
 use Cubist\Util\CommandLine;
 
 class Online extends Base
-{   protected $origHTML;
+{
+    protected $origHTML;
     protected $_labels = array();
     protected $_allowNeworking = 'all';
     protected $_ext = 'html';
-    protected $_disableScorm = true;
+    public $type = 'html';
+
     protected $_compileOnConstruct = false;
 
-    public function __construct($book_id, $vdir = null, $whole = true, $options = [])
-    {
-        parent::__construct($book_id, $vdir, $whole, $options);
-        $this->version = 'html';
-    }
 
     protected function preparePackage()
     {
         parent::preparePackage();
 
-        if ($this->_disableScorm) {
-            $this->book->parametres->scorm_enable = false;
-        }
-
-        $this->_ext = $this->book->parametres->htmlExtension;
-        $this->book->parametres->actualHtmlExtension = $this->_ext;
-
-        $this->copyFluidbookFiles();
-        $this->mergeJavascript();
+        $this->book->getSettings()->set('scorm_enable', $this->scormVariant);
 
-//        $others = array('fluidbook.js', 'getflash.gif', 'index.html', 'style.css');
-//        $others = array_merge($others, $this->getSWFFiles());
-//
-//        $this->copyOtherFiles($others);
-
-        if (!file_exists($this->vdir . '/pages')) {
-            mkdir($this->vdir . '/pages/', 0777, true);
-        }
+        $this->_ext = $this->book->getSettings()->get('htmlExtension');
+        $this->book->getSettings()->set('actualHtmlExtension', $this->_ext);
 
-        $ga = '';
-        if ($this->book->parametres->googleAnalyticsCustom) {
-            $ga = $this->book->parametres->googleAnalyticsCustom;
-        } elseif ($this->book->parametres->googleAnalytics != '') {
-            $variables = array('Language' => array('value' => 'getLang()', 'valueAsJS' => true, 'scope' => 2));
-            $ga = cubePage::googleAnalytics(explode(',', $this->book->parametres->googleAnalytics), true, $variables);
-        }
-
-        $statsfooter = '';
-        if ($this->book->parametres->statsCustom != '') {
-            $statsfooter = $this->book->parametres->statsCustom;
-        }
-
-        $facebook = '';
-        if ($this->book->parametres->facebook) {
-            if ($this->book->parametres->facebook_title != '') {
-                $facebook .= '<meta property="og:title" content="' . self::escape($this->book->parametres->facebook_title) . '" />';
-            } else {
-                $facebook .= '<meta property="og:title" content="' . self::escape($this->book->parametres->title) . '" />';
-            }
-            if ($this->book->parametres->facebook_description != '') {
-                $facebook .= '<meta property="og:description" content="' . self::escape($this->book->parametres->facebook_description) . '" />';
-            }
-            $t = 'https://workshop.fluidbook.com/services/facebook_thumbnail?cid=' . $this->book->cid . '&j=' . time();
-            $dim = getimagesize($t);
-            $facebook .= '<meta property="og:image" content="' . $t . '" />';
-            $facebook .= '<meta property="og:image:width" content="' . $dim[0] . '" />';
-            $facebook .= '<meta property="og:image:height" content="' . $dim[1] . '" />';
-        }
-
-        $favicon = '';
-
-        if ($this->theme->parametres->favicon != '') {
-            $favicon = '<link rel="shortcut icon" href="data/fluidbook.ico">';
-        }
-
-        $redirectPDF = 'redirectPDF();';
-        if ($this->book->parametres->mobileVersion == 'pdf') {
-            $redirectMobile = $redirectPDF;
-        } else {
-            $redirectMobile = 'redirectMobile();';
-            $this->prepareHTML5();
-        }
-
-        $seoVersion = true;
-        if (isset($this->book->parametres->seoVersion)) {
-            $seoVersion = $this->book->parametres->seoVersion;
-        }
-
-        $seoRobot = true;
-        if (isset($this->book->parametres->seoRobots)) {
-            $seoRobot = $this->book->parametres->seoRobots;
-        }
-
-        $robots = '';
-        if (!$seoRobot) {
-            $robots = '<meta name="robots" content="noindex, nofollow">';
-        }
-
-        $keywords = '';
-        if ($this->book->parametres->seoKeywords) {
-            $keywords = '<meta name="keywords" content="' . self::escape($this->book->parametres->seoKeywords) . '">';
-        }
-
-        $alwaysHTML5 = true;
-        $html5priority = true;
-
-
-        // Stuffs to replace in html
-        $toReplace = array('lang' => strtolower($this->book->lang),
-            'ga' => $ga,
-            'statsfooter' => $statsfooter,
-            'facebook' => $facebook,
-            'bgcolor' => $this->theme->parametres->loadingBackColor,
-            'junk' => TIME,
-            'robots' => $robots,
-            'favicon' => $favicon,
-            'alwaysHTML5' => $alwaysHTML5,
-            'keywords' => $keywords,
-        );
-
-        $this->origHTML = $this->book->parametres->htmlPrepend;
-        $h = $this->vdir . '/index.html';
-        if (file_exists($h)) {
-            $this->origHTML .= file_get_contents($h);
-            unlink($h);
-        }
-        $this->origHTML = $this->replaceHTML($toReplace);
-
-        $nav1 = $this->makeHTMLNav(true);
-        $nav = $this->makeHTMLNav(false);
-        $footer = $this->makeHTMLFooter();
-
-
-        foreach ($this->pages as $page => $infos) {
-            $pathToIndex = 'index.swf';
-            $pathToGetflash = 'getflash.gif';
-            $redirectScript = '';
-            if ($page == 1) {
-                $dest = 'index.' . $this->_ext;
-                $title = $this->book->parametres->title;
-                $sp = '';
-            } else {
-                $label = $this->_getLabelOfPage($page);
-                $title = $label . ' - ' . $this->book->parametres->title;
-                $dest = 'pages/' . $page . '-' . mb_strtolower(cubeText::str2URL($label)) . '.' . $this->_ext;
-                $pathToIndex = '../index.swf';
-                $pathToGetflash = '../getflash.gif';
-                $sp = '../';
-                $redirectScript = '<script type="text/javascript">window.location=\'../index.' . $this->_ext . '#/' . $page . '\';</script>';
-            }
-            $alt = '';
-
-//                     if ($seoVersion && CubeIT_Util_Gzip::file_exists($htmlfile)) {
-//                             $html = CubeIT_Util_Gzip::file_get_contents($htmlfile);
-//                             $alt .= "\n" . $html . "\n";
-//
-//                             if ($page == 1) {
-//                                     $alt .= $nav1;
-//                             } else {
-//                                     $alt .= $nav;
-//                             }
-//                     }
-
-            $alt .= $footer;
-
-            $base = '';
-            if ($this->book->parametres->baseUrl) {
-                $base = '<base href="' . $this->book->parametres->baseUrl . '" />';
-            }
-
-            if ($page == 1 && $this->book->parametres->seoDescription) {
-                $description = $this->book->parametres->seoDescription;
-            } else {
-                $textfile = wsDocument::getDir($infos['document_id']) . 'ph' . $infos['document_page'] . '.txt';
-                if (file_exists($textfile)) {
-                    $description = mb_substr(file_get_contents($textfile), 0, 150);
-                } else {
-                    $description = '';
-                }
-            }
-
-            $data = str_replace('$alt', $alt, $this->origHTML);
-            $data = str_replace('$base', $base, $data);
-            $data = str_replace('$pathToIndex', $pathToIndex, $data);
-            $data = str_replace('$title', $this->escape($title), $data);
-            $data = str_replace('$pathToGetflash', $pathToGetflash, $data);
-            $data = str_replace('$redirectScript', $redirectScript, $data);
-            $data = str_replace('$sp', $sp, $data);
-            $data = str_replace('$index_ext', $this->_ext, $data);
-            $data = str_replace('$description', '<meta name="description" content="' . self::escape($description, true) . '">', $data);
-
-            file_put_contents($this->vdir . $dest, $data);
-
-            if (!$seoVersion) {
-                break;
-            }
-        }
+        $this->prepareHTML5();
     }
 
-    protected function getFlashvars()
-    {
-        return array();
-    }
 
     public function prepareHTML5()
     {
-        if (!$this->whole) {
-            return;
-        }
-        $dest = $this->vdir . 'm';
+        $dest = $this->vdir;
 
-        $mfid = $this->book->parametres->mobilefirstFluidbookId;
+        $mfid = $this->book->getSettings()->get('mobilefirstFluidbookId', '');
         if ($mfid != '' && (int)$mfid > 0) {
-            $mfbook = $this->daoBook->selectById($mfid);
+            $mfbook = FluidbookPublication::find($mfid);
             $this->_compileHTML5($this->book_id, $this->book, $dest . '/d', true);
             $vars = wsDAOBook::$lastHTML5Compiler->getIndexVars();
             $this->_compileHTML5($mfid, $mfbook, $dest . '/mf', true);
 
-            $hybrid = file_get_contents(WS_COMPILE_ASSETS . '/hybrid/index.html');
+            $hybrid = file_get_contents($this->resource_path('hybrid.html'));
             $replace = [
                 'titre' => $vars['<!-- $titre -->'],
                 'breakpoint' => $this->book->parametres->mobilefirstBreakpoint . 'px',
@@ -242,32 +63,17 @@ class Online extends Base
 
     protected function _compileHTML5($bookId, $book, $dest, $hybrid = false)
     {
+        $compiler = new FluidbookCompiler($book, $this->scormVariant, false, "latest", null, false, false, false, null, $hybrid);
+        $compiler->handle();
 
-        $this->daoBook->compile($bookId, 'html5', false, $book->parametres->forceCompileOnDownload, false, $book, true, false, $hybrid);
-
-        if (!file_exists($dest)) {
-            mkdir($dest, 0777, true);
-        }
-
-        $cp = new CommandLine('cp');
-        $cp->setPath(CONVERTER_PATH);
-        $cp->setArg('r');
-        $cp->setArg('p');
-        $cp->setArg(null, WS_BOOKS . '/html5/' . $bookId . '/*');
-        $cp->setArg(null, $dest);
-        $cp->execute();
-
-        $filesToAdd = array();
-        foreach ($filesToAdd as $f) {
-            $this->copy(WS_COMPILE_ASSETS . '/_html5/' . $f, $dest . '/' . $f);
-        }
-
-        $filesToDelete = array('indext.html', 'indexu.html');
+        $rsync = new CommandLine\Rsync(rtrim($compiler->getFinalPath(),'/'), $dest, true);
+        $rsync->execute();
 
         $htmlFiles = array('index');
+        $filesToDelete = [];
 
         foreach ($htmlFiles as $name) {
-            $html = $book->parametres->htmlPrepend . file_get_contents($dest . '/' . $name . '.html');
+            $html = $book->getSettings()->get('htmlPrepend') . file_get_contents($dest . $name . '.html');
             file_put_contents($dest . '/' . $name . '.' . $this->_ext, $html);
             if ($this->_ext != 'html') {
                 $filesToDelete[] = $name . '.html';
@@ -275,7 +81,6 @@ class Online extends Base
         }
 
         $rm = new CommandLine('rm');
-        $rm->setPath(CONVERTER_PATH);
         foreach ($filesToDelete as $f) {
             $rm->setArg(null, $dest . '/' . $f);
         }
@@ -284,7 +89,6 @@ class Online extends Base
         if ($this->_ext !== 'html') {
             $e = $this->_ext;
             `find $dest -type f -name "*.html" -exec rename 's/\.html$/.$e/' '{}' \;`;
-
         }
     }
 
@@ -297,145 +101,5 @@ class Online extends Base
         return $this->getFinalPackageDir();
     }
 
-    protected function makeHTMLNav($root)
-    {
-        $res = '<nav>';
-        foreach ($this->pages as $page => $infos) {
-            $label = $this->_getLabelOfPage($page);
-            if ($page == 1) {
-                if ($root) {
-                    $url = 'index.' . $this->_ext;
-                } else {
-                    $url = '../index.' . $this->_ext;
-                }
-            } else {
-                if ($root) {
-                    $url = 'pages/' . $page . '-' . mb_strtolower(cubeText::str2URL($label)) . '.' . $this->_ext;
-                } else {
-                    $url = $page . '-' . mb_strtolower(cubeText::str2URL($label)) . '.' . $this->_ext;
-                }
-            }
-            $res .= '<a href="' . $url . '">' . $label . '</a>';
-        }
-        $res .= '</nav>';
-        return $res;
-    }
-
-    protected function _getLabelOfPage($page)
-    {
-        if (!isset($this->_chapters)) {
-            $this->_chapters = $this->book->chapters;
-        }
-
-
-        if (isset($this->_labels[$page])) {
-            return $this->_labels[$page];
-        }
-
-
-        if ($page == 1) {
-            $this->_labels[1] = $this->book->parametres->title;
-
-            return $this->_labels[1];
-        }
-
-
-        $virtual = $this->_getVirtualPage($page);
-
-        $candidates = array();
-        foreach ($this->_chapters as $c) {
-            if ($c->page == $virtual) {
-                $candidates[] = $c;
-            }
-        }
-        if (!count($candidates)) {
-            $this->_labels[$page] = $this->_getLabelOfPage($page - 1);
-            return $this->_labels[$page];
-        }
-
-        usort($candidates, array($this, '_sortCandidates'));
-        $c = array_shift($candidates);
-
-        $this->_labels[$page] = $c->label;
-        return $this->_labels[$page];
-    }
-
-    protected function _sortCandidates($a, $b)
-    {
-        if ($a->level > $b->level) {
-            return 1;
-        } else if ($a->level < $b->level) {
-            return -1;
-        } else {
-            return 0;
-        }
-    }
-
-    protected function _getVirtualPage($page)
-    {
-        $num = explode(',', $this->book->numerotation);
-        if (isset($num[$page - 1])) {
-            return $num[$page - 1];
-        }
-        return 1;
-    }
-
-    protected function escape($txt, $replaceNewLines = false)
-    {
-        $res = htmlentities($txt, ENT_COMPAT, 'UTF-8');
-        if ($replaceNewLines) {
-            $res = str_replace("\n", ' ', $res);
-            $res = str_replace("\r", '', $res);
-        }
-        return $res;
-    }
-
-    protected function makeHTMLFooter()
-    {
-        $res = '<footer>';
-        $res .= '<h2><a href="https://www.fluidbook.com">Fluidbook : Solution de catalogues interactifs et brochures en ligne</a></h2>';
-        $res .= '</footer>';
-        return $res;
-    }
-
-    protected function replaceHTML($toReplace)
-    {
-        return $this->replaceContents($this->origHTML, $toReplace);
-    }
-
-    protected function mergeJavascript()
-    {
-        $dest = WS_COMPILE_ASSETS . '/fluidbook.js';
-        $orig = WS_COMPILE_ASSETS . '/_js/';
-        $files = array('log4js.js' => false, 'esapi.js' => false, 'resources/i18n/ESAPI_Standard_en_US.properties.js' => false, 'resources/Base.esapi.properties.js' => false, 'swfobject.js' => false, 'swfaddress.js' => true, 'fluidbook.js' => true);
-
-        $refresh = false;
-        if (file_exists($dest)) {
-            $mtime = filemtime($dest);
-            foreach ($files as $file => $min) {
-                if (filemtime($orig . $file) > $mtime) {
-                    $refresh = true;
-                    break;
-                }
-            }
-        } else {
-            $refresh = true;
-        }
-        if (!$refresh) {
-            return;
-        }
-
-        $minjs = "\n\n";
-        foreach ($files as $file => $min) {
-            $c = file_get_contents($orig . $file);
-            if ($min) {
-                $c = JSMin::minify($c);
-            }
-
-            $minjs .= $c . "\n\n";
-        }
-        file_put_contents($dest, $minjs);
-    }
-
 
 }
index 45b87e92661bee1ac9bbb462e7e8fe794abd2c5e..6f2ce8364f8101ac2601501666e1934ab80369e5 100644 (file)
@@ -4,10 +4,11 @@ namespace App\Fluidbook\Packager;
 
 class Precompiled extends Online
 {
-    public function __construct($book_id, $vdir = null, $whole = true,$options=[])
+    public $type = 'precompiled';
+
+    public function __construct($book_id, $vdir = null,  $options = [])
     {
-        parent::__construct($book_id, $vdir, $whole,$options);
-        $this->version = 'precompiled';
+        parent::__construct($book_id, $vdir, $options);
         $this->book->parametres->embedAllLibraries = true;
     }
 
index dcba067fb9f0e41116a50afb9c54b3626503200a..c7f4c0d14bc770b93d33f4c21c1b42a428628292 100644 (file)
@@ -1,13 +1,11 @@
 <?php
+
 namespace App\Fluidbook\Packager;
 class Scorm extends Online
 {
-    public function __construct($book_id, $vdir = null, $whole = true, $options = [])
-    {
-        parent::__construct($book_id, $vdir, $whole, $options);
-        $this->version = 'scorm';
-        $this->_disableScorm = false;
-    }
+    protected $scormVariant = true;
+
+    public $type = 'scorm';
 
     protected function preparePackage()
     {
index 341849ac06088ec78e2f061d122bfef499e5ed53..c569b6023d69e0dbc25e9deab9637101ca8722ff 100644 (file)
@@ -4,12 +4,13 @@ namespace App\Fluidbook\Packager;
 
 class Sharepoint extends Online
 {
-    public function __construct($book_id, $vdir = null, $whole = true, $options = [])
+    public $type = 'sharepoint';
+
+    public function __construct($book_id, $vdir = null, $options = [])
     {
-        parent::__construct($book_id, $vdir, $whole, $options);
-        $this->version = 'sharepoint';
-        $this->book->parametres->seoVersion = false;
-        $this->book->parametres->maxResolution = 150;
-        $this->book->parametres->htmlExtension = 'aspx';
+        parent::__construct($book_id, $vdir, $options);
+        $this->book->getSettings()->set('seoVersion', false);
+        $this->book->getSettings()->set('maxResolution', 150);
+        $this->book->getSettings()->set('htmlExtension', 'aspx');
     }
 }
index e3a65c38bd8da0a745880c6e80b898171c79a47c..91082f9495b444677ad3ae07cc2c1d51bd716253 100644 (file)
@@ -2,12 +2,7 @@
 namespace App\Fluidbook\Packager;
 class USBKey extends MacOS
 {
-
-       public function __construct($book_id,$options=[])
-       {
-               parent::__construct($book_id,$options);
-               $this->version = 'win_cd_html';
-       }
+    public $type='win_cd_html';
 
        protected function preparePackage()
        {
index 937497dd0cb07b8ba168d3dc16c5b4fcf675a8a6..5e26ed213f7b4b99d190c83b23b12c0ac244fa74 100644 (file)
@@ -1,13 +1,10 @@
 <?php
+
 namespace App\Fluidbook\Packager;
 class WindowsEXE extends WindowsInstaller
 {
 
     protected $nsifile = 'html-silent';
+    public $type = 'win_inss_html';
 
-    public function __construct($book_id, $options = [])
-    {
-        parent::__construct($book_id, $options);
-        $this->version = 'win_inss_html';
-    }
 }
index e3c61f3e42a78c1b7e8d416211b14d0271cdb8f8..8d7ab471c4fc3a30ef9be5c156d6c047770c633f 100644 (file)
@@ -6,11 +6,8 @@ class WindowsInstaller extends WindowsZIP
     protected $nsi;
     protected $nsifile = 'html';
 
-    public function __construct($book_id, $options = [])
-    {
-        parent::__construct($book_id, $options);
-        $this->version = 'win_ins_html';
-    }
+    public $type='win_ins_html';
+
 
     protected function preparePackage()
     {
index 7526a8ca9840a941290af693447855de70c4d97d..b1643bc79e01d1500b700d5a6ccae7ccc2734460 100644 (file)
@@ -4,6 +4,7 @@ namespace App\Fluidbook\Packager;
 
 use Cubist\Net\SSH2;
 use Cubist\Util\CommandLine;
+use Cubist\Util\Text;
 
 class WindowsZIP extends Base
 {
@@ -17,10 +18,11 @@ class WindowsZIP extends Base
     protected $exenameMaxlength = 30;
     protected $_compileOnConstruct = true;
 
-    public function __construct($book_id, $options = [])
+    public $type = 'win_exe_html';
+
+    public function __construct($book_id, $vdir = null, $options = [])
     {
-        parent::__construct($book_id, null, true, $options);
-        $this->version = 'win_exe_html';
+        parent::__construct($book_id, $vdir, $options);
         $this->appName = '';
         $this->appversion = '1.0.' . time();
         $this->_clean = false;
@@ -29,7 +31,7 @@ class WindowsZIP extends Base
             $this->exeName = $this->book->book_id . '-' . trim(cubeText::str2URL(mb_substr($this->book->parametres->title, 0, $this->exenameMaxlength - 6)), '-');
             $this->appName = $this->book->parametres->title;
         } else {
-            $this->exeName = trim(cubeText::str2URL(mb_substr($this->book->parametres->offlineTitle, 0, $this->exenameMaxlength)), '-');
+            $this->exeName = trim(Text::str2URL(mb_substr($this->book->parametres->offlineTitle, 0, $this->exenameMaxlength)), '-');
             $this->appName = $this->book->parametres->offlineTitle;
         }
 
index f2f97568f600ee6e07419dbf7b4084c441f4eabf..e7a14b8c5d33cfff26ecbb811b01f9f99127b549 100644 (file)
@@ -197,6 +197,10 @@ class FluidbookCompiler extends Base implements CompilerInterface
     public $dir;
     public $z = 3;
     protected $_lottieIDByHash = [];
+
+    /**
+     * @var FluidbookPublication
+     */
     public $book;
     public $pages;
     public $theme;
@@ -269,7 +273,7 @@ class FluidbookCompiler extends Base implements CompilerInterface
 
     /**
      * @param FluidbookPublication $book
-     * @param $version null|string
+     * @param bool $scormVariant
      * @param $phonegap
      * @param $phonegapVersion
      * @param $dir
@@ -282,7 +286,7 @@ class FluidbookCompiler extends Base implements CompilerInterface
      * @throws \Exception
      */
 
-    function __construct(FluidbookPublication $book, $version = 'online', $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false, $appcache = false, $home = false, FluidbookTheme $theme = null, $hybrid = false, Command $command = null)
+    function __construct(FluidbookPublication $book, $scormVariant = false, $phonegap = false, $phonegapVersion = 'latest', $dir = null, $standalone = false, $appcache = false, $home = false, FluidbookTheme $theme = null, $hybrid = false, Command $command = null)
     {
         parent::__construct();
 
@@ -293,7 +297,7 @@ class FluidbookCompiler extends Base implements CompilerInterface
         $this->appcache = $appcache;
         $this->multiApp = $this->home = $home;
         $this->devversion = $this->getFluidbook()->mobileLVersion;
-        $this->version = $version;
+        $this->scormVariant = $scormVariant;
 
         $this->hybrid = $hybrid;
 
@@ -312,7 +316,7 @@ class FluidbookCompiler extends Base implements CompilerInterface
         $this->book_id = $this->getFluidbook()->id;
         $this->log('Start compilation');
 
-        $this->dir = $this->getFluidbook()->getFinalPath($theme, $version);
+        $this->dir = $this->getFluidbook()->getFinalPath($theme, $scormVariant);
         $this->vdir = new VirtualDirectory($this->dir);
 
         $this->wdir = $this->getFluidbook()->getAssetDir();
@@ -332,7 +336,6 @@ class FluidbookCompiler extends Base implements CompilerInterface
 
         $this->imageFormat = $this->fluidbookSettings->imageFormat;
 
-
         $p1 = $this->getFluidbook()->getFile(1, $this->imageFormat, 150);
         $imagesize = Image::getimagesize($p1);
         $this->pdf2htmlRatio = round(($imagesize[0] * 0.48) / $this->width, 12);
@@ -375,6 +378,11 @@ class FluidbookCompiler extends Base implements CompilerInterface
         $this->log('Defined dimensions');
     }
 
+    public function getFinalPath()
+    {
+        return $this->dir;
+    }
+
 
     public function getSetting($key, $default = null)
     {
@@ -470,7 +478,7 @@ class FluidbookCompiler extends Base implements CompilerInterface
 
     public function initConfig()
     {
-        if ($this->version !== 'scorm') {
+        if (!$this->scormVariant) {
             $this->fluidbookSettings->scorm_enable = false;
         }
 
index 41c57325d3fff6d2475ac71678d1c79ce31fb868..e978a62745bd3d9e8829fbb2fc62def0df72e036 100644 (file)
@@ -62,15 +62,6 @@ class FluidbookPublication extends ToolboxSettingsModel
     {
         parent::setFields();
 
-//        $this->addField([
-//            'name' => 'name',
-//            'type' => FluidbookTitle::class,
-//            'label' => __('Titre de la publication'),
-//            'default' => '',
-//            'column' => true,
-//            'translatable' => false,
-//            'non_default_tracking' => false,
-//        ]);
 
         $this->addOwnerField();
 
@@ -330,10 +321,10 @@ class FluidbookPublication extends ToolboxSettingsModel
         return (float)$this->getDocumentSize($page)[1];
     }
 
-    public function getFinalPath($theme = null, $version = 'online')
+    public function getFinalPath($theme = null, $scormVariant = false)
     {
         $dir = $this->id;
-        if (null === $theme || ($theme instanceof FluidbookTheme && $theme->id != $this->theme)) {
+        if (null !== $theme || ($theme instanceof FluidbookTheme && $theme->id != $this->theme)) {
             $dir .= '-';
             if (is_string($theme) || is_numeric($theme)) {
                 $dir .= $theme;
@@ -341,7 +332,7 @@ class FluidbookPublication extends ToolboxSettingsModel
                 $dir .= $theme->id;
             }
         }
-        return protected_path('fluidbookpublication/final/' . $dir . '/' . $version);
+        return protected_path('fluidbookpublication/final/' . $dir . '/' . ($scormVariant ? 'scorm' : 'online'));
     }
 
     public function getAssetDir()
diff --git a/resources/fluidbookpublication/packager/_ffmpeg/libffmpeg.dylib b/resources/fluidbookpublication/packager/_ffmpeg/libffmpeg.dylib
new file mode 100644 (file)
index 0000000..03951a7
Binary files /dev/null and b/resources/fluidbookpublication/packager/_ffmpeg/libffmpeg.dylib differ
diff --git a/resources/fluidbookpublication/packager/_ffmpeg/windows-x32-ffmpeg.dll b/resources/fluidbookpublication/packager/_ffmpeg/windows-x32-ffmpeg.dll
new file mode 100644 (file)
index 0000000..4d335be
Binary files /dev/null and b/resources/fluidbookpublication/packager/_ffmpeg/windows-x32-ffmpeg.dll differ
diff --git a/resources/fluidbookpublication/packager/_ffmpeg/windows-x64-ffmpeg.dll b/resources/fluidbookpublication/packager/_ffmpeg/windows-x64-ffmpeg.dll
new file mode 100644 (file)
index 0000000..faa1b7d
Binary files /dev/null and b/resources/fluidbookpublication/packager/_ffmpeg/windows-x64-ffmpeg.dll differ
diff --git a/resources/fluidbookpublication/packager/autorun-html.inf b/resources/fluidbookpublication/packager/autorun-html.inf
new file mode 100644 (file)
index 0000000..8625bb1
--- /dev/null
@@ -0,0 +1,5 @@
+[autorun]
+label=$title
+icon=$exe
+open=$exe
+action=$title
\ No newline at end of file
diff --git a/resources/fluidbookpublication/packager/autorun.inf b/resources/fluidbookpublication/packager/autorun.inf
new file mode 100644 (file)
index 0000000..ee85c2a
--- /dev/null
@@ -0,0 +1,5 @@
+[autorun]
+label=$title
+icon=data\fluidbook.ico
+open=$exe
+action=$title
\ No newline at end of file
diff --git a/resources/fluidbookpublication/packager/fluidbook.ico b/resources/fluidbookpublication/packager/fluidbook.ico
new file mode 100644 (file)
index 0000000..fdaa6af
Binary files /dev/null and b/resources/fluidbookpublication/packager/fluidbook.ico differ
diff --git a/resources/fluidbookpublication/packager/html-silent.nsi b/resources/fluidbookpublication/packager/html-silent.nsi
new file mode 100644 (file)
index 0000000..89ff111
--- /dev/null
@@ -0,0 +1,80 @@
+; Fluidbook
+;--------------------------------
+
+!define FLUIDBOOKNAME "$name"
+!define REG_UNINSTALL "Software\Microsoft\Windows\CurrentVersion\Uninstall\$fname"
+
+Unicode true
+
+; The name of the installer
+Name "${FLUIDBOOKNAME}"
+
+; The file to write
+OutFile "$output"
+
+; The default installation directory
+InstallDir $LOCALAPPDATA\$fname
+
+; Request application privileges for Windows Vista
+RequestExecutionLevel user
+
+; Style
+XPStyle on
+
+Icon "$favicon"
+
+; not released
+;TargetMinimalOS 5.0
+
+; Langues
+LoadLanguageFile "$nsisdir/Contrib/Language files/$lang.nlf"
+
+; Pages
+
+Page directory
+Page instfiles
+
+; Compression
+SetCompress off
+
+;--------------------------------
+
+Function .onInit
+    SetSilent silent
+FunctionEnd
+
+; The stuff to install
+Section "" ;No components page, name is not important
+    ; Set output path to the installation directory.
+    SetOutPath $INSTDIR
+
+    ; Put file there
+    SetOverwrite ifnewer
+    File /r "$fdir\*"
+
+    ; Create shortcut
+    CreateShortCut "$SMPROGRAMS\${FLUIDBOOKNAME}.lnk" "$INSTDIR\$fname.exe" "--disable-crash-handler=true" "$INSTDIR\package.nw\icon.ico"
+    CreateShortCut "$DESKTOP\${FLUIDBOOKNAME}.lnk" "$INSTDIR\$fname.exe" "--disable-crash-handler=true" "$INSTDIR\package.nw\icon.ico"
+
+    WriteRegStr HKCU "${REG_UNINSTALL}" "DisplayName" "${FLUIDBOOKNAME}"
+    WriteRegStr HKCU "${REG_UNINSTALL}" "DisplayIcon" "$\"$INSTDIR\package.nw\icon.ico$\""
+    WriteRegStr HKCU "${REG_UNINSTALL}" "InstallLocation" "$\"$INSTDIR$\""
+    WriteRegDWord HKCU "${REG_UNINSTALL}" "NoModify" 1
+    WriteRegDWord HKCU "${REG_UNINSTALL}" "NoRepair" 1
+    WriteRegStr HKCU "${REG_UNINSTALL}" "UninstallString" "$\"$INSTDIR\Uninstall.exe$\""
+
+    WriteUninstaller "$INSTDIR\Uninstall.exe"
+
+    ExecShell "" "$INSTDIR\$fname.exe" "--disable-crash-handler=true"
+SectionEnd
+
+Section "Uninstall"
+    DeleteRegKey HKCU "${REG_UNINSTALL}"
+    Delete "$SMPROGRAMS\${FLUIDBOOKNAME}.lnk"
+    Delete "$DESKTOP\${FLUIDBOOKNAME}.lnk"
+    Delete "$INSTDIR\Uninstall.exe"
+    RMDIR /r /REBOOTOK $INSTDIR
+    SetRebootFlag false
+SectionEnd
+
+
diff --git a/resources/fluidbookpublication/packager/html.inf b/resources/fluidbookpublication/packager/html.inf
new file mode 100644 (file)
index 0000000..8b6ece3
--- /dev/null
@@ -0,0 +1,5 @@
+[autorun]
+label=$title
+icon=$nwplatform\package.nw\icon.ico
+open=$exe
+action=$title
\ No newline at end of file
diff --git a/resources/fluidbookpublication/packager/html.nsi b/resources/fluidbookpublication/packager/html.nsi
new file mode 100644 (file)
index 0000000..2b80e9f
--- /dev/null
@@ -0,0 +1,74 @@
+; Fluidbook
+;--------------------------------
+
+!define FLUIDBOOKNAME "$name"
+!define REG_UNINSTALL "Software\Microsoft\Windows\CurrentVersion\Uninstall\$fname"
+
+Unicode true
+
+; The name of the installer
+Name "${FLUIDBOOKNAME}"
+
+; The file to write
+OutFile "$output"
+
+; The default installation directory
+InstallDir $LOCALAPPDATA\$fname
+
+; Request application privileges for Windows Vista
+RequestExecutionLevel user
+
+; Style
+XPStyle on
+
+Icon "$favicon"
+
+; not released
+;TargetMinimalOS 5.0
+
+; Langues
+LoadLanguageFile "$nsisdir/Contrib/Language files/$lang.nlf"
+
+; Pages
+
+Page directory
+Page instfiles
+
+; Compression
+SetCompress off
+
+; The stuff to install
+Section "" ;No components page, name is not important
+    ; Set output path to the installation directory.
+    SetOutPath $INSTDIR
+
+    ; Put file there
+    SetOverwrite ifnewer
+    File /r "$fdir\*"
+
+    ; Create shortcut
+    CreateShortCut "$SMPROGRAMS\${FLUIDBOOKNAME}.lnk" "$INSTDIR\$fname.exe" "--disable-crash-handler=true" "$INSTDIR\package.nw\icon.ico"
+    CreateShortCut "$DESKTOP\${FLUIDBOOKNAME}.lnk" "$INSTDIR\$fname.exe" "--disable-crash-handler=true" "$INSTDIR\package.nw\icon.ico"
+
+    WriteRegStr HKCU "${REG_UNINSTALL}" "DisplayName" "${FLUIDBOOKNAME}"
+    WriteRegStr HKCU "${REG_UNINSTALL}" "DisplayIcon" "$\"$INSTDIR\package.nw\icon.ico$\""
+    WriteRegStr HKCU "${REG_UNINSTALL}" "InstallLocation" "$\"$INSTDIR$\""
+    WriteRegDWord HKCU "${REG_UNINSTALL}" "NoModify" 1
+    WriteRegDWord HKCU "${REG_UNINSTALL}" "NoRepair" 1
+    WriteRegStr HKCU "${REG_UNINSTALL}" "UninstallString" "$\"$INSTDIR\Uninstall.exe$\""
+
+    WriteUninstaller "$INSTDIR\Uninstall.exe"
+
+    ExecShell "" "$INSTDIR\$fname.exe" "--disable-crash-handler=true"
+SectionEnd
+
+Section "Uninstall"
+    DeleteRegKey HKCU "${REG_UNINSTALL}"
+    Delete "$SMPROGRAMS\${FLUIDBOOKNAME}.lnk"
+    Delete "$DESKTOP\${FLUIDBOOKNAME}.lnk"
+    Delete "$INSTDIR\Uninstall.exe"
+    RMDIR /r /REBOOTOK $INSTDIR
+    SetRebootFlag false
+SectionEnd
+
+
diff --git a/resources/fluidbookpublication/packager/hybrid.html b/resources/fluidbookpublication/packager/hybrid.html
new file mode 100644 (file)
index 0000000..b504f9a
--- /dev/null
@@ -0,0 +1,46 @@
+<!doctype html>
+<html>
+<head>
+    <title>$titre</title>
+    <meta charset="utf-8">
+    <meta name="viewport" content="width=device-width">
+    $description
+    $opengraph
+    $twittercard
+    <style type="text/css">
+        * {
+            padding: 0;
+            margin: 0;
+        }
+
+        body, html {
+            background-color: #$bgcolor;
+            width: 100%;
+            height: 100%;
+        }
+
+        footer {
+            visibility: hidden;
+        }
+    </style>
+    <script>
+        var redirect;
+        var locationWithoutHash = window.location.href.split('#')[0];
+        var e = locationWithoutHash.split('?', 2);
+        var params = '';
+        if (e.length === 2 && e[1]!=='') {
+            params = e[1] + '&';
+        }
+        var hash = window.location.hash;
+        if (window.matchMedia('(min-device-width: $breakpoint) and (min-device-height: $breakpoint)').matches) {
+            redirect = 'd';
+        } else {
+            redirect = 'mf';
+        }
+        window.location = './' + redirect + '/index.html?' + params + 'hybrid=1&from=' + encodeURIComponent(locationWithoutHash) + hash;
+    </script>
+</head>
+<body>
+<footer id="credits">$credits</footer>
+</body>
+</html>
\ No newline at end of file
diff --git a/resources/fluidbookpublication/packager/script.nsi b/resources/fluidbookpublication/packager/script.nsi
new file mode 100644 (file)
index 0000000..7499cb6
--- /dev/null
@@ -0,0 +1,74 @@
+; Fluidbook
+;--------------------------------
+
+!define FLUIDBOOKNAME "$name"
+!define REG_UNINSTALL "Software\Microsoft\Windows\CurrentVersion\Uninstall\$fname"
+
+; The name of the installer
+Name "${FLUIDBOOKNAME}"
+
+; The file to write
+OutFile "$output"
+
+; The default installation directory
+InstallDir $LOCALAPPDATA\$fname
+
+; Request application privileges for Windows Vista
+RequestExecutionLevel user
+
+; Style
+XPStyle on
+
+Icon "$favicon"
+
+; not released
+;TargetMinimalOS 5.0
+
+; Langues
+LoadLanguageFile "$nsisdir/Contrib/Language files/$lang.nlf"
+
+; Pages
+
+Page directory
+Page instfiles
+
+; Compression
+SetCompress off
+
+;--------------------------------
+
+; The stuff to install
+Section "" ;No components page, name is not important
+
+  ; Set output path to the installation directory.
+  SetOutPath $INSTDIR
+  
+  ; Put file there
+  File /r "$fdir\*"
+  
+  ; Create shortcut
+  CreateShortCut "$SMPROGRAMS\${FLUIDBOOKNAME}.lnk" "$INSTDIR\$fname.exe" "" "$INSTDIR\data\fluidbook.ico"
+  CreateShortCut "$DESKTOP\${FLUIDBOOKNAME}.lnk" "$INSTDIR\$fname.exe" "" "$INSTDIR\data\fluidbook.ico"
+  
+  WriteRegStr HKCU "${REG_UNINSTALL}" "DisplayName" "${FLUIDBOOKNAME}"
+  WriteRegStr HKCU "${REG_UNINSTALL}" "DisplayIcon" "$\"$INSTDIR\data\fluidbook.ico$\""
+  WriteRegStr HKCU "${REG_UNINSTALL}" "InstallLocation" "$\"$INSTDIR$\""
+  WriteRegDWord HKCU "${REG_UNINSTALL}" "NoModify" 1
+  WriteRegDWord HKCU "${REG_UNINSTALL}" "NoRepair" 1
+  WriteRegStr HKCU "${REG_UNINSTALL}" "UninstallString" "$\"$INSTDIR\Uninstall.exe$\""
+
+  WriteUninstaller "$INSTDIR\Uninstall.exe"
+
+  ExecShell "" "$INSTDIR\$fname.exe"
+SectionEnd
+
+Section "Uninstall"
+DeleteRegKey HKCU "${REG_UNINSTALL}"
+Delete "$SMPROGRAMS\${FLUIDBOOKNAME}.lnk"
+Delete "$DESKTOP\${FLUIDBOOKNAME}.lnk"
+Delete "$INSTDIR\Uninstall.exe"
+RMDIR /r /REBOOTOK $INSTDIR
+SetRebootFlag false
+SectionEnd 
+
+