Skip to content

Commit bd095d1

Browse files
authored
Merge pull request #269 from decaf-dev/dev
1.35.0
2 parents 6e4b7ab + 9d6aa3e commit bd095d1

File tree

9 files changed

+101
-41
lines changed

9 files changed

+101
-41
lines changed

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "vault-explorer",
33
"name": "Vault Explorer",
4-
"version": "1.34.3",
4+
"version": "1.35.0",
55
"minAppVersion": "1.4.13",
66
"description": "Explore your vault in visual format",
77
"author": "DecafDev",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-vault-explorer",
3-
"version": "1.34.3",
3+
"version": "1.35.0",
44
"description": "Explore your vault in visual format",
55
"main": "main.js",
66
"scripts": {

src/obsidian/styles.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
11
.vault-explorer-premium-setting {
22
color: var(--text-accent);
33
}
4+
5+
.vault-explorer-setting-description {
6+
padding-top: var(--size-4-1);
7+
font-size: var(--font-smaller);
8+
}

src/obsidian/vault-explorer-settings-tab.ts

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,13 @@ import {
1414
} from "src/logger/constants";
1515
import Logger from "js-logger";
1616
import { stringToLogLevel } from "src/logger";
17-
import {
18-
CollapseStyle,
19-
CoverImageSource,
20-
FileInteractionStyle,
21-
TExplorerView,
22-
} from "src/types";
17+
import { CollapseStyle, CoverImageSource, TExplorerView } from "src/types";
2318
import EventManager from "src/event/event-manager";
2419
import LicenseKeyApp from "../svelte/license-key-app/index.svelte";
2520
import { PluginEvent } from "src/event/types";
2621

2722
import "./styles.css";
23+
import { clearSocialImageCache } from "src/svelte/app/services/social-media-image";
2824

2925
export default class VaultExplorerSettingsTab extends PluginSettingTab {
3026
plugin: VaultExplorerPlugin;
@@ -653,29 +649,6 @@ export default class VaultExplorerSettingsTab extends PluginSettingTab {
653649
target: containerEl,
654650
});
655651

656-
new Setting(containerEl).setName("Storage").setHeading();
657-
658-
const configFolderDesc = new DocumentFragment();
659-
configFolderDesc.createDiv({
660-
text: "Set the plugin configuration folder.",
661-
});
662-
configFolderDesc.createDiv({
663-
text: "Restart Obsidian after changing this setting.",
664-
cls: "mod-warning",
665-
});
666-
667-
new Setting(containerEl)
668-
.setName("Config folder")
669-
.setDesc(configFolderDesc)
670-
.addText((component) =>
671-
component
672-
.setValue(this.plugin.settings.configDir)
673-
.onChange(async (value) => {
674-
this.plugin.settings.configDir = value;
675-
await this.plugin.saveSettings();
676-
})
677-
);
678-
679652
new Setting(containerEl).setName("Debugging").setHeading();
680653
new Setting(containerEl)
681654
.setName("Log level")
@@ -699,6 +672,40 @@ export default class VaultExplorerSettingsTab extends PluginSettingTab {
699672
}
700673
);
701674
});
675+
676+
new Setting(containerEl).setName("Data").setHeading();
677+
678+
const configFolderDesc = new DocumentFragment();
679+
configFolderDesc.createDiv({
680+
text: "Set the plugin configuration folder.",
681+
});
682+
configFolderDesc.createDiv({
683+
text: "Restart Obsidian after changing this setting.",
684+
cls: "mod-warning vault-explorer-setting-description",
685+
});
686+
687+
new Setting(containerEl)
688+
.setName("Config folder")
689+
.setDesc(configFolderDesc)
690+
.addText((component) =>
691+
component
692+
.setValue(this.plugin.settings.configDir)
693+
.onChange(async (value) => {
694+
this.plugin.settings.configDir = value;
695+
await this.plugin.saveSettings();
696+
})
697+
);
698+
699+
new Setting(containerEl)
700+
.setName("Social media image cache")
701+
.addButton((button) =>
702+
button
703+
.setClass("mod-destructive")
704+
.setButtonText("Clear cache")
705+
.onClick(async () => {
706+
await clearSocialImageCache();
707+
})
708+
);
702709
}
703710

704711
onClose() {

src/obsidian/vault-explorer-view.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ItemView, Vault, WorkspaceLeaf } from "obsidian";
1+
import { ItemView, WorkspaceLeaf } from "obsidian";
22

