Changed thumb to thumbnail for consistency

This commit is contained in:
Marcin Kurczewski 2014-05-20 19:20:07 +02:00
parent 65e909d053
commit e12308d3cc
29 changed files with 130 additions and 136 deletions

View file

@ -1,14 +1,14 @@
[main] [main]
dbDriver = "sqlite" dbDriver = "sqlite"
dbLocation = "./data/db.sqlite" dbLocation = "./data/db.sqlite"
dbUser = "test" dbUser = "test"
dbPass = "test" dbPass = "test"
filesPath = "./data/files/" filesPath = "./data/files/"
thumbsPath = "./public_html/thumbs/" logsPath = "./data/logs/{yyyy}-{mm}.log"
logsPath = "./data/logs/{yyyy}-{mm}.log" mediaPath = "./public_html/media/"
mediaPath = "./public_html/media/" thumbnailsPath = "./public_html/thumbs/"
title = "szurubooru" title = "szurubooru"
salt = "1A2/$_4xVa" salt = "1A2/$_4xVa"
[misc] [misc]
featuredPostMaxDays=7 featuredPostMaxDays=7
@ -31,9 +31,9 @@ postsPerPage=20
logsPerPage=250 logsPerPage=250
tagsPerPage=100 tagsPerPage=100
tagsRelated=15 tagsRelated=15
thumbWidth=150 thumbnailWidth=150
thumbHeight=150 thumbnailHeight=150
thumbStyle=outside thumbnailStyle=outside
endlessScrollingDefault=1 endlessScrollingDefault=1
showPostTagTitlesDefault=0 showPostTagTitlesDefault=0
showDislikedPostsDefault=1 showDislikedPostsDefault=1
@ -95,7 +95,7 @@ favoritePost=registered
addPost=registered addPost=registered
addPostSafety=registered addPostSafety=registered
addPostTags=registered addPostTags=registered
addPostThumb=power-user addPostThumbnail=power-user
addPostSource=registered addPostSource=registered
addPostRelations=power-user addPostRelations=power-user
addPostContent=registered addPostContent=registered
@ -104,7 +104,7 @@ editPost=registered
editPostSafety.own=registered editPostSafety.own=registered
editPostSafety.all=moderator editPostSafety.all=moderator
editPostTags=registered editPostTags=registered
editPostThumb=moderator editPostThumbnail=moderator
editPostSource=moderator editPostSource=moderator
editPostRelations.own=registered editPostRelations.own=registered
editPostRelations.all=moderator editPostRelations.all=moderator

View file

@ -13,8 +13,8 @@ foreach ($posts as $post)
{ {
++ $i; ++ $i;
printf('%s (%d/%d)' . PHP_EOL, TextHelper::reprPost($post), $i, $entityCount); printf('%s (%d/%d)' . PHP_EOL, TextHelper::reprPost($post), $i, $entityCount);
if (!$post->tryGetWorkingThumbPath()) if (!$post->tryGetWorkingThumbnailPath())
$post->generateThumb(); $post->generateThumbnail();
} }
echo 'Don\'t forget to check access rights.'; echo 'Don\'t forget to check access rights.' . PHP_EOL;

View file

@ -32,7 +32,7 @@ class JobArgs
const ARG_NEW_RELATED_POST_IDS = 'new-related-post-ids'; const ARG_NEW_RELATED_POST_IDS = 'new-related-post-ids';
const ARG_NEW_SAFETY = 'new-safety'; const ARG_NEW_SAFETY = 'new-safety';
const ARG_NEW_SOURCE = 'new-source'; 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_TAG_NAMES = 'new-tag-names';
const ARG_NEW_ACCESS_RANK = 'new-access-rank'; const ARG_NEW_ACCESS_RANK = 'new-access-rank';

View file

@ -8,7 +8,7 @@ class AddPostJob extends AbstractJob
$this->addSubJob(new EditPostSourceJob()); $this->addSubJob(new EditPostSourceJob());
$this->addSubJob(new EditPostRelationsJob()); $this->addSubJob(new EditPostRelationsJob());
$this->addSubJob(new EditPostContentJob()); $this->addSubJob(new EditPostContentJob());
$this->addSubJob(new EditPostThumbJob()); $this->addSubJob(new EditPostThumbnailJob());
} }
public function execute() public function execute()

View file

@ -11,7 +11,7 @@ class EditPostJob extends AbstractJob
$this->addSubJob(new EditPostSourceJob()); $this->addSubJob(new EditPostSourceJob());
$this->addSubJob(new EditPostRelationsJob()); $this->addSubJob(new EditPostRelationsJob());
$this->addSubJob(new EditPostContentJob()); $this->addSubJob(new EditPostContentJob());
$this->addSubJob(new EditPostThumbJob()); $this->addSubJob(new EditPostThumbnailJob());
} }
public function execute() public function execute()

View file

@ -1,5 +1,5 @@
<?php <?php
class EditPostThumbJob extends AbstractJob class EditPostThumbnailJob extends AbstractJob
{ {
protected $postRetriever; protected $postRetriever;
@ -11,7 +11,7 @@ class EditPostThumbJob extends AbstractJob
public function execute() public function execute()
{ {
$post = $this->postRetriever->retrieve(); $post = $this->postRetriever->retrieve();
$file = $this->getArgument(JobArgs::ARG_NEW_THUMB_CONTENT); $file = $this->getArgument(JobArgs::ARG_NEW_THUMBNAIL_CONTENT);
$post->setCustomThumbnailFromPath($file->filePath); $post->setCustomThumbnailFromPath($file->filePath);
@ -29,14 +29,14 @@ class EditPostThumbJob extends AbstractJob
{ {
return JobArgs::Conjunction( return JobArgs::Conjunction(
$this->postRetriever->getRequiredArguments(), $this->postRetriever->getRequiredArguments(),
JobArgs::ARG_NEW_THUMB_CONTENT); JobArgs::ARG_NEW_THUMBNAIL_CONTENT);
} }
public function getRequiredMainPrivilege() public function getRequiredMainPrivilege()
{ {
return $this->getContext() == self::CONTEXT_BATCH_ADD return $this->getContext() == self::CONTEXT_BATCH_ADD
? Privilege::AddPostThumb ? Privilege::AddPostThumbnail
: Privilege::EditPostThumb; : Privilege::EditPostThumbnail;
} }
public function getRequiredSubPrivileges() public function getRequiredSubPrivileges()

View file

@ -1,5 +1,5 @@
<?php <?php
class GetPostThumbJob extends AbstractJob class GetPostThumbnailJob extends AbstractJob
{ {
protected $postRetriever; protected $postRetriever;
@ -19,18 +19,18 @@ class GetPostThumbJob extends AbstractJob
$name = $post->getName(); $name = $post->getName();
} }
$path = PostModel::tryGetWorkingThumbPath($name); $path = PostModel::tryGetWorkingThumbnailPath($name);
if (!$path) if (!$path)
{ {
$post = PostModel::getByName($name); $post = PostModel::getByName($name);
$post = $this->postRetriever->retrieve(); $post = $this->postRetriever->retrieve();
$post->generateThumb(); $post->generateThumbnail();
$path = PostModel::tryGetWorkingThumbPath($name); $path = PostModel::tryGetWorkingThumbnailPath($name);
if (!$path) 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); $path = TextHelper::absolutePath($path);
} }
} }

View file

@ -186,12 +186,12 @@ class PostController extends AbstractController
$file['name']); $file['name']);
} }
if (!empty($_FILES['thumb']['name'])) if (!empty($_FILES['thumbnail']['name']))
{ {
$file = $_FILES['thumb']; $file = $_FILES['thumbnail'];
TransferHelper::handleUploadErrors($file); TransferHelper::handleUploadErrors($file);
$jobArgs[JobArgs::ARG_NEW_THUMB_CONTENT] = new ApiFileInput( $jobArgs[JobArgs::ARG_NEW_THUMBNAIL_CONTENT] = new ApiFileInput(
$file['tmp_name'], $file['tmp_name'],
$file['name']); $file['name']);
} }
@ -321,9 +321,9 @@ class PostController extends AbstractController
$this->renderFile(); $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 = Core::getContext();
$context->transport->cacheDaysToLive = 365; $context->transport->cacheDaysToLive = 365;

View file

@ -14,7 +14,7 @@ class Privilege extends AbstractEnum implements IEnum
const EditPost = 'editPost'; const EditPost = 'editPost';
const EditPostSafety = 'editPostSafety'; const EditPostSafety = 'editPostSafety';
const EditPostTags = 'editPostTags'; const EditPostTags = 'editPostTags';
const EditPostThumb = 'editPostThumb'; const EditPostThumbnail = 'editPostThumbnail';
const EditPostSource = 'editPostSource'; const EditPostSource = 'editPostSource';
const EditPostRelations = 'editPostRelations'; const EditPostRelations = 'editPostRelations';
const EditPostContent = 'editPostContent'; const EditPostContent = 'editPostContent';
@ -22,7 +22,7 @@ class Privilege extends AbstractEnum implements IEnum
const AddPost = 'addPost'; const AddPost = 'addPost';
const AddPostSafety = 'addPostSafety'; const AddPostSafety = 'addPostSafety';
const AddPostTags = 'addPostTags'; const AddPostTags = 'addPostTags';
const AddPostThumb = 'addPostThumb'; const AddPostThumbnail = 'addPostThumbnail';
const AddPostSource = 'addPostSource'; const AddPostSource = 'addPostSource';
const AddPostRelations = 'addPostRelations'; const AddPostRelations = 'addPostRelations';
const AddPostContent = 'addPostContent'; const AddPostContent = 'addPostContent';

View file

@ -1,7 +1,7 @@
<?php <?php
class Assets extends \Chibi\Util\Assets class Assets extends \Chibi\Util\Assets
{ {
private $pageThumb = null; private $pageThumbnail = null;
private $subTitle = null; private $subTitle = null;
public function setSubTitle($text) public function setSubTitle($text)
@ -9,9 +9,9 @@ class Assets extends \Chibi\Util\Assets
$this->subTitle = $text; $this->subTitle = $text;
} }
public function setPageThumb($path) public function setPageThumbnail($path)
{ {
$this->pageThumb = $path; $this->pageThumbnail = $path;
} }
public function addStylesheet($path) public function addStylesheet($path)
@ -34,8 +34,8 @@ class Assets extends \Chibi\Util\Assets
$headSnippet = '<meta property="og:title" content="' . $this->title . '"/>'; $headSnippet = '<meta property="og:title" content="' . $this->title . '"/>';
$headSnippet .= '<meta property="og:url" content="' . \Chibi\Util\Url::currentUrl() . '"/>'; $headSnippet .= '<meta property="og:url" content="' . \Chibi\Util\Url::currentUrl() . '"/>';
if (!empty($this->pageThumb)) if (!empty($this->pageThumbnail))
$headSnippet .= '<meta property="og:image" content="' . $this->pageThumb . '"/>'; $headSnippet .= '<meta property="og:image" content="' . $this->pageThumbnail . '"/>';
$bodySnippet = '<script type="text/javascript">'; $bodySnippet = '<script type="text/javascript">';
$bodySnippet .= '$(function() {'; $bodySnippet .= '$(function() {';

View file

