Skip to content

Commit 9b7a4d8

Browse files
thavelickclaude
andcommitted
Apply prettier formatting to existing files
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent b643f33 commit 9b7a4d8

File tree

5 files changed

+99
-81
lines changed

5 files changed

+99
-81
lines changed

.github/workflows/static.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
- name: Upload artifact
2929
uses: actions/upload-pages-artifact@v3
3030
with:
31-
path: './public_html'
31+
path: "./public_html"
3232
- name: Deploy to GitHub Pages
3333
id: deployment
34-
uses: actions/deploy-pages@v4
34+
uses: actions/deploy-pages@v4

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ A lightweight, client-side search tool with bang shortcuts. This JavaScript vers
1313
## Usage
1414

1515
### Basic Search
16+
1617
- `just bangs gh!` → Search GitHub for "just bangs"
1718
- `!gh just bangs` → Also works with bang at the start
1819
- `python w!` → Search Wikipedia for "python"
@@ -21,6 +22,7 @@ A lightweight, client-side search tool with bang shortcuts. This JavaScript vers
2122
### Supported Bangs
2223

2324
**Common:**
25+
2426
- `g!` → Google
2527
- `ddg!` → DuckDuckGo
2628
- `d!` → DuckDuckGo Lite (default fallback)
@@ -30,6 +32,7 @@ A lightweight, client-side search tool with bang shortcuts. This JavaScript vers
3032
- `pypi!` → PyPI
3133

3234
**Specialized:**
35+
3336
- `al!` → Arch Linux docs
3437
- `cl!` → Craigslist
3538
- `e!` → eBay
@@ -46,16 +49,20 @@ A lightweight, client-side search tool with bang shortcuts. This JavaScript vers
4649
## Installation
4750

4851
### Local Usage
52+
4953
1. Download `index.html`
5054
2. Open in your browser or serve from any web server
5155
3. Start searching!
5256

5357
### Browser Search Engine
58+
5459
Add as a custom search engine in your browser:
60+
5561
- **URL**: `https://your-domain.com/path/to/index.html?q=%s`
5662
- **Local**: `file:///path/to/index.html?q=%s`
5763

5864
### Web Server
65+
5966
Place `index.html` in any directory on your web server. Works great as a subdirectory install.
6067

6168
## Development
@@ -68,4 +75,4 @@ GNU Affero General Public License v3.0 - same as the original just-bangs project
6875

6976
## Related Projects
7077

