namespace App\Console\Commands;
+use App\Fluidbook\Packager\Download;
use App\Fluidbook\Packager\Packager;
+use App\Models\FluidbookPublication;
+use App\Models\User;
use Cubist\Backpack\Console\Commands\CubistCommand;
class FluidbookPackage extends CubistCommand
{
- protected $signature = 'fluidbook:package {id} {type} {--zip}';
+ protected $signature = 'fluidbook:package {id} {type=online} {action=download} {--zip}';
protected $description = 'Compile a fluidbook';
/**
*/
public function handle()
{
- $packager = Packager::package($this->argument('id'), $this->argument('type'), $this->option('zip', false));
- $packager->handle();
+ $download = new Download(FluidbookPublication::find($this->argument('id')), $this->argument('type'), $this->argument('action'), User::withoutGlobalScope('ownerclause')->findOrFail(5));
+ $download->handle();
}
}
}
$text = __('Une erreur s\'est produite lors de l\'envoi sur SCORM Cloud (App ID :appid) : :error', ['error' => $e->getMessage(), 'appid' => env('SCORM_CLOUD_APP_ID')]);
}
+ } else if ($this->action === 'install_hosting') {
+ $path = $this->_compileandpackage(false);
+ dd($path);
+ } else if ($this->action === 'install_ftp') {
+
}
} catch (\Exception $e) {
$subject = __('Erreur lors de la compilation du :type :nb', ['nb' => $this->_id(), 'type' => $this->type]);
$this->sendNotification($subject, $text, $actions);
}
- protected function _compileandpackage()
+ protected function _compileandpackage($zip = true)
{
- if ($this->action === 'download' || $this->action === '') {
- $zip = true;
- }
$packager = Packager::package($this->entry->id, $this->version, $zip);
$packager->makePackage($zip);
$url = $packager->getFinalURL();
protected $exenameMaxlength = 30;
protected $_compileOnConstruct = true;
protected $packageIconExt = 'ico';
- protected $nwbuildVersion = '4.0.7';
+ protected $nwbuildVersion = '4.0.8';
protected $nwCacheDir;
protected $_ext = 'html';
$this->makeJSON();
`umask 0000;sudo rm -rf $this->buildPath;mkdir -p 0777 $this->buildPath;chmod -R 777 $this->vdir;mkdir -p 0777 /application/tmp;chmod -R 777 /application/tmp`;
- if (version_compare($this->nwbuildVersion, 4, '<')) {
- $cl = $this->_nwbuilder3();
- } else {
- $cl = $this->_nwbuilder4();
- }
+ $cl = $this->_nwbuilder4();
`sudo chown -R 1001:33 $this->buildPath`;
if (!$this->nwBuildOK()) {
- throw new \Exception('Error while making exe : ' . $cl->commande . ' // ' . $cl->output);
+ throw new \Exception('Error while making exe : ' . $cl->getCommand() . ' // ' . $cl->getOutput());
}
}
return file_exists($this->buildPath);
}
- /**
- * @return CommandLine
- */
- protected function _nwbuilder3()
- {
- $platform = $this->getNWbuilder3Platform();
-
- $cl = new CommandLine('nwbuild');
- $cl->setArg(null, $this->vdir . '**');
- $cl->setLongArgumentSeparator(' ');
- $cl->setArg('platforms', $platform);
- $cl->setArg('buildDir', $this->buildPath);
- $cl->setArg('version', $this->nwversion);
- $cl->setArg('mode', 'build');
- $cl->setArg('flavor', 'normal');
- if ($this->nwplatform === 'win') {
- $cl->setArg('winIco', $this->vdir . 'icon.ico');
- $cl->setArg('useRcedit', 'true');
- } elseif ($this->nwplatform === 'osx') {
- $cl->setArg('macIcns', $this->vdir . 'icon.icns');
- }
- $cl->execute();
- return $cl;
- }
-
/**
* @return CommandLine
*/
$cl->setArg('version', $this->nwversion);
$cl->setArg('arch', $this->arch);
$cl->execute();
+ $cl->debug();
return $cl;
}
function _sign($source, $symbolicLink = false)
{
$rand = 'sign-' . hash_file('sha256', $source) . '.exe';
- $distant = 'C:/Sign/' . $rand;
+ $remote = 'C:/Sign/' . $rand;
$local = protected_path('signedexe/' . $rand);
if (!file_exists($local)) {
$ssh = new SSH2('paris.cubedesigners.com', 'vince', 'Y@mUC9mY2DOYWXkN', '22422');
- $ssh->send($source, $distant);
+ $ssh->send($source, $remote);
unlink($source);
+ if (!$ssh->file_exists($remote)) {
+ throw new \Exception("An error occured when sending exe to signing machine");
+ }
$cli = new CommandLine('C:/Program Files (x86)/Windows Kits/10/bin/10.0.18362.0/x64/signtool.exe');
$cli->setManualArg("sign /f C:/Users/vince/Documents/Cubedesigners.cer /csp \"eToken Base Cryptographic Provider\" /k \"[SafeNet Token JC 0{{TYWjZacq%hAH98}}]=54C3F1B91759268A\" /tr http://timestamp.sectigo.com /td sha256 /fd sha256 /a C:/Sign/$rand");
$cli->execute($ssh);
if (!stristr($cli->getOutput(), 'Successfully signed')) {
- unlink($distant);
- throw new \Exception('Error while signing exe ' . $rand . ' : ' . $cli->getOutput());
+ $ssh->unlink($remote);
+ throw new \Exception('Error while signing exe ' . $rand . ' : ' . $cli->getCommand() . ' /// ' . $cli->getOutput());
}
- $ssh->recv($distant, $local);
- $ssh->unlink($distant);
+ $ssh->recv($remote, $local);
+ $ssh->unlink($remote);
sleep(2);
}
if ($symbolicLink) {
*/
function makeJSON()
{
+ $app = [
+ 'name' => $this->appName,
+ 'icon' => $this->vdir . 'icon.' . $this->packageIconExt,
+ 'version' => '1.0.' . $this->_time,
+ ];
+
$data = ['app_name' => $this->appName,
'main' => 'index.html',
'name' => $this->exeName,
'version' => '1.0.' . $this->_time,
+ 'icon' => $this->vdir . 'icon.' . $this->packageIconExt,
'webkit' => [],
'window' => [
'height' => 768,
'id' => 'main',
'icon' => 'icon.png',
],
+ 'app' => $app,
'nwbuild' => [
'platform' => $this->nwplatform,
'outDir' => $this->buildPath,
'flavour' => 'normal',
'version' => $this->nwversion,
'arch' => $this->arch,
- 'app' => [
- 'name' => $this->appName,
- 'icon' => $this->vdir . 'icon.' . $this->packageIconExt,
- ],
+ 'app' => $app,
],
'dependencies' =>
[
public function getFinalPackageDir()
{
- if ($this->nwbuildVersion === 3) {
- return $this->buildPath . '/' . $this->exeName . '/' . $this->getNWBuilder3Platform();
- } else {
- return $this->buildPath;
- }
+ return $this->buildPath;
}
protected function compile($forceCompile = false)
abort(401, __('Cette version n\'est pas disponible au téléchargement'));
}
- Download::dispatch($fluidbook, $version, $action, backpack_user())->onQueue('download');;
+ Download::dispatch($fluidbook, $version, $action, backpack_user())->onQueue('download');
Alert::add('success', __('La compilation a été placée en file d\'attente. Vous recevrez un email lorsqu\'elle sera terminée.'))->flash();
return redirect(backpack_url('fluidbook-publication'));
}
use Cubist\Backpack\Magic\Fields\Number;
use Cubist\Backpack\Magic\Fields\ReadOnlyValue;
use Cubist\Backpack\Magic\Fields\SelectFromArray;
+use Cubist\Backpack\Magic\Fields\Text;
use Cubist\Backpack\Magic\Fields\Textarea;
/**
public static function getDownloadVersions()
{
return [
- 'online' => ['label' => __('Version online - Version par défaut'), 'default' => true],
- 'sharepoint' => ['label' => __('Version Sharepoint - Version par défaut'), 'default' => false],
- 'scorm' => ['label' => __('Version SCORM - Version par défaut'), 'default' => false],
- 'win_inss_html' => ['label' => __('Version offline - Executable Windows'), 'default' => false],
- 'win_ins_html' => ['label' => __('Version offline - Installeur Auto-executable Windows'), 'default' => false],
- 'win_exe_html' => ['label' => __('Version offline - ZIP Windows'), 'default' => false],
- 'mac_exe_html' => ['label' => __('Version offline - Exécutable Mac OS X'), 'default' => false],
- 'win_cd_html' => ['label' => __('Version offline - CD-ROM / Clé USB'), 'default' => false],
- 'win_html' => ['label' => __('Version offline - HTML (Non adaptée à l\'installation sur un serveur web)'), 'default' => false],
- 'precompiled' => ['label' => __('Version precompilée'), 'default' => false],
+ 'online' => ['label' => __('Version online'), 'default' => true, 'install' => true],
+ 'sharepoint' => ['label' => __('Version Sharepoint'), 'default' => false, 'install' => false],
+ 'scorm' => ['label' => __('Version SCORM'), 'default' => false, 'install' => false],
+ 'win_inss_html' => ['label' => __('Version offline - Executable Windows'), 'default' => false, 'install' => false],
+ 'win_ins_html' => ['label' => __('Version offline - Installeur Auto-executable Windows'), 'default' => false, 'install' => false],
+ 'win_exe_html' => ['label' => __('Version offline - ZIP Windows'), 'default' => false, 'install' => false],
+ 'mac_exe_html' => ['label' => __('Version offline - Exécutable Mac OS X'), 'default' => false, 'install' => false],
+ 'win_cd_html' => ['label' => __('Version offline - CD-ROM / Clé USB'), 'default' => false, 'install' => false],
+ 'win_html' => ['label' => __('Version offline - HTML (Non adaptée à l\'installation sur un serveur web)'), 'default' => false, 'install' => false],
+ 'precompiled' => ['label' => __('Version precompilée'), 'default' => false, 'install' => false],
];
}
$this->addField('section_downloads', FormSection::class, $this->__('Versions disponibles au téléchargement'));
- foreach (self::getDownloadVersions() as $name=>$downloadVersion) {
- $this->addField('download_'.$name, Checkbox::class, $downloadVersion['label'], [
- 'v2' => json_encode(['type'=>'boolean','editable'=>true,'default'=>$downloadVersion['default'],'label'=>$downloadVersion['label'],'grade'=>3]),
+ foreach (self::getDownloadVersions() as $name => $downloadVersion) {
+ $this->addField('download_' . $name, Checkbox::class, $downloadVersion['label'], [
+ 'v2' => json_encode(['type' => 'boolean', 'editable' => true, 'default' => $downloadVersion['default'], 'label' => $downloadVersion['label'], 'grade' => 3]),
'default' => $downloadVersion['default'],
'fake' => true,
'store_in' => 'settings',
'translatable' => false,
]);
+ if ($downloadVersion['install']) {
+ $installFields = [
+ 'hosting' => ['prefix' => 'https://hosting.fluidbook.com/', 'label' => __('Chemin sur le serveur hosting'), 'hint' => null],
+ 'ftp' => ['prefix' => 'ftp://', 'label' => __('Chemin de connexion au serveur FTP'), 'hint' => __('username:password@host/path/to/install/folder')],
+ ];
+ foreach ($installFields as $iname => $installField) {
+ $this->addField('install_' . $name . '_' . $iname, Text::class, $installField['label'], ['default' => '', 'fake' => true, 'translatable' => false, 'store_in' => 'settings', 'prefix' => $installField['prefix'], 'hint' => $installField['hint'], 'when' => ['download_' . $name => 1]]);
+ }
+
+ }
}
$this->addField('section_elearning', FormSuperSection::class, __('E-Learning'));