Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: excluding the root #91

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 21 additions & 22 deletions interfaces/ZottelkeeperPluginSettings.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import { SortOrder } from './../models';
import { IndexItemStyle } from './IndexItemStyle';
import { SortOrder } from "./../models";
import { IndexItemStyle } from "./IndexItemStyle";

export interface ZoottelkeeperPluginSettings {
indexPrefix: string;
indexItemStyle: IndexItemStyle;
indexTagValue: string;
indexTagBoolean: boolean;
indexTagLabel: string;
cleanPathBoolean: boolean;
indexTagSeparator: string;
folderEmoji: string;
fileEmoji: string;
enableEmojis: boolean;
foldersIncluded: string;
foldersExcluded: string;
sortOrder: SortOrder;
addSquareBrackets: boolean;
embedSubIndex: boolean;
templateFile: string;
frontMatterSeparator: string;
[key: string]: any;

}
indexPrefix: string;
indexItemStyle: IndexItemStyle;
indexTagValue: string;
indexTagBoolean: boolean;
indexTagLabel: string;
cleanPathBoolean: boolean;
indexTagSeparator: string;
folderEmoji: string;
fileEmoji: string;
enableEmojis: boolean;
foldersIncluded: string;
foldersExcluded: string;
sortOrder: SortOrder;
addSquareBrackets: boolean;
embedSubIndex: boolean;
templateFile: string;
frontMatterSeparator: string;
[key: string]: any;
}
18 changes: 13 additions & 5 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,9 @@ export default class ZoottelkeeperPlugin extends Plugin {

getInnerIndexFilePath = (folderPath: string): string => {
const folderName = this.getFolderName(folderPath);
return `${folderPath}/${this.settings.indexPrefix}${folderName}.md`;
return this.createIndexFilePath(folderPath, folderName);
}

getIndexFilePath = (filePath: string): string => {
const fileAbstrPath = this.app.vault.getAbstractFileByPath(filePath);

Expand All @@ -253,16 +254,23 @@ export default class ZoottelkeeperPlugin extends Plugin {
}
const parentName = this.getParentFolderName(filePath);

return `${parentPath}${this.settings.indexPrefix}${parentName}.md`;
};
return this.createIndexFilePath(parentPath, parentName);
}

createIndexFilePath = (folderPath: string, folderName: string) => {
if (!folderPath.endsWith('/') && folderPath !== '') {
folderPath += '/';
}
return `${folderPath}${this.settings.indexPrefix}${folderName}.md`;
}

removeDisallowedFoldersIndexes = async (indexFiles: Set<string>): Promise<void> => {
for (const folder of this.settings.foldersExcluded.split('\n').map(f=> f.trim())){
const innerIndex = this.getInnerIndexFilePath(folder);
indexFiles.delete(innerIndex);
}
}

cleanDisallowedFolders = async (): Promise<void> => {
for (const folder of this.settings.foldersExcluded.split('\n').map(f=> f.trim())){
const innerIndex = this.getInnerIndexFilePath(folder);
Expand Down Expand Up @@ -353,7 +361,7 @@ class ZoottelkeeperPluginSettingTab extends PluginSettingTab {
new Setting(containerEl)
.setName('Folders excluded')
.setDesc(
'Specify the folders NOT to be handled by Zoottelkeeper. They must be absolute paths starting from the root vault, one per line. Example: "Notes/ <enter> Articles/ ", it will exclude Notes and Articles folder in the root folder. * can be added to the end, to exclude the folder\'s subdirectories recursively.'
'Specify the folders NOT to be handled by Zoottelkeeper. They must be absolute paths starting from the root vault, one per line, an empty line excluding the root folder itself. Example: "Notes/ <enter> Articles/ ", it will exclude Notes and Articles folder in the root folder. * can be added to the end, to exclude the folder\'s subdirectories recursively.'
)
.addTextArea((text) =>
text
Expand Down
16 changes: 8 additions & 8 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"id": "zoottelkeeper-obsidian-plugin",
"name": "Zoottelkeeper Plugin",
"version": "0.18.0",
"minAppVersion": "0.12.1",
"description": "This plugin automatically creates, maintains and tags MOCs for all your folders.",
"author": "Akos Balasko, Micha Brugger",
"authorUrl": "https://github.com/akosbalasko, https://github.com/michabrugger",
"isDesktopOnly": false
"id": "zoottelkeeper-obsidian-plugin",
"name": "Zoottelkeeper Plugin",
"version": "0.18.2",
"minAppVersion": "0.12.1",
"description": "This plugin automatically creates, maintains and tags MOCs for all your folders.",
"author": "Akos Balasko, Micha Brugger",
"authorUrl": "https://github.com/akosbalasko, https://github.com/michabrugger",
"isDesktopOnly": false
}