@ -351,25 +351,25 @@ final class PostEntity extends AbstractEntity implements IValidatable, ISerializ
return PostModel::getFullPath($this->getName()); return PostModel::getFullPath($this->getName());
} }
public function tryGetWorkingThumbPath() public function tryGetWorkingThumbnailPath()
{ {
return PostModel::tryGetWorkingThumbPath($this->getName()); return PostModel::tryGetWorkingThumbnailPath($this->getName());
} }
public function getThumbCustomSourcePath() public function getCustomThumbnailSourcePath()
{ {
return PostModel::getThumbCustomSourcePath($this->getName()); return PostModel::getCustomThumbnailSourcePath($this->getName());
} }
public function getThumbPath() public function getThumbnailPath()
{ {
return PostModel::getThumbPath($this->getName()); return PostModel::getThumbnailPath($this->getName());
} }
public function hasCustomThumb() public function hasCustomThumbnail()
{ {
$thumbPath = $this->getThumbCustomSourcePath(); $thumbnailPath = $this->getCustomThumbnailSourcePath();
return file_exists($thumbPath); return file_exists($thumbnailPath);
} }
public function setCustomThumbnailFromPath($srcPath) public function setCustomThumbnailFromPath($srcPath)
@ -378,27 +378,27 @@ final class PostEntity extends AbstractEntity implements IValidatable, ISerializ
$mimeType = mime_content_type($srcPath); $mimeType = mime_content_type($srcPath);
if (!in_array($mimeType, ['image/gif', 'image/png', 'image/jpeg'])) if (!in_array($mimeType, ['image/gif', 'image/png', 'image/jpeg']))
throw new SimpleException('Invalid thumbnail type "%s"', $mimeType); throw new SimpleException('Invalid file type "%s"', $mimeType);
$dstPath = $this->getThumbCustomSourcePath(); $dstPath = $this->getCustomThumbnailSourcePath();
TransferHelper::copy($srcPath, $dstPath); TransferHelper::copy($srcPath, $dstPath);
$this->generateThumb(); $this->generateThumbnail();
} }
public function generateThumb() public function generateThumbnail()
{ {
$width = Core::getConfig()->browsing->thumbWidth; $width = Core::getConfig()->browsing->thumbnailWidth;
$height = Core::getConfig()->browsing->thumbHeight; $height = Core::getConfig()->browsing->thumbnailHeight;
$dstPath = $this->getThumbPath($width, $height); $dstPath = $this->getThumbnailPath($width, $height);
$thumbnailGenerator = new SmartThumbnailGenerator(); $thumbnailGenerator = new SmartThumbnailGenerator();
if (file_exists($this->getThumbCustomSourcePath())) if (file_exists($this->getCustomThumbnailSourcePath()))
{ {
return $thumbnailGenerator->generateFromFile( return $thumbnailGenerator->generateFromFile(
$this->getThumbCustomSourcePath(), $this->getCustomThumbnailSourcePath(),
$dstPath, $dstPath,
$width, $width,
$height); $height);
@ -475,9 +475,9 @@ final class PostEntity extends AbstractEntity implements IValidatable, ISerializ
TransferHelper::copy($srcPath, $dstPath); TransferHelper::copy($srcPath, $dstPath);
$thumbPath = $this->getThumbPath(); $thumbnailPath = $this->getThumbnailPath();
if (file_exists($thumbPath)) if (file_exists($thumbnailPath))
unlink($thumbPath); unlink($thumbnailPath);
} }
public function setContentFromUrl($srcUrl) public function setContentFromUrl($srcUrl)
@ -497,9 +497,9 @@ final class PostEntity extends AbstractEntity implements IValidatable, ISerializ
$this->setImageWidth(null); $this->setImageWidth(null);
$this->setImageHeight(null); $this->setImageHeight(null);
$thumbPath = $this->getThumbPath(); $thumbnailPath = $this->getThumbnailPath();
if (file_exists($thumbPath)) if (file_exists($thumbnailPath))
unlink($thumbPath); unlink($thumbnailPath);
$duplicatedPost = PostModel::tryGetByHash($youtubeId); $duplicatedPost = PostModel::tryGetByHash($youtubeId);
if ($duplicatedPost !== null and (!$this->getId() or $this->getId() != $duplicatedPost->getId())) if ($duplicatedPost !== null and (!$this->getId() or $this->getId() != $duplicatedPost->getId()))

View file

@ -255,29 +255,23 @@ final class PostModel extends AbstractCrudModel
public static function tryGetWorkingThumbPath($name) public static function tryGetWorkingThumbnailPath($name)
{ {
$path = PostModel::getThumbPath($name); $path = PostModel::getThumbnailPath($name);
if (file_exists($path) and is_readable($path)) if (file_exists($path) and is_readable($path))
return $path; return $path;
return null; return null;
} }
public static function getThumbCustomSourcePath($name) public static function getCustomThumbnailSourcePath($name)
{ {
return self::getThumbPathTokenized('{fullpath}.thumb_source', $name); return Core::getConfig()->main->thumbnailsPath . DS . $name . '.thumb_source';
} }
public static function getThumbPath($name) public static function getThumbnailPath($name)
{ {
return self::getThumbPathTokenized('{fullpath}.thumb', $name); return Core::getConfig()->main->thumbnailsPath . DS . $name . '.thumb';
}
private static function getThumbPathTokenized($text, $name)
{
return TextHelper::absolutePath(TextHelper::replaceTokens($text, [
'fullpath' => Core::getConfig()->main->thumbsPath . DS . $name]));
} }
public static function tryGetWorkingFullPath($name) public static function tryGetWorkingFullPath($name)
@ -303,7 +297,7 @@ final class PostModel extends AbstractCrudModel
return PropertyModel::get(PropertyModel::PostSpaceUsage); return PropertyModel::get(PropertyModel::PostSpaceUsage);
$totalBytes = 0; $totalBytes = 0;
$paths = [Core::getConfig()->main->filesPath, Core::getConfig()->main->thumbsPath]; $paths = [Core::getConfig()->main->filesPath, Core::getConfig()->main->thumbnailsPath];
foreach ($paths as $path) foreach ($paths as $path)
{ {

View file

@ -24,7 +24,7 @@ class ImageGdThumbnailGenerator implements IThumbnailGenerator
} }
$config = Core::getConfig(); $config = Core::getConfig();
switch ($config->browsing->thumbStyle) switch ($config->browsing->thumbnailStyle)
{ {
case 'outside': case 'outside':
$dstImage = $this->cropOutside($srcImage, $width, $height); $dstImage = $this->cropOutside($srcImage, $width, $height);

View file

@ -7,7 +7,7 @@ class ImageImagickThumbnailGenerator implements IThumbnailGenerator
$image = $image->coalesceImages(); $image = $image->coalesceImages();
$config = Core::getConfig(); $config = Core::getConfig();
switch ($config->browsing->thumbStyle) switch ($config->browsing->thumbnailStyle)
{ {
case 'outside': case 'outside':
$this->cropOutside($image, $width, $height); $this->cropOutside($image, $width, $height);

View file

@ -89,13 +89,13 @@
} }
if (Access::check(new Privilege( if (Access::check(new Privilege(
Privilege::EditPostThumb, Privilege::EditPostThumbnail,
Access::getIdentity($this->context->transport->post->getUploader())))) Access::getIdentity($this->context->transport->post->getUploader()))))
{ {
$context = new StdClass; $context = new StdClass;
$context->name = 'thumb'; $context->name = 'thumbnail';
$context->label = 'Thumb'; $context->label = 'Thumb';
if ($this->context->transport->post->hasCustomThumb()) if ($this->context->transport->post->hasCustomThumbnail())
$context->additionalInfo = '(Currently using custom thumb)'; $context->additionalInfo = '(Currently using custom thumb)';
$this->renderExternal('input-file', $context); $this->renderExternal('input-file', $context);
} }

View file

@ -1,6 +1,6 @@
<?php <?php
$this->assets->setPageThumb(\Chibi\Router::linkTo( $this->assets->setPageThumbnail(\Chibi\Router::linkTo(
['PostController', 'thumbView'], ['PostController', 'thumbnailView'],
['name' => $this->context->transport->post->getName()])); ['name' => $this->context->transport->post->getName()]));
$post = $this->context->transport->post; $post = $this->context->transport->post;
?> ?>

View file

@ -49,7 +49,7 @@ if ($masstag)
<img <img
class="thumb" class="thumb"
src="<?= \Chibi\Router::linkTo(['PostController', 'thumbView'], ['name' => $this->context->post->getName()]) ?>" src="<?= \Chibi\Router::linkTo(['PostController', 'thumbnailView'], ['name' => $this->context->post->getName()]) ?>"
alt="<?= TextHelper::reprPost($this->context->post) ?>"/> alt="<?= TextHelper::reprPost($this->context->post) ?>"/>
<?php <?php

View file

@ -11,7 +11,7 @@ $this->assets->addScript('../lib/tagit/jquery.tagit.js');
$editPostPrivileges = [ $editPostPrivileges = [
Privilege::EditPostSafety, Privilege::EditPostSafety,
Privilege::EditPostTags, Privilege::EditPostTags,
Privilege::EditPostThumb, Privilege::EditPostThumbnail,
Privilege::EditPostSource, Privilege::EditPostSource,
]; ];
$editPostPrivileges = array_fill_keys($editPostPrivileges, false); $editPostPrivileges = array_fill_keys($editPostPrivileges, false);

View file

@ -67,7 +67,7 @@ final class Core
$config = self::getConfig(); $config = self::getConfig();
TransferHelper::createDirectory($config->main->filesPath); TransferHelper::createDirectory($config->main->filesPath);
TransferHelper::createDirectory($config->main->thumbsPath); TransferHelper::createDirectory($config->main->thumbnailsPath);
//extension sanity checks //extension sanity checks
$requiredExtensions = ['pdo', 'pdo_' . $config->main->dbDriver, 'openssl', 'fileinfo']; $requiredExtensions = ['pdo', 'pdo_' . $config->main->dbDriver, 'openssl', 'fileinfo'];

View file

@ -51,7 +51,7 @@ $postValidation =
\Chibi\Router::register(['PostController', 'genericView'], 'GET', '/post/{id}', $postValidation); \Chibi\Router::register(['PostController', 'genericView'], 'GET', '/post/{id}', $postValidation);
\Chibi\Router::register(['PostController', 'fileView'], 'GET', '/post/{name}/retrieve', $postValidation); \Chibi\Router::register(['PostController', 'fileView'], 'GET', '/post/{name}/retrieve', $postValidation);
\Chibi\Router::register(['PostController', 'thumbView'], 'GET', '/post/{name}/thumb', $postValidation); \Chibi\Router::register(['PostController', 'thumbnailView'], 'GET', '/post/{name}/thumb', $postValidation);
\Chibi\Router::register(['PostController', 'toggleTagAction'], null, '/post/{id}/toggle-tag/{tag}/{enable}', $postValidation); \Chibi\Router::register(['PostController', 'toggleTagAction'], null, '/post/{id}/toggle-tag/{tag}/{enable}', $postValidation);
\Chibi\Router::register(['PostController', 'flagAction'], null, '/post/{id}/flag', $postValidation); \Chibi\Router::register(['PostController', 'flagAction'], null, '/post/{id}/flag', $postValidation);

View file

@ -112,7 +112,7 @@ class SzurubooruTestRunner implements ITestRunner
$folders = $folders =
[ [
realpath(Core::getConfig()->main->filesPath), realpath(Core::getConfig()->main->filesPath),
realpath(Core::getConfig()->main->thumbsPath), realpath(Core::getConfig()->main->thumbnailsPath),
realpath(dirname(Core::getConfig()->main->logsPath)), realpath(dirname(Core::getConfig()->main->logsPath)),
]; ];

View file

@ -109,12 +109,12 @@ class ApiArgumentTest extends AbstractFullApiTest
JobArgs::ARG_NEW_TAG_NAMES)); JobArgs::ARG_NEW_TAG_NAMES));
} }
public function testEditPostThumbJob() public function testEditPostThumbnailJob()
{ {
$this->testArguments(new EditPostThumbJob(), $this->testArguments(new EditPostThumbnailJob(),
JobArgs::Conjunction( JobArgs::Conjunction(
$this->getPostSelector(), $this->getPostSelector(),
JobArgs::ARG_NEW_THUMB_CONTENT)); JobArgs::ARG_NEW_THUMBNAIL_CONTENT));
} }
public function testEditUserAccessRankJob() public function testEditUserAccessRankJob()
@ -201,9 +201,9 @@ class ApiArgumentTest extends AbstractFullApiTest
$this->getPostSelector()); $this->getPostSelector());
} }
public function testGetPostThumbJob() public function testGetPostThumbnailJob()
{ {
$this->testArguments(new GetPostThumbJob(), $this->getPostSafeSelector()); $this->testArguments(new GetPostThumbnailJob(), $this->getPostSafeSelector());
} }
public function testGetUserJob() public function testGetUserJob()

