-
-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
86 changed files
with
2,080 additions
and
265 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
namespace App\Actions\Photo; | ||
|
||
use App\Eloquent\FixedQueryBuilder; | ||
use App\Enum\ColumnSortingPhotoType; | ||
use App\Enum\OrderSortingType; | ||
use App\Models\Configs; | ||
use App\Models\Photo; | ||
use App\Policies\PhotoQueryPolicy; | ||
use Illuminate\Database\Eloquent\Builder; | ||
|
||
class Timeline | ||
{ | ||
protected PhotoQueryPolicy $photoQueryPolicy; | ||
|
||
public function __construct(PhotoQueryPolicy $photoQueryPolicy) | ||
{ | ||
$this->photoQueryPolicy = $photoQueryPolicy; | ||
} | ||
|
||
/** | ||
* Create the query manually. | ||
* | ||
* @return FixedQueryBuilder<Photo> | ||
*/ | ||
public function do(): Builder | ||
{ | ||
$order = Configs::getValueAsEnum('timeline_photos_order', ColumnSortingPhotoType::class); | ||
|
||
// Safe default (should not be needed). | ||
// @codeCoverageIgnoreStart | ||
if (!in_array($order, [ColumnSortingPhotoType::CREATED_AT, ColumnSortingPhotoType::TAKEN_AT], true)) { | ||
$order = ColumnSortingPhotoType::TAKEN_AT; | ||
} | ||
// @codeCoverageIgnoreEnd | ||
|
||
return $this->photoQueryPolicy->applySearchabilityFilter( | ||
query: Photo::query()->with(['album', 'size_variants', 'size_variants.sym_links']), | ||
origin: null, | ||
include_nsfw: !Configs::getValueAsBool('hide_nsfw_in_timeline') | ||
)->orderBy($order->value, OrderSortingType::DESC->value); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace App\Contracts\Http\Requests; | ||
|
||
use App\Enum\TimelineAlbumGranularity; | ||
|
||
interface HasTimelineAlbum | ||
{ | ||
/** | ||
* @return TimelineAlbumGranularity|null | ||
*/ | ||
public function album_timeline(): ?TimelineAlbumGranularity; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace App\Contracts\Http\Requests; | ||
|
||
use App\Enum\TimelinePhotoGranularity; | ||
|
||
interface HasTimelinePhoto | ||
{ | ||
/** | ||
* @return TimelinePhotoGranularity|null | ||
*/ | ||
public function photo_timeline(): ?TimelinePhotoGranularity; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace App\Enum; | ||
|
||
/** | ||
* Defines the possible granularities for album timelines. | ||
*/ | ||
enum TimelineAlbumGranularity: string | ||
{ | ||
case DEFAULT = 'default'; | ||
case DISABLED = 'disabled'; | ||
case YEAR = 'year'; | ||
case MONTH = 'month'; | ||
case DAY = 'day'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace App\Enum; | ||
|
||
/** | ||
* Defines the possible granularities for photo timelines. | ||
*/ | ||
enum TimelinePhotoGranularity: string | ||
{ | ||
case DEFAULT = 'default'; | ||
case DISABLED = 'disabled'; | ||
case YEAR = 'year'; | ||
case MONTH = 'month'; | ||
case DAY = 'day'; | ||
case HOUR = 'hour'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace App\Http\Controllers\Gallery; | ||
|
||
use App\Actions\Photo\Timeline; | ||
use App\Http\Requests\Photo\GetTimelineRequest; | ||
use App\Http\Resources\Timeline\InitResource; | ||
use App\Http\Resources\Timeline\TimelineResource; | ||
use App\Models\Configs; | ||
use App\Models\Photo; | ||
use Illuminate\Contracts\Pagination\LengthAwarePaginator; | ||
use Illuminate\Routing\Controller; | ||
use Spatie\LaravelData\Data; | ||
|
||
/** | ||
* Controller responsible for the Timeline data. | ||
*/ | ||
class TimelineController extends Controller | ||
{ | ||
public function __invoke(GetTimelineRequest $request, Timeline $timeline): Data | ||
{ | ||
/** @var LengthAwarePaginator<Photo> $photoResults */ | ||
/** @disregard P1013 Undefined method withQueryString() (stupid intelephense) */ | ||
$photoResults = $timeline->do()->paginate(Configs::getValueAsInt('timeline_photos_pagination_limit')); | ||
|
||
return TimelineResource::fromData($photoResults); | ||
} | ||
|
||
/** | ||
* Return init Search. | ||
* | ||
* @param GetTimelineRequest $request | ||
* | ||
* @return InitResource | ||
*/ | ||
public function init(GetTimelineRequest $request): Data | ||
{ | ||
return new InitResource(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.