Initial commit

This commit is contained in:
2026-03-02 17:06:32 +00:00
commit 430dd71917
1190 changed files with 622790 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
<%*
const title = tp.date.now("YYYY-MM-DD HHmmss");
const folder = "Notes";
const template = tp.file.find_tfile("Journal Template");
// Create the file
const newFile = await tp.file.create_new(template, title, false, folder);
// Open it in a new tab so you don't lose your current note
await app.workspace.getLeaf('tab').openFile(newFile);
%>

View File

@@ -0,0 +1,16 @@
function get_clean_title(filename) {
// Regex matches: [4 digits]-[2 digits]-[2 digits] [space] [4 digits] [optional space] [capture everything else]
const timestampRegex = /^\d{4}-\d{2}-\d{2}\s\d{4}\s?(.*)/;
const match = filename.match(timestampRegex);
// If it matches your timestamp format, return the captured group (the text after)
// If it doesn't match (no timestamp), return the whole filename
let title = match ? match[1] : filename;
// Clean up common placeholder names
//if (title.toLowerCase().includes("untitled")) return "";
return title.trim();
}
module.exports = get_clean_title;

View File

@@ -0,0 +1,91 @@
//
// copy this code into this site to create a bookmarklet: https://caiorss.github.io/bookmarklet-maker/
//
javascript: (function () {
if (window.obs_active) return;
window.obs_active = true;
Promise.all([
import('https://unpkg.com/turndown@6.0.0?module'),
import('https://unpkg.com/@tehshrike/readability@0.2.0'),
]).then(async ([{ default: T }, { default: R }]) => {
/* 1. CONFIGURATION */
const vault = "Bobbie's Vault";
const folder = "Library/";
let tags = "clippings"; // disabled lower down
/* 2. DATE & TIME */
const d = new Date();
const pad = (n) => n.toString().padStart(2, '0');
const isoNow = `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}T${pad(d.getHours())}:${pad(d.getMinutes())}:${pad(d.getSeconds())}`;
const today = `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())}`;
/* 3. ORIGINAL TAG LOGIC */
if (document.querySelector('meta[name="keywords" i]')) {
var keywords = document.querySelector('meta[name="keywords" i]').getAttribute('content').split(',');
keywords.forEach(function (keyword) {
tags += ' ' + keyword.split(' ').join('');
});
}
/* 4. CONTENT CAPTURE */
const { title, byline, content } = new R(document.cloneNode(true)).parse();
const selection = window.getSelection().toString();
const md = new T({
headingStyle: 'atx',
hr: '---',
bulletListMarker: '-',
codeBlockStyle: 'fenced',
emDelimiter: '*',
}).turndown(selection || content);
/* 5. ORIGINAL METADATA LOGIC */
const getMeta = (attr, val) => {
const el = document.querySelector(`meta[${attr}='${val}']`);
return el ? el.getAttribute("content").trim() : "";
};
const author = byline || getMeta("name", "author") || getMeta("property", "author") || getMeta("property", "og:site_name");
const authorBrackets = author ? `"[[${author}]]"` : "";
const timeEl = document.querySelector("time");
let published = "";
const pubAttr = timeEl ? timeEl.getAttribute("datetime") : "";
if (pubAttr) {
const pD = new Date(pubAttr);
published = `${pD.getFullYear()}-${pad(pD.getMonth() + 1)}-${pad(pD.getDate())}`;
}
/* 6. BUILD YAML & FILE */
const fileContent =
'---\n'
+ 'created: ' + isoNow + '\n'
+ 'up:\n'
+ ' - "[[Library]]"\n'
+ 'title: "' + title + '"\n'
+ 'source: ' + document.URL + '\n'
+ 'author: ' + authorBrackets + '\n'
+ 'published: ' + published + '\n'
+ 'topics: \n'
+ 'tags:\n'
+ '---\n\n'
+ md;
/* 7. SAFE URI CONSTRUCTION */
const fileName = today + " " + title.replace(/[:/\\|?*<>]/g, '-').substring(0, 60).trim();
const uri = `obsidian://new?vault=${encodeURIComponent(vault)}&file=${encodeURIComponent(folder + fileName)}&content=${encodeURIComponent(fileContent)}`;
/* 8. STABLE EXECUTION (IFRAME) */
const iframe = document.createElement('iframe');
iframe.style.display = 'none';
iframe.src = uri;
document.body.appendChild(iframe);
setTimeout(() => {
document.body.removeChild(iframe);
window.obs_active = false;
}, 1000);
});
})();

View File

@@ -0,0 +1,48 @@
module.exports = async (params) => {
const { app } = params;
const activeFile = app.workspace.getActiveFile();
if (!activeFile) return;
const cache = app.metadataCache.getFileCache(activeFile);
const fm = cache?.frontmatter;
if (!fm || !fm.title) {
new Notice("No changes made, title property not set");
return;
}
// 1. Get the Date components
const createdDate = fm.created?.split('T')[0]; // e.g. 2026-01-06
const eventDate = fm.date || createdDate || moment().format("YYYY-MM-DD");
// 2. Logic: Should we use actual time or 0000?
let timePart = "";
// If the event is happening today, use the actual created time
if (eventDate === createdDate) {
if (fm.created && fm.created.includes('T')) {
timePart = fm.created.split('T')[1].replace(/:/g, '').substring(0, 4);
} else {
new Notice("Error: 'created' property is missing or incorrect format");
return;
}
}
// 3. Construct filename
let newName = "";
if (timePart.length === 0) {
newName = `${eventDate} ${fm.title}`;
}
else {
newName = `${eventDate} ${timePart} ${fm.title}`;
}
const newPath = `${activeFile.parent.path}/${newName}.md`;
// 4. Rename
if (activeFile.name !== `${newName}.md`) {
await app.fileManager.renameFile(activeFile, newPath);
new Notice(`Renamed: ${newName}`);
} else {
new Notice("Filename already matches.");
}
};