feat: add raw-query option for search bangs

pull/896/head
NecRaul 2025-12-06 15:20:33 +07:00
parent 784bf53425
commit 3f566df015
No known key found for this signature in database
4 changed files with 50 additions and 7 deletions

@ -1205,6 +1205,7 @@ Example:
- title: YouTube
shortcut: "!yt"
url: https://www.youtube.com/results?search_query={QUERY}
raw-query: false
```
Preview:
@ -1264,11 +1265,12 @@ What now? [Bangs](https://duckduckgo.com/bangs). They're shortcuts that allow yo
![](images/search-widget-bangs-preview.png)
##### Properties for each bang
| Name | Type | Required |
| ---- | ---- | -------- |
| title | string | no |
| shortcut | string | yes |
| url | string | yes |
| Name | Type | Required | Default |
| ---- | ---- | -------- | ------- |
| title | string | no | |
| shortcut | string | yes | |
| url | string | yes | |
| raw-query | boolean | no | false |
###### `title`
Optional title that will appear on the right side of the search bar when the query starts with the associated shortcut.
@ -1292,6 +1294,43 @@ url: https://store.steampowered.com/search/?term={QUERY}
url: https://www.amazon.com/s?k={QUERY}
```
###### `raw-query`
Optional boolean that determines whether the query is inserted raw (without URL encoding) into the URL.
> ```yaml
> shortcut: "!gh"
> url: https://github.com/{QUERY}
> raw-query: false
>
> shortcut: "!ghr"
> url: https://github.com/{QUERY}
> raw-query: true
>```
Typing
```
!gh glanceapp/glance
```
would result in
```
https://github.com/glanceapp%2Fglance
```
whereas
```
!ghr glanceapp/glance
```
would result in
```
https://github.com/glanceapp/glance
```
### Group
Group multiple widgets into one using tabs. Widgets are defined using a `widgets` property exactly as you would on a page column. The only limitation is that you cannot place a group widget or a split column widget within a group widget.

@ -142,7 +142,10 @@ function setupSearchBoxes() {
return;
}
const url = searchUrlTemplate.replace("!QUERY!", encodeURIComponent(query));
const url = currentBang.dataset.raw === "true"
? searchUrlTemplate.replace("!QUERY!", query)
: searchUrlTemplate.replace("!QUERY!", encodeURIComponent(query));
if (newTab && !event.ctrlKey || !newTab && event.ctrlKey) {
window.open(url, target).focus();

@ -6,7 +6,7 @@
<div class="search widget-content-frame padding-inline-widget flex gap-15 items-center" data-default-search-url="{{ .SearchEngine }}" data-new-tab="{{ .NewTab }}" data-target="{{ .Target }}">
<div class="search-bangs">
{{ range .Bangs }}
<input type="hidden" data-shortcut="{{ .Shortcut }}" data-title="{{ .Title }}" data-url="{{ .URL }}">
<input type="hidden" data-shortcut="{{ .Shortcut }}" data-title="{{ .Title }}" data-url="{{ .URL }}" data-raw="{{ .RawQuery }}">
{{ end }}
</div>

@ -12,6 +12,7 @@ type SearchBang struct {
Title string
Shortcut string
URL string
RawQuery bool `yaml:"raw-query"`
}
type searchWidget struct {