NOW MANAGED ON CODEBERG
Fixed settings redirect issue and custom head display
Dan Brownda4308bb0f69
diff --git a/app/Http/Controllers/SettingController.php b/app/Http/Controllers/SettingController.phpindex 598058ef4..2e46bbe40 100644--- a/app/Http/Controllers/SettingController.php+++ b/app/Http/Controllers/SettingController.php@@ -19,9 +19,17 @@ class SettingController extends Controller}/**- * Display a listing of the settings.+ * Handle requests to the settings index path*/- public function index(string $category)+ public function index()+ {+ return redirect('/settings/features');+ }++ /**+ * Display the settings for the given category.+ */+ public function category(string $category){$this->ensureCategoryExists($category);$this->checkPermission('settings-manage');diff --git a/resources/views/common/custom-head.blade.php b/resources/views/common/custom-head.blade.phpindex 7f2e93cdc..a13215cf8 100644--- a/resources/views/common/custom-head.blade.php+++ b/resources/views/common/custom-head.blade.php@@ -1,6 +1,6 @@@inject('headContent', 'BookStack\Theming\CustomHtmlHeadContentProvider')-@if(setting('app-custom-head') && \Route::currentRouteName() !== 'settings')+@if(setting('app-custom-head') && !request()->routeIs('settings.category'))<!-- Start: custom user content -->{!! $headContent->forWeb() !!}<!-- End: custom user content -->diff --git a/routes/web.php b/routes/web.phpindex 223d97c66..37f59b970 100644--- a/routes/web.php+++ b/routes/web.php@@ -265,8 +265,8 @@ Route::middleware('auth')->group(function () {Route::delete('/settings/webhooks/{id}', [WebhookController::class, 'destroy']);// Settings- Route::redirect('/settings', '/settings/features')->name('settings');- Route::get('/settings/{category}', [SettingController::class, 'index']);+ Route::get('/settings', [SettingController::class, 'index'])->name('settings');+ Route::get('/settings/{category}', [SettingController::class, 'category'])->name('settings.category');Route::post('/settings/{category}', [SettingController::class, 'update']);});diff --git a/tests/Settings/CustomHeadContentTest.php b/tests/Settings/CustomHeadContentTest.phpindex eeeab3f45..b2e21b91c 100644--- a/tests/Settings/CustomHeadContentTest.php+++ b/tests/Settings/CustomHeadContentTest.php@@ -26,7 +26,7 @@ class CustomHeadContentTest extends TestCasepublic function test_configured_content_does_not_show_on_settings_page(){$this->setSettings(['app-custom-head' => '<script>console.log("cat");</script>']);- $resp = $this->asAdmin()->get('/settings');+ $resp = $this->asAdmin()->get('/settings/features');$resp->assertDontSee('console.log("cat")', false);}diff --git a/tests/Settings/SettingsTest.php b/tests/Settings/SettingsTest.phpindex bef354dac..48840fc0b 100644--- a/tests/Settings/SettingsTest.php+++ b/tests/Settings/SettingsTest.php@@ -10,7 +10,11 @@ class SettingsTest extends TestCase{$resp = $this->asAdmin()->get('/settings');- $resp->assertRedirect('/settings/features');+ $resp->assertStatus(302);++ // Manually check path to ensure it's generated as the full path+ $location = $resp->headers->get('location');+ $this->assertEquals(url('/settings/features'), $location);}public function test_settings_category_links_work_as_expected()