$dim = SocialImage::getSocialImageSize($this->getFluidbook());
if ($dim) {
- $socialImage = backpack_url('services/socialimage/' . $this->getFluidbook()->cid . '/' . time());
+ $socialImage = SocialImage::socialImageURL($this->getFluidbook()->cid);
$socialImageWidth = $dim[0];
$socialImageHeight = $dim[1];
}
}
- protected function writeWidget()
- {
- // Write widget html
-// if ($this->widget) {
-// $whtml = file_get_contents($this->assets . '/widget.html');
-// $script = '<script type="text/javascript" charset="utf-8" src="data/datas.js"></script>';
-// $script .= '<script type="text/javascript" charset="utf-8" src="data/widget.js"></script>';
-//
-// $style = '<link type="text/css" rel="stylesheet" href="style/widget.css">';
-// $vars = array('titre', 'style', 'script');
-// foreach ($vars as $v) {
-// if (isset($$v)) {
-// $whtml = str_replace('<!-- $' . $v . ' -->', $$v, $whtml);
-// } else {
-// $whtml = str_replace('<!-- $' . $v . ' -->', '', $whtml);
-// }
-// }
-// $this->vdir->file_put_contents('widget.html', $whtml);
-// }
- }
-
function writeSEO()
{
foreach ($this->seoArticles as $seoArticle) {
}
$a = $seoArticle;
unset($a['image']);
- $a['imageurl'] = 'https://workshop.fluidbook.com/services/facebook_thumbnail?cid=' . $this->getFluidbook()->cid . '&j=' . time();
- if ($seoArticle['image']) {
- $a['imageurl'] .= '&image=' . $seoArticle['image'];
+ $a['imageurl'] = SocialImage::socialImageURL($this->getFluidbook()->cid, $seoArticle['image']);
+ $dim = SocialImage::getSocialImageSize($this->getFluidbook(), $seoArticle['image']);
+ if (null !== $dim) {
+ $a['imagewidth'] = $dim[0];
+ $a['imageheight'] = $dim[1];
}
- $dim = Image::getimagesize($a['imageurl']);
- $a['imagewidth'] = $dim[0];
- $a['imageheight'] = $dim[1];
foreach ($a as $k => $v) {
$html = str_replace('$' . $k, $v, $html);
}
if (!$this->canonical) {
$this->canonical = $this->getURL();
}
- if (!$this->next && isset($this->_container->pages[$this->page + 1]) && $this->_container->pages[$this->page + 1] instanceof wsHTML5SeoPage) {
+ if (!$this->next && isset($this->_container->pages[$this->page + 1]) && $this->_container->pages[$this->page + 1] instanceof Page) {
$this->next = $this->_container->pages[$this->page + 1]->getURL();
}
- if (!$this->prev && isset($this->_container->pages[$this->page - 1]) && $this->_container->pages[$this->page - 1] instanceof wsHTML5SeoPage) {
+ if (!$this->prev && isset($this->_container->pages[$this->page - 1]) && $this->_container->pages[$this->page - 1] instanceof Page) {
$this->prev = $this->_container->pages[$this->page - 1]->getURL();
}
* @return array
* @throws \Exception
*/
- public static function getSocialImageSize($fluidbook)
+ public static function getSocialImageSize($fluidbook, $image=null)
{
- $socialImage = self::socialImagePath($fluidbook->id);
+ $socialImage = self::socialImagePath($fluidbook->id,$image);
if (!file_exists($socialImage)) {
return null;
}
{
return Files::mkdir(protected_path('fluidbookpublication/socialimage')) . $id . '.' . $ext;
}
+
+ public static function socialImageURL($cid, $image = null)
+ {
+ return backpack_url('services/socialimage/' . $cid . '/' . time() . ($image !== null ? '/' . $image : ''));
+ }
}
protected function setupSocialimageRoutes($segment, $routeName, $controller)
{
foreach (['services', 's'] as $segment) {
- Route::match(['get'], $segment . '/socialimage/{cid?}/{time?}', $controller . '@socialImage')->withoutMiddleware([CheckIfAdmin::class])->name('social_image');
+ Route::match(['get'], $segment . '/socialimage/{cid?}/{time?}/{image?}', $controller . '@socialImage')->withoutMiddleware([CheckIfAdmin::class])->name('social_image');
Route::match(['get'], $segment . '/socialimage', $controller . '@ws2SocialImage')->withoutMiddleware([CheckIfAdmin::class]);
Route::match(['get'], $segment . '/facebook_thumbnail', $controller . '@ws2SocialImage')->withoutMiddleware([CheckIfAdmin::class]);
}
abort(404);
}
- public function socialImage($cid = null, $time = null)
+ public function socialImage($cid = null, $time = null, $image = null)
{
$publication = FluidbookPublication::where('cid', $cid)->first();
if (null === $publication) {
abort(404);
}
- return $this->_socialImage($publication);
+ return $this->_socialImage($publication, $image);
}
/**