View file

@ -18,7 +18,7 @@ class ApiAuthTest extends AbstractFullApiTest
$this->testAuth(new EditPostSafetyJob(), false); $this->testAuth(new EditPostSafetyJob(), false);
$this->testAuth(new EditPostSourceJob(), false); $this->testAuth(new EditPostSourceJob(), false);
$this->testAuth(new EditPostTagsJob(), false); $this->testAuth(new EditPostTagsJob(), false);
$this->testAuth(new EditPostThumbJob(), false); $this->testAuth(new EditPostThumbnailJob(), false);
$this->testAuth(new EditUserJob(), false); $this->testAuth(new EditUserJob(), false);
$this->testAuth(new EditUserAccessRankJob(), false); $this->testAuth(new EditUserAccessRankJob(), false);
$this->testAuth(new EditUserEmailJob(), false); $this->testAuth(new EditUserEmailJob(), false);
@ -32,7 +32,7 @@ class ApiAuthTest extends AbstractFullApiTest
$this->testAuth(new GetPropertyJob(), false); $this->testAuth(new GetPropertyJob(), false);
$this->testAuth(new GetPostJob(), false); $this->testAuth(new GetPostJob(), false);
$this->testAuth(new GetPostContentJob(), false); $this->testAuth(new GetPostContentJob(), false);
$this->testAuth(new GetPostThumbJob(), false); $this->testAuth(new GetPostThumbnailJob(), false);
$this->testAuth(new GetUserJob(), false); $this->testAuth(new GetUserJob(), false);
$this->testAuth(new GetUserSettingsJob(), false); $this->testAuth(new GetUserSettingsJob(), false);
$this->testAuth(new ListCommentsJob(), false); $this->testAuth(new ListCommentsJob(), false);

View file

@ -19,7 +19,7 @@ class ApiEmailRequirementsTest extends AbstractFullApiTest
$this->testRegularEmailRequirement(new EditPostSafetyJob()); $this->testRegularEmailRequirement(new EditPostSafetyJob());
$this->testRegularEmailRequirement(new EditPostSourceJob()); $this->testRegularEmailRequirement(new EditPostSourceJob());
$this->testRegularEmailRequirement(new EditPostTagsJob()); $this->testRegularEmailRequirement(new EditPostTagsJob());
$this->testRegularEmailRequirement(new EditPostThumbJob()); $this->testRegularEmailRequirement(new EditPostThumbnailJob());
$this->testRegularEmailRequirement(new EditUserJob()); $this->testRegularEmailRequirement(new EditUserJob());
$this->testRegularEmailRequirement(new EditUserAccessRankJob()); $this->testRegularEmailRequirement(new EditUserAccessRankJob());
$this->testRegularEmailRequirement(new EditUserEmailJob()); $this->testRegularEmailRequirement(new EditUserEmailJob());
@ -33,7 +33,7 @@ class ApiEmailRequirementsTest extends AbstractFullApiTest
$this->testRegularEmailRequirement(new GetPropertyJob()); $this->testRegularEmailRequirement(new GetPropertyJob());
$this->testRegularEmailRequirement(new GetPostJob()); $this->testRegularEmailRequirement(new GetPostJob());
$this->testRegularEmailRequirement(new GetPostContentJob()); $this->testRegularEmailRequirement(new GetPostContentJob());
$this->testRegularEmailRequirement(new GetPostThumbJob()); $this->testRegularEmailRequirement(new GetPostThumbnailJob());
$this->testRegularEmailRequirement(new GetUserJob()); $this->testRegularEmailRequirement(new GetUserJob());
$this->testRegularEmailRequirement(new GetUserSettingsJob()); $this->testRegularEmailRequirement(new GetUserSettingsJob());
$this->testRegularEmailRequirement(new ListCommentsJob()); $this->testRegularEmailRequirement(new ListCommentsJob());

View file

@ -49,7 +49,7 @@ class ApiPrivilegeTest extends AbstractFullApiTest
$this->testDynamicPostPrivilege(new EditPostSafetyJob(), Privilege::EditPostSafety); $this->testDynamicPostPrivilege(new EditPostSafetyJob(), Privilege::EditPostSafety);
$this->testDynamicPostPrivilege(new EditPostSourceJob(), Privilege::EditPostSource); $this->testDynamicPostPrivilege(new EditPostSourceJob(), Privilege::EditPostSource);
$this->testDynamicPostPrivilege(new EditPostTagsJob(), Privilege::EditPostTags); $this->testDynamicPostPrivilege(new EditPostTagsJob(), Privilege::EditPostTags);
$this->testDynamicPostPrivilege(new EditPostThumbJob(), Privilege::EditPostThumb); $this->testDynamicPostPrivilege(new EditPostThumbnailJob(), Privilege::EditPostThumbnail);
$ctx = function($job) $ctx = function($job)
{ {
@ -61,7 +61,7 @@ class ApiPrivilegeTest extends AbstractFullApiTest
$this->testDynamicPostPrivilege($ctx(new EditPostSafetyJob), Privilege::AddPostSafety); $this->testDynamicPostPrivilege($ctx(new EditPostSafetyJob), Privilege::AddPostSafety);
$this->testDynamicPostPrivilege($ctx(new EditPostSourceJob), Privilege::AddPostSource); $this->testDynamicPostPrivilege($ctx(new EditPostSourceJob), Privilege::AddPostSource);
$this->testDynamicPostPrivilege($ctx(new EditPostTagsJob), Privilege::AddPostTags); $this->testDynamicPostPrivilege($ctx(new EditPostTagsJob), Privilege::AddPostTags);
$this->testDynamicPostPrivilege($ctx(new EditPostThumbJob), Privilege::AddPostThumb); $this->testDynamicPostPrivilege($ctx(new EditPostThumbnailJob), Privilege::AddPostThumbnail);
$this->testDynamicPostPrivilege(new FeaturePostJob(), Privilege::FeaturePost); $this->testDynamicPostPrivilege(new FeaturePostJob(), Privilege::FeaturePost);
$this->testDynamicPostPrivilege(new FlagPostJob(), Privilege::FlagPost); $this->testDynamicPostPrivilege(new FlagPostJob(), Privilege::FlagPost);
@ -117,9 +117,9 @@ class ApiPrivilegeTest extends AbstractFullApiTest
} }
} }
public function testDynamicPostThumbPrivileges() public function testDynamicPostThumbnailPrivileges()
{ {
$job = new GetPostThumbJob(); $job = new GetPostThumbnailJob();
$this->testedJobs []= $job; $this->testedJobs []= $job;
$this->assert->isNull($job->getRequiredMainPrivilege()); $this->assert->isNull($job->getRequiredMainPrivilege());
} }

View file

