From 0dccd1a7f89b90a068f9400a3d2ea8ab3c996b00 Mon Sep 17 00:00:00 2001 From: Kovah Date: Sat, 16 Nov 2024 11:55:02 +0100 Subject: [PATCH] Add several new features (#862 #863 #864) - contact page with editable content - additional footer link - custom navbar title / logo text - small optimizations for guest mode --- .../Admin/SystemSettingsController.php | 6 +- app/Http/Controllers/ContactController.php | 20 +++ app/Http/Middleware/SettingsMiddleware.php | 2 + .../Requests/SystemSettingsUpdateRequest.php | 37 +++++- app/Settings/GuestSettings.php | 2 + app/Settings/SystemSettings.php | 10 ++ config/settings.php | 1 + ...24_11_16_092942_extend_system_settings.php | 20 +++ lang/en_US/linkace.php | 1 + lang/en_US/settings.php | 11 ++ resources/assets/sass/custom/_app.scss | 4 + .../partials/general-settings.blade.php | 119 ++++++++++++++++-- .../partials/guest-settings.blade.php | 46 +++++++ resources/views/app/contact.blade.php | 13 ++ .../views/layouts/partials/footer.blade.php | 10 ++ .../partials/configure-darkmode.blade.php | 6 +- resources/views/partials/nav.blade.php | 12 +- routes/web.php | 3 + tests/Controller/API/GeneralApiTest.php | 3 +- 19 files changed, 304 insertions(+), 22 deletions(-) create mode 100644 app/Http/Controllers/ContactController.php create mode 100644 database/settings/2024_11_16_092942_extend_system_settings.php create mode 100644 resources/views/app/contact.blade.php diff --git a/app/Http/Controllers/Admin/SystemSettingsController.php b/app/Http/Controllers/Admin/SystemSettingsController.php index 46bd58a1..05816ce4 100644 --- a/app/Http/Controllers/Admin/SystemSettingsController.php +++ b/app/Http/Controllers/Admin/SystemSettingsController.php @@ -41,8 +41,11 @@ class SystemSettingsController extends Controller 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; @@ -56,6 +59,7 @@ class SystemSettingsController extends Controller } } + $systemSettings->save(); $guestSettings->save(); flash(trans('settings.settings_saved')); diff --git a/app/Http/Controllers/ContactController.php b/app/Http/Controllers/ContactController.php new file mode 100644 index 00000000..959fecd3 --- /dev/null +++ b/app/Http/Controllers/ContactController.php @@ -0,0 +1,20 @@ +contact_page_enabled) { + abort(404); + } + + return view('app.contact', [ + 'title' => $systemSettings->contact_page_title, + 'content' => $systemSettings->contact_page_content, + ]); + } +} diff --git a/app/Http/Middleware/SettingsMiddleware.php b/app/Http/Middleware/SettingsMiddleware.php index c329c38c..7737502b 100644 --- a/app/Http/Middleware/SettingsMiddleware.php +++ b/app/Http/Middleware/SettingsMiddleware.php @@ -28,6 +28,8 @@ class SettingsMiddleware if ($userLocale = usersettings('locale')) { app()->setLocale($userLocale); + } else { + app()->setLocale(guestsettings('locale')); } return $next($request); diff --git a/app/Http/Requests/SystemSettingsUpdateRequest.php b/app/Http/Requests/SystemSettingsUpdateRequest.php index 7cd42b49..fc590088 100644 --- a/app/Http/Requests/SystemSettingsUpdateRequest.php +++ b/app/Http/Requests/SystemSettingsUpdateRequest.php @@ -11,14 +11,49 @@ class SystemSettingsUpdateRequest extends FormRequest 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', ], diff --git a/app/Settings/GuestSettings.php b/app/Settings/GuestSettings.php index 70ec6c03..25080146 100644 --- a/app/Settings/GuestSettings.php +++ b/app/Settings/GuestSettings.php @@ -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; diff --git a/app/Settings/SystemSettings.php b/app/Settings/SystemSettings.php index 78b728ca..e9b6fbac 100644 --- a/app/Settings/SystemSettings.php +++ b/app/Settings/SystemSettings.php @@ -7,9 +7,19 @@ use Spatie\LaravelSettings\Settings; 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; diff --git a/config/settings.php b/config/settings.php index c7c673a8..a80d84c5 100644 --- a/config/settings.php +++ b/config/settings.php @@ -7,6 +7,7 @@ return [ * put them (manually) here. */ 'settings' => [ + \App\Settings\GuestSettings::class, \App\Settings\SystemSettings::class, \App\Settings\UserSettings::class, ], diff --git a/database/settings/2024_11_16_092942_extend_system_settings.php b/database/settings/2024_11_16_092942_extend_system_settings.php new file mode 100644 index 00000000..1b3a30c9 --- /dev/null +++ b/database/settings/2024_11_16_092942_extend_system_settings.php @@ -0,0 +1,20 @@ +migrator->add('system.logo_text', null); + + $this->migrator->add('system.additional_footer_link_url', null); + $this->migrator->add('system.additional_footer_link_text', null); + + $this->migrator->add('system.contact_page_enabled', false); + $this->migrator->add('system.contact_page_title', null); + $this->migrator->add('system.contact_page_content', null); + + $this->migrator->add('guest.locale', config('app.fallback_locale')); + } +} diff --git a/lang/en_US/linkace.php b/lang/en_US/linkace.php index 5ac2aaea..062f71e7 100644 --- a/lang/en_US/linkace.php +++ b/lang/en_US/linkace.php @@ -47,6 +47,7 @@ return [ 'menu' => 'Menu', 'entries' => 'Entries', 'feed' => 'Feed', + 'contact' => 'Contact', 'continue_adding' => 'Continue Adding', diff --git a/lang/en_US/settings.php b/lang/en_US/settings.php index cdd417cd..30faf601 100644 --- a/lang/en_US/settings.php +++ b/lang/en_US/settings.php @@ -74,11 +74,22 @@ return [ 'two_factor_regenerate_recovery_codes' => 'Generate new Recovery Codes', 'page_title' => 'Page Title', + 'logo_text' => 'Custom Logo Text', 'guest_access' => 'Enable Guest Access', 'guest_access_help' => 'If enabled, guest will be able to see all links that are not private.', 'custom_header_content' => 'Custom Header Content', 'custom_header_content_help' => 'Content entered here will be placed before the </head> tag on all LinkAce sites. Useful to place analytics or customization scripts. Caution: contents are not escaped and may break the site!', + 'additional_footer_link' => 'Additional Link in the Footer', + 'additional_footer_link_url' => 'Link URL', + 'additional_footer_link_text' => 'Link Text', + + 'contact_page' => 'Contact/About Page', + 'contact_page_info' => 'The contact/about page can be used to display additional information about your bookmarks. The link is visible in the footer. Markdown is supported.', + 'contact_page_enabled' => 'Enable the contact/about page', + 'contact_page_title' => 'Custom title for the page', + 'contact_page_content' => 'Content of the page', + 'cron_token' => 'Cron Token', 'cron_token_generate' => 'Generate Token', 'cron_token_generate_confirm' => 'Do you really want to generate a new token?', diff --git a/resources/assets/sass/custom/_app.scss b/resources/assets/sass/custom/_app.scss index 32fe1e6e..10d663e8 100644 --- a/resources/assets/sass/custom/_app.scss +++ b/resources/assets/sass/custom/_app.scss @@ -50,6 +50,10 @@ body:not(.bookmarklet) { } } +.navbar-brand { + font-family: $font-family-sans-condensed; +} + .card-table { margin: -#{$card-border-width}; diff --git a/resources/views/admin/system-settings/partials/general-settings.blade.php b/resources/views/admin/system-settings/partials/general-settings.blade.php index 2a2807ce..49e0bd46 100644 --- a/resources/views/admin/system-settings/partials/general-settings.blade.php +++ b/resources/views/admin/system-settings/partials/general-settings.blade.php @@ -27,17 +27,14 @@
-
@@ -45,24 +42,122 @@
+
+
@lang('settings.additional_footer_link')
+
+ +
+ + + @if ($errors->has('additional_footer_link_url')) + + @endif +
+ +
+
+ +
+ + + @if ($errors->has('additional_footer_link_text')) + + @endif +
+ +
+
+ +
+
+
@lang('settings.contact_page')
+

@lang('settings.contact_page_info')

+
+
+ +
+ + +

@lang('settings.guest_access_help')

+ @if ($errors->has('contact_page_enabled')) + + @endif +
+ +
+
+ +
+ + + @if ($errors->has('contact_page_title')) + + @endif +
+ +
+
+ +
+ + + @error('contact_page_content') + + @enderror +
+ +
+
+
+
-

@lang('settings.custom_header_content_help')

- @error('custom_header_content') @enderror
+
diff --git a/resources/views/admin/system-settings/partials/guest-settings.blade.php b/resources/views/admin/system-settings/partials/guest-settings.blade.php index ca989b5e..b664dcf4 100644 --- a/resources/views/admin/system-settings/partials/guest-settings.blade.php +++ b/resources/views/admin/system-settings/partials/guest-settings.blade.php @@ -10,6 +10,52 @@ @csrf
+
+ +
+ + +

@lang('settings.guest_access_help')

+ @if ($errors->has('guest_access_enabled')) + + @endif +
+ +
+
+
+
+
+
+ +
+ + + @if($errors->has('locale')) + + @endif +
+ +
diff --git a/resources/views/app/contact.blade.php b/resources/views/app/contact.blade.php new file mode 100644 index 00000000..b04cdd3f --- /dev/null +++ b/resources/views/app/contact.blade.php @@ -0,0 +1,13 @@ +@extends('layouts.app') + +@section('content') +
+

{{ $title ?? trans('linkace.contact') }}

+ +
+
+ {!! \Illuminate\Support\Str::markdown($content) !!} +
+
+
+@endsection diff --git a/resources/views/layouts/partials/footer.blade.php b/resources/views/layouts/partials/footer.blade.php index 840e6bd4..a8b16263 100644 --- a/resources/views/layouts/partials/footer.blade.php +++ b/resources/views/layouts/partials/footer.blade.php @@ -1,6 +1,16 @@