Skip to content

Instantly share code, notes, and snippets.

@sidedwards
Last active March 6, 2024 18:47
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sidedwards/ab67be678ff93081cd06bcd683e60106 to your computer and use it in GitHub Desktop.
Save sidedwards/ab67be678ff93081cd06bcd683e60106 to your computer and use it in GitHub Desktop.
Journal Template for Trilium Notes. https://github.com/zadam/trilium
api.addButtonToToolbar({
title: 'New Journal Entry',
icon: 'book',
shortcut: 'alt+j',
action: async function() {
const todayDateStr = api.formatDateISO(new Date());
const todayEntry = await api.runOnServer(async todayDateStr => {
return await api.getDateNote(todayDateStr);
}, [todayDateStr]);
const dateCreated = api.parseDate(todayEntry.dateCreated);
// newly created note isn't in the tree cache yet
if (new Date().getTime() - dateCreated.getTime() < 60 * 1000) {
await api.refreshTree();
}
api.activateNote(todayEntry.noteId);
const request = async () => {
const response = await fetch('https://quotes.rest/qod?category=life');
const json = await response.json();
const journalEntry = await api.runOnServer(async (todayEntry, json) => {
const journalTemplate = `
<blockquote>
<p>${json.contents.quotes[0].quote} - ${json.contents.quotes[0].author}</p>
</blockquote>
<p>&nbsp;</p>
<p>
<strong>1. Take a moment to reflect on yesterday.</strong> How was your nutrition? How was your physical activity? Did you achieve your daily goals? How did you feel?
</p>
<h2>Yesterday</h2>
<p>&nbsp;</p>
<p>
<strong>Action Item Follow-up</strong>
</p>
<ol>
<li>&nbsp;</li>
</ol>
<p>
<strong>2. Take a moment to plan for today.</strong> What does your schedule look like? Is there anything that&nbsp;doesn’t support today’s intention and if so, can you get it off your calendar? What would you like to achieve today? Which few small action items will help you achieve it? What are you grateful for?
</p>
<h2>Today</h2>
<p>&nbsp;</p>
<p>
<strong>Action Items</strong>
</p>
<ol>
<li>&nbsp;</li>
</ol>
<p>
<strong>Grateful For</strong>
</p>
<ol>
<li>&nbsp;</li>
</ol>
`;
return await api.createNote(todayEntry.noteId, 'Journal Entry', journalTemplate, {isProtected:true});
}, [todayEntry, json]);
const journalDateCreated = api.parseDate(journalEntry.dateCreated);
// newly created note isn't in the tree cache yet
if (new Date().getTime() - journalDateCreated.getTime() < 60 * 1000) {
await api.refreshTree();
}
api.activateNote(journalEntry.noteId);
};
request();
}
});
@sidedwards
Copy link
Author

sidedwards commented Jan 9, 2019

This script creates a "New Journal Entry" button that will create a new entry for that day when clicked. It also pulls in a quote of the day via the https://theysaidso.com/api/. Template preview below. I also added the isProtected flag so you'll have to enter a protected session to create or read entries.

Journal Entry

Our mind is all we've got. Not that it won't lead us astray sometimes, but we still have to analyze things out within ourselves. - Bobby Fischer

1. Take a moment to reflect on yesterday. How was your nutrition? How was your physical activity? Did you achieve your daily goals? How did you feel?

Yesterday

Action Item Follow-up

2. Take a moment to plan for today. What does your schedule look like? Is there anything that doesn’t support today’s intention and if so, can you get it off your calendar? What would you like to achieve today? Which few small action items will help you achieve it? What are you grateful for?

Today

Action Items

Grateful For

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment