Skip to content

Instantly share code, notes, and snippets.

@evantravers
Created July 1, 2019 16:00
Show Gist options
  • Save evantravers/a0ff7e2950dfdf035c135587886d4fd2 to your computer and use it in GitHub Desktop.
Save evantravers/a0ff7e2950dfdf035c135587886d4fd2 to your computer and use it in GitHub Desktop.
// 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