71-
- [just-bangs](https://github.com/thavelick/just-bangs) - The original Python server-based version
78+
- [just-bangs](https://github.com/thavelick/just-bangs) - The original Python server-based version

public_html/index.html

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
1-
<!DOCTYPE html>
1+
<!doctype html>
22
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
3+
<head>
4+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
5+
<link
6+
rel="search"
7+
type="application/opensearchdescription+xml"
8+
title="Just Bangs Lite"
9+
href="search.xml"
10+
/>
11+
<title>Just Bangs!</title>
12+
<script src="script.js"></script>
13+
<link rel="stylesheet" href="style.css" />
14+
</head>
315

4-
<head>
5-
<meta http-equiv="content-type" content="text/html; charset=utf-8">
6-
<link rel="search" type="application/opensearchdescription+xml" title="Just Bangs Lite" href="search.xml" />
7-
<title>Just Bangs!</title>
8-
<script src="script.js"></script>
9-
<link rel="stylesheet" href="style.css">
10-
</head>
11-
12-
<body>
13-
<h1>Just Bangs!</h1>
14-
<form id="searchForm">
15-
<input type="text" id="searchInput" name="q" autocomplete="off" value="" autofocus="" placeholder="Enter search query with !bang" />
16-
<input type="button" id="searchButton" value="Search" />
17-
</form>
18-
19-
</body>
20-
21-
</html>
16+
<body>
17+
<h1>Just Bangs!</h1>
18+
<form id="searchForm">
19+
<input
20+
type="text"
21+
id="searchInput"
22+
name="q"
23+
autocomplete="off"
24+
value=""
25+
autofocus=""
26+
placeholder="Enter search query with !bang"
27+
/>
28+
<input type="button" id="searchButton" value="Search" />
29+
</form>
30+
</body>
31+
</html>

public_html/script.js

Lines changed: 59 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,95 +1,95 @@
11
const bangs = [
22
{
3-
"t": "al",
4-
"u": "https://kiwix.tristanhavelick.com/search?content=archlinux_en_all_nopic_2022-05&pattern={{{s}}}"
3+
t: "al",
4+
u: "https://kiwix.tristanhavelick.com/search?content=archlinux_en_all_nopic_2022-05&pattern={{{s}}}",
55
},
66
{
7-
"t": "cl",
8-
"u": "https://denver.craigslist.org/search/?query={{{s}}}"
7+
t: "cl",
8+
u: "https://denver.craigslist.org/search/?query={{{s}}}",
99
},
1010
{
11-
"t": "d",
12-
"u": "https://lite.duckduckgo.com/lite?q={{{s}}}&kl=us-en"
11+
t: "d",
12+
u: "https://lite.duckduckgo.com/lite?q={{{s}}}&kl=us-en",
1313
},
1414
{
15-
"t": "e",
16-
"u": "https://www.ebay.com/sch/i.html?_nkw={{{s}}}&rt=nc&LH_ItemCondition=4"
15+
t: "e",
16+
u: "https://www.ebay.com/sch/i.html?_nkw={{{s}}}&rt=nc&LH_ItemCondition=4",
1717
},
1818
{
19-
"t": "jw",
20-
"u": "https://www.justwatch.com/us/search?q={{{s}}}"
19+
t: "jw",
20+
u: "https://www.justwatch.com/us/search?q={{{s}}}",
2121
},
2222
{
23-
"t": "k",
24-
"u": "https://kiwix.tristanhavelick.com/search?pattern={{{s}}}"
23+
t: "k",
24+
u: "https://kiwix.tristanhavelick.com/search?pattern={{{s}}}",
2525
},
2626
{
27-
"t": "lg",
28-
"u": "http://libgen.is/search.php?req={{{s}}}"
27+
t: "lg",
28+
u: "http://libgen.is/search.php?req={{{s}}}",
2929
},
3030
{
31-
"t": "lgf",
32-
"u": "http://libgen.is/fiction/?q={{{s}}}"
31+
t: "lgf",
32+
u: "http://libgen.is/fiction/?q={{{s}}}",
3333
},
3434
{
35-
"t": "m",
36-
"u": "https://search.marginalia.nu/search?query={{{s}}}"
35+
t: "m",
36+
u: "https://search.marginalia.nu/search?query={{{s}}}",
3737
},
3838
{
39-
"t": "py",
40-
"u": "https://kiwix.tristanhavelick.com/search?content=python-3.10.2&pattern={{{s}}}"
39+
t: "py",
40+
u: "https://kiwix.tristanhavelick.com/search?content=python-3.10.2&pattern={{{s}}}",
4141
},
4242
{
43-
"t": "sg",
44-
"u": "https://app.thestorygraph.com/browse?search_term={{{s}}}"
43+
t: "sg",
44+
u: "https://app.thestorygraph.com/browse?search_term={{{s}}}",
4545
},
4646
{
47-
"t": "ytt",
48-
"u": "https://youtranscript.tristanhavelick.com/search?search_term={{{s}}}"
47+
t: "ytt",
48+
u: "https://youtranscript.tristanhavelick.com/search?search_term={{{s}}}",
4949
},
5050
{
51-
"t": "x",
52-
"u": "https://searxng.tristanhavelick.com/search?q={{{s}}}"
51+
t: "x",
52+
u: "https://searxng.tristanhavelick.com/search?q={{{s}}}",
5353
},
5454
{
55-
"t": "gh",
56-
"u": "https://github.com/search?q={{{s}}}"
55+
t: "gh",
56+
u: "https://github.com/search?q={{{s}}}",
5757
},
5858
{
59-
"t": "g",
60-
"u": "https://www.google.com/search?q={{{s}}}"
59+
t: "g",
60+
u: "https://www.google.com/search?q={{{s}}}",
6161
},
6262
{
63-
"t": "ddg",
64-
"u": "https://duckduckgo.com/?q={{{s}}}"
63+
t: "ddg",
64+
u: "https://duckduckgo.com/?q={{{s}}}",
6565
},
6666
{
67-
"t": "a",
68-
"u": "https://www.amazon.com/s?k={{{s}}}"
67+
t: "a",
68+
u: "https://www.amazon.com/s?k={{{s}}}",
6969
},
7070
{
71-
"t": "pypi",
72-
"u": "https://pypi.org/search/?q={{{s}}}"
71+
t: "pypi",
72+
u: "https://pypi.org/search/?q={{{s}}}",
7373
},
7474
{
75-
"t": "w",
76-
"u": "https://en.wikipedia.org/wiki/Special:Search?search={{{s}}}"
77-
}
75+
t: "w",
76+
u: "https://en.wikipedia.org/wiki/Special:Search?search={{{s}}}",
77+
},
7878
];
7979

8080
function processBang(query) {
8181
const trimmed = query.trim();
82-
83-
if (trimmed.startsWith('!')) {
84-
const spaceIndex = trimmed.indexOf(' ');
82+
83+
if (trimmed.startsWith("!")) {
84+
const spaceIndex = trimmed.indexOf(" ");
8585
if (spaceIndex === -1) {
8686
return null;
8787
}
88-
88+
8989
const bangTag = trimmed.substring(1, spaceIndex);
9090
const searchTerm = trimmed.substring(spaceIndex + 1).trim();
91-
92-
const bang = bangs.find(b => b.t === bangTag);
91+
92+
const bang = bangs.find((b) => b.t === bangTag);
9393
if (bang) {
9494
return bang.u.replace(/{{{s}}}/g, encodeURIComponent(searchTerm));
9595
}
@@ -98,8 +98,8 @@ function processBang(query) {
9898
if (bangMatch) {
9999
const searchTerm = bangMatch[1].trim();
100100
const bangTag = bangMatch[2];
101-
102-
const bang = bangs.find(b => b.t === bangTag);
101+
102+
const bang = bangs.find((b) => b.t === bangTag);
103103
if (bang) {
104104
return bang.u.replace(/{{{s}}}/g, encodeURIComponent(searchTerm));
105105
}
@@ -117,45 +117,47 @@ function redirect(url) {
117117
}
118118

119119
function setupUI() {
120-
const searchInput = document.getElementById('searchInput');
121-
120+
const searchInput = document.getElementById("searchInput");
121+
122122
function performSearch() {
123123
const query = searchInput.value;
124124
const url = processBang(query);
125125
if (url) {
126-
window.location.hash = '#q=' + encodeURIComponent(query);
126+
window.location.hash = "#q=" + encodeURIComponent(query);
127127
redirect(url);
128128
}
129129
}
130130

131-
document.getElementById('searchButton').addEventListener('click', performSearch);
131+
document
132+
.getElementById("searchButton")
133+
.addEventListener("click", performSearch);
132134

133-
searchInput.addEventListener('keypress', function(e) {
134-
if (e.key === 'Enter') {
135+
searchInput.addEventListener("keypress", function (e) {
136+
if (e.key === "Enter") {
135137
e.preventDefault();
136138
performSearch();
137139
}
138140
});
139141

140142
if (window.location.hash) {
141143
const hashParams = new URLSearchParams(window.location.hash.substring(1));
142-
const hashQuery = hashParams.get('q');
144+
const hashQuery = hashParams.get("q");
143145
if (hashQuery) {
144146
searchInput.value = decodeURIComponent(hashQuery);
145147
}
146148
}
147149
}
148150

149151
function initialize() {
150-
const queryParam = getQueryParam('q');
152+
const queryParam = getQueryParam("q");
151153
if (queryParam) {
152154
const url = processBang(queryParam);
153155
if (url) {
154156
redirect(url);
155157
}
156158
} else {
157-
document.addEventListener('DOMContentLoaded', setupUI);
159+
document.addEventListener("DOMContentLoaded", setupUI);
158160
}
159161
}
160162

161-
initialize();
163+
initialize();

public_html/style.css

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ input[type="submit"] {
5555
}
5656

5757
@media (prefers-color-scheme: dark) {
58-
5958
html,
6059
input[type="text"] {
6160
background-color: #2d4f8e;
@@ -66,4 +65,4 @@ input[type="submit"] {
6665
input[type="text"] {
6766
color: white;
6867
}
69-
}
68+
}

0 commit comments

Comments
 (0)