diff --git a/lib/Ebook.php b/lib/Ebook.php index 0758cea3..715d8db5 100644 --- a/lib/Ebook.php +++ b/lib/Ebook.php @@ -1,6 +1,7 @@ use Safe\DateTime; use function Safe\file_get_contents; +use function Safe\filesize; use function Safe\json_encode; use function Safe\glob; use function Safe\preg_match; @@ -57,6 +58,8 @@ class Ebook{ public $Updated; public $TextUrl; public $TextSinglePageUrl; + public $TextSinglePageSizeNumber = null; + public $TextSinglePageSizeUnit = null; public $TocEntries = null; // A list of non-Roman ToC entries ONLY IF the work has the 'se:is-a-collection' metadata element, null otherwise public function __construct(?string $wwwFilesystemPath = null){ @@ -100,10 +103,18 @@ class Ebook{ $this->TextUrl = $this->Url . '/text'; - $tempPath = glob($this->WwwFilesystemPath . '/text/single-page.xhtml'); - if(sizeof($tempPath) > 0){ + try{ + $bytes = filesize($this->WwwFilesystemPath . '/text/single-page.xhtml'); + $sizes = 'BKMGTP'; + $factor = floor((strlen($bytes) - 1) / 3); + $this->TextSinglePageSizeNumber = sprintf('%.1f', $bytes / pow(1024, $factor)); + $this->TextSinglePageSizeUnit = $sizes[$factor] ?? ''; $this->TextSinglePageUrl = $this->Url . '/text/single-page'; } + catch(Exception $ex){ + // Single page file doesn't exist, just pass + } + // Generate the Kindle cover URL. $tempPath = glob($this->WwwFilesystemPath . '/downloads/*_EBOK_portrait.jpg'); diff --git a/www/css/core.css b/www/css/core.css index b720722f..284712e4 100644 --- a/www/css/core.css +++ b/www/css/core.css @@ -64,6 +64,7 @@ --light-input-border: #777; --light-input-outline: #000; --light-table-row-hover: #dddbd5; + --light-warning: #932d2d; --dark-body-bg: #2c3035; --dark-body-text: #fff; @@ -76,6 +77,7 @@ --dark-input-hover: #118460; --dark-input-outline: #fff; --dark-table-row-hover: #373b3f; + --dark-warning: #ec6161; --body-text: var(--light-body-text); --header: var(--light-header); @@ -90,6 +92,7 @@ --input-outline: var(--light-input-outline); --link-highlight: var(--button); --table-row-hover: var(--light-table-row-hover); + --warning: var(--light-warning); } /* Start CSS reset */ @@ -1141,9 +1144,6 @@ article.ebook #more-ebooks li:nth-child(4) img{ height: 180px; } -article.ebook #more-ebooks li:nth-child(3) img{ -} - time{ color: var(--sub-text); margin-right: 15px; @@ -2757,6 +2757,24 @@ aside button.close:active{ transition: transform .5s; } +article.ebook section#read-online ul li p.has-size{ + display: flex; +} + +article.ebook section#read-online ul li p.has-size span{ + color: var(--warning); + border: 1px solid var(--warning); + border-radius: 5px; + padding: .25rem .5rem; + margin-left: .5rem; +} + +article.ebook section#read-online ul li p.has-size span::before{ + content: "\f071"; + font-family: "Fork Awesome"; + margin-right: .25rem; +} + ul.feed p{ margin: 0; } diff --git a/www/css/dark.css b/www/css/dark.css index 8e4f12cc..222084ae 100644 --- a/www/css/dark.css +++ b/www/css/dark.css @@ -11,6 +11,7 @@ --input-outline: var(--dark-input-outline); --link-highlight: var(--button-highlight); /* lighter looks better in dark mode */ --table-row-hover: var(--dark-table-row-hover); + --warning: var(--dark-warning); } main.front-page > section > section figure img{ diff --git a/www/ebooks/ebook.php b/www/ebooks/ebook.php index 7ab1c64b..257b065b 100644 --- a/www/ebooks/ebook.php +++ b/www/ebooks/ebook.php @@ -281,8 +281,8 @@ catch(Exceptions\InvalidEbookException $ex){
- Read on one page +
TextSinglePageSizeNumber >= 3 && $ebook->TextSinglePageSizeUnit == 'M'){ ?> class="has-size" } ?>> + Read on one page if($ebook->TextSinglePageSizeNumber >= 3 && $ebook->TextSinglePageSizeUnit == 'M'){ ?>= $ebook->TextSinglePageSizeNumber ?>MB } ?>