Learn JavaScript with me


#21

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


#22
# 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


#23

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?


#24

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

#25

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)


#26

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


#27

Excellent idea, Rose.

Should we create a Google Doc or something for this?


#28

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.


#29

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:


#30

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


#31

I think it’s called Working Copy.


#32

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!)


#33

Ready for the Next Task :stuck_out_tongue_winking_eye:


#34

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


#35

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)


#36

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


#37

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?


#38

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


#39

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…?


#40

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: