Skip to content

Commit

Permalink
Add OpenSearch description file
Browse files Browse the repository at this point in the history
Resolves #19
  • Loading branch information
shesek committed Dec 10, 2018
1 parent ddbbedc commit 4a03c11
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ All options are optional.
- `BASE_HREF` - base href for user interface (defaults to `/`, change if not served from the root directory)
- `API_URL` - URL for HTTP REST API (defaults to `/api`, change if the API is available elsewhere)
- `PORT` - port to bind http development server (defaults to `3000`, has no effect when building)
- `BASE_URL` - absolute base url for user interface (no default, only required for opensearch functionality)
- `NATIVE_ASSET_LABEL` - the name of the network native asset (defaults to `BTC`)
- `SITE_TITLE` - website title for `<title>` (defaults to `Block Explorer`)
- `SITE_DESC` - meta description (defaults to `Esplora Block Explorer`)
Expand Down
5 changes: 5 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ cp -rL www/* $CUSTOM_ASSETS $DEST/
# Index HTML
pug client/index.pug -o $DEST

# Open search (requires absolute BASE_URL)
if [ -n "$BASE_URL" ]; then
pug client/opensearch.pug -E xml -o $DEST
fi

# RTLify CSS
cat www/style.css | node -p "require('cssjanus').transform(fs.readFileSync('/dev/stdin').toString(), false, true)" > $DEST/style-rtl.css

Expand Down
4 changes: 4 additions & 0 deletions client/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ head
link(rel='stylesheet', href='bootstrap.min.css')
link(rel='stylesheet', href='style.css')

if process.env.BASE_URL
//- open search requires the absolute URL of the explorer
link(rel='search', href='opensearch.xml', type='application/opensearchdescription+xml', title=process.env.SITE_TITLE || 'Block Explorer')

!= process.env.HEAD_HTML

body(class=prerender_html?'theme-dark':'')
Expand Down
9 changes: 9 additions & 0 deletions client/opensearch.pug
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
doctype xml

OpenSearchDescription(xmlns='http://a9.com/-/spec/opensearch/1.1/', xmlns:moz='http://www.mozilla.org/2006/browser/search/')
ShortName= process.env.SITE_TITLE || 'Esplora Block Explorer'
Description= process.env.SITE_DESC || 'Esplora Block Explorer'
InputEncoding UTF-8
Image(width='16', height='16', type='image/x-icon')= `${process.env.BASE_URL}/img/favicon.png`
Url(type='text/html', method='GET', template=`${process.env.BASE_URL}/{searchTerms}`)
SearchForm= process.env.BASE_URL

0 comments on commit 4a03c11

Please sign in to comment.