Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable full support of Livewire + Tailwind: New front-end #1303

Closed
wants to merge 244 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
244 commits
Select commit Hold shift + click to select a range
69c5c1b
squash
ildyria Aug 21, 2023
d467118
fix stupid
ildyria Aug 21, 2023
69a503c
fix U2F
ildyria Aug 21, 2023
2b137a9
formatting
ildyria Aug 21, 2023
c50e30d
fix phpstan
ildyria Aug 21, 2023
513104a
Merge branch 'master' into livewire/more-work
ildyria Aug 24, 2023
1e3627d
Merge branch 'master' into livewire/more-work
ildyria Aug 25, 2023
d01e624
fix login for multiple users
ildyria Aug 31, 2023
d875804
support more users
ildyria Aug 31, 2023
60f00da
fix formatting
ildyria Aug 31, 2023
60ce8cc
fix phpstan
ildyria Aug 31, 2023
660cb40
more work
ildyria Sep 1, 2023
0be6539
support left-right navigation on photo view
ildyria Sep 2, 2023
e7b11b5
fix phpstan + formatting
ildyria Sep 2, 2023
b36327d
fix wrap around
ildyria Sep 2, 2023
4c4eed8
tailwind on landing page (first animation gone for now)
ildyria Sep 2, 2023
98577f4
refine
ildyria Sep 2, 2023
b193a69
keybind o to rotate overlay
ildyria Sep 2, 2023
eed808d
support completely old landing page without jquery
ildyria Sep 2, 2023
52707ee
remove no longer needed scss
ildyria Sep 2, 2023
83c5c15
fixing missing animation on hover
ildyria Sep 2, 2023
686d845
Merge branch 'master' into livewire/more-work
ildyria Sep 3, 2023
a298c85
download button on picture panel
ildyria Sep 3, 2023
126724b
fix phpstan complaints
ildyria Sep 3, 2023
ea7cc7b
when enabled in settings, it is now fully enabled
ildyria Sep 3, 2023
2f21765
add dev tools in left menu
ildyria Sep 3, 2023
679c7a2
better csp support
ildyria Sep 3, 2023
d968f44
fix url
ildyria Sep 3, 2023
5a5367c
finalize import from url
ildyria Sep 3, 2023
a68f0ba
persist status of side bar
ildyria Sep 4, 2023
fd618ed
fix phpstan & formatting
ildyria Sep 4, 2023
892929d
Merge branch 'master' into livewire/more-work
ildyria Sep 4, 2023
903b930
fix formatting
ildyria Sep 4, 2023
b32ad98
remove public smart album, bye bye
ildyria Sep 5, 2023
a5ae0e9
full screen also on album
ildyria Sep 5, 2023
3004480
shortcut
ildyria Sep 5, 2023
c6d793a
improve interaction with shortcut menu
ildyria Sep 6, 2023
598bc08
update composer
ildyria Sep 7, 2023
5d62979
revert
ildyria Sep 7, 2023
56a5987
trickery to avoid reload
ildyria Sep 7, 2023
fe5004f
avoid reloading nicely
ildyria Sep 7, 2023
d9c5b37
composer update
ildyria Sep 10, 2023
3e7775d
minor refactoring
ildyria Sep 10, 2023
58916b3
dedicate component for searching albums
ildyria Sep 10, 2023
db32477
more locked
ildyria Sep 10, 2023
934aa2f
move picture done
ildyria Sep 10, 2023
c901a29
fixes
ildyria Sep 10, 2023
399c9ea
small indication that photo is starred in header
ildyria Sep 10, 2023
c2adb6f
support for password
ildyria Sep 10, 2023
2219cc2
fix phpstan
ildyria Sep 10, 2023
356fe1a
better css + fix full screen image size
ildyria Sep 11, 2023
3bae53d
improve code structure and support for login
ildyria Sep 11, 2023
1308dcd
remove useless file
ildyria Sep 11, 2023
f5b3ca0
more improvements
ildyria Sep 11, 2023
30eadd4
Merge branch 'master' into livewire/more-work
ildyria Sep 11, 2023
019dc15
WIP upload by chunks
ildyria Sep 13, 2023
6ce55f8
continue working on upload
ildyria Sep 13, 2023
386456e
minor
ildyria Sep 13, 2023
8a88fed
better
ildyria Sep 13, 2023
0b4b48a
fixes
ildyria Sep 13, 2023
f86f779
fix phpstan
ildyria Sep 13, 2023
54ffc82
upload done
ildyria Sep 13, 2023
35ca03f
no debug symbol
ildyria Sep 13, 2023
3bdfea1
cleaning + composer update
ildyria Sep 13, 2023
69e6f7c
more work
ildyria Sep 13, 2023
ab9df57
forgot form
ildyria Sep 13, 2023
76d8752
fix front
ildyria Sep 13, 2023
b14fb30
fix import but still a bit broken
ildyria Sep 14, 2023
46f0fcc
Apply fixes from PHP-CS-Fixer (#2014)
github-actions[bot] Sep 14, 2023
89653e2
Merge branch 'master' into livewire/more-work
ildyria Sep 15, 2023
950d409
fixes
ildyria Sep 15, 2023
f40d34b
fix
ildyria Sep 15, 2023
ec0a623
replace layout and overlay to proper Enum types
ildyria Sep 16, 2023
09db1a6
update tests
ildyria Sep 16, 2023
d25f5c0
formatting & sync
ildyria Sep 16, 2023
3eb9429
oups
ildyria Sep 16, 2023
f4b944a
Merge branch 'refactor-type-layout' into livewire/more-work
ildyria Sep 16, 2023
6b8364b
Merge branch 'master' into livewire/more-work
ildyria Sep 16, 2023
b1604a0
Merge branch 'master' into livewire/more-work
ildyria Sep 16, 2023
4a56aac
composer update
ildyria Sep 16, 2023
f3689c3
merge changes on layout and overlay type
ildyria Sep 16, 2023
e1bb4aa
apply migrations after 4.12
ildyria Sep 16, 2023
f660d9d
layout is now square, justified, masonry, grid. No more unjustified
ildyria Sep 16, 2023
8240298
ensure unique key in config
ildyria Sep 16, 2023
6d32082
formatting
ildyria Sep 16, 2023
f3ec56c
npm update
ildyria Sep 16, 2023
10e0804
access rights to diagnostic page
ildyria Sep 16, 2023
af4fe28
formatting
ildyria Sep 16, 2023
79b6966
cleaning + fixing layout setting
ildyria Sep 16, 2023
faea39f
WIP
ildyria Sep 16, 2023
9a21202
WIP
ildyria Sep 16, 2023
21596f0
no longer used
ildyria Sep 16, 2023
f19e5e3
WIP
ildyria Sep 16, 2023
81c3258
more work
ildyria Sep 16, 2023
b670000
more work
ildyria Sep 16, 2023
024aa3f
Merge branch 'master' into livewire/more-work
ildyria Sep 16, 2023
ac31f4e
fixes PSR4 + update composer
ildyria Sep 16, 2023
ae3535b
right click for pictures done
ildyria Sep 16, 2023
a2c7524
fix phpstan
ildyria Sep 16, 2023
c0a7ff6
reordering
ildyria Sep 16, 2023
caebeb7
stronger security
ildyria Sep 16, 2023
496d6f5
done
ildyria Sep 16, 2023
e30e503
fixes
ildyria Sep 16, 2023
f219cd3
more integration
ildyria Sep 16, 2023
65ccd0f
debug cover_id
ildyria Sep 17, 2023
6f994bc
remove unused imports
ildyria Sep 17, 2023
7ef7c56
better code
ildyria Sep 17, 2023
cd621a2
Merge branch 'master' into livewire/more-work
ildyria Sep 17, 2023
8fe9274
fix layout selection
ildyria Sep 17, 2023
8744925
fix id on null bug
ildyria Sep 17, 2023
614acba
better support for js
ildyria Sep 17, 2023
6ffce8b
Merge branch 'master' into livewire/more-work
ildyria Sep 17, 2023
5cb955d
Merge branch 'master' into livewire/more-work
ildyria Sep 17, 2023
b8d7a04
centralize data
ildyria Sep 17, 2023
1f50f98
more work
ildyria Sep 17, 2023
5fb8cd5
fix problem of alpineJS
ildyria Sep 17, 2023
df264a7
improve keybindings - fix not working after focusing on one elem
ildyria Sep 17, 2023
114357e
n is working
ildyria Sep 17, 2023
b5bab72
CTRL + A working
ildyria Sep 17, 2023
e3b1a39
formatting
ildyria Sep 17, 2023
ffe677a
add JS checks on CICD
ildyria Sep 17, 2023
fc7530f
more CICD
ildyria Sep 17, 2023
3d6f1e2
prettier
ildyria Sep 17, 2023
6b4def7
somewhat working shift click
ildyria Sep 18, 2023
e583c9a
more work
ildyria Sep 19, 2023
a3748cd
more actions
ildyria Sep 19, 2023
533b044
formatting
ildyria Sep 19, 2023
ce1af33
more work
ildyria Sep 20, 2023
c307956
more keybindings
ildyria Sep 20, 2023
36c680b
add setCover
ildyria Sep 21, 2023
aee2f53
add star & unstar
ildyria Sep 21, 2023
e7b9547
star unstar working
ildyria Sep 21, 2023
f303746
better integration
ildyria Sep 21, 2023
23ab7e7
Merge branch 'master' into livewire/more-work
ildyria Sep 22, 2023
658067d
composer.lock
ildyria Sep 22, 2023
2db7ade
add License type
ildyria Sep 22, 2023
3461041
Merge branch 'master' into livewire/more-work
ildyria Sep 23, 2023
89c795d
composer update
ildyria Sep 23, 2023
732e94c
support licenses
ildyria Sep 23, 2023
dcf69fd
support changing uploaded date @qwerty287
ildyria Sep 23, 2023
382927f
fix phpstan & formatting
ildyria Sep 23, 2023
9979184
improved layout when no albums
ildyria Sep 23, 2023
983e803
working on tests
ildyria Sep 23, 2023
8c72aa3
revert
ildyria Sep 23, 2023
1e4233b
better CICD?
ildyria Sep 23, 2023
ef62b91
fix phpstan
ildyria Sep 23, 2023
faae8a0
faster dist because we only care about lower version
ildyria Sep 23, 2023
b6da4f1
start testing
ildyria Sep 23, 2023
2ce7081
fix formatting
ildyria Sep 23, 2023
6d98fff
more tests
ildyria Sep 23, 2023
1a508e9
more tests
ildyria Sep 23, 2023
0d00564
Revert stupid changes
ildyria Sep 23, 2023
f8edaca
more tests
ildyria Sep 23, 2023
1558510
Merge branch 'master' into livewire/more-work
ildyria Sep 23, 2023
3e51708
fix some phpstan shit
ildyria Sep 23, 2023
55273c9
test back
ildyria Sep 23, 2023
ae9e9c2
trying more tests
ildyria Sep 23, 2023
b5c8d39
fix tests
ildyria Sep 23, 2023
c91efb9
fix phpstan
ildyria Sep 23, 2023
799223f
formatting
ildyria Sep 23, 2023
459e7bb
more tests
ildyria Sep 23, 2023
dcd3b8f
more tests
ildyria Sep 23, 2023
0bb7090
more coverage
ildyria Sep 23, 2023
266b2ab
fix phpstan
ildyria Sep 23, 2023
6c78dbf
formatting
ildyria Sep 23, 2023
3b65a47
more coverage
ildyria Sep 23, 2023
46f8f22
more coverage
ildyria Sep 23, 2023
2ae58b1
more coverage
ildyria Sep 23, 2023
22ec7b9
more coverage
ildyria Sep 23, 2023
5fbda35
no lazy on diagnostics
ildyria Sep 23, 2023
eeecad6
remove footer in those
ildyria Sep 23, 2023
6dc3329
Merge branch 'master' into livewire/more-work
ildyria Sep 24, 2023
da44b30
delay migrations
ildyria Sep 24, 2023
8f427b8
more coverage
ildyria Sep 24, 2023
ff85667
more coverage
ildyria Sep 24, 2023
f89fea1
more coverage
ildyria Sep 24, 2023
8c4a374
more coverage
ildyria Sep 24, 2023
e5d6067
more coverage
ildyria Sep 24, 2023
72feba8
more coverage
ildyria Sep 24, 2023
6899929
fix phpstan
ildyria Sep 25, 2023
5baa3a0
more tests
ildyria Sep 25, 2023
b91b77d
formatting
ildyria Sep 25, 2023
097baa4
more coverage
ildyria Sep 25, 2023
4eda597
minor
ildyria Sep 25, 2023
1a5a809
more coverage
ildyria Sep 25, 2023
48aad0e
more coverage
ildyria Sep 25, 2023
7d6a468
more coverage
ildyria Sep 25, 2023
ec7bd17
more coverage
ildyria Sep 25, 2023
c1f970c
removing comments & dead code
ildyria Sep 25, 2023
d6728d3
corner cases
ildyria Sep 25, 2023
ff1cee9
fix test
ildyria Sep 25, 2023
03b3b48
more tests
ildyria Sep 25, 2023
63d4f22
more tests
ildyria Sep 25, 2023
c9e3616
add sensitive warning
ildyria Sep 25, 2023
11e0eda
forgot NSFW albums
ildyria Sep 25, 2023
aeb1bec
formatting
ildyria Sep 25, 2023
ad59943
add more coverage
ildyria Sep 25, 2023
aa2a0d8
improved tests
ildyria Sep 26, 2023
4582d6c
fix formatting
ildyria Sep 26, 2023
79f252b
more coverage
ildyria Sep 27, 2023
8d73e61
more tests
ildyria Sep 27, 2023
64c1f52
more coverage
ildyria Sep 27, 2023
40a57e4
more coverage
ildyria Sep 27, 2023
8581977
more coverage
ildyria Sep 27, 2023
5eab067
more coverage
ildyria Sep 27, 2023
87ea7e4
fix phpstan
ildyria Sep 27, 2023
78fc5ed
more tests
ildyria Sep 27, 2023
687fa7a
more tests
ildyria Sep 27, 2023
e273261
more tests
ildyria Sep 27, 2023
4863e06
more tests
ildyria Sep 27, 2023
5eb6fe2
add tests for tags
ildyria Sep 27, 2023
f6976e7
more tests
ildyria Sep 27, 2023
5d51eec
more tests
ildyria Sep 28, 2023
4b04b1f
corner cases
ildyria Sep 28, 2023
a78f412
fixes
ildyria Sep 28, 2023
a297593
more
ildyria Sep 28, 2023
e9d3e9b
more tests
ildyria Sep 28, 2023
22ff083
more tests & coverage + fixes
ildyria Sep 28, 2023
f0cac37
corner
ildyria Sep 28, 2023
1530599
blabla
ildyria Sep 28, 2023
6d0ec61
use js instad of php for layout Justified
ildyria Sep 28, 2023
3a8341c
clean code
ildyria Sep 28, 2023
e8a51fe
fix tests
ildyria Sep 28, 2023
e549ebf
fix formatting
ildyria Sep 28, 2023
7427a54
better masonry
ildyria Sep 28, 2023
08bd915
remove this super slow library
ildyria Sep 28, 2023
df22c99
formatting
ildyria Sep 28, 2023
bc5c95c
more translations
ildyria Sep 28, 2023
7145f4e
fix formatting
ildyria Sep 28, 2023
2d60951
more cols
ildyria Sep 28, 2023
6c24c0c
grid layout
ildyria Sep 29, 2023
51f3e57
a bit wonky, but it is now possible to set on the fly which layout we…
ildyria Sep 29, 2023
82f6ef5
formatting
ildyria Sep 29, 2023
e365d86
WIP
ildyria Oct 1, 2023
c35a095
Merge branch 'master' into livewire/more-work
ildyria Oct 1, 2023
8e3dd45
map on Albums
ildyria Oct 1, 2023
658e6aa
fix phpstan
ildyria Oct 1, 2023
8c3f30d
todo
ildyria Oct 1, 2023
45b011d
bye bye import from server
ildyria Oct 2, 2023
e19130e
add authorization layer
ildyria Oct 2, 2023
a93875e
map on sidebar too
ildyria Oct 2, 2023
331c5b8
add more tests
ildyria Oct 2, 2023
497c3c6
add frame + tests
ildyria Oct 3, 2023
3bffd15
show layout selector only when there are pictures
ildyria Oct 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 4 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ APP_FORCE_HTTPS=false
# enable or disable debug bar. By default it is disabled.
# Do note that this disable CSP!!
DEBUGBAR_ENABLED=false
LIVEWIRE_ENABLED=false

# enable or disable log viewer. By default it is enabled.
LOG_VIEWER_ENABLED=true
Expand Down Expand Up @@ -101,3 +102,6 @@ TRUSTED_PROXIES=null

# Comma-separated list of class names of diagnostics checks that should be skipped.
#SKIP_DIAGNOSTICS_CHECKS=

VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
38 changes: 38 additions & 0 deletions .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,32 @@ jobs:
- name: Check source code for code style errors
run: PHP_CS_FIXER_IGNORE_ENV=1 vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --verbose --diff --dry-run

check_js:
name: 2️⃣ JS Node ${{ matrix.node-version }} - Code Style errors & Compilation
runs-on: ubuntu-latest
needs:
- php_syntax_errors
strategy:
matrix:
node-version: [16, 18, 20]
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}

