Skip to content

Instantly share code, notes, and snippets.

@GitMurf
Last active August 11, 2023 15:26
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GitMurf/595ac211b4503ba6e82a2f8bc68d1ca3 to your computer and use it in GitHub Desktop.
Save GitMurf/595ac211b4503ba6e82a2f8bc68d1ca3 to your computer and use it in GitHub Desktop.
<%*
const openInNewPane = false; //If false, will save link to clipboard
const folderName = `refactor`;
const firstVal = await tp.system.prompt("First thought to add to the new note");
//Client name
const files = await app.vault.getMarkdownFiles();
const links = [];
const finalLinkArr = [];
files.forEach(file => {
links.push(file.basename);
finalLinkArr.push('📄 ' + file.basename);
});
const unResLinks = Object.entries(app.metadataCache.unresolvedLinks);
unResLinks.forEach((file) => {
Object.entries(file[1]).forEach(eachItem => {
if(!links.includes(eachItem[0])) {
links.push(eachItem[0]);
finalLinkArr.push('🔗 ' + eachItem[0]);
}
});
});
const selection = await tp.system.suggester(finalLinkArr, links, false, 'Client Name');
const clientName = '[' + `[${selection}]]`;
const clientNameClean = clientName.replace(/[\[\]]/gim, '');
let subjOptions = [];
subjOptions.push('Weekly status call');
subjOptions.push('Negotiation update');
subjOptions.push('1on1 meeting');
subjOptions.push('OTHER');
let subject = await tp.system.suggester(subjOptions, subjOptions, false, 'Meeting Subject');
if(subject == "OTHER") {
subject = await tp.system.prompt("Meeting subject");
} else {
subject = await tp.system.prompt("Add more to subject?", subject);
}
let meetOptions = [];
meetOptions.push('#meeting');
meetOptions.push('#meeting/status');
meetOptions.push('#meeting/1on1');
meetOptions.push('#meeting/general');
meetOptions.push('#meeting/deliverable');
let meetType = await tp.system.suggester(meetOptions, meetOptions, false, 'Type of meeting');
let fullPage = `---\n`;
fullPage += `company: ['${clientNameClean}']\n`;
fullPage += `categories: ['meeting']\n`;
fullPage += `---\n
`;
fullPage += `# [` + '[' + `${ tp.date.now('YYYY-MM-DD') }]] [[Business]] ${clientName}\n
`;
fullPage += `## ${clientName} - ${subject} ${meetType}\n
`;
fullPage += `### [[Meeting notes]]\n
`;
fullPage += `- ${firstVal}\n
`;
let newFileName = `${tp.date.now('YYYY-MM-DD_HH-mm')}_${clientName} - ${subject} - ${meetType}`;
newFileName = newFileName.replace(/[\.#\*"\/\\<>\:\|\[\]\?]/gim, '').trim().slice(0, 255);
let useSource = '';
const thisFile = this.app.workspace.getActiveFile();
if(thisFile) {useSource = thisFile.path}
let vaultRootPath = this.app.fileManager.getNewFileParent(useSource).path;
let bNewFolder = await this.app.vault.adapter.exists(vaultRootPath + `/${folderName}`, false);
if(!bNewFolder){await this.app.vault.createFolder(vaultRootPath + `/${folderName}`);}
let newFilePath = vaultRootPath + `/${folderName}/` + newFileName + ".md";
let newFileObj = await this.app.vault.create(newFilePath, fullPage);
if(openInNewPane) {
await this.app.workspace.openLinkText(newFileObj.basename, newFileObj.path, true);
let newLink = '![' + '[' + newFileName + ']]';
const finalText = `## ${clientName}
${newLink}`;
tR = finalText;
} else {
let newLink = '[' + '[' + newFileName + ']]';
navigator.clipboard.writeText(newLink).then(text => text);
new Notice("Link to your new Note has been copied to the Clipboard", 5000);
}
%>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment