Skip to content

Commit

Permalink
Merge pull request #865 from Kovah/2.x-features
Browse files Browse the repository at this point in the history
Add several new features (#862 #863 #864)
  • Loading branch information
Kovah authored Nov 16, 2024
2 parents bba868d + 3e9fedd commit 5b80fa3
Show file tree
Hide file tree
Showing 44 changed files with 1,056 additions and 459 deletions.
6 changes: 5 additions & 1 deletion app/Http/Controllers/Admin/SystemSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,11 @@ public function update(SystemSettingsUpdateRequest $request): RedirectResponse
public function updateGuest(SystemSettingsUpdateRequest $request): RedirectResponse
{
$guestSettings = app(GuestSettings::class);
$systemSettings = app(SystemSettings::class);

$settings = $request->except(['_token', 'guest_share']);
$systemSettings->guest_access_enabled = $request->input('guest_access_enabled');

$settings = $request->except(['_token', 'guest_share', 'guest_access_enabled']);

foreach ($settings as $key => $value) {
$guestSettings->$key = $value;
Expand All @@ -56,6 +59,7 @@ public function updateGuest(SystemSettingsUpdateRequest $request): RedirectRespo
}
}

$systemSettings->save();
$guestSettings->save();

flash(trans('settings.settings_saved'));
Expand Down
20 changes: 20 additions & 0 deletions app/Http/Controllers/ContactController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace App\Http\Controllers;

use App\Settings\SystemSettings;

class ContactController extends Controller
{
public function __invoke(SystemSettings $systemSettings)
{
if (!$systemSettings->contact_page_enabled) {
abort(404);
}

return view('app.contact', [
'title' => $systemSettings->contact_page_title,
'content' => $systemSettings->contact_page_content,
]);
}
}
2 changes: 2 additions & 0 deletions app/Http/Middleware/SettingsMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public function handle(Request $request, Closure $next): mixed

if ($userLocale = usersettings('locale')) {
app()->setLocale($userLocale);
} else {
app()->setLocale(guestsettings('locale'));
}

return $next($request);
Expand Down
37 changes: 36 additions & 1 deletion app/Http/Requests/SystemSettingsUpdateRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,49 @@ public function rules(): array
return [
'system_page_title' => [
'max:256',
'nullable',
'string',
],
'system_guest_access' => [
'system_logo_text' => [
'max:20',
'nullable',
'string',
],
'additional_footer_link_url' => [
'nullable',
'string',
'required_with:additional_footer_link_text'
],
'additional_footer_link_text' => [
'max:20',
'nullable',
'string',
'required_with:additional_footer_link_url'
],
'contact_page_enabled' => [
'boolean',
],
'contact_page_title' => [
'max:20',
'nullable',
'string',
],
'contact_page_content' => [
'max:10000',
'nullable',
'string',
],
'system_custom_header_content' => [
'nullable',
'string',
],
// Guest settings
'system_guest_access' => [
'boolean',
],
'guest_locale' => [
'string',
],
'guest_listitem_count' => [
'integer',
],
Expand Down
2 changes: 2 additions & 0 deletions app/Settings/GuestSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class GuestSettings extends Settings
public bool $links_new_tab;
public int $darkmode_setting;

public string $locale;

public bool $share_email;
public bool $share_buffer;
public bool $share_evernote;
Expand Down
10 changes: 10 additions & 0 deletions app/Settings/SystemSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,19 @@
class SystemSettings extends Settings
{
public ?string $page_title;
public ?string $logo_text;

public ?string $cron_token;

public ?string $custom_header_content;

public ?string $additional_footer_link_url;
public ?string $additional_footer_link_text;

public bool $contact_page_enabled;
public ?string $contact_page_title;
public ?string $contact_page_content;

public bool $guest_access_enabled;
public bool $setup_completed;

Expand Down
Loading

0 comments on commit 5b80fa3

Please sign in to comment.