From 377e503555a9b5feb89e15275f26333545a6e414 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Wed, 26 Jul 2023 21:48:06 +0200 Subject: rename project and add some more ui --- bangs-ddgless.cabal | 44 -------------------------------------------- fastbangs.cabal | 44 ++++++++++++++++++++++++++++++++++++++++++++ frontend/index.html | 2 +- frontend/query.ts | 7 ++++--- frontend/style.sass | 3 +++ frontend/ui.ts | 16 +++++++++------- makefile | 6 +++--- package.yaml | 6 +++--- src/Config.hs | 4 ++-- 9 files changed, 69 insertions(+), 63 deletions(-) delete mode 100644 bangs-ddgless.cabal create mode 100644 fastbangs.cabal diff --git a/bangs-ddgless.cabal b/bangs-ddgless.cabal deleted file mode 100644 index c0b5f07..0000000 --- a/bangs-ddgless.cabal +++ /dev/null @@ -1,44 +0,0 @@ -cabal-version: 1.12 - --- This file has been generated from package.yaml by hpack version 0.35.2. --- --- see: https://github.com/sol/hpack - -name: bangs-ddgless -version: 0.1.0.0 -category: Web -homepage: https://codeberg.org/lialenck/bangs-ddgless -author: Lia Lenckowski -maintainer: lialenck@protonmail.com -copyright: 2023 Lia Lenckowski -license: AGPL -build-type: Simple - -executable bangs-ddgless - main-is: Main.hs - other-modules: - Bangs - BangState - Config - Paths_bangs_ddgless - 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 - build-depends: - aeson - , atomic-write - , base >=4.7 && <5 - , brotli - , bytestring - , containers - , ghc-prim - , http-conduit - , monad-logger - , persistent-sqlite - , resourcet - , stm - , text - , time - , warp - , yesod - default-language: Haskell2010 diff --git a/fastbangs.cabal b/fastbangs.cabal new file mode 100644 index 0000000..79f501e --- /dev/null +++ b/fastbangs.cabal @@ -0,0 +1,44 @@ +cabal-version: 1.12 + +-- This file has been generated from package.yaml by hpack version 0.35.2. +-- +-- see: https://github.com/sol/hpack + +name: fastbangs +version: 0.1.0.0 +category: Web +homepage: https://codeberg.org/lialenck/fastbangs +author: Lia Lenckowski +maintainer: lialenck@protonmail.com +copyright: 2023 Lia Lenckowski +license: AGPL +build-type: Simple + +executable fastbangs + main-is: Main.hs + other-modules: + Bangs + BangState + Config + 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 + build-depends: + aeson + , atomic-write + , base >=4.7 && <5 + , brotli + , bytestring + , containers + , ghc-prim + , http-conduit + , monad-logger + , persistent-sqlite + , resourcet + , stm + , text + , time + , warp + , yesod + default-language: Haskell2010 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 @@ - Projectname + Fastbangs 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 " 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 $ " " xmlns:moz=\"http://www.mozilla.org/2006/browser/search/\">\n" - <> " Banger\n" - <> " Bangs von ddg, ohne ddg\n" + <> " Fastbangs\n" + <> " Handles search bangs (mostly) locally.\n" <> " UTF-8\n" <> " " <> favicon <> "\n" <> " searchUrl <> "\"/>\n" -- cgit v1.2.3-70-g09d2