Learn JavaScript with me

Illustration of output ? ( Not sure that I have a clear picture of what the generated text looks like )

# 2018-04-23 user-entered-text-here

Or

#### 2018-04-23 depending on entry

For bonus points you could replace all spaces in the entry with hyphens as in the 1st example

1 Like

That sounds achievable.

But maybe we need a baby step before that?

Anyone fancy creating a broken script that does something of similar complexity that we can debug?

I’d say break that one down into separate testable / achievable steps & build it up incrementally e.g.

  1. create a prompt that inputs text
  2. insert same into current draft
  3. add the prepended date
  4. add the selection menu to the prompt and the selected heading to the text
  5. convert the spaces to hyphens in the input text

Alternatively here is a version of the script for steps 1&2 above with three fatal bugs to fix:

(https://gist.github.com/derickfay/defb2046c01300c76b06533e7f500401)

How about I create some skeletons with instructions to complete? That might be useful for you.

Excellent idea, Rose.

Should we create a Google Doc or something for this?

1 Like

To make this more practical, what if we made these steps into a product?

I want to use Drafts to create journal entries for various things. I’ll be making a work journal, a personal journal, and probably one for health and fitness stuff.

Could we shape the project into a set of journal actions? Adding text like “journal title”, date, location (does drafts have access to your location?) and an action to post the journal entry as plain text/rich text to wherever you intend to keep it? I’m thinkng DEVONthink might be where I keep my journal.

1 Like

A git repo might be best, then we can see who has changed what and when, plus why.

A series of lessons with specific aims would be good, e.g. “Creating a journal entry and saving it” would be a mini course perhaps with a few lessons. Darn, I want the weekend already so I would have more time to work on it :slight_smile:

1 Like

Does that mean we all need to download that app everyone uses for GIT?

I think it’s called Working Copy.

You could. I’ll have a think about it and see if maybe I can figure out another solution (Working Copy isn’t cheap, and Git can be complicated. Overwhelming you is not the aim!)

Ready for the Next Task :stuck_out_tongue_winking_eye:

2 Likes

could you post source on gist (github)? then others can click through to see if they choose to

This is embarrassing but I have to ask for help with something very simple: how can I create a prompt action that simply opens a url in safari?

Buttons would be something like: Blog address, google sheet address etc

My goal is to create two prompt keys — one that visits certain webpages, like a google doc, so I can grab some text — and another that inserts certain urls into a draft (frequently used links etc)

Not embarrassing in the slightest. Everyone is ignorant of almost everything. We shouldn’t be afraid to ask for help.

Here is my solution.
I think I’ll work on an action group to automate these date options a little bit (and later we can include some of these actions into our own scripts with just a line of code)

btw. does drafts save variables which are created in one script and are therefore usable in a further action step or the script which calls the action?

here’s the approach i’ve found - saving a variable as a template tag for use later

I just wanted to make a Action group with some handy features like „getDateString“ and ill receive the Date sting without coping the Code into Otter scripts:)
I didnt Look up how to do this in a script but there is the „include action“ Step which can be used but i don’t really know If it will Save the variables so that they are useable in following Script action steps…?

So, I’ve been hard at work for the last few weeks, and after pinging Agile Tortoise to make sure this was ok I would like to offer a venue for these lessons: Automation Orchard. I’ve only posted two lessons so far, though there’s a place to request more. Anyone is welcome to post lessons, and I will hopefully be adding some more as soon as I can.

To be clear, Automation Orchard is my own site with its own forum, not affiliated with Agile Tortose :smile:

4 Likes