Skip to content

Commit 2324755

Browse files
authored
🔀 Merge pull request #1212 from alayham/custom-search
initial commit of the custom search widget
2 parents f1d3547 + e1d4adb commit 2324755

File tree

3 files changed

+127
-1
lines changed

3 files changed

+127
-1
lines changed

docs/widgets.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ Dashy has support for displaying dynamic content in the form of widgets. There a
3737
- [Healthchecks Status](#healthchecks-status)
3838
- [Mvg Departure](#mvg-departure)
3939
- [Mvg Connection](#mvg-connection)
40+
- [Custom search](#custom-search)
4041
- **[Self-Hosted Services Widgets](#self-hosted-services-widgets)**
4142
- [System Info](#system-info)
4243
- [Cron Monitoring](#cron-monitoring-health-checks)
@@ -1264,11 +1265,61 @@ In other words: Private, noncomercial, moderate use of the API is tolerated. The
12641265

12651266
---
12661267

1268+
### Custom search
1269+
1270+
Allows web search using multiple user-defined search engines and other websites.
1271+
1272+
#### Options
1273+
1274+
**Field** | **Type** | **Required** | **Description**
1275+
--- | --- | --- | ---
1276+
**`engines`** | `array` | required | An array of search engine objects. Each search engine object should have two required properties: **title** and **url**. See the example below.
1277+
**`placeholder`** | `string` | optional | Placeholder text in the search box.
1278+
1279+
#### Notes
1280+
- The first search engine in the engines array will be treated as the default search engine, and used when the user presses `Enter` in the search box.
1281+
- Popup blockers can interfere with opening a new search window.
1282+
1283+
#### Example
1284+
1285+
This widget allows searching multiple search engines from dashy.
1286+
```yaml
1287+
- type: 'custom-search'
1288+
options:
1289+
placeholder: Search for something using the buttons below
1290+
engines:
1291+
- title: SearXNG
1292+
url: https://searx.lan/?q=
1293+
- title: Quant
1294+
url: https://www.qwant.com/?q=
1295+
- title: Bing Web
1296+
url: http://www.bing.com/search?q=
1297+
- title: Bing Images
1298+
url: http://www.bing.com/images/search?q=
1299+
- title: Bing Maps
1300+
url: http://www.bing.com/maps/search?q=
1301+
- title: Yandex
1302+
url: https://www.yandex.com/search/?text=
1303+
- title: Passmark
1304+
url: https://www.passmark.com/search/zoomsearch.php?zoom_query=
1305+
- title: IMDB
1306+
url: http://www.imdb.com/find?q=
1307+
```
1308+
#### Info
1309+
1310+
- **CORS**: 🟢 Not needed
1311+
- **Auth**: 🟢 Not Required
1312+
- **Price**: 🟢 Free
1313+
- **Host**: user defined
1314+
- **Privacy**: depends on the user defined search engines.
1315+
1316+
---
1317+
12671318

12681319
## Self-Hosted Services Widgets
12691320

12701321
### System Info
1271-
1322+
_See [MVG Datenschutz](https://www.mvg.de/datenschutz-mvg.html)_
12721323
Displays info about the server which Dashy is hosted on. Includes user + host, operating system, uptime and basic memory & load data.
12731324

12741325
<p align="center"><img width="400" src="https://i.ibb.co/rvDPBDF/system-info.png" /></p>
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
<template>
2+
<div class="custom-search">
3+
<input type="text" v-model="query"
4+
@keyup.enter="search(defaultEngine)"
5+
@keyup.stop @keydown.stop
6+
:placeholder="placeholder">
7+
<div class="buttons">
8+
<button
9+
v-for="(engine, key) in engines" :key="key"
10+
v-on:click="search(engine)">
11+
{{ engine.title }}
12+
</button>
13+
</div>
14+
</div>
15+
</template>
16+
17+
<script>
18+
import WidgetMixin from '@/mixins/WidgetMixin';
19+
20+
export default {
21+
mixins: [WidgetMixin],
22+
components: {},
23+
data() {
24+
return {
25+
query: '',
26+
};
27+
},
28+
computed: {
29+
placeholder() {
30+
return this.options.placeholder || '';
31+
},
32+
engines() {
33+
return this.options.engines || [];
34+
},
35+
defaultEngine() {
36+
return this.engines[0];
37+
},
38+
},
39+
methods: {
40+
search(engine) {
41+
if (engine !== undefined && this.query !== '') {
42+
window.open(engine.url + this.query, '_blank');
43+
}
44+
},
45+
},
46+
};
47+
48+
</script>
49+
50+
<style scoped lang="scss">
51+
52+
.custom-search {
53+
font-size: 1.2rem;
54+
input {
55+
width: 80%;
56+
margin: 1rem 10%;
57+
padding: 0.5rem;
58+
font-size: 1.2rem;
59+
}
60+
.buttons {
61+
text-align:center;
62+
button{
63+
margin: 0.5rem;
64+
padding: 0.5rem;
65+
border: none;
66+
color: var(--item-text-color);
67+
background: var(--item-background);
68+
font-size: 1.2rem;
69+
}
70+
71+
}
72+
73+
}
74+
</style>

src/components/Widgets/WidgetBase.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ const COMPAT = {
5252
clock: 'Clock',
5353
'crypto-price-chart': 'CryptoPriceChart',
5454
'crypto-watch-list': 'CryptoWatchList',
55+
'custom-search': 'CustomSearch',
5556
'cve-vulnerabilities': 'CveVulnerabilities',
5657
'domain-monitor': 'DomainMonitor',
5758
'code-stats': 'CodeStats',

0 commit comments

Comments
 (0)