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

5 Likes

@jsamlarose thanks for sharing your morning routine. We have a lot of similarities … but you’ve incorporated a few elements I’d like to add.

If your willing - would you share the action(s) for the following elements:

of:

  • a daily quote/aphorism (as described above) the action that pulls these into the draft
  • 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. I do this manually now in the same format for the same reasons - action available?
  • projects to focus on today (currently drawn from a Trello board, titles in double brackets for links to drafts) *wondering if I could do this from todoist?
  • 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. spaced repetition- would love to do something similar

Many thanks in advance for sharing.

You’re welcome! Glad it resonates.

I’ve simplified my morning routine workflow quite a bit since I posted this. What I was doing before was essentially creating a one-stop overview of all of today’s tasks and notes (the dashboard). My morning routine in Drafts is now more focused on capturing first thoughts and reviewing yesterday’s actions/achievements/thoughts.

I no longer use Trello; GoodTask is my one true tool for managing actionable items, particularly since it now has a Kanban view. I’ve been experimenting with timeline views of Reminders projects in Drafts via vis.js, and that’s been working well. Trello’s great, but working between Drafts and GoodTask feels cleaner and less complicated.

Another thing to note is that I was doing more via Shortcuts when I wrote the post. While I still appreciate Shortcuts, Drafts actions and scripts are much more robust.

All of this is just a long-winded way of saying I have no idea whether I archived that old workflow or over-wrote it! I’ll take a look back through the actions/shortcuts I was using, and see if I can retrieve enough to share.

1 Like

Okay. The system works. Kinda.

Here’s the main dashboard shortcut.

It has a few dependencies, including the quotes and aphorisms shortcut.

That should cover most of what you’ve asked for, or at least point you in the right direction. Please forgive the rough edges— I picked a back-up from around that time, but I’m not sure if these were the most up-to-date versions of the shortcuts at the time I stopped using them. Holler if any probs.

Todoist: haven’t worked with it, but if it provides appropriate data via Shortcuts, no reason why it shouldn’t be possible to wire in.

1 Like

Thanks for the generous reply.

Fascinating how workflows are in constant evolution.

Looking forward to reviewing these to evolve my own.

With appreciation!

1 Like