]> _ Git - fluidbook-toolbox.git/commitdiff
wip #5898
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 28 Jun 2023 08:01:19 +0000 (10:01 +0200)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Wed, 28 Jun 2023 08:01:19 +0000 (10:01 +0200)
app/Fluidbook/Compiler/Secure.php
app/Fluidbook/SocialImage.php
app/Http/Controllers/Admin/Operations/FluidbookPublication/PreviewOperation.php
resources/fluidbookpublication/social_screenshot/social_screenshot.js

index 4f88caa1a99f984a545e3da75c70b22af66e8edc..e21c25f3ebcedcb14975a794399ca0740525a957 100644 (file)
@@ -79,7 +79,8 @@ trait Secure
 
         $l10n = $this->getFluidbook()->getTranslations();
 
-        $locale = $this->fluidbookSettings->secureClientSideLocale === 'fluidbook' ? $l10n['default'] : $l10n[$this->fluidbookSettings->secureClientSideLocale];
+        $secureLocale = $this->fluidbookSettings->secureClientSideLocale ?: 'default';
+        $locale = $this->fluidbookSettings->secureClientSideLocale === 'fluidbook' ? $l10n['default'] : $l10n[$secureLocale];
         $variables['FORM_USERNAME'] = $locale['Username'] ?? 'Username';
         $variables['FORM_PASSWORD'] = $locale['Password'] ?? 'Password';
         $variables['FORM_SIGN_IN'] = $locale['Sign in'] ?? 'Sign in';
@@ -111,7 +112,7 @@ trait Secure
             });
         });';
         $variables['CSS'] = $this->fluidbookSettings->secureClientSideStyles;
-
+        $this->fluidbookSettings->secureClientSideFont = $this->fluidbookSettings->secureClientSideFont ?: 'OpenSans';
         $this->addFontKit($this->fluidbookSettings->secureClientSideFont);
         $variables['FONT'] = $this->fluidbookSettings->secureClientSideFont;
         $variables['LINKS'] .= '<link rel="stylesheet" href="style/fonts/' . $this->fluidbookSettings->secureClientSideFont . '/font.css">';
index 7a11b3b75f13c26a31da437e79e158a82db2f378..d9a8f79610df171b771c160ffa89cb886dd2cefc 100644 (file)
@@ -46,13 +46,17 @@ class SocialImage
                     $cl->setArg(null, resource_path('fluidbookpublication/social_screenshot/social_screenshot.js'));
                     $cl->setArg('width', $w);
                     $cl->setArg('height', $h);
-                    $cl->setArg('delay', 2);
+                    $cl->setArg('delay', 10);
                     $cl->setArg('scale', 0.5);
                     $cl->setArg('dest', $res);
                     $cl->setArg('url', '"' . $url . '"');
                     $cl->execute();
                     unlink($lock);
 
+                    if (!file_exists($res)) {
+                        $cl->dd();
+                    }
+
                     self::getSocialImageSize($fluidbook);
                 }
             }
index c604d5d080db1f3d5151e64bb77eb99e21755c77..0d81c9a19509d0d37333180ded7b6cd053d2ef47 100644 (file)
@@ -46,7 +46,7 @@ trait PreviewOperation
 
     protected function _preview($segment, $version, $id, $hash, $time = null, $path = null)
     {
-        PHP::neverStop(false);
+        PHP::neverStop(true);
         $q = request()->getQueryString();
         if ($q) {
             $q = '?' . $q;
index 20954d803bf888abdf5c1cbe2bf84514e8cf6425..5385dd2a2bf34f402501203c0495603684032b63 100644 (file)
@@ -18,6 +18,7 @@ const optionDefinitions = [
             "--no-sandbox",
         ],
         executablePath: 'google-chrome-stable',
+        protocolTimeout: 1800000,
     });
     const page = await browser.newPage();
     page.on('console', msg => console.log('PAGE LOG:', msg));
@@ -27,8 +28,10 @@ const optionDefinitions = [
         deviceScaleFactor: options.scale,
     });
     await page.setDefaultNavigationTimeout(0);
-    await page.goto(options.url, {waitUntil: 'networkidle2'});
-    await new Promise(r => setTimeout(r, 1000 * options.delay));
-    await page.screenshot({path: options.dest, type: 'jpeg', quality: 95});
+    const response = await page.goto(options.url, {waitUntil: 'networkidle2', timeout: 0});
+    if (response.status() === 200) {
+        await new Promise(r => setTimeout(r, 1000 * options.delay));
+        await page.screenshot({path: options.dest, type: 'jpeg', quality: 95});
+    }
     await browser.close();
 })();