aboutsummaryrefslogtreecommitdiff
path: root/src/Config.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Config.hs')
-rw-r--r--src/Config.hs13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/Config.hs b/src/Config.hs
index 799b297..45f9808 100644
--- a/src/Config.hs
+++ b/src/Config.hs
@@ -26,16 +26,19 @@ faviconUrl :: IsString s => IO s
faviconUrl = (fromString . fromMaybe "https://69owo.de/favicon.ico")
<$> lookupEnv "FAVICON_URL"
-makeOpenSearch :: (IsString s, Semigroup s) => s -> IO s
-makeOpenSearch searchUrl = do
+makeOpenSearch :: (IsString s, Semigroup s) => Maybe s -> IO s
+makeOpenSearch defBang = do
favicon <- faviconUrl
+ bp <- getBaseUrl
+ let (searchUrl, name) = case defBang of
+ Nothing -> (bp <> "/#{searchTerms}", "FastBangs")
+ Just b -> (bp <> "/#" <> b <> "#{searchTerms}", "FastBangs (" <> b <> ")")
+
return $ "<OpenSearchDescription xmlns=\"http://a9.com/-/spec/opensearch/1.1/\"\n"
<> " xmlns:moz=\"http://www.mozilla.org/2006/browser/search/\">\n"
- <> " <ShortName>Fastbangs</ShortName>\n"
+ <> " <ShortName>" <> name <> "</ShortName>\n"
<> " <Description>Handles search bangs (mostly) locally.</Description>\n"
<> " <InputEncoding>UTF-8</InputEncoding>\n"
<> " <Image width=\"16\" height=\"16\" type=\"image/x-icon\">" <> favicon <> "</Image>\n"
<> " <Url type=\"text/html\" template=\"" <> searchUrl <> "\"/>\n"
- <> " <!--<Url type=\"application/x-suggestions+json\" template=\"[suggestionURL]\"/>-->\n"
- <> " <!--<moz:SearchForm>[https://example.com/search]</moz:SearchForm>-->\n"
<> "</OpenSearchDescription>\n"