From c0ef3c526725d739e43a1986c416867ce2bf83aa Mon Sep 17 00:00:00 2001 From: Eco-Gaming <7ecogaming4@gmail.com> Date: Thu, 11 Apr 2024 14:46:29 +0200 Subject: [PATCH 1/4] bump package-lock.json to 1.0.23 --- package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3528d6e..9607815 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "obsidian-sample-plugin", - "version": "1.0.22", + "version": "1.0.23", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "obsidian-sample-plugin", - "version": "1.0.22", + "version": "1.0.23", "license": "MIT", "devDependencies": { "@types/node": "16.11.6", From 843785897dbbea3b7f4887c29344cefd624623b4 Mon Sep 17 00:00:00 2001 From: Eco-Gaming <7ecogaming4@gmail.com> Date: Thu, 11 Apr 2024 14:46:56 +0200 Subject: [PATCH 2/4] exclude folders completely --- src/modules/FolderNoteModule.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/modules/FolderNoteModule.ts b/src/modules/FolderNoteModule.ts index d961ce2..49e1116 100644 --- a/src/modules/FolderNoteModule.ts +++ b/src/modules/FolderNoteModule.ts @@ -81,8 +81,8 @@ export class FolderNoteModule { indexFilePath = this.plugin.settings.rootIndexFile } - // Create the File if it doesn't exist and open it - if (!this.doesFileExist(indexFilePath)) { + // Create the File if it doesn't exist and isn't excluded, then open it + if (!this.doesFileExist(indexFilePath) && (folderName == null || !this.plugin.settings.excludeFolders.includes(folderName))) { if (await this.createIndexFile(indexFilePath)) { await this.openIndexFile(indexFilePath) } From 5987c3cd89dca5d78173a6fe2239e044e772bfac Mon Sep 17 00:00:00 2001 From: Eco-Gaming <7ecogaming4@gmail.com> Date: Fri, 12 Apr 2024 10:54:00 +0200 Subject: [PATCH 3/4] fix structure --- src/modules/FolderNoteModule.ts | 4 ++-- src/types/Utilities.ts | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/modules/FolderNoteModule.ts b/src/modules/FolderNoteModule.ts index 49e1116..d961ce2 100644 --- a/src/modules/FolderNoteModule.ts +++ b/src/modules/FolderNoteModule.ts @@ -81,8 +81,8 @@ export class FolderNoteModule { indexFilePath = this.plugin.settings.rootIndexFile } - // Create the File if it doesn't exist and isn't excluded, then open it - if (!this.doesFileExist(indexFilePath) && (folderName == null || !this.plugin.settings.excludeFolders.includes(folderName))) { + // Create the File if it doesn't exist and open it + if (!this.doesFileExist(indexFilePath)) { if (await this.createIndexFile(indexFilePath)) { await this.openIndexFile(indexFilePath) } diff --git a/src/types/Utilities.ts b/src/types/Utilities.ts index f52ed90..81f1bdf 100644 --- a/src/types/Utilities.ts +++ b/src/types/Utilities.ts @@ -1,5 +1,6 @@ import {TFile} from "obsidian"; import FolderIndexPlugin from "../main"; +import * as typescriptPath from "path"; export function isIndexFileWithFile(file: TFile) { return isIndexFile(file.path) @@ -22,7 +23,7 @@ export function isExcludedPath(path: string) { for (const excludedFolder of FolderIndexPlugin.PLUGIN.settings.excludeFolders) { if (excludedFolder == "") continue - if (RegExp(`^${excludedFolder}$`).test(path)) + if (RegExp(`^${excludedFolder}$`).test(path) || RegExp(`^${excludedFolder}$`).test(typescriptPath.dirname(path))) return true; } return false From 4d4cad7f1bd2069bf834b3c97255a3aecb6993e0 Mon Sep 17 00:00:00 2001 From: Eco-Gaming <7ecogaming4@gmail.com> Date: Fri, 19 Apr 2024 20:23:42 +0200 Subject: [PATCH 4/4] accept more readable regex --- src/models/PluginSettingsTab.ts | 2 +- src/types/Utilities.ts | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/models/PluginSettingsTab.ts b/src/models/PluginSettingsTab.ts index eeffc84..1dcc854 100644 --- a/src/models/PluginSettingsTab.ts +++ b/src/models/PluginSettingsTab.ts @@ -110,7 +110,7 @@ export class PluginSettingsTab extends PluginSettingTab { .setName("Excluded Folders") .setDesc("These Folders will not automatically create an IndexFile") .addTextArea(component => { - component.setPlaceholder("Folder1\nFolder2/Foo\nFolder3/Foo/Bar") + component.setPlaceholder("Folder1\nFolder2/Foo\nFolder3/*") .setValue(this.plugin.settings.excludeFolders.join("\n")) .onChange(async (value) => { this.plugin.settings.excludeFolders = value.split("\n") diff --git a/src/types/Utilities.ts b/src/types/Utilities.ts index 81f1bdf..7a827bc 100644 --- a/src/types/Utilities.ts +++ b/src/types/Utilities.ts @@ -20,9 +20,13 @@ export function isIndexFile(path: string) { } export function isExcludedPath(path: string) { - for (const excludedFolder of FolderIndexPlugin.PLUGIN.settings.excludeFolders) { + for (let excludedFolder of FolderIndexPlugin.PLUGIN.settings.excludeFolders) { if (excludedFolder == "") continue + + if (excludedFolder.endsWith("/*")) + excludedFolder = excludedFolder.slice(0, -1) + ".*"; + if (RegExp(`^${excludedFolder}$`).test(path) || RegExp(`^${excludedFolder}$`).test(typescriptPath.dirname(path))) return true; }