33
import { VAULT_EXPLORER_VIEW } from "src/constants";
44
import VaultExplorerApp from "../svelte/app/index.svelte";

src/svelte/app/components/filter-group-list.svelte

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@
107107
padding-bottom: 8px;
108108
resize: horizontal;
109109
overflow-x: auto;
110+
max-width: 100%;
110111
}
111112
112113
.vault-explorer-empty-label {

src/svelte/app/services/social-media-image.ts

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { DBSchema, IDBPDatabase, openDB } from "idb";
22
import Logger from "js-logger";
3-
import { requestUrl } from "obsidian";
3+
import { Notice, requestUrl } from "obsidian";
44

55
const DATABASE_NAME = "vaultexplorer";
66
const STORE_NAME = "socialMediaImage";
@@ -24,8 +24,22 @@ export const clearSocialImageCache = async () => {
2424
functionName: "clearSocialMediaImageCache",
2525
message: "called",
2626
});
27-
const db = await openDatabase();
28-
await db.clear(STORE_NAME);
27+
try {
28+
const db = await openDatabase();
29+
await db.clear(STORE_NAME);
30+
new Notice("Vault Explorer: social media image cache cleared");
31+
} catch (err) {
32+
new Notice("Failed to clear social media image cache");
33+
const error = err as Error;
34+
Logger.error(
35+
{
36+
fileName: "social-media-image.ts",
37+
functionName: "clearSocialMediaImageCache",
38+
message: "failed to clear cache",
39+
},
40+
error.message
41+
);
42+
}
2943
};
3044

3145
export const fetchSocialImage = async (url: string) => {
@@ -73,9 +87,21 @@ export const fetchSocialImage = async (url: string) => {
7387
const ogImage = getMetaTagContent(document, "og:image");
7488
const twitterImage = getMetaTagContent(document, "twitter:image");
7589

76-
const imageUrl = ogImage || twitterImage;
90+
let imageUrl = ogImage || twitterImage;
7791

7892
if (imageUrl) {
93+
//Handle edge case where social media image URL has slashes at the beginning
94+
//See issue #265
95+
if (imageUrl.startsWith("//")) {
96+
imageUrl = imageUrl.replace(/^\/+/, "");
97+
}
98+
99+
//Handle edge case where the url doesn't start with https://
100+
//See issue #265
101+
if (!imageUrl.startsWith("https://")) {
102+
imageUrl = `https://${imageUrl}`;
103+
}
104+
79105
Logger.debug(
80106
{
81107
fileName: "social-media-image.ts",

test-vault/.obsidian/plugins/vault-explorer/data.json

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,28 @@
2525
},
2626
"custom": {
2727
"isEnabled": true,
28-
"selectedGroupId": "",
29-
"groups": []
28+
"selectedGroupId": "A3PgwC3AaYu1XqDn",
29+
"groups": [
30+
{
31+
"id": "A3PgwC3AaYu1XqDn",
32+
"name": "Group 1",
33+
"rules": [
34+
{
35+
"id": "EiihU98U3T6b6UNr",
36+
"type": "property",
37+
"propertyType": "text",
38+
"propertyName": "",
39+
"operator": "and",
40+
"isEnabled": true,
41+
"condition": "is",
42+
"value": "",
43+
"matchWhenPropertyDNE": false
44+
}
45+
],
46+
"isEnabled": false,
47+
"isSticky": false
48+
}
49+
]
3050
},
3151
"favorites": {
3252
"isEnabled": true,
@@ -75,7 +95,7 @@
7595
"enableClockUpdates": true,
7696
"enableFileIcons": true,
7797
"enableScrollButtons": true,
78-
"filterGroupsWidth": "201px",
98+
"filterGroupsWidth": "759px",
7999
"shouldWrapFilterGroups": false,
80100
"pageSize": 25,
81101
"viewOrder": [
@@ -84,6 +104,6 @@
84104
"feed"
85105
],
86106
"configDir": ".vaultexplorer",
87-
"pluginVersion": "1.34.2",
107+
"pluginVersion": "1.34.3",
88108
"logLevel": "trace"
89109
}

versions.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,5 +120,6 @@
120120
"1.34.0": "1.4.13",
121121
"1.34.1": "1.4.13",
122122
"1.34.2": "1.4.13",
123-
"1.34.3": "1.4.13"
123+
"1.34.3": "1.4.13",
124+
"1.35.0": "1.4.13"
124125
}

0 commit comments

Comments
 (0)