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.
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.
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
remember their access token, and
make that API request manually.
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?
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.
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: