From 5e23dc069e6ac05b845fc558e3af1d7b12437d0f Mon Sep 17 00:00:00 2001 From: Alex Cabal Date: Sun, 30 Dec 2018 18:23:58 -0600 Subject: [PATCH] Improve Open Graph data --- lib/Ebook.php | 8 +- templates/Header.php | 8 +- www/css/core.css | 2 +- www/ebooks/ebook.php | 2 +- www/images/logo-small.svg | 66 ++++++ www/images/logo.svg | 438 ++++++++++++++++++++++++++++++++------ 6 files changed, 457 insertions(+), 67 deletions(-) create mode 100644 www/images/logo-small.svg diff --git a/lib/Ebook.php b/lib/Ebook.php index cb5a4199..51f8c314 100644 --- a/lib/Ebook.php +++ b/lib/Ebook.php @@ -18,6 +18,7 @@ class Ebook{ public $HeroImage2xUrl; public $CoverImageUrl; public $CoverImage2xUrl; + public $DistCoverUrl; public $Title; public $FullTitle; public $Description; @@ -107,6 +108,11 @@ class Ebook{ $this->HasDownloads = $this->EpubUrl || $this->Epub3Url || $this->KepubUrl || $this->Azw3Url; + $tempPath = glob($this->WwwFilesystemPath . '/dist/cover.jpg'); + if(sizeof($tempPath) > 0){ + $this->DistCoverUrl = $this->Url . '/dist/' . basename($tempPath[0]); + } + // Fill in the short history of this repo. $historyEntries = explode("\n", shell_exec('cd ' . escapeshellarg($this->RepoFilesystemPath) . ' && git log -n5 --pretty=format:"%ct %s"')); @@ -353,7 +359,7 @@ class Ebook{ $output->publisher = $organizationObject; $output->name = $this->Title; - $output->image = SITE_URL . $this->Url . '/dist/cover.jpg'; + $output->image = SITE_URL . $this->DistCoverUrl; $output->thumbnailUrl = SITE_URL . $this->Url . '/dist/cover-thumbnail.jpg'; $output->url = SITE_URL . $this->Url; $output->{'@id'} = SITE_URL . $this->Url; diff --git a/templates/Header.php b/templates/Header.php index 8d4064dd..1fbd5cd4 100644 --- a/templates/Header.php +++ b/templates/Header.php @@ -38,10 +38,10 @@ if(!isset($js)){ - - - - + + + + diff --git a/www/css/core.css b/www/css/core.css index ebea037d..cb939075 100644 --- a/www/css/core.css +++ b/www/css/core.css @@ -873,7 +873,7 @@ footer p:last-child a{ footer p:last-child a::before{ content: ''; - background: url('/images/logo.svg'); + background: url('/images/logo-small.svg'); background-size: contain; background-repeat: no-repeat; display: block; diff --git a/www/ebooks/ebook.php b/www/ebooks/ebook.php index 90b1ae17..e32a7b72 100644 --- a/www/ebooks/ebook.php +++ b/www/ebooks/ebook.php @@ -53,7 +53,7 @@ catch(\Exception $ex){ include(SITE_ROOT . '/www/404.php'); exit(); } -?> strip_tags($ebook->TitleWithCreditsHtml), 'highlight' => 'ebooks', 'description' => 'The Standard Ebooks edition of ' . $ebook->Title . ': ' . $ebook->Description, 'jsonld' => $ebook->GenerateJsonLd()]) ?> +?> strip_tags($ebook->TitleWithCreditsHtml), 'ogType' => 'book', 'coverUrl' => $ebook->DistCoverUrl, 'highlight' => 'ebooks', 'description' => 'The Standard Ebooks edition of ' . $ebook->Title . ': ' . $ebook->Description, 'jsonld' => $ebook->GenerateJsonLd()]) ?>
diff --git a/www/images/logo-small.svg b/www/images/logo-small.svg new file mode 100644 index 00000000..9d45c16f --- /dev/null +++ b/www/images/logo-small.svg @@ -0,0 +1,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/www/images/logo.svg b/www/images/logo.svg index 9d45c16f..42680b73 100644 --- a/www/images/logo.svg +++ b/www/images/logo.svg @@ -1,66 +1,384 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - + + + + + - - + +