Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Safe defaults
var path_fragment = "";
var filename = draft.processTemplate("[[safe_title]]");
var content = draft.content;
var diaryFormat = {};
if (/dbox:(.+)$/m.test(draft.content))
{
app.queueAction(Action.find("Save to Dropbox Path"), draft);
}
else
{
if (draft.hasTag("booknote"))
{
path_fragment = "booknotes"
}
else if (draft.hasTag("meeting"))
{
path_fragment = "diary";
filename =
draft
.title
.split("::")
.slice(-1)[0]
.trim()
}
else
{
path_fragment = "diary";
let d = draft.modifiedAt;
filename = d.strftime(d, "%Y-%m-%d-%H").toString();
}
var path = "/wiki/" + path_fragment + "/" + filename + ".md";
var db = Dropbox.create();
var check = db.write(path, content, "append");
if (!check) {
alert("Couldn't save to " + path);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment