Hi, I have what might be quite a niche use case that I’m hoping some smart person here can help me solve for. Here’s the tl;dr, and after that I’ll go into a few more specifics:
I want to be able to add the text of a draft to a Dropbox-hosted .txt file at a predetermined point
Phrased another way: I almost want to prepend to an existing file, but I need to leave in place the first four lines of that file.
OK, a bit of context. I use a blogging tool called Blot which operates by mirroring a Dropbox folder, and turning anything in that folder into a blog post or page. (It’s super neat, surprisingly versatile, and I enjoy using it a great deal.) In order to take advantage of some of Blot’s functions, I need to use the first few lines of an uploaded text file for metadata. For example, a typical blog post .txt file will start something like this:
Title: Title of Post Date: YYYY-mm-dd Permalink: permalink Tags: tag1, tag2
(Side note: Drafts is fantastic in combination with Blot. I’ve built simple actions that push drafts, posts, and pages to Dropbox (and hence to my site) all with no problem. I basically have a Workspace set up in Drafts that acts as a dedicated writing space for my blog, with one-touch publishing actions.)
Now I’m trying to work out a way of updating a page on my site, rather than adding one. Let’s say I have a file named Wire.txt and it begins like this:
Title: Wire Permalink: wire Menu: no 1 Jan 2020, 12:00 Hello World
I’m trying to build a Drafts action that will add the text of a draft before ‘1 Jan 2020, 12:00’, but which will leave the three lines of metadata at the top of the file. What I’m looking for essentially is a command that tells Drafts to go to line 5 of the .txt file and insert:
[[date|%d %b %Y, %H:%M:%S]] [[draft]]
It would be easy to append to the file, but I’m looking to keep a reverse-chronological log, so I need it to go at the top. If I choose prepend it pushes the metadata down, and the file stops working as intended at Blot’s end.
Any and all assistance greatly appreciated. If I’ve not made something clear by all means just ask.
For additional context:
I was hopeful this might be solvable with the
[[line|n]]content tag, but as far as I can see that’s referring to lines in the draft itself, not lines in the file you’re altering.
I looked at the
/replaceRangeparameter to see if I could figure out an x-callback-url implementation, but that requires a defined length for the insertion, and I’m looking for the freedom to add a draft of any given length.