I'm a longtime user of agiletortoise's Drafts on iOS and macOS but have remained less than a novice in Javascript, which powers its configurables, "Actions." I've been gradually working toward direct integration between Drafts and Write.as - you might call my workflow involving the CLI a midstep. After much fiddling, I'm pleased to report that I've finally accomplished this integration via the Writeas API.
Here's a brief video demo on YouTube showing the actions in use
On the Drafts Directory:
At first run of either action, a credential identifier called "writeas" is created, which will prompt you for "Collection" and "Access Token."
"Collection" is just the backend term for blog (correct me if I'm wrong there,) so you should enter the lowercase slug of your blog. (Ex: bilge
for write.as/bilge
.) "Access Token" is referring to a WriteFreely/Writeas/Snapas API token. (See: the docs.)
Post to Writeas will publish the current draft contents as an anonymous/"unclaimed" post. These are accessed in the "Posts" menu at /me/posts/
. The URL of the result is then inserted at the cursor (in Drafts) as a markdown-formatted hyperlink.
Post to Writeas Blog will publish the current draft contents as a new post on the blog you specified at credential creation. The URL of the result is then inserted at the cursor (in Drafts) as a markdown-formatted hyperlink.
Example:
I intend to continue exploring the possibilities of this integration and perhaps eventually publish a dedicated "Action Group." I'd especially love to hear from any Drafts users also using Writeas/WriteFreely.
DavidBlue | 2022-05-03 08:54:40 UTC | #1
I'm a longtime user of agiletortoise's Drafts on iOS and macOS but have remained less than a novice in Javascript, which powers its configurables, "Actions." I've been gradually working toward direct integration between Drafts and Write.as - you might call my workflow involving the CLI a midstep. After much fiddling, I'm pleased to report that I've finally accomplished this integration via the Writeas API.
Here's a brief video demo on YouTube showing the actions in use
On the Drafts Directory:
At first run of either action, a credential identifier called "writeas" is created, which will prompt you for "Collection" and "Access Token."
"Collection" is just the backend term for blog (correct me if I'm wrong there,) so you should enter the lowercase slug of your blog. (Ex: bilge
for write.as/bilge
.) "Access Token" is referring to a WriteFreely/Writeas/Snapas API token. (See: the docs.)
Post to Writeas will publish the current draft contents as an anonymous/"unclaimed" post. These are accessed in the "Posts" menu at /me/posts/
. The URL of the result is then inserted at the cursor (in Drafts) as a markdown-formatted hyperlink.
Post to Writeas Blog will publish the current draft contents as a new post on the blog you specified at credential creation. The URL of the result is then inserted at the cursor (in Drafts) as a markdown-formatted hyperlink.
Example:
I intend to continue exploring the possibilities of this integration and perhaps eventually publish a dedicated "Action Group." I'd especially love to hear from any Drafts users also using Writeas/WriteFreely.
angelo | 2022-05-10 12:06:18 UTC | #2
That's awesome, @DavidBlue! Drafts is a great writing environment, and I love the integration work that Greg at Agile Tortoise has put into the app. It really is a fantastic central point for get thoughts out of your head, and out to whatever home they need to get to.
One interesting thing is that while you can have Drafts "forget" the credentials for the service, all that does is delete the credentials from your device. In your case, since you're using an access token, you'd normally want to send a DELETE
request to the Write.as API to invalidate the token, so that it can't be reused — but the Drafts Actions scripting reference doesn't seem to provide a way to do that.
That means that if someone wants to delete this access token, it's up to them to
It's a bit fiddly, but if you're already fetching that token yourself, you're probably savvy enough to delete it yourself.
One question for you, though: both the Post to Writeas and Post to Writeas Blog actions take a collection
— it seems to me that would only be necessary for the Post to Writeas Blog action. Is there a reason you're requesting it for both?
DavidBlue | 2022-05-10 15:12:12 UTC | #3
Only to simply things for someone intending to use both or the latter, basically, by unifying them under a single credential identifier. Maybe I should include a note in the setup step about this? It’s either that or I could set it up so the collection has to be manually identified every time in the latter, which I don’t think would be too much to do every run.
angelo | 2022-05-12 12:19:18 UTC | #4
Gotcha, that makes sense!
ChloeDontCode | 2022-05-26 18:31:34 UTC | #5
Awesome @DavidBlue. I’d love to use Drafts. May I ask how you get the Write.as API key? I’ve searched all over and can’t find out how to get my key.
DavidBlue | 2022-06-09 21:43:58 UTC | #6
oh my goodness I am just seeing this now!!! for some reason. so sorry about that.
first, here's the "Authenticate a User heading" in the API documentation for a reference on how to do it manually.
hopefully though, if you're on Apple platforms, my Siri Shortcut specifically for this function will prove the straightest-forward method of retrieving your key.
DavidBlue | 2022-06-22 21:17:35 UTC | #7
I don't know why it didn't occur to me sooner, but I just put up a quick shortcut for actually retrieving any public write.as post's body text via the API: Get Write.as Post Text
By default, it just copies the text to the system clipboard, but - as I noted on the RoutineHub page - you could append an action from any application(s) that saves text. Here's my personalized example for Drafts:
This one does not require authorization, FYI.