From 60f0ea16cb38e052418f30492c8d7b755ff49b55 Mon Sep 17 00:00:00 2001 From: Alex Cabal Date: Mon, 4 Nov 2024 13:31:17 -0600 Subject: [PATCH] Formatting tweaks --- www/ebooks/ebook.php | 115 ++++++++++++++++++++++++------------------- 1 file changed, 65 insertions(+), 50 deletions(-) diff --git a/www/ebooks/ebook.php b/www/ebooks/ebook.php index 3a33378b..93190d90 100644 --- a/www/ebooks/ebook.php +++ b/www/ebooks/ebook.php @@ -1,5 +1,5 @@ for RDFa metadata details. use Safe\DateTimeImmutable; use function Safe\preg_match; @@ -15,24 +15,23 @@ $carouselTag = null; $targetCarouselSize = 5; try{ - $urlPath = trim(str_replace('.', '', HttpInput::Str(GET, 'url-path') ?? ''), '/'); // Contains the portion of the URL (without query string) that comes after https://standardebooks.org/ebooks/ - $wwwFilesystemPath = EBOOKS_DIST_PATH . $urlPath; // Path to the deployed WWW files for this ebook + $urlPath = trim(str_replace('.', '', HttpInput::Str(GET, 'url-path') ?? ''), '/'); // Contains the portion of the URL (without query string) that comes after `https://standardebooks.org/ebooks/`. + $wwwFilesystemPath = EBOOKS_DIST_PATH . $urlPath; // Path to the deployed WWW files for this ebook. if($urlPath == '' || mb_stripos($wwwFilesystemPath, EBOOKS_DIST_PATH) !== 0){ - // Ensure the path exists and that the root is in our www directory + // Ensure the path exists and that the root is in our www directory. throw new Exceptions\EbookNotFoundException(); } + // Were we passed the author and a work but not the translator? - // For example: - // https://standardebooks.org/ebooks/omar-khayyam/the-rubaiyat-of-omar-khayyam - // Instead of: - // https://standardebooks.org/ebooks/omar-khayyam/the-rubaiyat-of-omar-khayyam/edward-fitzgerald/edmund-dulac - // We can tell because if so, the dir we are passed will exist, but there will be no 'src' folder. + // For example: + // Instead of: . + // We can tell because if so, the dir we are passed will exist, but there will be no `src` folder. if(is_dir($wwwFilesystemPath) && !is_dir($wwwFilesystemPath . '/src')){ /** @var DirectoryIterator $file */ foreach(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($wwwFilesystemPath)) as $file){ - // This iterator will do a deep scan on the directory. When we hit another directory, the filename will be "." and the path will contain the directory path. - // We want to find where the "src" directory is, and the directory directly below that will be the final web URL we're looking for. + // This iterator will do a deep scan on the directory. When we hit another directory, the filename will be `.` and the path will contain the directory path. + // We want to find where the `src` directory is, and the directory directly below that will be the final web URL we're looking for. if($file->getFilename() == '.' && preg_match('|/src$|ius', $file->getPath())){ throw new Exceptions\SeeOtherEbookException(preg_replace(['|' . WEB_ROOT . '|ius', '|/src$|ius'], '', $file->getPath())); } @@ -42,7 +41,7 @@ try{ $identifier = EBOOKS_IDENTIFIER_PREFIX . $urlPath; $ebook = Ebook::GetByIdentifier($identifier); - // Divide our sources into transcriptions and scans + // Divide our sources into transcriptions and scans. foreach($ebook->Sources as $source){ switch($source->Type){ case EbookSourceType::ProjectGutenberg: @@ -94,15 +93,16 @@ catch(Exceptions\EbookNotFoundException){ For example, William Wordsworth & Samuel Coleridge will both link to /ebooks/william-wordsworth_samuel-taylor-coleridge But, each author is an individual, so we have to differentiate them in RDFa with `resource` */ ?> Name != 'Anonymous'){ ?> -

- Name) ?> - - NacoafUrl){ ?> - - - WikipediaUrl){ ?> - - +

+ + Name) ?> + + NacoafUrl){ ?> + + + WikipediaUrl){ ?> + +

@@ -127,18 +127,25 @@ catch(Exceptions\EbookNotFoundException){ CollectionMemberships as $collectionMembership){ ?> Collection; ?> SequenceNumber; ?> -

in thePart of the Name)) ?> - Type !== null){ ?> - Name), mb_strtolower($collection->Type->value), -strlen(mb_strtolower($collection->Type->value))) !== 0){ ?> - Type->value ?>. +

+ in thePart of the Name)) ?> + Type !== null){ ?> + Name), mb_strtolower($collection->Type->value), -strlen(mb_strtolower($collection->Type->value))) !== 0){ ?> + Type->value ?>. + + + collection. - - collection. -

- +
    + Tags as $tag){ ?> +
  • + Name) ?> +
  • + +
@@ -149,7 +156,9 @@ catch(Exceptions\EbookNotFoundException){ LongDescription === null){ ?> -

There’s no description for this ebook yet.

+

+ There’s no description for this ebook yet. +

LongDescription ?> @@ -277,7 +286,9 @@ catch(Exceptions\EbookNotFoundException){ GitCommits as $commit){ ?>
  • -

    Message) ?>

    +

    + Message) ?> +

  • @@ -294,12 +305,16 @@ catch(Exceptions\EbookNotFoundException){ @@ -314,23 +329,23 @@ catch(Exceptions\EbookNotFoundException){

    Transcriptions