Skip to content

Instantly share code, notes, and snippets.

@am1t
Last active Nov 24, 2021
Embed
What would you like to do?
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

This comment has been minimized.

Copy link

@alexjj 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

This comment has been minimized.

Copy link
Owner Author

@am1t 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