Skip to content

Commit

Permalink
try fix opensearch generation and discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
h.u.g.u.rp committed Jul 16, 2023
1 parent ad78d98 commit 90b0b71
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 95 deletions.
14 changes: 3 additions & 11 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<title>Find('!?')</title>
<title>Find</title>
<meta charset="utf-8">

<meta name="viewport" content="width=device-width">
<meta name="description" content="">

<link rel="apple-touch-icon" sizes="180x180" href="./public/favicons/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="./public/favicons/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="./public/favicons/favicon-16x16.png">
<link rel="manifest" href="./public/favicons/manifest.json">
<link rel="shortcut icon" href="./public/favicons/favicon.ico">
<meta name="msapplication-config" content="./public/favicons/browserconfig.xml">
<meta name="theme-color" content="#ffffff">
<link rel="shortcut icon" href="./public/favicon.ico">

<!-- define the open search so find is easily "discoverable" as a search engine
`title` property should match `ShortName` key of the xml -->
<link rel="search" type="application/opensearchdescription+xml" href="./public/opensearch.xml" title="Find" />
<link rel="self" type="application/opensearchdescription+xml" href="./public/opensearch.xml" title="Find" />

<!-- the main Find! script. Loads and parse user query from URL, then redirects if any -->
<script type="module">
Expand Down
24 changes: 6 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,11 @@
"localStorageKey": "i4find",
"queryParamName": "q",
"documentationUrl": "https://github.com/internet4000/find",
"osd": {
"shortName": "Find",
"description": "Find anything anywhere",
"tags": "find now productivity search",
"contact": "https://github.com/internet4000",
"templateHTML": "https://internet4000.github.io/find/#q={searchTerms}",
"templateXML": "https://internet4000.github.io/find/public/opensearch.xml",
"image": "https://internet4000.github.io/find/public/favicons/favicon-32x32.png",
"longName": "Customize the browser omnibox URL bar with custom search engines and actions",
"exampleSearchTerms": "!gh internet4000",
"developer": "i4k",
"attribution": "gpl-v3",
"syndicationRight": "open",
"adultContent": "false",
"language": "en-us",
"outputEncoding": "UTF-8",
"inputEncoding": "UTF-8"
}
"shortName": "Find",
"description": "Find anything anywhere",
"image": "https://internet4000.github.io/find/public/favicon.ico",
"templateHTML": "https://internet4000.github.io/find/#q={searchTerms}",
"templateXML": "https://internet4000.github.io/find/public/opensearch.xml",
"templateSuggestionsJSON": "https://internet4000.github.io/find/public/opensearch.xml"
}
}
45 changes: 7 additions & 38 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,20 +109,10 @@ export class OpenSearchDescription {
return [
"shortName",
"description",
"tags",
"contact",
"templateHTML",
"templateXML",
"templateSuggestionsJSON",
"image",
"longName",
"exampleSearchTerms",
"developer",
"attribution",
"syndicationRight",
"adultContent",
"language",
"outputEncoding",
"inputEncoding",
];
}
get config() {
Expand All @@ -149,20 +139,10 @@ export class OpenSearchDescription {
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>${config.shortName}</ShortName>
<Description>${config.description}</Description>
<Tags>${config.tags}</Tags>
<Contact>${config.contact}</Contact>
<Image height="64" width="64" type="image/png">${config.image}</Image>
<Url type="text/html" template="${config.templateHTML}" />
<Url type="application/opensearchdescription+xml" rel="self" template="${config.templateXML}" />
<Image height="64" width="64" type="image/png">${config.image}</Image>
<LongName>${config.longName}</LongName>
<Query role="example" searchTerms="${config.exampleSearchTerms}" />
<Developer>${config.developer}</Developer>
<Attribution>${config.attribution}</Attribution>
<SyndicationRight>${config.syndicationRight}</SyndicationRight>
<AdultContent>${config.adultContent}</AdultContent>
<Language>${config.language}</Language>
<OutputEncoding>${config.outputEncoding}</OutputEncoding>
<InputEncoding>${config.inputEncoding}</InputEncoding>
<Url type="application/x-suggestions+json" template="${config.templateSuggestionsJSON}" />
</OpenSearchDescription>`;
}

Expand Down Expand Up @@ -477,22 +457,11 @@ export class I4kFind {
export const DEFAULT_OSD = {
shortName: "Find",
description: "Find anything anywhere",
tags: "find now productivity search",
contact: "internet4000.com",
image: "https://internet4000.github.io/find/public/favicon.ico",
templateHTML: "https://internet4000.github.io/find/#q={searchTerms}",
templateXML: "https://internet4000.github.io/find/opensearch.xml",
image:
"https://internet4000.github.io/find/public/favicons/favicon-32x32.png",
longName:
"Customize the browser omnibox URL bar with custom search engines and actions",
exampleSearchTerms: "test",
developer: "Internet4000",
attribution: "public domain",
syndicationRight: "open",
adultContent: "false",
language: "en-us",
outputEncoding: "UTF-8",
inputEncoding: "UTF-8",
templateXML: "https://internet4000.github.io/find/public/opensearch.xml",
templateSuggestionsJSON:
"https://internet4000.github.io/find/public/suggestions.json",
};

const App = new I4kFind();
Expand Down
35 changes: 7 additions & 28 deletions src/tests/open-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,21 @@ import Find, { OpenSearchDescription } from "../../src/index.js";
const CONFIG_EXPORT = {
shortName: "Find",
description: "Find anything anywhere",
tags: "find now productivity search",
contact: "internet4000.com",
image: "https://internet4000.github.io/find/public/favicon.ico",
templateHTML: "https://internet4000.github.io/find/#q={searchTerms}",
templateXML: "https://internet4000.github.io/find/opensearch.xml",
image:
"https://internet4000.github.io/find/public/favicons/favicon-32x32.png",
longName:
"Customize the browser omnibox URL bar with custom search engines and actions",
exampleSearchTerms: "test",
developer: "Internet4000",
attribution: "public domain",
syndicationRight: "open",
adultContent: "false",
language: "en-us",
outputEncoding: "UTF-8",
inputEncoding: "UTF-8",
templateXML: "https://internet4000.github.io/find/public/opensearch.xml",
templateSuggestionsJSON:
"https://internet4000.github.io/find/public/suggestions.json",
};

const XML_EXPORT = `<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>Find</ShortName>
<Description>Find anything anywhere</Description>
<Tags>find now productivity search</Tags>
<Contact>internet4000.com</Contact>
<Image height="64" width="64" type="image/png">https://internet4000.github.io/find/public/favicon.ico</Image>
<Url type="text/html" template="https://internet4000.github.io/find/#q={searchTerms}" />
<Url type="application/opensearchdescription+xml" rel="self" template="https://internet4000.github.io/find/opensearch.xml" />
<Image height="64" width="64" type="image/png">https://internet4000.github.io/find/public/favicons/favicon-32x32.png</Image>
<LongName>Customize the browser omnibox URL bar with custom search engines and actions</LongName>
<Query role="example" searchTerms="test" />
<Developer>Internet4000</Developer>
<Attribution>public domain</Attribution>
<SyndicationRight>open</SyndicationRight>
<AdultContent>false</AdultContent>
<Language>en-us</Language>
<OutputEncoding>UTF-8</OutputEncoding>
<InputEncoding>UTF-8</InputEncoding>
<Url type="application/opensearchdescription+xml" rel="self" template="https://internet4000.github.io/find/public/opensearch.xml" />
<Url type="application/x-suggestions+json" template="https://internet4000.github.io/find/public/suggestions.json" />
</OpenSearchDescription>`;

test("OpenSearchDescription is in Find with a config", (t) => {
Expand Down

0 comments on commit 90b0b71

Please sign in to comment.