Skip to content

Instantly share code, notes, and snippets.

@am1t
Last active November 24, 2021 16:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save am1t/c1a1d37af7cd33aedc9e1263888a70e0 to your computer and use it in GitHub Desktop.
Save am1t/c1a1d37af7cd33aedc9e1263888a70e0 to your computer and use it in GitHub Desktop.
Get the URL for the selected node in Drummer
var created = op.attributes.getOne("created");
var baseurl = opml.getHeaders().urlBlogWebsite;
if(typeof(baseurl) == "undefined"){
baseurl = "http://oldschool.scripting.com/" + opml.getHeaders().ownerTwitterScreenName + "/";
}
var dt = new Date(created)
var day = (dt.getUTCDate() < 10 ? '0' : '') + dt.getUTCDate();
var month = ((dt.getUTCMonth() +1) < 10 ? '0' : '') + (dt.getUTCMonth() + 1);
var year = dt.getUTCFullYear();
var hour = (dt.getUTCHours() < 10 ? '0' : '') + dt.getUTCHours();
var minutes = (dt.getUTCMinutes() < 10 ? '0' : '') + dt.getUTCMinutes()
var seconds = (dt.getUTCSeconds() < 10 ? '0' : '') + dt.getUTCSeconds()
var post = opml.parse(op.getCursorOpml());
var isTitledPost = typeof(post.opml.body.subs[0].subs) != "undefined";
var postUrl = "";
if(isTitledPost) {
postUrl = baseurl + year + "/" + month + "/" + day + "/" + hour + minutes + seconds + ".html";
postUrl = postUrl + "?title=" + op.getLineText();
} else {
postUrl = baseurl + year + "/" + month + "/" + day + ".html#a" + hour + minutes + seconds;
}
dialog.ask("This is the URL for the selected post:", postUrl);
@alexjj
Copy link

alexjj commented Nov 24, 2021

With the new verb added, an alternative to this script could be:

var postUrl = oldSchool.getCursorLink()
if(postUrl) {
  dialog.ask("Here's your URL", postUrl)
} else {
  dialog.alert("No URL is available for selected node")
}

@am1t
Copy link
Author

am1t commented Nov 24, 2021

Yeah, absolutely. I have changed the script I have.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment