Skip to content

NOW MANAGED ON CODEBERG

Add XML for OpenSearch

Maximilian Walter476c2be5a625
diff --git a/app/App/MetaController.php b/app/App/MetaController.php
index 1515b4f7e..a94334c58 100644
--- a/app/App/MetaController.php
+++ b/app/App/MetaController.php
@@ -64,4 +64,14 @@ class MetaController extends Controller
'jsLibData' => file_get_contents(base_path('dev/licensing/js-library-licenses.txt')),
]);
}
+
+ /**
+ * Show the view for /opensearch.xml.
+ */
+ public function opensearch()
+ {
+ return response()
+ ->view('misc.opensearch')
+ ->header('Content-Type', 'application/opensearchdescription+xml');
+ }
}
diff --git a/resources/views/layouts/base.blade.php b/resources/views/layouts/base.blade.php
index 4d4d07dc2..ddecb8e76 100644
--- a/resources/views/layouts/base.blade.php
+++ b/resources/views/layouts/base.blade.php
@@ -32,6 +32,9 @@
<link rel="manifest" href="{{ url('/manifest.json') }}">
<meta name="mobile-web-app-capable" content="yes">
+ <!-- OpenSearch -->
+ <link rel="search" type="application/opensearchdescription+xml" title="{{ setting('app-name') }}" href="{{ url('/opensearch.xml') }}">
+
@yield('head')
<!-- Custom Styles & Head Content -->
diff --git a/resources/views/misc/opensearch.blade.php b/resources/views/misc/opensearch.blade.php
new file mode 100644
index 000000000..cfcca8e41
--- /dev/null
+++ b/resources/views/misc/opensearch.blade.php
@@ -0,0 +1,11 @@
+<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
+ <ShortName>{{ setting('app-name') }}</ShortName>
+ <Description>Search {{ setting('app-name') }}</Description>
+ <Image width="256" height="256" type="image/png">{{ setting('app-icon') ?: url('/icon.png') }}</Image>
+ <Image width="180" height="180" type="image/png">{{ setting('app-icon-180') ?: url('/icon-180.png') }}</Image>
+ <Image width="128" height="128" type="image/png">{{ setting('app-icon-128') ?: url('/icon-128.png') }}</Image>
+ <Image width="64" height="64" type="image/png">{{ setting('app-icon-64') ?: url('/icon-64.png') }}</Image>
+ <Image width="32" height="32" type="image/png">{{ setting('app-icon-32') ?: url('/icon-32.png') }}</Image>
+ <Url type="text/html" rel="results" method="get" template="{{ url('/search') }}?term={searchTerms}"/>
+ <Url type="application/opensearchdescription+xml" rel="self" template="{{ url('/opensearch.xml') }}"/>
+</OpenSearchDescription>
diff --git a/routes/web.php b/routes/web.php
index 58b8f4e54..81b938f32 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -23,6 +23,7 @@ Route::get('/robots.txt', [MetaController::class, 'robots']);
Route::get('/favicon.ico', [MetaController::class, 'favicon']);
Route::get('/manifest.json', [MetaController::class, 'pwaManifest']);
Route::get('/licenses', [MetaController::class, 'licenses']);
+Route::get('/opensearch.xml', [MetaController::class, 'opensearch']);
// Authenticated routes...
Route::middleware('auth')->group(function () {