- name: Install
run: npm install

- name: Check Style
run: npm run check-formatting

- name: Compile Front-end
run: npm run build

phpstan:
name: 2️⃣ PHP 8.1 - PHPStan
runs-on: ubuntu-latest
Expand Down Expand Up @@ -106,6 +132,7 @@ jobs:
- sqlite
test-suite:
- Feature
- Livewire
# Service containers to run with `container-job`
services:
# Label used to access the service container
Expand Down Expand Up @@ -282,6 +309,17 @@ jobs:
with:
composer-options: --no-dev

- name: Use Node.js 20
uses: actions/setup-node@v3
with:
node-version: 20

- name: Install
run: npm install

- name: Compile Front-end
run: npm run build

- name: Build Dist
run: |
make clean dist
Expand Down
3 changes: 3 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"printWidth": 150
}
10 changes: 10 additions & 0 deletions app/Actions/Diagnostics/Pipes/Infos/SystemInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

use App\Actions\Diagnostics\Diagnostics;
use App\Contracts\DiagnosticPipe;
use App\Facades\Helpers;
use App\Livewire\Components\Forms\Add\Upload;
use Carbon\CarbonTimeZone;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\DB;
Expand Down Expand Up @@ -53,10 +55,18 @@ public function handle(array &$data, \Closure $next): array
$data[] = Diagnostics::line('Timezone:', ($timeZone !== false ? $timeZone : null)?->getName());
$data[] = Diagnostics::line('Max uploaded file size:', ini_get('upload_max_filesize'));
$data[] = Diagnostics::line('Max post size:', ini_get('post_max_size'));
$this->getUploadLimit($data);
$data[] = Diagnostics::line('Max execution time: ', ini_get('max_execution_time'));
$data[] = Diagnostics::line($dbtype . ' Version:', $dbver);
$data[] = '';

