From e12308d3cc910f86d999329e85343fb9bd20b619 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Tue, 20 May 2014 19:20:07 +0200 Subject: [PATCH] Changed thumb to thumbnail for consistency --- data/config.ini | 30 ++++++------ scripts/generate-thumbs.php | 6 +-- src/Api/JobArgs/JobArgs.php | 2 +- src/Api/Jobs/PostJobs/AddPostJob.php | 2 +- src/Api/Jobs/PostJobs/EditPostJob.php | 2 +- ...tThumbJob.php => EditPostThumbnailJob.php} | 10 ++-- ...stThumbJob.php => GetPostThumbnailJob.php} | 10 ++-- src/Controllers/PostController.php | 10 ++-- src/Enums/Privilege.php | 4 +- src/Helpers/Assets.php | 10 ++-- src/Models/Entities/PostEntity.php | 48 +++++++++---------- src/Models/PostModel.php | 20 +++----- .../ImageGdThumbnailGenerator.php | 2 +- .../ImageImagickThumbnailGenerator.php | 2 +- src/Views/post/post-edit.phtml | 6 +-- src/Views/post/post-file-render.phtml | 4 +- src/Views/post/post-small.phtml | 2 +- src/Views/post/post-view.phtml | 2 +- src/core.php | 2 +- src/routes.php | 2 +- tests/SzurubooruTestRunner.php | 2 +- tests/Tests/ApiTests/ApiArgumentTest.php | 10 ++-- tests/Tests/ApiTests/ApiAuthTest.php | 4 +- .../ApiTests/ApiEmailRequirementsTest.php | 4 +- tests/Tests/ApiTests/ApiPrivilegeTest.php | 8 ++-- .../Tests/JobTests/EditPostContentJobTest.php | 8 ++-- ...bTest.php => EditPostThumbnailJobTest.php} | 26 +++++----- ...obTest.php => GetPostThumbnailJobTest.php} | 10 ++-- tests/config.ini | 18 +++---- 29 files changed, 130 insertions(+), 136 deletions(-) rename src/Api/Jobs/PostJobs/{EditPostThumbJob.php => EditPostThumbnailJob.php} (82%) rename src/Api/Jobs/PostJobs/{GetPostThumbJob.php => GetPostThumbnailJob.php} (83%) rename tests/Tests/JobTests/{EditPostThumbJobTest.php => EditPostThumbnailJobTest.php} (57%) rename tests/Tests/JobTests/{GetPostThumbJobTest.php => GetPostThumbnailJobTest.php} (83%) diff --git a/data/config.ini b/data/config.ini index 0e3e4310..b687fd54 100644 --- a/data/config.ini +++ b/data/config.ini @@ -1,14 +1,14 @@ [main] -dbDriver = "sqlite" -dbLocation = "./data/db.sqlite" -dbUser = "test" -dbPass = "test" -filesPath = "./data/files/" -thumbsPath = "./public_html/thumbs/" -logsPath = "./data/logs/{yyyy}-{mm}.log" -mediaPath = "./public_html/media/" -title = "szurubooru" -salt = "1A2/$_4xVa" +dbDriver = "sqlite" +dbLocation = "./data/db.sqlite" +dbUser = "test" +dbPass = "test" +filesPath = "./data/files/" +logsPath = "./data/logs/{yyyy}-{mm}.log" +mediaPath = "./public_html/media/" +thumbnailsPath = "./public_html/thumbs/" +title = "szurubooru" +salt = "1A2/$_4xVa" [misc] featuredPostMaxDays=7 @@ -31,9 +31,9 @@ postsPerPage=20 logsPerPage=250 tagsPerPage=100 tagsRelated=15 -thumbWidth=150 -thumbHeight=150 -thumbStyle=outside +thumbnailWidth=150 +thumbnailHeight=150 +thumbnailStyle=outside endlessScrollingDefault=1 showPostTagTitlesDefault=0 showDislikedPostsDefault=1 @@ -95,7 +95,7 @@ favoritePost=registered addPost=registered addPostSafety=registered addPostTags=registered -addPostThumb=power-user +addPostThumbnail=power-user addPostSource=registered addPostRelations=power-user addPostContent=registered @@ -104,7 +104,7 @@ editPost=registered editPostSafety.own=registered editPostSafety.all=moderator editPostTags=registered -editPostThumb=moderator +editPostThumbnail=moderator editPostSource=moderator editPostRelations.own=registered editPostRelations.all=moderator diff --git a/scripts/generate-thumbs.php b/scripts/generate-thumbs.php index b154c788..96dae4cb 100644 --- a/scripts/generate-thumbs.php +++ b/scripts/generate-thumbs.php @@ -13,8 +13,8 @@ foreach ($posts as $post) { ++ $i; printf('%s (%d/%d)' . PHP_EOL, TextHelper::reprPost($post), $i, $entityCount); - if (!$post->tryGetWorkingThumbPath()) - $post->generateThumb(); + if (!$post->tryGetWorkingThumbnailPath()) + $post->generateThumbnail(); } -echo 'Don\'t forget to check access rights.'; +echo 'Don\'t forget to check access rights.' . PHP_EOL; diff --git a/src/Api/JobArgs/JobArgs.php b/src/Api/JobArgs/JobArgs.php index 9c802bd4..b0316e1b 100644 --- a/src/Api/JobArgs/JobArgs.php +++ b/src/Api/JobArgs/JobArgs.php @@ -32,7 +32,7 @@ class JobArgs const ARG_NEW_RELATED_POST_IDS = 'new-related-post-ids'; const ARG_NEW_SAFETY = 'new-safety'; const ARG_NEW_SOURCE = 'new-source'; - const ARG_NEW_THUMB_CONTENT = 'new-thumb-content'; + const ARG_NEW_THUMBNAIL_CONTENT = 'new-thumbnail-content'; const ARG_NEW_TAG_NAMES = 'new-tag-names'; const ARG_NEW_ACCESS_RANK = 'new-access-rank'; diff --git a/src/Api/Jobs/PostJobs/AddPostJob.php b/src/Api/Jobs/PostJobs/AddPostJob.php index 27b2dc5b..4f7b2dcf 100644 --- a/src/Api/Jobs/PostJobs/AddPostJob.php +++ b/src/Api/Jobs/PostJobs/AddPostJob.php @@ -8,7 +8,7 @@ class AddPostJob extends AbstractJob $this->addSubJob(new EditPostSourceJob()); $this->addSubJob(new EditPostRelationsJob()); $this->addSubJob(new EditPostContentJob()); - $this->addSubJob(new EditPostThumbJob()); + $this->addSubJob(new EditPostThumbnailJob()); } public function execute() diff --git a/src/Api/Jobs/PostJobs/EditPostJob.php b/src/Api/Jobs/PostJobs/EditPostJob.php index 283ccb90..04ebf28f 100644 --- a/src/Api/Jobs/PostJobs/EditPostJob.php +++ b/src/Api/Jobs/PostJobs/EditPostJob.php @@ -11,7 +11,7 @@ class EditPostJob extends AbstractJob $this->addSubJob(new EditPostSourceJob()); $this->addSubJob(new EditPostRelationsJob()); $this->addSubJob(new EditPostContentJob()); - $this->addSubJob(new EditPostThumbJob()); + $this->addSubJob(new EditPostThumbnailJob()); } public function execute() diff --git a/src/Api/Jobs/PostJobs/EditPostThumbJob.php b/src/Api/Jobs/PostJobs/EditPostThumbnailJob.php similarity index 82% rename from src/Api/Jobs/PostJobs/EditPostThumbJob.php rename to src/Api/Jobs/PostJobs/EditPostThumbnailJob.php index ab57cff1..3afd5219 100644 --- a/src/Api/Jobs/PostJobs/EditPostThumbJob.php +++ b/src/Api/Jobs/PostJobs/EditPostThumbnailJob.php @@ -1,5 +1,5 @@ postRetriever->retrieve(); - $file = $this->getArgument(JobArgs::ARG_NEW_THUMB_CONTENT); + $file = $this->getArgument(JobArgs::ARG_NEW_THUMBNAIL_CONTENT); $post->setCustomThumbnailFromPath($file->filePath); @@ -29,14 +29,14 @@ class EditPostThumbJob extends AbstractJob { return JobArgs::Conjunction( $this->postRetriever->getRequiredArguments(), - JobArgs::ARG_NEW_THUMB_CONTENT); + JobArgs::ARG_NEW_THUMBNAIL_CONTENT); } public function getRequiredMainPrivilege() { return $this->getContext() == self::CONTEXT_BATCH_ADD - ? Privilege::AddPostThumb - : Privilege::EditPostThumb; + ? Privilege::AddPostThumbnail + : Privilege::EditPostThumbnail; } public function getRequiredSubPrivileges() diff --git a/src/Api/Jobs/PostJobs/GetPostThumbJob.php b/src/Api/Jobs/PostJobs/GetPostThumbnailJob.php similarity index 83% rename from src/Api/Jobs/PostJobs/GetPostThumbJob.php rename to src/Api/Jobs/PostJobs/GetPostThumbnailJob.php index 1298226d..63a1aa9d 100644 --- a/src/Api/Jobs/PostJobs/GetPostThumbJob.php +++ b/src/Api/Jobs/PostJobs/GetPostThumbnailJob.php @@ -1,5 +1,5 @@ getName(); } - $path = PostModel::tryGetWorkingThumbPath($name); + $path = PostModel::tryGetWorkingThumbnailPath($name); if (!$path) { $post = PostModel::getByName($name); $post = $this->postRetriever->retrieve(); - $post->generateThumb(); - $path = PostModel::tryGetWorkingThumbPath($name); + $post->generateThumbnail(); + $path = PostModel::tryGetWorkingThumbnailPath($name); if (!$path) { - $path = Core::getConfig()->main->mediaPath . DS . 'img' . DS . 'thumb.jpg'; + $path = Core::getConfig()->main->mediaPath . DS . 'img' . DS . 'thumbnail.jpg'; $path = TextHelper::absolutePath($path); } } diff --git a/src/Controllers/PostController.php b/src/Controllers/PostController.php index 97995fa7..6537d503 100644 --- a/src/Controllers/PostController.php +++ b/src/Controllers/PostController.php @@ -186,12 +186,12 @@ class PostController extends AbstractController $file['name']); } - if (!empty($_FILES['thumb']['name'])) + if (!empty($_FILES['thumbnail']['name'])) { - $file = $_FILES['thumb']; + $file = $_FILES['thumbnail']; TransferHelper::handleUploadErrors($file); - $jobArgs[JobArgs::ARG_NEW_THUMB_CONTENT] = new ApiFileInput( + $jobArgs[JobArgs::ARG_NEW_THUMBNAIL_CONTENT] = new ApiFileInput( $file['tmp_name'], $file['name']); } @@ -321,9 +321,9 @@ class PostController extends AbstractController $this->renderFile(); } - public function thumbView($name) + public function thumbnailView($name) { - $ret = Api::run(new GetPostThumbJob(), [JobArgs::ARG_POST_NAME => $name]); + $ret = Api::run(new GetPostThumbnailJob(), [JobArgs::ARG_POST_NAME => $name]); $context = Core::getContext(); $context->transport->cacheDaysToLive = 365; diff --git a/src/Enums/Privilege.php b/src/Enums/Privilege.php index 478ba8fd..4060f92f 100644 --- a/src/Enums/Privilege.php +++ b/src/Enums/Privilege.php @@ -14,7 +14,7 @@ class Privilege extends AbstractEnum implements IEnum const EditPost = 'editPost'; const EditPostSafety = 'editPostSafety'; const EditPostTags = 'editPostTags'; - const EditPostThumb = 'editPostThumb'; + const EditPostThumbnail = 'editPostThumbnail'; const EditPostSource = 'editPostSource'; const EditPostRelations = 'editPostRelations'; const EditPostContent = 'editPostContent'; @@ -22,7 +22,7 @@ class Privilege extends AbstractEnum implements IEnum const AddPost = 'addPost'; const AddPostSafety = 'addPostSafety'; const AddPostTags = 'addPostTags'; - const AddPostThumb = 'addPostThumb'; + const AddPostThumbnail = 'addPostThumbnail'; const AddPostSource = 'addPostSource'; const AddPostRelations = 'addPostRelations'; const AddPostContent = 'addPostContent'; diff --git a/src/Helpers/Assets.php b/src/Helpers/Assets.php index 1a798740..1ad80c0d 100644 --- a/src/Helpers/Assets.php +++ b/src/Helpers/Assets.php @@ -1,7 +1,7 @@ subTitle = $text; } - public function setPageThumb($path) + public function setPageThumbnail($path) { - $this->pageThumb = $path; + $this->pageThumbnail = $path; } public function addStylesheet($path) @@ -34,8 +34,8 @@ class Assets extends \Chibi\Util\Assets $headSnippet = ''; $headSnippet .= ''; - if (!empty($this->pageThumb)) - $headSnippet .= ''; + if (!empty($this->pageThumbnail)) + $headSnippet .= ''; $bodySnippet = '