Scriptable App Widgets Pulling Text from Drafts

Would anyone be interested in an idea? I’m super impressed with Scriptable widgets for displaying simple text. I’d love the ability to display text from Drafts in a Scriptable widget. From there, users could make small script adjustments to use last line, first line, etc from the Draft. I’m guessing this would be extremely useful for a lot of users.
Relevant information here:



I’ve been trying to build this for a few days using my very js knowledge and can’t quite make it happen. If someone smarter than I wants to build it that would be fabulous or I’ll keep hacking away and see what I can manage.
2 Likes

:raised_hand: Yep. Interested. A while back I’d asked here whether it was possible to display the text of a draft in a widget. At the time, I was trying to build something that would allow me to display my current task in a widget, something to approximate a version of Brett Terpstra’s GeekTool view of “Doing” for iOS. Doubt whether I’ve got the JS-chops for this right now— my last experiment with Scriptable ended horribly and with the revelation that my current JS credentials are very Drafts specific— but I’ll noodle and report back if I achieve anything worth reporting. In the meantime: good luck!

1 Like

Thanks for your interest here. I’ve gone as far as I’m going to get, I’m afraid. I got a Drafts URL to open Scriptable and display text. I can’t figure out how to get that data into a widget and I think I have to be done. Learning curve wins this time—I can’t really see why way through it. Here’s as far as I could go with it.

Running a URL:
drafts://x-callback-url/get?uuid=[your UUID]&x-success=scriptable:///run?scriptName=U

const successURL = args.queryParameters["x-success"];
console.log(successURL)

let alert = new Alert()
alert.message = “Draft content”
alert.title = args.queryParameters.text;
alert.addAction("OK")
await alert.presentAlert()

Update. So I got to where I wanted using Shortcuts and the new (still in beta), Widget Pack app. I’m excited! This shortcut just grabs the latest text block from the Draft in question and pops it into the widget. Of course all manner of variations / automations can also ensue.

Nice work! I’m thinking the shortcut could be tweaked to get the most recent draft matching a query string or tag (e.g. @inprogress). The widget could be supplied with the url for the draft so tapping on the widget takes you to the draft…

This almost makes up for the loss of live filtering in shortcut menus! (Almost…)

1 Like

Yeah, I’m thinking more of a random draft too–could be a good way to get random inspiration quotes or something to appear. (although I’d still like to see this as a native Drafts widget that we could script @agiletortoise, maybe after you’ve had a break and the syntax stuff is done!)

I’m always going to be in favor of increased functionality in Drafts. It’s already pretty much the hub of my life, so…
However, I honestly think this kind of function is already better served by other software. For what you described with random inspirational quotes, I think you want Scriptable. You could probably adapt one of the examples here by just inserting a different API source.
If you wanted to draw random quotes from a list you yourself compiled, you could just adjust my script to split by line and then choose a random item from that list. That would do it.

My daily dashboard in Drafts pulls a random quote (line/paragraph) from a collection of different source drafts— The Enchiridion (Epictetus), Goethe’s Maxims, and other random quotes from things I’ve read. Sets the tone for the day. I’ve grown to appreciate that greatly. :slight_smile:

2 Likes

Keen to get my head around Scriptable. Also looking at JSBox. I have yet to experiment with its widget capabilities, but it looks like a very accessible complement or possibly even alternative to Scriptable. I’d seen it before but it was listed as something that helps you “learn to code”, and I didn’t think it was as powerful/functional as it seems to be…

https://xteko.com/demos/en

Talk to me about this daily dashboard. What’ve you got going on there?

Every morning I run a shortcut (as part of a morning routine) that creates a new draft titled “[date:yyyyMMdd]-dashboard”.

It consists of:

  • a daily quote/aphorism (as described above)
  • a header and placeholder for a list of the day’s actionable items
  • events from today’s calendars; format: - [[[yyyyMMdd-HHmmss] - event title]]; makes it easy to create a new, appropriately titled note for any event during the day.
  • projects to focus on today (currently drawn from a Trello board, titles in double brackets for links to drafts)
  • today’s reminders (drawn from a GoodTask/Reminders list with links back to specific items in GoodTask)
  • any drafts with today’s date referenced e.g. @due(date) or @follow-up(date) tags.
  • a list of reading items: a wiki-linked reference to one knowledge item stored in drafts; a link to a random “read later” item stored in Reeder; a wiki-link for each of the current books/documents I’m reading, managed through a Trello board.

Been running this for the past few months now, and I’m still tweaking/refining, but it’s been working well for me. Since I spend a lot of time in Drafts, it’s proven really useful to have a daily jumping off point there for everything else. It means I don’t have to go looking at things in a number of other apps to maintain an overview.

Recent update was a shortcut that updates the block for today’s events, so that if I add an event during the day, it’s easy to reflect those changes in the dashboard

4 Likes