Added meaningful name to saved posts
This commit is contained in:
parent
6c9954f298
commit
04bdb04f20
3 changed files with 14 additions and 4 deletions
2
TODO
2
TODO
|
@ -8,8 +8,6 @@ everything related to posts:
|
||||||
|
|
||||||
- ability to paste many urls in post upload
|
- ability to paste many urls in post upload
|
||||||
|
|
||||||
- generate meaningful file name when saving posts
|
|
||||||
|
|
||||||
- post notes
|
- post notes
|
||||||
- "add note" in sidebar creates new note in the middle of image
|
- "add note" in sidebar creates new note in the middle of image
|
||||||
- hovering notes shows note text
|
- hovering notes shows note text
|
||||||
|
|
|
@ -3,7 +3,7 @@ DirectoryIndex index.html
|
||||||
|
|
||||||
RewriteEngine On
|
RewriteEngine On
|
||||||
|
|
||||||
RewriteCond %{REQUEST_FILENAME} !-f
|
#RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
RewriteRule ^/?data/posts/([^/]+)/? /api/posts/$1/content [L]
|
RewriteRule ^/?data/posts/([^/]+)/? /api/posts/$1/content [L]
|
||||||
|
|
||||||
RewriteCond %{REQUEST_FILENAME} !-f
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
namespace Szurubooru\Controllers;
|
namespace Szurubooru\Controllers;
|
||||||
|
use Szurubooru\Config;
|
||||||
use Szurubooru\Dao\PublicFileDao;
|
use Szurubooru\Dao\PublicFileDao;
|
||||||
|
use Szurubooru\Helpers\MimeHelper;
|
||||||
use Szurubooru\Router;
|
use Szurubooru\Router;
|
||||||
use Szurubooru\Services\NetworkingService;
|
use Szurubooru\Services\NetworkingService;
|
||||||
use Szurubooru\Services\PostService;
|
use Szurubooru\Services\PostService;
|
||||||
|
@ -8,17 +10,20 @@ use Szurubooru\Services\ThumbnailService;
|
||||||
|
|
||||||
final class PostContentController extends AbstractController
|
final class PostContentController extends AbstractController
|
||||||
{
|
{
|
||||||
|
private $config;
|
||||||
private $fileDao;
|
private $fileDao;
|
||||||
private $postService;
|
private $postService;
|
||||||
private $networkingService;
|
private $networkingService;
|
||||||
private $thumbnailService;
|
private $thumbnailService;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
|
Config $config,
|
||||||
PublicFileDao $fileDao,
|
PublicFileDao $fileDao,
|
||||||
PostService $postService,
|
PostService $postService,
|
||||||
NetworkingService $networkingService,
|
NetworkingService $networkingService,
|
||||||
ThumbnailService $thumbnailService)
|
ThumbnailService $thumbnailService)
|
||||||
{
|
{
|
||||||
|
$this->config = $config;
|
||||||
$this->fileDao = $fileDao;
|
$this->fileDao = $fileDao;
|
||||||
$this->postService = $postService;
|
$this->postService = $postService;
|
||||||
$this->networkingService = $networkingService;
|
$this->networkingService = $networkingService;
|
||||||
|
@ -34,7 +39,14 @@ final class PostContentController extends AbstractController
|
||||||
public function getPostContent($postName)
|
public function getPostContent($postName)
|
||||||
{
|
{
|
||||||
$post = $this->postService->getByName($postName);
|
$post = $this->postService->getByName($postName);
|
||||||
$this->networkingService->serveFile($this->fileDao->getFullPath($post->getContentPath()));
|
|
||||||
|
$options = new \StdClass;
|
||||||
|
$options->customFileName = sprintf('%s_%s.%s',
|
||||||
|
$this->config->basic->serviceName,
|
||||||
|
$post->getName(),
|
||||||
|
strtolower(MimeHelper::getExtension($post->getContentMimeType())));
|
||||||
|
|
||||||
|
$this->networkingService->serveFile($this->fileDao->getFullPath($post->getContentPath()), $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPostThumbnail($postName, $size)
|
public function getPostThumbnail($postName, $size)
|
||||||
|
|
Loading…
Reference in a new issue