Complete refactoring of opensearch
Refactored opensearch.xml to only exist as a template that is served by a flask route, which is then populated with the necessary url root.pull/9/head
parent
02bb5a3426
commit
1f6bfa092e
@ -1,13 +0,0 @@
|
||||
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
|
||||
xmlns:moz="http://www.mozilla.org/2006/browser/search/">
|
||||
<ShortName>Shoogle</ShortName>
|
||||
<Description>Shoogle: A lightweight, deployable Google search proxy for desktop/mobile that removes Javascript, AMP links, and ads</Description>
|
||||
<InputEncoding>UTF-8</InputEncoding>
|
||||
<Image width="32" height="32" type="image/x-icon">/static/img/favicon/favicon-32x32.png</Image>
|
||||
<Url type="text/html" template="SHOOGLE_URL/search">
|
||||
<Param name="q" value="{searchTerms}"/>
|
||||
</Url>
|
||||
<Url type="application/x-suggestions+json" template="SHOOGLE_URL/search"/>
|
||||
<moz:SearchForm>SHOOGLE_URL/search</moz:SearchForm>
|
||||
</OpenSearchDescription>
|
||||
|
@ -1,21 +0,0 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
script_path = os.path.dirname(os.path.realpath(__file__))
|
||||
template_path = script_path + '/../app/static/opensearch.template'
|
||||
opensearch_path = script_path + '/../app/static/opensearch.xml'
|
||||
replace_tag = 'SHOOGLE_URL'
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
print('You must provide the url as an argument for this script.')
|
||||
print('Example: python opensearch.py "https://my-app-1776.herokuapps.com"')
|
||||
sys.exit(0)
|
||||
|
||||
app_url = sys.argv[1].rstrip('/')
|
||||
opensearch_template = open(template_path, 'r').read()
|
||||
|
||||
with open(opensearch_path, 'w') as opensearch_xml:
|
||||
opensearch_xml.write(opensearch_template.replace(replace_tag, app_url))
|
||||
opensearch_xml.close()
|
||||
|
||||
print('\nDone - you may now set Shoogle as your primary search engine')
|
Loading…
Reference in New Issue