return $next($data);
}

private function getUploadLimit(array &$data): void
{
$size = Upload::getUploadLimit();

$data[] = Diagnostics::line('Livewire chunk size:', Helpers::getSymbolByQuantity($size));
}
}
32 changes: 32 additions & 0 deletions app/Contracts/Livewire/Openable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace App\Contracts\Livewire;

/**
* This defines components which have an openable state.
*
* @property bool $isOpen whether the Openable component is open or not.
*/
interface Openable
{
/**
* Open the component.
*
* @return void
*/
public function open(): void;

/**
* Close the component.
*
* @return void
*/
public function close(): void;

/**
* Toggle the component.
*
* @return void
*/
public function toggle(): void;
}
17 changes: 17 additions & 0 deletions app/Contracts/Livewire/Params.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

namespace App\Contracts\Livewire;

/**
* This defines constants which are used as keys when sending dispatch messages between components.
*/
interface Params
{
public const PARENT_ID = 'parentID';

public const ALBUM_ID = 'albumID';
public const ALBUM_IDS = 'albumIDs';

public const PHOTO_ID = 'photoID';
public const PHOTO_IDS = 'photoIDs';
}
8 changes: 8 additions & 0 deletions app/Contracts/Livewire/Reloadable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

namespace App\Contracts\Livewire;

