2021-07-23 17:34:11 +02:00
|
|
|
const { URL, SITE_TITLE, FAVICON } = require('../../config.js');
|
|
|
|
const favicon = FAVICON || `${URL}/public/favicon.png`;
|
2020-08-07 18:17:29 +02:00
|
|
|
function getOpenSearchXml() {
|
|
|
|
return (
|
|
|
|
`<ShortName>${SITE_TITLE}</ShortName>` +
|
|
|
|
`<Description>Search ${SITE_TITLE}</Description>` +
|
|
|
|
'<InputEncoding>UTF-8</InputEncoding>' +
|
2021-07-23 17:34:11 +02:00
|
|
|
`<Image width="32" height="32" type="image/png">${favicon}</Image>` +
|
2020-08-07 18:17:29 +02:00
|
|
|
`<Url type="text/html" method="get" template="${URL}/$/search?q={searchTerms}"/>` +
|
|
|
|
`<moz:SearchForm>${URL}</moz:SearchForm>`
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function insertVariableXml(fullXml, xmlToInsert) {
|
|
|
|
return fullXml.replace(/<!-- VARIABLE_XML_BEGIN -->.*<!-- VARIABLE_XML_END -->/s, xmlToInsert);
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = { getOpenSearchXml, insertVariableXml };
|