Prepend Drafts entry to a Drafts entry with timestamp

#1

Ironically, I’m asking this as the DayOne episode just came out.

I’m thinking of starting a very simple journal. I was thinking of using Drafts 5 to do this. What I would like to do is create a first (main) draft item. Then, at the end of each day, I write a new draft of what I wanted to document and then hit the action button which will give me an option to prepend that draft to my main draft item (the first one I created). With the prepend, I also want it to have a date stamp on it. Ideally, once I hit the action, it does it all and I have no need to click on anything else.

Is this possible? As simple as some actions are, I can’t seem to wrap my head around this scenario.

Thanks,

Paul

0 Likes

#2

Paging the one and only @nahumck

1 Like

#3

As @ismh sent out the Drafts signal, I’ve answered the call.

I get mostly what you’re trying to do, but I wanted to get some clarification first: why use a single draft and then create a new one with the journal entry at the end of the day? I have a lot more to say on the topic, but if you create a journal entry at the start of the day in the format you want, you can always add to that entry throughout the day. Might make it easier. Let me know if that works better for you.

I’m going to write it up now (will take me a little time, but likely this weekend), but I also had a Journal module which I outlined in the Drafts 5 Review on MacStories. You might find something useful there to get you started.

2 Likes

#4

I need something ridiculously easy to do or I won’t do it. It doesn’t get any easier than opening a new draft and just start typing. This is where DayOne fell apart for me. Too many clicks.

I also am happy to just capture at the end of the day instead of throughout the day. If I get to the point where I want to capture throughout the day, then I can always adjust but again, I need something that is super easy to do or I will fail.

I’m happy to learn a better way though. I will check out your journal module shortly.

Thanks,

Paul

0 Likes

#5

The short answer is yes, you can do this, and the bonus good news is that it’s relatively simple.

In short you should:

  • create the original draft (the first entry)
  • create a new action that prepends to that first entry (you’ll want the UUID of that draft)
  • have the content that the action adds be something like [[date]][[draft]]

This is a great first action for you to create if you’re just getting started. If you run into hiccups, we’re all happy to help you sort them out.

1 Like

#6

Thanks so much for this. I will definitely try this out.

@nahumck - Please don’t do anything else on this. I’m going to try this and see how it works for me. If I want more, I may just follow your Journal module writeup.

1 Like

#7

I’m happy to do nothing! :smirk::laughing::rofl:

1 Like

#8

Don’t kid yourself. I just freed you up to work on the next problem I’m sure to have!

1 Like

#9

Ok, I’ve been researching and I’m really baffled. Tried to find an existing action that does something like this but no luck.

I’m having an issue creating the new action. Specifically, I’m not sure what Step Type I use for this.

Can someone shed some light for me? I am all for learning but I’m just not grasping something basic, I think.

0 Likes

#10

did you try to look at this add to list plus action?
If I understood what you’re trying to do it might help, and it explains how to prepend instead of appending.
hope this helps :smile:

0 Likes

#11

Certainly.

I think you have two options to explore.

First, you can definitely do this with scripting. (And your script doesn’t need to be anywhere near as complex as the sample action above.)

Second, I haven’t tested it, but you might also be able to do this with a URL step by calling Drafts’ own URL scheme.

I may be able to provide more guidance at some point this weekend.

0 Likes

#12

Here’s a basic script that you could customize:

// prepend current draft to existing draft with date info


let d = Draft.find(''); // put the UUID of your draft inside the quotes 

let today = new Date();

d.content = today.toString() + '\n' + draft.content + '\n\n' + d.content;

d.update();
0 Likes

#13

And here’s how you’d do that with the URL scheme:

drafts5:///prepend?uuid=[REPLACE BRACKETED TEXT WITH UUID]&text=%5B%5Bdate%5D%5D%0A%5B%5Bdraft%5D%5D%0A%0A

The %0As are just new line characters. You can omit/adjust/add as you see fit. And you can format the date however you like using either the URL method or the scripting method.

0 Likes