interface Reloadable
{
public function reloadPage(): void;
}
16 changes: 16 additions & 0 deletions app/Enum/AlbumDecorationOrientation.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,20 @@ enum AlbumDecorationOrientation: string
case ROW_REVERSE = 'row-reverse';
case COLUMN = 'column';
case COLUMN_REVERSE = 'column-reverse';

/**
* Convert the enum into it's translated format.
* Note that it is missing owner.
*
* @return array<string,string>
*/
public static function localized(): array
{
return [
self::ROW->value => __('lychee.ALBUM_DECORATION_ORIENTATION_ROW'),
self::ROW_REVERSE->value => __('lychee.ALBUM_DECORATION_ORIENTATION_ROW_REVERSE'),
self::COLUMN->value => __('lychee.ALBUM_DECORATION_ORIENTATION_COLUMN'),
self::COLUMN_REVERSE->value => __('lychee.ALBUM_DECORATION_ORIENTATION_COLUMN_REVERSE'),
];
}
}
17 changes: 17 additions & 0 deletions app/Enum/AlbumDecorationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,21 @@ enum AlbumDecorationType: string
case ALBUM = 'album';
case PHOTO = 'photo';
case ALL = 'all';

/**
* Convert the enum into it's translated format.
* Note that it is missing owner.
*
* @return array<string,string>
*/
public static function localized(): array
{
return [
self::NONE->value => __('lychee.ALBUM_DECORATION_NONE'),
self::LAYERS->value => __('lychee.ALBUM_DECORATION_ORIGINAL'),
self::ALBUM->value => __('lychee.ALBUM_DECORATION_ALBUM'),
self::PHOTO->value => __('lychee.ALBUM_DECORATION_PHOTO'),
self::ALL->value => __('lychee.ALBUM_DECORATION_ALL'),
];
}
}
21 changes: 20 additions & 1 deletion app/Enum/AlbumLayoutType.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,24 @@ enum AlbumLayoutType: string
{
case SQUARE = 'square';
case JUSTIFIED = 'justified';
case UNJUSTIFIED = 'unjustified';
case UNJUSTIFIED = 'unjustified'; // ! Legcay
case MASONRY = 'masonry';
case GRID = 'grid';

/**
* Convert the enum into it's translated format.
* Note that it is missing owner.
*
* @return array<string,string>
*/
public static function localized(): array
{
// yes, the UNJUSTIFIED is dropped.
return [
self::SQUARE->value => __('lychee.LAYOUT_SQUARES'),
self::JUSTIFIED->value => __('lychee.LAYOUT_JUSTIFIED'),
self::MASONRY->value => __('lychee.LAYOUT_MASONRY'),
self::GRID->value => __('lychee.LAYOUT_GRID'),
];
}
}
16 changes: 16 additions & 0 deletions app/Enum/ImageOverlayType.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,20 @@ enum ImageOverlayType: string
case DESC = 'desc';
case DATE = 'date';
case EXIF = 'exif';

