$js = $_GET['js'];
}
+
if ($js == '') {
ob_end_clean();
exit;
file_put_contents($tmp, $js);
$uglify = new cubeCommandLine('uglifyjs');
$uglify->setPath(CONVERTER_PATH);
- $uglify->setArg('o', $res);
- $uglify->setArg('mangle-toplevel');
- $uglify->setArg('no-copyright');
- $uglify->setArg('unsafe');
$uglify->setArg(null, $tmp);
+ $uglify->setArg('o', $res);
+ $uglify->setArg('c');
+ $uglify->setArg('m');
$uglify->execute();
ob_end_clean();
+ fb($uglify->commande);
+ fb($uglify->output);
+
header('Content-type: text/javascript');
if (file_exists($res)) {
echo file_get_contents($res);
public function collection() {\r
global $core;\r
$id = $this->callArgs[0];\r
- $local = (isset($this->callArgs[1])) ? $this->callArgs[1] : null;\r
+ $os = $this->callArgs[1];\r
+ $local = (isset($this->callArgs[2])) ? $this->callArgs[2] : null;\r
+\r
\r
$this->outputXML = false;\r
header('Content-type: application/json');\r
\r
- $cache = WS_COLLECTIONS . '/ws/' . $id . '.json';\r
- $update = WS_COLLECTIONS . '/ws/' . $id . '.update';\r
+ $cache = WS_COLLECTIONS . '/ws/' . $id . '.' . $os . '.json';\r
+ $update = WS_COLLECTIONS . '/ws/' . $id . '.' . $os . '.update';\r
+\r
+ if (file_exists($update) && filemtime(__FILE__) > filemtime($update)) {\r
+ unlink($update);\r
+ }\r
\r
if (!is_null($local) && file_exists($update) && file_get_contents($update) == $local) {\r
echo 'false';\r
$composition = json_decode(file_get_contents(WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/composition.json'));\r
\r
$couvertures = array();\r
+ $vroot = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/' . $os . '/';\r
+\r
foreach ($composition as $k => $g) {\r
foreach ($g->publications as $l => $p) {\r
- $couv = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/ios/' . $p->id . '/data/background/36/t1.jpg';\r
+ $root = WS_COLLECTIONS . '/versions/' . $id . '/' . $version . '/' . $os . '/' . $p->id;\r
+ $couv = $root . '/data/background/36/t1.jpg';\r
$couvertures[$p->id] = base64_encode(file_get_contents($couv));\r
+ $publications[] = $p->id;\r
}\r
}\r
\r
- $d = array('id' => $id, 'time' => $version, 'datas' => $composition, 'couvertures' => $couvertures);\r
+ $d = array('id' => $id, 'time' => $version, 'manifest' => $this->_getManifest($publications, '/fluidbook/collections/versions/' . $id . '/' . $version . '/' . $os), 'datas' => $composition, 'couvertures' => $couvertures);\r
\r
$dao = new wsDAOCollection($core->con);\r
$col = $dao->selectById($id);\r
exit;\r
}\r
\r
+ protected function _getManifest($publications, $dir) {\r
+\r
+\r
+ $res = array('assetRoot' => 'http://workshop.fluidbook.com' . $dir . '/', 'autoDownload' => false);\r
+ $bundles = array();\r
+\r
+ $removeFromRelative = realpath(ROOT . '/' . $dir) . '/';\r
+\r
+ foreach ($publications as $p) {\r
+ $c = array();\r
+ $c1 = array();\r
+ $r = $p . '/';\r
+ $iterator = CubeIT_Files::getRecursiveDirectoryIterator(ROOT . $dir . '/' . $p);\r
+ foreach ($iterator as $k => $f) {\r
+ if ($f->isDir()) {\r
+ continue;\r
+ }\r
+ $path = str_replace($removeFromRelative, '', $k);\r
+ $order = $this->_inFirstManifest($path, $r);\r
+ if ($order === 0) {\r
+ $c1[] = $path;\r
+ } elseif ($order === 1) {\r
+ $c[] = $path;\r
+ }\r
+ }\r
+ //shuffle($c);\r
+\r
+ $bundles[] = array('name' => 'p_' . $p, 'contents' => $c1);\r
+ $bundles[] = array('name' => 'p_' . $p . '_', 'contents' => $c);\r
+ }\r
+\r
+ $res['bundles'] = $bundles;\r
+ return $res;\r
+ }\r
+\r
+ protected function _inFirstManifest($p, $r) {\r
+\r
+ $ok = array('^' . $r . 'style/(.*)$', '^' . $r . 'index.html$', '^' . $r . 'images/(.*)$', '^' . $r . 'data/images/(.*)$', '^' . $r . 'data/style/(.*)$', '^' . $r . 'data/(.*).js$');\r
+ foreach ($ok as $v) {\r
+ if (preg_match('|' . $v . '|i', $p)) {\r
+ fb('ok : ' . $v, $p);\r
+ return 0;\r
+ }\r
+ }\r
+ return 1;\r
+ }\r
+\r
public function collectionPushRegister() {\r
global $core;\r
\r