Skip to content

Commit 7cb7293

Browse files
authored
Merge pull request #895 from cbos/linkding_support
Add Linkding support
2 parents 3f154b0 + 2024297 commit 7cb7293

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

docs/customservices.md

+22
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ within Homer:
2525
- [Immich](#immich)
2626
- [Jellystat](#jellystat)
2727
- [Lidarr, Prowlarr, Sonarr, Readarr and Radarr](#lidarr-prowlarr-sonarr-readarr-and-radarr)
28+
- [Linkding](#linkding)
2829
- [Matrix](#matrix)
2930
- [Mealie](#mealie)
3031
- [Medusa](#medusa)
@@ -279,6 +280,27 @@ If you are using an older version of Radarr or Sonarr which don't support the ne
279280
legacyApi: true
280281
```
281282

283+
## Linkding
284+
285+
This integration makes it possible to query Linkding and list multiple results from Linkding.
286+
Linkding has to be configured with CORS enabled. Linkding does not support that, but a reverse proxy in front can fix that.
287+
For example if you use Traefik, documentation about that is here: https://doc.traefik.io/traefik/middlewares/http/headers/#cors-headers
288+
Examples for various servers can be found at https://enable-cors.org/server.html.
289+
290+
This integration supports at max 15 results from Linkding. But you can add it multiple times to you dashboard with different queries to retrieve what you need.
291+
292+
```yaml
293+
- name: "Linkding"
294+
# Url to Linkding instance
295+
url: https://ld.ceesbos.nl
296+
token: "<add your secret token here>"
297+
type: "Linkding"
298+
# Maximum number of items returned by Linkding, minimal 1 and max 15
299+
limit: 10
300+
# query to do on Linkding. User #tagname to search for tags
301+
query: "#ToDo #Homer"
302+
```
303+
282304
## Matrix
283305

284306
This service displays a version string instead of a subtitle. The indicator

src/components/services/Linkding.vue

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<template>
2+
<Generic v-for="bookmark in bookmarks" :key="bookmark.name" :item="bookmark">
3+
</Generic>
4+
</template>
5+
6+
<script>
7+
import service from "@/mixins/service.js";
8+
import Generic from "./Generic.vue";
9+
10+
export default {
11+
name: "Linkding",
12+
components: {
13+
Generic,
14+
},
15+
mixins: [service],
16+
props: {
17+
item: Object,
18+
},
19+
data: () => ({
20+
bookmarks: [],
21+
}),
22+
computed: {
23+
calculatedLimit: function () {
24+
const limit = parseInt(this.item.limit) || 5;
25+
return Math.min(Math.max(limit, 1), 15);
26+
},
27+
},
28+
created() {
29+
this.fetchBookmarks();
30+
},
31+
methods: {
32+
fetchBookmarks: async function () {
33+
const headers = {
34+
Authorization: `Token ${this.item.token}`,
35+
Accept: "application/json",
36+
};
37+
38+
let query = "";
39+
if (this.item.query) {
40+
query = `&q=${encodeURIComponent(this.item.query)}`;
41+
}
42+
43+
let url = `/api/bookmarks/?limit=${this.calculatedLimit}${query}`;
44+
45+
this.fetch(url, {
46+
headers,
47+
})
48+
.then((ld_response) => {
49+
this.bookmarks = ld_response.results.map((bookmark) => ({
50+
name: `${bookmark.title}`,
51+
subtitle: `${bookmark.description}`,
52+
url: bookmark.url,
53+
logo: `${bookmark.favicon_url}`,
54+
tag: `${bookmark.tag_names.join(" #")}`,
55+
}));
56+
})
57+
.catch((e) => {
58+
console.log(e);
59+
});
60+
},
61+
},
62+
};
63+
</script>

0 commit comments

Comments
 (0)