Created
July 1, 2019 16:00
-
-
Save evantravers/a0ff7e2950dfdf035c135587886d4fd2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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