forked from corowne/lorekeeper
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'release/v3.0.0' of https://github.com/corowne/lorekeeper …
…into extension/character-titles # Conflicts: # app/Console/Commands/AddSiteSettings.php # app/Http/Controllers/Admin/Characters/CharacterController.php # app/Http/Controllers/Admin/Characters/CharacterImageController.php # app/Http/Controllers/BrowseController.php # app/Http/Controllers/Characters/DesignController.php # app/Http/Controllers/WorldController.php # app/Models/Character/Character.php # app/Models/Character/CharacterDesignUpdate.php # app/Models/Character/CharacterImage.php # app/Services/CharacterManager.php # config/lorekeeper/extension_tracker.php # resources/views/admin/masterlist/create_character.blade.php # resources/views/browse/_masterlist_content.blade.php # resources/views/character/_header.blade.php # resources/views/character/admin/_edit_features_modal.blade.php # resources/views/character/design/features.blade.php # routes/lorekeeper/admin.php
- Loading branch information
Showing
806 changed files
with
73,528 additions
and
35,120 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"indentSize": 4, | ||
"wrapLineLength": 250, | ||
"endWithNewLine": true, | ||
"useTabs": false | ||
} |
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 @@ | ||
vendor/* |
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,27 @@ | ||
name: Lint | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
pull_request: | ||
branches: | ||
- '**' | ||
types: | ||
- opened | ||
- edited | ||
- synchronize | ||
- reopened | ||
|
||
jobs: | ||
pint: | ||
uses: itinerare/github-actions/.github/workflows/pint.yml@main | ||
with: | ||
php-version: '8.1' | ||
concurrency: | ||
group: ci-${{ github.head_ref || github.ref_name }} | ||
|
||
blade-formatter: | ||
uses: itinerare/github-actions/.github/workflows/blade_formatter.yml@main | ||
concurrency: | ||
group: ci-${{ github.head_ref || github.ref_name }} |
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 |
---|---|---|
|
@@ -9,6 +9,6 @@ Homestead.json | |
Homestead.yaml | ||
npm-debug.log | ||
yarn-error.log | ||
/composer.lock | ||
*.env | ||
/composer.phar | ||
*.cache |
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,45 @@ | ||
<?php | ||
|
||
namespace App\Actions\Fortify; | ||
|
||
use App\Models\Invitation; | ||
use App\Models\User\User; | ||
use App\Services\InvitationService; | ||
use App\Services\UserService; | ||
use Illuminate\Support\Facades\Hash; | ||
use Laravel\Fortify\Contracts\CreatesNewUsers; | ||
|
||
class CreateNewUser implements CreatesNewUsers { | ||
use PasswordValidationRules; | ||
|
||
/** | ||
* Validate and create a newly registered user. | ||
* | ||
* @return \App\Models\User | ||
*/ | ||
public function create(array $input) { | ||
(new UserService)->validator($input)->validate(); | ||
|
||
$user = User::create([ | ||
'name' => $input['name'], | ||
'email' => $input['email'], | ||
'password' => Hash::make($input['password']), | ||
'rank_id' => 2, | ||
'birthday' => $input['dob'], | ||
]); | ||
$user->settings()->create([ | ||
'user_id' => $user->id, | ||
]); | ||
$user->profile()->create([ | ||
'user_id' => $user->id, | ||
]); | ||
|
||
if (isset($input['code'])) { | ||
if (!(new InvitationService)->useInvitation(Invitation::where('code', $input['code'])->whereNull('recipient_id')->first(), $user)) { | ||
throw new \Exception('An error occurred while using the invitation code.'); | ||
} | ||
} | ||
|
||
return $user; | ||
} | ||
} |
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\Actions\Fortify; | ||
|
||
use Laravel\Fortify\Rules\Password; | ||
|
||
trait PasswordValidationRules { | ||
/** | ||
* Get the validation rules used to validate passwords. | ||
* | ||
* @return array | ||
*/ | ||
protected function passwordRules() { | ||
return ['required', 'string', new Password, 'confirmed']; | ||
} | ||
} |
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,26 @@ | ||
<?php | ||
|
||
namespace App\Actions\Fortify; | ||
|
||
use Illuminate\Support\Facades\Hash; | ||
use Illuminate\Support\Facades\Validator; | ||
use Laravel\Fortify\Contracts\ResetsUserPasswords; | ||
|
||
class ResetUserPassword implements ResetsUserPasswords { | ||
use PasswordValidationRules; | ||
|
||
/** | ||
* Validate and reset the user's forgotten password. | ||
* | ||
* @param mixed $user | ||
*/ | ||
public function reset($user, array $input) { | ||
Validator::make($input, [ | ||
'password' => $this->passwordRules(), | ||
])->validate(); | ||
|
||
$user->forceFill([ | ||
'password' => Hash::make($input['password']), | ||
])->save(); | ||
} | ||
} |
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,31 @@ | ||
<?php | ||
|
||
namespace App\Actions\Fortify; | ||
|
||
use Illuminate\Support\Facades\Hash; | ||
use Illuminate\Support\Facades\Validator; | ||
use Laravel\Fortify\Contracts\UpdatesUserPasswords; | ||
|
||
class UpdateUserPassword implements UpdatesUserPasswords { | ||
use PasswordValidationRules; | ||
|
||
/** | ||
* Validate and update the user's password. | ||
* | ||
* @param mixed $user | ||
*/ | ||
public function update($user, array $input) { | ||
Validator::make($input, [ | ||
'current_password' => ['required', 'string'], | ||
'password' => $this->passwordRules(), | ||
])->after(function ($validator) use ($user, $input) { | ||
if (!isset($input['current_password']) || !Hash::check($input['current_password'], $user->password)) { | ||
$validator->errors()->add('current_password', __('The provided password does not match your current password.')); | ||
} | ||
})->validateWithBag('updatePassword'); | ||
|
||
$user->forceFill([ | ||
'password' => Hash::make($input['password']), | ||
])->save(); | ||
} | ||
} |
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,54 @@ | ||
<?php | ||
|
||
namespace App\Actions\Fortify; | ||
|
||
use Illuminate\Contracts\Auth\MustVerifyEmail; | ||
use Illuminate\Support\Facades\Validator; | ||
use Illuminate\Validation\Rule; | ||
use Laravel\Fortify\Contracts\UpdatesUserProfileInformation; | ||
|
||
class UpdateUserProfileInformation implements UpdatesUserProfileInformation { | ||
/** | ||
* Validate and update the given user's profile information. | ||
* | ||
* @param mixed $user | ||
*/ | ||
public function update($user, array $input) { | ||
Validator::make($input, [ | ||
'name' => ['required', 'string', 'max:255'], | ||
|
||
'email' => [ | ||
'required', | ||
'string', | ||
'email', | ||
'max:255', | ||
Rule::unique('users')->ignore($user->id), | ||
], | ||
])->validateWithBag('updateProfileInformation'); | ||
|
||
if ($input['email'] !== $user->email && | ||
$user instanceof MustVerifyEmail) { | ||
$this->updateVerifiedUser($user, $input); | ||
} else { | ||
$user->forceFill([ | ||
'name' => $input['name'], | ||
'email' => $input['email'], | ||
])->save(); | ||
} | ||
} | ||
|
||
/** | ||
* Update the given verified user's profile information. | ||
* | ||
* @param mixed $user | ||
*/ | ||
protected function updateVerifiedUser($user, array $input) { | ||
$user->forceFill([ | ||
'name' => $input['name'], | ||
'email' => $input['email'], | ||
'email_verified_at' => null, | ||
])->save(); | ||
|
||
$user->sendEmailVerificationNotification(); | ||
} | ||
} |
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,105 @@ | ||
<?php | ||
|
||
namespace App\Console\Commands; | ||
|
||
use App\Models\Character\CharacterCategory; | ||
use App\Models\Currency\Currency; | ||
use App\Models\Feature\Feature; | ||
use App\Models\Feature\FeatureCategory; | ||
use App\Models\Item\Item; | ||
use App\Models\Item\ItemCategory; | ||
use App\Models\Prompt\Prompt; | ||
use App\Models\Prompt\PromptCategory; | ||
use App\Models\Rarity; | ||
use App\Models\Shop\Shop; | ||
use App\Models\Species\Species; | ||
use App\Models\Species\Subtype; | ||
use App\Services\FeatureService; | ||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Facades\File; | ||
|
||
class AddImageHashes extends Command { | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'add-image-hashes'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'Adds hashes to any existing images that don\'t already have them.'; | ||
|
||
/** | ||
* Create a new command instance. | ||
*/ | ||
public function __construct() { | ||
parent::__construct(); | ||
} | ||
|
||
/** | ||
* Execute the console command. | ||
* | ||
* @return mixed | ||
*/ | ||
public function handle() { | ||
$images = CharacterCategory::where('has_image', 1)->whereNull('hash')->get(); | ||
$images = $images->concat(Currency::where('has_image', 1)->whereNull('hash')->orWhere('has_icon', 1)->whereNull('hash')->get()); | ||
$images = $images->concat(Feature::where('has_image', 1)->whereNull('hash')->get()); | ||
$images = $images->concat(FeatureCategory::where('has_image', 1)->whereNull('hash')->get()); | ||
$images = $images->concat(Item::where('has_image', 1)->whereNull('hash')->get()); | ||
$images = $images->concat(ItemCategory::where('has_image', 1)->whereNull('hash')->get()); | ||
$images = $images->concat(Prompt::where('has_image', 1)->whereNull('hash')->get()); | ||
$images = $images->concat(PromptCategory::where('has_image', 1)->whereNull('hash')->get()); | ||
$images = $images->concat(Rarity::where('has_image', 1)->whereNull('hash')->get()); | ||
$images = $images->concat(Shop::where('has_image', 1)->whereNull('hash')->get()); | ||
$images = $images->concat(Species::where('has_image', 1)->whereNull('hash')->get()); | ||
$images = $images->concat(Subtype::where('has_image', 1)->whereNull('hash')->get()); | ||
|
||
if ($images->count()) { | ||
$this->line('Updating images...'); | ||
foreach ($images as $image) { | ||
$oldName = $image->id.'-image.png'; | ||
$image->hash = randomString(10); | ||
// Any service works, I can't use the abstract one | ||
if ( | ||
File::exists(public_path($image->imageDirectory).'/'.$oldName) && | ||
(new FeatureService)->handleImage( | ||
null, | ||
public_path($image->imageDirectory), | ||
$image->hash.$image->id.'-image.png', | ||
$oldName | ||
) | ||
) { | ||
$image->save(); | ||
} else { | ||
$this->info('Didn\'t add hash to '.get_class($image).', this could be expected or an error, id '.$image->id); | ||
} | ||
|
||
// Just for currency icons | ||
if ($image instanceof Currency) { | ||
$oldName = $image->id.'-icon.png'; | ||
if ( | ||
File::exists(public_path($image->imageDirectory).'/'.$oldName) && | ||
(new FeatureService)->handleImage( | ||
null, | ||
public_path($image->imageDirectory), | ||
$image->hash.$image->id.'-icon.png', | ||
$oldName | ||
) | ||
) { | ||
$image->save(); | ||
} else { | ||
$this->info('Didn\'t add hash to currency icon image, this could be expected or an error, id '.$image->id); | ||
} | ||
} | ||
} | ||
$this->info('Updated images.'); | ||
} else { | ||
$this->line('No images need updating!'); | ||
} | ||
} | ||
} |
Oops, something went wrong.