Skip to content

Commit

Permalink
squash to clean history
Browse files Browse the repository at this point in the history
  • Loading branch information
ildyria committed Jan 11, 2023
1 parent dc33883 commit fde767e
Show file tree
Hide file tree
Showing 129 changed files with 6,403 additions and 1,623 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ APP_URL=http://localhost

# enable or disable debug bar. By default it is disabled.
DEBUGBAR_ENABLED=false
LIVEWIRE_ENABLED=false

##############################################################################
# IMPORTANT: To migrate from Lychee v3 you *MUST* use the same MySQL/MariaDB #
Expand Down
22 changes: 22 additions & 0 deletions app/Assets/Helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,28 @@ public function data_index_set(int $idx = 0): void
$this->numTab = $idx;
}

/**
* From https://www.php.net/manual/en/function.disk-total-space.php.
*
* @param float $bytes
*
* @return string
*/
public function getSymbolByQuantity(float $bytes): string
{
$symbols = [
'B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB',
];
$exp = intval(floor(log($bytes) / log(1024.0)));

if ($exp >= sizeof($symbols)) {
// if the number is too large, we fall back to the largest available symbol
$exp = sizeof($symbols) - 1;
}

return sprintf('%.2f %s', ($bytes / pow(1024, $exp)), $symbols[$exp]);
}

/**
* Check if the `exec` function is available.
*
Expand Down
3 changes: 2 additions & 1 deletion app/Contracts/Models/AbstractAlbum.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Relations\Relation;
use Livewire\Wireable;

/**
* Interface AbsractAlbum.
Expand All @@ -30,7 +31,7 @@
* @property bool $grants_download
* @property bool $grants_full_photo_access
*/
interface AbstractAlbum extends \JsonSerializable, Arrayable, Jsonable
interface AbstractAlbum extends \JsonSerializable, Arrayable, Jsonable, Wireable
{
/**
* @return Relation|Builder
Expand Down
3 changes: 1 addition & 2 deletions app/DTO/AlbumProtectionPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\DTO;

use App\Models\Album;
use App\Models\BaseAlbumImpl;
use App\Models\Configs;
use App\Models\Extensions\BaseAlbum;
Expand Down Expand Up @@ -56,7 +55,7 @@ public static function ofBaseAlbumImplementation(BaseAlbumImpl $baseAlbum): self
/**
* Given a {@link BaseAlbum}, returns the Protection Policy associated to it.
*
* @param Album $baseAlbum
* @param BaseAlbum $baseAlbum
*
* @return AlbumProtectionPolicy
*/
Expand Down
15 changes: 15 additions & 0 deletions app/Enum/AlbumMode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace App\Enum;

use App\Enum\Traits\WireableEnumTrait;
use Livewire\Wireable;

enum AlbumMode: int implements Wireable
{
use WireableEnumTrait;

case FLKR = 0;
case MASONRY = 1;
case SQUARE = 2;
}
16 changes: 16 additions & 0 deletions app/Enum/PageMode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace App\Enum;

use App\Enum\Traits\WireableEnumTrait;
use Livewire\Wireable;

enum PageMode: string implements Wireable
{
use WireableEnumTrait;

case ALBUM = 'album';
case ALBUMS = 'albums';
case PHOTO = 'photo';
case MAP = 'map';
}
42 changes: 42 additions & 0 deletions app/Enum/PhotoOverlayMode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace App\Enum;

use App\Enum\Traits\WireableEnumTrait;
use Livewire\Wireable;

enum PhotoOverlayMode: string implements Wireable
{
use WireableEnumTrait;

case NONE = 'none';
case DESC = 'desc';
case EXIF = 'exif';
case DATE = 'date';

/**
* Iterate to the next OverlayMode.
*
* @return PhotoOverlayMode
*/
public function next(): PhotoOverlayMode
{
return match ($this) {
self::NONE => self::DESC,
self::DESC => self::DATE,
self::DATE => self::EXIF,
self::EXIF => self::NONE,
default => self::NONE
};
}

/**
* Number of valid values.
*
* @return int
*/
public static function count(): int
{
return 4;
}
}
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);
};
}
}
1 change: 0 additions & 1 deletion app/Http/Controllers/Administration/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ public function updateLogin(ChangeLoginRequest $request, UpdateLogin $updateLogi
$request->oldPassword(),
$request->ip()
);

// Update the session with the new credentials of the user.
// Otherwise, the session is out-of-sync and falsely assumes the user
// to be unauthenticated upon the next request.
Expand Down
65 changes: 0 additions & 65 deletions app/Http/Livewire/Album.php

This file was deleted.

37 changes: 0 additions & 37 deletions app/Http/Livewire/Albums.php

This file was deleted.

90 changes: 90 additions & 0 deletions app/Http/Livewire/Components/Base/Modal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<?php

namespace App\Http\Livewire\Components\Base;

use Illuminate\View\View;

/**
* Modal component, extends Openable.
*
* This aims to encapsulate any floating box that appears in Lychee Interface:
* - login
* - privacy properties...
*/
class Modal extends Openable
{
/** @var string defines the opacity status (unused for now) */
public string $opacity = '0';

/**
* ! defines the type of Modal. This correspond to the Livewire component loaded inside the Modal.
*
* @var string
*/
public string $type = '';

/**
* ! defines the arguments to be passed to the Livewire component loaded inside the Modal.
*
* @var array
*/
public array $params = [];

/**
* Css properties for the modal.
*
* @var string
*/
public string $modalSize = 'md:max-w-xl';

/**
* This defined the events that the Component will intercept.
* In order to facilitate the use of those events, the trait
* app/Livewire/Traits/InteractWithModal.php can be used to
* add access to the modal.
*
* @var string[] listeners for modal events
* */
protected $listeners = [
'openModal',
'closeModal',
'deleteModal',
];

/**
* Open a Modal.
*
* @param string $type defines the Component loaded inside the modal
* @param array $params Arguments to pass to the modal
*
* @return void
*/
public function openModal(string $type, array $params = []): void
{
$this->open();
$this->type = $type;
$this->params = $params;
$this->opacity = '100';
}

/**
* Close the Modal component.
*
* @return void
*/
public function closeModal(): void
{
$this->close();
$this->opacity = '0';
}

/**
* Rendering of the Component.
*
* @return View
*/
public function render(): View
{
return view('livewire.modal');
}
}
Loading

0 comments on commit fde767e

Please sign in to comment.