From a84cd2dcae692d29031fd1b2f4fb5b78e4d9ea18 Mon Sep 17 00:00:00 2001 From: Akos Balasko Date: Tue, 17 Aug 2021 16:19:06 +0200 Subject: [PATCH 1/2] cleanPath reintroduced --- main.ts | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/main.ts b/main.ts index d21188b..3083027 100644 --- a/main.ts +++ b/main.ts @@ -6,6 +6,7 @@ interface ZoottelkeeperPluginSettings { indexItemStyle: IndexItemStyle; indexTagValue: string; indexTagBoolean: boolean; + cleanPathBoolean: boolean; } interface GeneralContentOptions { @@ -19,6 +20,7 @@ const DEFAULT_SETTINGS: ZoottelkeeperPluginSettings = { indexItemStyle: IndexItemStyle.PureLink, indexTagValue: 'MOC', indexTagBoolean: true, + cleanPathBoolean: true, }; export default class ZoottelkeeperPlugin extends Plugin { @@ -204,7 +206,7 @@ export default class ZoottelkeeperPlugin extends Plugin { } }; - generateIndexItem = (path: string): string => { + generateFormattedIndexItem = (path: string): string => { switch (this.settings.indexItemStyle) { case IndexItemStyle.PureLink: return `[[${path}]]`; @@ -215,6 +217,21 @@ export default class ZoottelkeeperPlugin extends Plugin { }; } + generateIndexItem = (path: string): string => { + let internalFormattedIndex; + if (this.settings.cleanPathBoolean) { + const cleanPath = ( path.endsWith(".md")) + ? path.replace(/\.md$/,'') + : path; + const fileName = cleanPath.split("/").pop(); + internalFormattedIndex = `${cleanPath}|${fileName}`; + } + else { + internalFormattedIndex = path; + } + return this.generateFormattedIndexItem(internalFormattedIndex); + } + generateIndexFolderItem = (path: string): string => { return this.generateIndexItem(this.getInnerIndexFilePath(path)); } @@ -295,7 +312,18 @@ class ZoottelkeeperPluginSettingTab extends PluginSettingTab { containerEl.createEl('h2', { text: 'Zoottelkeeper Settings' }); containerEl.createEl('h3', { text: 'General Settings' }); - + new Setting(containerEl) + .setName("Clean Files") + .setDesc( + "This enables you to only show the files without path and '.md' ending in preview mode." + ) + .addToggle((t) => { + t.setValue(this.plugin.settings.cleanPathBoolean); + t.onChange(async (v) => { + this.plugin.settings.cleanPathBoolean = v; + await this.plugin.saveSettings(); + }); + }); new Setting(containerEl) .setName('List Style') .setDesc('Select the style of the index-list.') From dfecc93d2d733adc9d8769b04fdf4f216fba8298 Mon Sep 17 00:00:00 2001 From: Akos Balasko Date: Tue, 17 Aug 2021 22:15:31 +0200 Subject: [PATCH 2/2] versions updated --- package.json | 2 +- versions.json | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f68a31e..ebbcde7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zoottelkeeper-obsidian-plugin", - "version": "0.8.0", + "version": "0.9.0", "description": "This plugin automatically creates, maintains and tags MOCs for all your folders.", "main": "main.js", "scripts": { diff --git a/versions.json b/versions.json index a07f756..c07035b 100644 --- a/versions.json +++ b/versions.json @@ -2,5 +2,6 @@ "0.5.2": "0.12.1", "0.5.3": "0.12.1", "0.6.0": "0.12.1", - "0.8.0": "0.12.1" + "0.8.0": "0.12.1", + "0.9.0": "0.12.1" } \ No newline at end of file