This commit is contained in:
parent
ec8ab05349
commit
d3bdc8065d
11 changed files with 73 additions and 30 deletions
|
@ -10,28 +10,49 @@ type OpenSearchDescription struct {
|
|||
XMLName xml.Name `xml:"OpenSearchDescription"`
|
||||
Xmlns string `xml:"xmlns,attr"`
|
||||
ShortName string `xml:"ShortName"`
|
||||
LongName string `xml:"LongName"`
|
||||
Description string `xml:"Description"`
|
||||
Tags string `xml:"Tags"`
|
||||
Tags string `xml:"Tags,omitempty"`
|
||||
InputEncoding string `xml:"InputEncoding"`
|
||||
OutputEncoding string `xml:"OutputEncoding"`
|
||||
Image *Image `xml:"Image,omitempty"`
|
||||
URLs []URL `xml:"Url"`
|
||||
}
|
||||
|
||||
type URL struct {
|
||||
Type string `xml:"type,attr"`
|
||||
Method string `xml:"method,attr,omitempty"`
|
||||
Template string `xml:"template,attr"`
|
||||
}
|
||||
|
||||
func generateOpenSearchXML(config Config) {
|
||||
// Ensure that language is initialized in `main` before calling this function
|
||||
type Image struct {
|
||||
Height int `xml:"height,attr"`
|
||||
Width int `xml:"width,attr"`
|
||||
Type string `xml:"type,attr"`
|
||||
URL string `xml:",chardata"`
|
||||
}
|
||||
|
||||
func generateOpenSearchXML(config Config) {
|
||||
baseURL := addProtocol(config.Domain)
|
||||
|
||||
opensearch := OpenSearchDescription{
|
||||
Xmlns: "http://a9.com/-/spec/opensearch/1.1/",
|
||||
ShortName: Translate("site_name"),
|
||||
LongName: Translate("site_name") + " Search",
|
||||
Description: Translate("site_description"),
|
||||
Tags: Translate("site_tags"),
|
||||
InputEncoding: "UTF-8",
|
||||
OutputEncoding: "UTF-8",
|
||||
Image: &Image{
|
||||
Height: 16,
|
||||
Width: 16,
|
||||
Type: "image/x-icon",
|
||||
URL: fmt.Sprintf("%s/favicon.ico", baseURL),
|
||||
},
|
||||
URLs: []URL{
|
||||
{
|
||||
Type: "text/html",
|
||||
Method: "get",
|
||||
Template: fmt.Sprintf("%s/search?q={searchTerms}", baseURL),
|
||||
},
|
||||
{
|
||||
|
@ -48,6 +69,8 @@ func generateOpenSearchXML(config Config) {
|
|||
}
|
||||
defer file.Close()
|
||||
|
||||
file.WriteString(`<?xml version="1.0" encoding="UTF-8"?>` + "\n")
|
||||
|
||||
enc := xml.NewEncoder(file)
|
||||
enc.Indent(" ", " ")
|
||||
if err := enc.Encode(opensearch); err != nil {
|
||||
|
|
|
@ -12,8 +12,10 @@
|
|||
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
||||
<link rel="stylesheet" href="/static/css/style-fonts.css">
|
||||
<link rel="stylesheet" href="/static/css/style-menu.css">
|
||||
<link rel="search" type="application/opensearchdescription+xml" title="{{ translate " site_name" }}"
|
||||
href="/opensearch.xml">
|
||||
|
||||
<!-- OpenSearch -->
|
||||
<link rel="search" type="application/opensearchdescription+xml" title="{{ translate "site_name" }}" href="/opensearch.xml">
|
||||
|
||||
<!-- Icons -->
|
||||
<link rel="icon" href="{{ .IconPathSVG }}" type="image/svg+xml">
|
||||
<link rel="icon" href="{{ .IconPathPNG }}" type="image/png">
|
||||
|
|
|
@ -13,9 +13,11 @@
|
|||
<link rel="stylesheet" href="/static/css/style-fonts.css">
|
||||
<link rel="stylesheet" href="/static/css/style-loadingindicator.css">
|
||||
<link rel="stylesheet" href="/static/css/style-menu.css">
|
||||
<link rel="search" type="application/opensearchdescription+xml" title="{{ translate " site_name" }}"
|
||||
href="/opensearch.xml">
|
||||
|
||||
<!-- OpenSearch -->
|
||||
<link rel="search" type="application/opensearchdescription+xml" title="{{ translate "site_name" }}" href="/opensearch.xml">
|
||||
<!-- Icons -->
|
||||
|
||||
<link rel="icon" href="{{ .IconPathSVG }}" type="image/svg+xml">
|
||||
<link rel="icon" href="{{ .IconPathPNG }}" type="image/png">
|
||||
<link rel="apple-touch-icon" href="{{ .IconPathPNG }}">
|
||||
|
|
|
@ -23,8 +23,10 @@
|
|||
<link rel="stylesheet" href="/static/css/style-menu.css">
|
||||
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
||||
<link rel="stylesheet" href="/static/css/style-fonts.css">
|
||||
<link rel="search" type="application/opensearchdescription+xml" title="{{ translate " site_name" }}"
|
||||
href="/opensearch.xml">
|
||||
|
||||
<!-- OpenSearch -->
|
||||
<link rel="search" type="application/opensearchdescription+xml" title="{{ translate "site_name" }}" href="/opensearch.xml">
|
||||
|
||||
<!-- Icons -->
|
||||
<link rel="icon" href="{{ .IconPathSVG }}" type="image/svg+xml">
|
||||
<link rel="icon" href="{{ .IconPathPNG }}" type="image/png">
|
||||
|
|
|
@ -12,8 +12,10 @@
|
|||
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
||||
<link rel="stylesheet" href="/static/css/style-fonts.css">
|
||||
<link rel="stylesheet" href="/static/css/style-menu.css">
|
||||
<link rel="search" type="application/opensearchdescription+xml" title="{{ translate " site_name" }}"
|
||||
href="/opensearch.xml">
|
||||
|
||||
<!-- OpenSearch -->
|
||||
<link rel="search" type="application/opensearchdescription+xml" title="{{ translate "site_name" }}" href="/opensearch.xml">
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/leaflet@1.9.4/dist/leaflet.js"></script>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/leaflet@1.9.4/dist/leaflet.css" />
|
||||
<!-- Icons -->
|
||||
|
|
|
@ -14,8 +14,10 @@
|
|||
<link rel="stylesheet" href="/static/css/style-music.css">
|
||||
<link rel="stylesheet" href="/static/css/style-loadingindicator.css">
|
||||
<link rel="stylesheet" href="/static/css/style-menu.css">
|
||||
<link rel="search" type="application/opensearchdescription+xml" title="{{ translate " site_name" }}"
|
||||
href="/opensearch.xml">
|
||||
|
||||
<!-- OpenSearch -->
|
||||
<link rel="search" type="application/opensearchdescription+xml" title="{{ translate "site_name" }}" href="/opensearch.xml">
|
||||
|
||||
<!-- Icons -->
|
||||
<link rel="icon" href="{{ .IconPathSVG }}" type="image/svg+xml">
|
||||
<link rel="icon" href="{{ .IconPathPNG }}" type="image/png">
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
<link rel="stylesheet" href="/static/css/style-fonts.css">
|
||||
<link rel="stylesheet" href="/static/css/style-privacy.css">
|
||||
|
||||
<!-- OpenSearch -->
|
||||
<link rel="search" type="application/opensearchdescription+xml" title="{{ translate "site_name" }}" href="/opensearch.xml">
|
||||
|
||||
<!-- Icons -->
|
||||
<link rel="icon" href="{{ .IconPathSVG }}" type="image/svg+xml">
|
||||
<link rel="icon" href="{{ .IconPathPNG }}" type="image/png">
|
||||
|
|
|
@ -65,8 +65,9 @@
|
|||
<link rel="stylesheet" href="/static/css/style-menu.css">
|
||||
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
||||
<link rel="stylesheet" href="/static/css/style-fonts.css">
|
||||
<link rel="search" type="application/opensearchdescription+xml" title="{{ translate " site_name" }}"
|
||||
href="/opensearch.xml">
|
||||
|
||||
<!-- OpenSearch -->
|
||||
<link rel="search" type="application/opensearchdescription+xml" title="{{ translate "site_name" }}" href="/opensearch.xml">
|
||||
|
||||
<!-- Icons -->
|
||||
<link rel="icon" href="{{ .IconPathSVG }}" type="image/svg+xml">
|
||||
|
|
|
@ -12,8 +12,10 @@
|
|||
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
||||
<link rel="stylesheet" href="/static/css/style-settings.css">
|
||||
<link rel="stylesheet" href="/static/css/style-fonts.css">
|
||||
<link rel="search" type="application/opensearchdescription+xml" title="{{ translate " site_name" }}"
|
||||
href="/opensearch.xml">
|
||||
|
||||
<!-- OpenSearch -->
|
||||
<link rel="search" type="application/opensearchdescription+xml" title="{{ translate "site_name" }}" href="/opensearch.xml">
|
||||
|
||||
<!-- Icons -->
|
||||
<link rel="icon" href="{{ .IconPathSVG }}" type="image/svg+xml">
|
||||
<link rel="icon" href="{{ .IconPathPNG }}" type="image/png">
|
||||
|
|
|
@ -13,8 +13,10 @@
|
|||
<link rel="stylesheet" href="/static/css/style-fonts.css">
|
||||
<link rel="stylesheet" href="/static/css/style-loadingcircle.css">
|
||||
<link rel="stylesheet" href="/static/css/style-menu.css">
|
||||
<link rel="search" type="application/opensearchdescription+xml" title="{{ translate " site_name" }}"
|
||||
href="/opensearch.xml">
|
||||
|
||||
<!-- OpenSearch -->
|
||||
<link rel="search" type="application/opensearchdescription+xml" title="{{ translate "site_name" }}" href="/opensearch.xml">
|
||||
|
||||
<!-- Icons -->
|
||||
<link rel="icon" href="{{ .IconPathSVG }}" type="image/svg+xml">
|
||||
<link rel="icon" href="{{ .IconPathPNG }}" type="image/png">
|
||||
|
|
|
@ -12,8 +12,10 @@
|
|||
<link rel="stylesheet" href="/static/css/{{.Theme}}.css">
|
||||
<link rel="stylesheet" href="/static/css/style-fonts.css">
|
||||
<link rel="stylesheet" href="/static/css/style-menu.css">
|
||||
<link rel="search" type="application/opensearchdescription+xml" title="{{ translate " site_name" }}"
|
||||
href="/opensearch.xml">
|
||||
|
||||
<!-- OpenSearch -->
|
||||
<link rel="search" type="application/opensearchdescription+xml" title="{{ translate "site_name" }}" href="/opensearch.xml">
|
||||
|
||||
<!-- Icons -->
|
||||
<link rel="icon" href="{{ .IconPathSVG }}" type="image/svg+xml">
|
||||
<link rel="icon" href="{{ .IconPathPNG }}" type="image/png">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue