From 941a773b7d931ce097db11de8d3a09ade0c2071c Mon Sep 17 00:00:00 2001 From: Omar Roth Date: Wed, 21 Nov 2018 20:00:17 -0600 Subject: [PATCH] Add opensearch.xml --- src/invidious.cr | 15 +++++++++++++++ src/invidious/views/template.ecr | 1 + 2 files changed, 16 insertions(+) diff --git a/src/invidious.cr b/src/invidious.cr index 74ae35db..de40698f 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -512,6 +512,21 @@ end # Search +get "/opensearch.xml" do |env| + env.response.content_type = "application/opensearchdescription+xml" + + XML.build(indent: " ", encoding: "UTF-8") do |xml| + xml.element("OpenSearchDescription", xmlns: "http://a9.com/-/spec/opensearch/1.1/") do + xml.element("ShortName") { xml.text "Invidious" } + xml.element("LongName") { xml.text "Invidious Search" } + xml.element("Description") { xml.text "Search for videos, channels, and playlists on Invidious" } + xml.element("InputEncoding") { xml.text "UTF-8" } + xml.element("Image", width: 48, height: 48, type: "image/x-icon") { xml.text "/favicon.ico" } + xml.element("Url", type: "text/html", method: "get", template: "/search?q={searchTerms}") + end + end +end + get "/results" do |env| query = env.params.query["search_query"]? query ||= env.params.query["q"]? diff --git a/src/invidious/views/template.ecr b/src/invidious/views/template.ecr index 748a691f..4cfb41df 100644 --- a/src/invidious/views/template.ecr +++ b/src/invidious/views/template.ecr @@ -13,6 +13,7 @@ +