/**
* Convert the enum into it's translated format.
* Note that it is missing owner.
*
* @return array<string,string>
*/
public static function localized(): array
{
return [
self::EXIF->value => __('lychee.OVERLAY_EXIF'),
self::DESC->value => __('lychee.OVERLAY_DESCRIPTION'),
self::DATE->value => __('lychee.OVERLAY_DATE'),
self::NONE->value => __('lychee.OVERLAY_NONE'),
];
}
}
13 changes: 13 additions & 0 deletions app/Enum/Livewire/FileStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace App\Enum\Livewire;

enum FileStatus: string
{
case UPLOADING = 'uploading';
case PROCESSING = 'processing';
case READY = 'ready';
case SKIPPED = 'skipped';
case DONE = 'done';
case ERROR = 'error';
}
11 changes: 11 additions & 0 deletions app/Enum/Livewire/NotificationType.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace App\Enum\Livewire;

enum NotificationType: string
{
case SUCCESS = 'success';
case ERROR = 'error';
case INFO = 'info';
case WARNING = 'warning';
}
35 changes: 35 additions & 0 deletions app/Enum/Traits/WireableEnumTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php

namespace App\Enum\Traits;

use App\Exceptions\Internal\LycheeLogicException;
use Closure;

trait WireableEnumTrait
{
public function toLivewire(): string|int
{
return $this->value;
}

public static function fromLivewire(mixed $value): self
{
if (!is_string($value) && !is_int($value)) {
throw new LycheeLogicException('Enum could not be instanciated from ' . strval($value), null);
}

return self::from($value);
}

/**
* @return string[]|int[]|\Closure
*
* @psalm-return array<string, string|int> | Closure(string):(int|string)
*/
protected static function values()
{
return function (string $name): string {
return mb_strtolower($name);
};
}
}
21 changes: 21 additions & 0 deletions app/Exceptions/PhotoCollectionEmptyException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace App\Exceptions;

use Symfony\Component\HttpFoundation\Response;

/**
* PhotoCollectionEmptyException.
*
* This exception is thrown, if a user request a frame but no pictures can be found.
* We throw an error 500 because it is likely to be a server error.
*/
class PhotoCollectionEmptyException extends BaseLycheeException
{
public const DEFAULT_MESSAGE = 'Photo collection is empty.';

public function __construct(string $msg = self::DEFAULT_MESSAGE, ?\Throwable $previous = null)
{
parent::__construct(Response::HTTP_INTERNAL_SERVER_ERROR, $msg, $previous);
}
}
7 changes: 7 additions & 0 deletions app/Http/Controllers/RedirectController.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ public function photo(Request $request, string $albumID, ?string $photoID): Symf
$this->unlock->do($album, $request['password']);
}

// If we are using livewire by default, we redirect to Livewire url intead.
if (config('app.livewire') === true) {
return $photoID === null ?
redirect(route('livewire-gallery-album', ['albumId' => $albumID])) :
redirect(route('livewire-gallery-photo', ['albumId' => $albumID, 'photoId' => $photoID]));
}

return $photoID === null ?
redirect('gallery#' . $albumID) :
redirect('gallery#' . $albumID . '/' . $photoID);
Expand Down
1 change: 1 addition & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,6 @@ class Kernel extends HttpKernel
'content_type' => \App\Http\Middleware\ContentType::class,
'accept_content_type' => \App\Http\Middleware\AcceptContentType::class,
'redirect-legacy-id' => \App\Http\Middleware\RedirectLegacyPhotoID::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
];
}
Loading