Amplejots

name

Amplejots

icon

edit

instructions

Features:
1. Create next day's jot
2. Navigate to a random jot
3. Navigate to the jot for a year in the past

Creating next day's jot
Visit Jots Mode and run the plugin from the Jots Suggestions that appear at the bottom of your Daily Jot. The suggestion will disappear if a Jot already exists for the upcoming day. The first time you run the plugin, you will have to select the template to pull from.

Navigate to a jot
Simply use Cmd-O or Cltr-O to bring up the Quick Open menu, then type in "Amplejots" and choose one of the options. Currently you can navigate to the jot corresponding to a year in the past or to a random jot.

setting

Source note UUID


linkChange log

January 18th, 2024

"Create next day's jot" will now store and remember the chosen template;

template is also stored as a plugin setting

October 26th, 2023

New appOption: navigate to random jot

New appOption: navigate to one year ago

October 6th, 2023

Fix: properly import empty tasks


repo: https://github.com/lukkes/amplejots


linkCode block

{
settings: {
sourceNoteUUID: null,
jotTag: "daily-jots",
},
 
dailyJotOption: {
async "Create tomorrow's jot" (app, noteHandle) {
const newNoteName = this._getNextDaysName(noteHandle.name);
console.log(newNoteName);
 
const newNote = await app.createNote(newNoteName, noteHandle.tags);
console.log(newNote);
 
const newNoteHandle = await app.findNote({uuid: newNote});
console.log(JSON.stringify(newNoteHandle));
 
const url = `https://www.amplenote.com/notes/${ newNote }`;
// const url = `https://www.amplenote.com/notes/new`;
 
if (!app.settings["Source note UUID"]) {
const noteHandle = await app.prompt(
"No template selected yet. Please choose one from this menu",
{
inputs: [
{
label: "Template note",
type: "note"
}
]
 
}
);
if (!noteHandle) return;
this.settings.sourceNoteUUID = noteHandle.uuid;
await app.setSetting("Source note UUID", noteHandle.uuid);
}
const sourceNote = await app.findNote({uuid: app.settings["Source note UUID"]});
console.log(JSON.stringify(sourceNote));
 
let sourceContents = await app.getNoteContent(sourceNote);
console.log(sourceContents);
 
// Make sure we handle empty tasks bug manifesting October 2023
sourceContents = sourceContents.replace("\\<!--", " <!--");
 
await app.insertContent(newNoteHandle, sourceContents);
app.navigate(url);
// TODO: insert note contents
}
},
 
appOption: {
async "Resurface random jot" (app) {
try {
let jotTag = this.settings.jotTag || "daily-jots";
console.log(jotTag);
let jotList = await app.filterNotes({tag: jotTag});
console.log(jotList);
let randomJot = jotList[Math.floor(Math.random() * jotList.length)];
console.log(randomJot);
await app.navigate(`https://www.amplenote.com/notes/${ randomJot.uuid }`);
} catch (err) {
console.log(err);
await app.alert(err);
}
},
 
async "One Year Ago" (app) {
try {
let jotTag = this.settings.jotTag || "daily-jots";
console.log(jotTag);
let oneYearAgo = this._getOneYearAgoName(this._getAmplenoteDate(new Date()));
let jotList = await app.filterNotes({tag: jotTag, query: oneYearAgo});
if (jotList.length == 0) {
console.log("Empty");
await app.alert(`No jot found for a year ago in ${ jotTag }`);
return;
}
console.log(jotList);
await app.navigate(`https://www.amplenote.com/notes/${ jotList[0].uuid }`);
} catch (err) {
console.log(err);
await app.alert(err);
}
}
},
 
_getAmplenoteDate(date) {
// array with month names
var monthNames = ["January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"];
 
// calculate the ordinal
var day = date.getDate();
var ordinal;
if (day > 3 && day < 21) {
ordinal = "th";
} else {
switch (day % 10) {
case 1: ordinal = "st"; break;
case 2: ordinal = "nd"; break;
case 3: ordinal = "rd"; break;
default: ordinal = "th"; break;
}
}
 
// construct the next day's date string
var dateString = monthNames[date.getMonth()] + " " + day + ordinal + ", " + date.getFullYear();
 
return dateString;
},
 
_getNextDaysName(dateString) {
// Remove ordinal suffix from day
var dateStringNoSuffix = dateString.replace(/(\d+)(st|nd|rd|th)/, "$1");
var date = new Date(dateStringNoSuffix); // parse the date string into a Date object
date.setDate(date.getDate() + 1); // increment the day by one
return this._getAmplenoteDate(date);
},
 
_getOneYearAgoName(dateString) {
// Remove ordinal suffix from day
var dateStringNoSuffix = dateString.replace(/(\d+)(st|nd|rd|th)/, "$1");
var date = new Date(dateStringNoSuffix); // parse the date string into a Date object
date.setFullYear(date.getFullYear() - 1);
return this._getAmplenoteDate(date);
}
}