@ -27,7 +27,7 @@ class EditPostContentJobTest extends AbstractTest
$this->assert->areEqual(240, $post->getImageHeight()); $this->assert->areEqual(240, $post->getImageHeight());
$this->assert->doesNotThrow(function() use ($post) $this->assert->doesNotThrow(function() use ($post)
{ {
$post->generateThumb(); $post->generateThumbnail();
}); });
} }
@ -42,7 +42,7 @@ class EditPostContentJobTest extends AbstractTest
$this->assert->areEqual(240, $post->getImageHeight()); $this->assert->areEqual(240, $post->getImageHeight());
$this->assert->doesNotThrow(function() use ($post) $this->assert->doesNotThrow(function() use ($post)
{ {
$post->generateThumb(); $post->generateThumbnail();
}); });
} }
@ -57,7 +57,7 @@ class EditPostContentJobTest extends AbstractTest
$this->assert->areEqual(240, $post->getImageHeight()); $this->assert->areEqual(240, $post->getImageHeight());
$this->assert->doesNotThrow(function() use ($post) $this->assert->doesNotThrow(function() use ($post)
{ {
$post->generateThumb(); $post->generateThumbnail();
}); });
} }
@ -102,7 +102,7 @@ class EditPostContentJobTest extends AbstractTest
$this->assert->areEqual('qWq_jydCUw4', $post->getFileHash()); $this->assert->areEqual('qWq_jydCUw4', $post->getFileHash());
$this->assert->doesNotThrow(function() use ($post) $this->assert->doesNotThrow(function() use ($post)
{ {
$post->generateThumb(); $post->generateThumbnail();
}); });
$this->assert->doesNotThrow(function() use ($post) $this->assert->doesNotThrow(function() use ($post)

View file

@ -1,25 +1,25 @@
<?php <?php
class EditPostThumbJobTest extends AbstractTest class EditPostThumbnailJobTest extends AbstractTest
{ {
public function testFile() public function testFile()
{ {
$this->grantAccess('editPostThumb'); $this->grantAccess('editPostThumbnail');
$post = $this->postMocker->mockSingle(); $post = $this->postMocker->mockSingle();
$this->assert->isFalse($post->hasCustomThumb()); $this->assert->isFalse($post->hasCustomThumbnail());
$post = $this->assert->doesNotThrow(function() use ($post) $post = $this->assert->doesNotThrow(function() use ($post)
{ {
return Api::run( return Api::run(
new EditPostThumbJob(), new EditPostThumbnailJob(),
[ [
JobArgs::ARG_POST_ID => $post->getId(), JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_THUMB_CONTENT => JobArgs::ARG_NEW_THUMBNAIL_CONTENT =>
new ApiFileInput($this->testSupport->getPath('thumb.jpg'), 'test.jpg'), new ApiFileInput($this->testSupport->getPath('thumb.jpg'), 'test.jpg'),
]); ]);
}); });
$this->assert->isTrue($post->hasCustomThumb()); $this->assert->isTrue($post->hasCustomThumbnail());
$img = imagecreatefromjpeg($post->tryGetWorkingThumbPath()); $img = imagecreatefromjpeg($post->tryGetWorkingThumbnailPath());
$this->assert->areEqual(150, imagesx($img)); $this->assert->areEqual(150, imagesx($img));
$this->assert->areEqual(150, imagesy($img)); $this->assert->areEqual(150, imagesy($img));
imagedestroy($img); imagedestroy($img);
@ -27,23 +27,23 @@ class EditPostThumbJobTest extends AbstractTest
public function testFileDifferentDimensions() public function testFileDifferentDimensions()
{ {
$this->grantAccess('editPostThumb'); $this->grantAccess('editPostThumbnail');
$post = $this->postMocker->mockSingle(); $post = $this->postMocker->mockSingle();
$this->assert->isFalse($post->hasCustomThumb()); $this->assert->isFalse($post->hasCustomThumbnail());
$post = $this->assert->doesNotThrow(function() use ($post) $post = $this->assert->doesNotThrow(function() use ($post)
{ {
return Api::run( return Api::run(
new EditPostThumbJob(), new EditPostThumbnailJob(),
[ [
JobArgs::ARG_POST_ID => $post->getId(), JobArgs::ARG_POST_ID => $post->getId(),
JobArgs::ARG_NEW_THUMB_CONTENT => JobArgs::ARG_NEW_THUMBNAIL_CONTENT =>
new ApiFileInput($this->testSupport->getPath('image.jpg'), 'test.jpg'), new ApiFileInput($this->testSupport->getPath('image.jpg'), 'test.jpg'),
]); ]);
}); });
$this->assert->isTrue($post->hasCustomThumb()); $this->assert->isTrue($post->hasCustomThumbnail());
$img = imagecreatefromjpeg($post->tryGetWorkingThumbPath()); $img = imagecreatefromjpeg($post->tryGetWorkingThumbnailPath());
$this->assert->areEqual(150, imagesx($img)); $this->assert->areEqual(150, imagesx($img));
$this->assert->areEqual(150, imagesy($img)); $this->assert->areEqual(150, imagesy($img));
imagedestroy($img); imagedestroy($img);

View file

@ -1,7 +1,7 @@
<?php <?php
class GetPostThumbJobTest extends AbstractTest class GetPostThumbnailJobTest extends AbstractTest
{ {
public function testThumbRetrieval() public function testThumbnailRetrieval()
{ {
$this->grantAccess('viewPost'); $this->grantAccess('viewPost');
$post = $this->postMocker->mockSingle(); $post = $this->postMocker->mockSingle();
@ -9,7 +9,7 @@ class GetPostThumbJobTest extends AbstractTest
$output = $this->assert->doesNotThrow(function() use ($post) $output = $this->assert->doesNotThrow(function() use ($post)
{ {
return Api::run( return Api::run(
new GetPostThumbJob(), new GetPostThumbnailJob(),
[ [
JobArgs::ARG_POST_NAME => $post->getName(), JobArgs::ARG_POST_NAME => $post->getName(),
]); ]);
@ -29,7 +29,7 @@ class GetPostThumbJobTest extends AbstractTest
$this->assert->throws(function() $this->assert->throws(function()
{ {
Api::run( Api::run(
new GetPostThumbJob(), new GetPostThumbnailJob(),
[ [
JobArgs::ARG_POST_ID => 100, JobArgs::ARG_POST_ID => 100,
]); ]);
@ -43,7 +43,7 @@ class GetPostThumbJobTest extends AbstractTest
$this->assert->throws(function() $this->assert->throws(function()
{ {
Api::run( Api::run(
new GetPostThumbJob(), new GetPostThumbnailJob(),
[ [
JobArgs::ARG_POST_NAME => 'nonsense', JobArgs::ARG_POST_NAME => 'nonsense',
]); ]);

View file

@ -1,10 +1,10 @@
[main] [main]
filesPath = "./tests/files/" filesPath = "./tests/files/"
thumbsPath = "./tests/thumbs/" thumbnailsPath = "./tests/thumbs/"
logsPath = "./tests/logs/{yyyy}-{mm}.log" logsPath = "./tests/logs/{yyyy}-{mm}.log"
mediaPath = "./public_html/media/" mediaPath = "./public_html/media/"
title = "szurubooru/tests" title = "szurubooru/tests"
salt = "salt..." salt = "salt..."
[misc] [misc]
featuredPostMaxDays=7 featuredPostMaxDays=7
@ -26,9 +26,9 @@ postsPerPage=20
logsPerPage=250 logsPerPage=250
tagsPerPage=100 tagsPerPage=100
tagsRelated=15 tagsRelated=15
thumbWidth=150 thumbnailWidth=150
thumbHeight=150 thumbnailHeight=150
thumbStyle=outside thumbnailStyle=outside
endlessScrollingDefault=1 endlessScrollingDefault=1
showPostTagTitlesDefault=0 showPostTagTitlesDefault=0
showDislikedPostsDefault=1 showDislikedPostsDefault=1