mirror of
https://github.com/bramses/bramses-highly-opinionated-vault-2023.git
synced 2025-02-26 07:53:55 +00:00
first commit
This commit is contained in:
33
_scripts/quick-add-create-project-folder.js
Normal file
33
_scripts/quick-add-create-project-folder.js
Normal file
@@ -0,0 +1,33 @@
|
||||
module.exports = async function createProject(params) {
|
||||
|
||||
const PROJECTS_FOLDER = "_PARA/Projects/";
|
||||
|
||||
const userInput = await params.quickAddApi.inputPrompt("CREATE a new Project (and remember to have fun!)", "Project Name")
|
||||
|
||||
// Check if user cancelled
|
||||
if (!userInput) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the project name
|
||||
const absolutePath = PROJECTS_FOLDER + userInput;
|
||||
|
||||
|
||||
|
||||
// Create a new folder
|
||||
await params.app.vault.createFolder(`${absolutePath}`);
|
||||
|
||||
|
||||
// // Create a new file in the new folder
|
||||
const newFile = await params.app.vault.create(`${absolutePath}/${userInput}.md`, `# ${userInput}\n\n`);
|
||||
|
||||
// // Create a scratchpad file in the new folder
|
||||
await params.app.vault.create(`${absolutePath}/Scratchpad.md`, "# Scratchpad\n\n");
|
||||
|
||||
// // Create a Kanban file in the new folder
|
||||
await params.app.vault.create(`${absolutePath}/Kanban.md`, `# Kanban\n\n## To Do\n\n## Doing\n\n## Done`);
|
||||
|
||||
|
||||
// Open the new file
|
||||
await params.app.workspace.activeLeaf.openFile(newFile);
|
||||
}
|
||||
37
_scripts/quick-add-file-filter.js
Normal file
37
_scripts/quick-add-file-filter.js
Normal file
@@ -0,0 +1,37 @@
|
||||
// https://forum.obsidian.md/t/quickadd-macro-showing-a-list-of-files-to-capture-automatically/41185
|
||||
|
||||
module.exports = async function listFiles(params) {
|
||||
// Grab fileType variables
|
||||
const fileType = params.variables.fileType;
|
||||
const folder = fileType.folder;
|
||||
const folderExclude = fileType.folderExclude;
|
||||
const filename = fileType.filename;
|
||||
|
||||
// Search for files that match fileType parameters
|
||||
const files = params.app.vault.getMarkdownFiles()
|
||||
.filter(file => file.path.match(folder))
|
||||
.filter(file => {
|
||||
//Check if folderExclude field exists
|
||||
if (folderExclude) { return !file.path.match(folderExclude) }
|
||||
else { return file }
|
||||
})
|
||||
.filter(file => file.basename.match(filename))
|
||||
|
||||
//Sort by File Name
|
||||
.sort((a,b) => a.basename.localeCompare(b.basename))
|
||||
//Sort by Folder
|
||||
.sort((a,b) => a.parent.path.localeCompare(b.parent.path))
|
||||
//This was to show file outside of inner folder on top
|
||||
//then sort the files in the inner folder
|
||||
|
||||
|
||||
|
||||
// Display files to select
|
||||
const notesDisplay = await params.quickAddApi.suggester(
|
||||
(files) => files.path.replace(".md", ""),
|
||||
files
|
||||
);
|
||||
|
||||
// Pass selected note's path to notes variable
|
||||
params.variables = { notes: notesDisplay.path };
|
||||
}
|
||||
8
_scripts/quick-add-projects-folder-variables.js
Normal file
8
_scripts/quick-add-projects-folder-variables.js
Normal file
@@ -0,0 +1,8 @@
|
||||
module.exports = (params) => {
|
||||
params.variables.fileType = {
|
||||
folder: "Projects",
|
||||
//folderExclude: "",
|
||||
// There's no folder to exclude so I commented it out
|
||||
filename:"Scratchpad"
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user