From 3cc2fd1c941ea91b33e18abf2be44afdf67940f4 Mon Sep 17 00:00:00 2001 From: kaiiiz Date: Wed, 15 Mar 2023 03:44:55 +0800 Subject: [PATCH 1/3] Improve tags field in default template --- src/assets/defaultTemplate.njk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assets/defaultTemplate.njk b/src/assets/defaultTemplate.njk index 108d4b0..6c606c9 100644 --- a/src/assets/defaultTemplate.njk +++ b/src/assets/defaultTemplate.njk @@ -1,7 +1,7 @@ {% if is_new_article %} # Metadata {% if link %}Source URL:: {{link}}{% endif %} -{% if tags|length %}Topics:: {{ tags | join(", ") }}{% endif %} +{% if tags|length %}Topics:: {{ tags | map("#{}") | join(", ") }}{% endif %} --- # {{title}} From 99967d73fb25047e9516a59b55c5911cb1dc5f6a Mon Sep 17 00:00:00 2001 From: kaiiiz Date: Tue, 21 Mar 2023 18:46:58 +0800 Subject: [PATCH 2/3] Fix nested collection --- src/api.ts | 29 ++++++++++++++++++++++------- src/types.ts | 2 +- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/api.ts b/src/api.ts index 4fae685..5607e3c 100644 --- a/src/api.ts +++ b/src/api.ts @@ -3,7 +3,12 @@ import axios from "axios"; import type { RaindropBookmark, RaindropCollection, RaindropHighlight, RaindropUser } from "./types"; import TokenManager from "./tokenManager"; -const BASEURL = "https://api.raindrop.io/rest/v1" +const BASEURL = "https://api.raindrop.io/rest/v1"; + +interface NestedRaindropCollection { + title: string, + parentId: number, +} export class RaindropAPI { app: App; @@ -42,16 +47,17 @@ export class RaindropAPI { async getCollections(): Promise { let res = await this.get(`${BASEURL}/collections`, {}); - const collectionMap: {[id: number]: string} = {}; let collections: RaindropCollection[] = [ { id: -1, title: 'Unsorted' }, { id: -99, title: 'Trash' }, ]; + + const rootCollectionMap: {[id: number]: string} = {}; res.items.forEach((collection: any) => { const id = collection['_id']; const title = collection['title']; - collectionMap[id] = title; + rootCollectionMap[id] = title; collections.push({ title: title, id: id, @@ -59,18 +65,27 @@ export class RaindropAPI { }); res = await this.get(`${BASEURL}/collections/childrens`, {}); + const nestedCollectionMap: {[id: number]: NestedRaindropCollection} = {}; + res.items.forEach((collection: any) => { + const id = collection['_id']; + nestedCollectionMap[id] = { + title: collection['title'], + parentId: collection['parent']['$id'], + }; + }); + res.items.forEach((collection: any) => { const id = collection['_id']; - const parentId = collection['parent']['$id']; + let parentId = collection['parent']['$id']; let title = collection['title']; - if (parentId in collectionMap) { - title = `${collectionMap[parentId]}/${collection['title']}`; + while (!(parentId in rootCollectionMap)) { + title = `${nestedCollectionMap[parentId].title}/${title}`; + parentId = nestedCollectionMap[parentId].parentId; } collections.push({ title: title, id: id, }); - collectionMap[id] = title; }); return collections; diff --git a/src/types.ts b/src/types.ts index c09a230..203184c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -21,7 +21,7 @@ export interface RaindropHighlight { // Remote state export interface RaindropCreatorRef { // Remote state name: string, id: number, -}; +} export interface RaindropBookmark { // Remote state id: number, From a75e0ab0b91fd9cf40561089d2ef0176ff5a54f0 Mon Sep 17 00:00:00 2001 From: kaiiiz Date: Tue, 21 Mar 2023 18:51:25 +0800 Subject: [PATCH 3/3] 0.0.16 release preparation --- manifest.json | 2 +- package.json | 2 +- src/constants.ts | 2 +- versions.json | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/manifest.json b/manifest.json index 12edd39..8fc2cad 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-raindrop-highlights", "name": "Raindrop Highlights", - "version": "0.0.15", + "version": "0.0.16", "minAppVersion": "0.14.0", "description": "Sync your Raindrop.io highlights.", "author": "kaiiiz", diff --git a/package.json b/package.json index 14be913..b7287f3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-raindrop-highlights", - "version": "0.0.15", + "version": "0.0.16", "description": "Sync your Raindrop.io highlights.", "main": "main.js", "scripts": { diff --git a/src/constants.ts b/src/constants.ts index 25754ca..1494473 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,7 +1,7 @@ import DEFAULT_TEMPLATE from './assets/defaultTemplate.njk'; import type { RaindropPluginSettings } from "./types"; -export const VERSION = '0.0.15'; +export const VERSION = '0.0.16'; export const DEFAULT_SETTINGS: RaindropPluginSettings = { version: VERSION, diff --git a/versions.json b/versions.json index 5b7fff0..1a063a3 100644 --- a/versions.json +++ b/versions.json @@ -13,5 +13,6 @@ "0.0.12": "0.14.0", "0.0.13": "0.14.0", "0.0.14": "0.14.0", - "0.0.15": "0.14.0" + "0.0.15": "0.14.0", + "0.0.16": "0.14.0" }