aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2023-07-26 21:48:06 +0200
committermetamuffin <metamuffin@disroot.org>2023-07-26 21:48:37 +0200
commit377e503555a9b5feb89e15275f26333545a6e414 (patch)
tree2e0d5907fee87a91799c9388ede8fa28c2c77579
parent25699e2d089ab21072e6894c098efea98fc14fa9 (diff)
downloadfastbangs-377e503555a9b5feb89e15275f26333545a6e414.tar
fastbangs-377e503555a9b5feb89e15275f26333545a6e414.tar.bz2
fastbangs-377e503555a9b5feb89e15275f26333545a6e414.tar.zst
rename project and add some more ui
-rw-r--r--fastbangs.cabal (renamed from bangs-ddgless.cabal)8
-rw-r--r--frontend/index.html2
-rw-r--r--frontend/query.ts7
-rw-r--r--frontend/style.sass3
-rw-r--r--frontend/ui.ts16
-rw-r--r--makefile6
-rw-r--r--package.yaml6
-rw-r--r--src/Config.hs4
8 files changed, 29 insertions, 23 deletions
diff --git a/bangs-ddgless.cabal b/fastbangs.cabal
index c0b5f07..79f501e 100644
--- a/bangs-ddgless.cabal
+++ b/fastbangs.cabal
@@ -4,23 +4,23 @@ cabal-version: 1.12
--
-- see: https://github.com/sol/hpack
-name: bangs-ddgless
+name: fastbangs
version: 0.1.0.0
category: Web
-homepage: https://codeberg.org/lialenck/bangs-ddgless
+homepage: https://codeberg.org/lialenck/fastbangs
author: Lia Lenckowski
maintainer: lialenck@protonmail.com
copyright: 2023 Lia Lenckowski
license: AGPL
build-type: Simple
-executable bangs-ddgless
+executable fastbangs
main-is: Main.hs
other-modules:
Bangs
BangState
Config
- Paths_bangs_ddgless
+ Paths_fastbangs
hs-source-dirs:
src
ghc-options: -Wall -Wcompat -Widentities -Wincomplete-record-updates -Wincomplete-uni-patterns -Wmissing-export-lists -Wmissing-home-modules -Wpartial-fields -Wredundant-constraints
diff --git a/frontend/index.html b/frontend/index.html
index f2c481f..52420db 100644
--- a/frontend/index.html
+++ b/frontend/index.html
@@ -5,7 +5,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script type="module" src="./bundle.js"></script>
<link rel="stylesheet" href="./style.css" />
- <title>Projectname</title>
+ <title>Fastbangs</title>
</head>
<body>
<noscript>requires javascript</noscript>
diff --git a/frontend/query.ts b/frontend/query.ts
index 8a5ec2e..a608c57 100644
--- a/frontend/query.ts
+++ b/frontend/query.ts
@@ -25,18 +25,19 @@ export function load_bangs() {
export async function process_query(default_engine: string, query: string) {
const bang_prefix = "!"
- let url = ""
+ let url: string | undefined
if (query.startsWith(bang_prefix)) {
const [engine, ...query_parts] = query.substring(bang_prefix.length).split(" ")
url = await search_url(engine, query_parts.join(" "))
} else {
url = await search_url(default_engine, query)
}
+ if (!url) return status("error", "Invalid search engine.")
status("success", `Forwarding to ${url}`)
- setTimeout(() => document.location.href = url, 0)
+ setTimeout(() => document.location.href = url!, 0)
}
async function search_url(engine: string, query: string) {
- return (await bangs)[engine]!.url.replace("{{{s}}}", encodeURIComponent(query).replaceAll("%20", "+"))
+ return (await bangs)[engine]?.url.replace("{{{s}}}", encodeURIComponent(query).replaceAll("%20", "+"))
}
diff --git a/frontend/style.sass b/frontend/style.sass
index eeaa708..5199a22 100644
--- a/frontend/style.sass
+++ b/frontend/style.sass
@@ -8,6 +8,9 @@ body
p, h1, h2, h3, h4, h5, h6, input, button, label, li
color: white
+h1
+ font-size: xx-large
+
.status
background-color: black
padding: 1em
diff --git a/frontend/ui.ts b/frontend/ui.ts
index 6a254c7..22f9d71 100644
--- a/frontend/ui.ts
+++ b/frontend/ui.ts
@@ -23,7 +23,7 @@ function section_search(engine: string) {
link.id = "search-link"
link.type = "application/opensearchdescription+xml"
link.href = `/search.xml?default=${encodeURIComponent(engine)}`
- link.title = `Projectname (default engine: ${engine})`
+ link.title = `Fastbangs (default engine: ${engine})`
document.head.append(link)
const heading = document.createElement("h1")
@@ -94,11 +94,11 @@ function section_info_search() {
const section = document.createElement("section")
section.classList.add("info")
- const heading = document.createElement("h1")
- heading.textContent = "Heading"
+ const heading = document.createElement("h2")
+ heading.textContent = "Setup"
const info = document.createElement("p")
- info.textContent = `To install this as the default search engine, select "Add <name>" in the context-menu of the URL-bar.`
+ info.textContent = `To install this as the default search engine, select "Add Fastbangs" in the context-menu of the URL-bar.`
section.append(heading, info)
return section
@@ -109,11 +109,13 @@ function section_info_start() {
section.classList.add("info")
const heading = document.createElement("h1")
- heading.textContent = "Projectname"
+ heading.textContent = "Fastbangs"
const info = document.createElement("p")
- info.textContent = "This is where one would write what this application does..."
-
+ info.textContent = `
+ This application provides a way to (mostly) locally handle search bangs.
+ First select a default engine to use, then register this page as a search in your browser
+ `
section.append(heading, info)
return section
}
diff --git a/makefile b/makefile
index 0b59ae1..ea6b296 100644
--- a/makefile
+++ b/makefile
@@ -1,6 +1,6 @@
ESFLAGS = --target=esnext --format=esm
-deploy-dir: deploy deploy/bundle.js deploy/style.css deploy/index.html deploy/bangs-ddgless
+deploy-dir: deploy deploy/bundle.js deploy/style.css deploy/index.html deploy/fastbangs
.PHONY: watch clean deploy-dir
watch-script:
@@ -10,7 +10,7 @@ watch-style:
clean:
stack clean --full
- rm deploy/{bundle.js,index.html,bangs-ddgless}
+ rm deploy/{bundle.js,index.html,fastbangs}
rm deploy.zip
rmdir deploy # this may fail if the server was run, due to the bangs.json being generated
@@ -20,7 +20,7 @@ deploy:
mkdir -p deploy
deploy/index.html: frontend/index.html
cp $< $@
-deploy/bangs-ddgless: $(shell find src -name '*.hs')
+deploy/fastbangs: $(shell find src -name '*.hs')
stack install --local-bin-path deploy
deploy/bundle.js: $(shell find frontend -name '*.ts')
esbuild frontend/main.ts --bundle --outfile=deploy/bundle.js $(ESFLAGS)
diff --git a/package.yaml b/package.yaml
index e331e84..b889e79 100644
--- a/package.yaml
+++ b/package.yaml
@@ -1,8 +1,8 @@
-name: bangs-ddgless
+name: fastbangs
version: 0.1.0.0
#synopsis:
#description:
-homepage: https://codeberg.org/lialenck/bangs-ddgless
+homepage: https://codeberg.org/lialenck/fastbangs
license: AGPL
author: Lia Lenckowski
maintainer: lialenck@protonmail.com
@@ -40,6 +40,6 @@ ghc-options:
- -Wredundant-constraints
executables:
- bangs-ddgless:
+ fastbangs:
source-dirs: src
main: Main.hs
diff --git a/src/Config.hs b/src/Config.hs
index da9206a..799b297 100644
--- a/src/Config.hs
+++ b/src/Config.hs
@@ -31,8 +31,8 @@ makeOpenSearch searchUrl = do
favicon <- faviconUrl
return $ "<OpenSearchDescription xmlns=\"http://a9.com/-/spec/opensearch/1.1/\"\n"
<> " xmlns:moz=\"http://www.mozilla.org/2006/browser/search/\">\n"
- <> " <ShortName>Banger</ShortName>\n"
- <> " <Description>Bangs von ddg, ohne ddg</Description>\n"
+ <> " <ShortName>Fastbangs</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"