Last active
April 15, 2024 14:20
-
-
Save scripting/550f3f0ea0f808446d690560b7871856 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
function getBlogrollOptions (headLevelAtts) { | |
/* | |
4/15/24; 8:58:41 AM by DW | |
The author of the blog can enable a blogroll via three head-level attributes. | |
We're looking for these -- | |
blogrollUsername -- required | |
blogrollServer -- optional | |
blogrollCategory -- optional | |
Defaults | |
If blogrollServer is not specified, we use feedland.com | |
If blogrollCategory is not specified, we don't specify one in the URLs we generate | |
We translate those values to the ones the blogroll software needs -- | |
urlSocketServer | |
urlFeedlandViewBlogroll | |
urlBlogrollOpml | |
We return undefined if no blogroll is called for, otherwise it has the three values we transmit to the blogroll software. | |
*/ | |
const urlFeedlandCom = "https://feedland.com/"; | |
const wsUrlFeedlandCom = "wss://feedland.com:443/_ws/"; | |
var username = headLevelAtts.blogrollUsername; | |
var urlServer = headLevelAtts.blogrollServer; | |
var catname = headLevelAtts.blogrollCategory; | |
var urlSocketServer, urlFeedlandViewBlogroll; | |
if (username === undefined) { //username is required | |
return (undefined); | |
} | |
else { | |
username = trimWhitespace (username); | |
if (username.length == 0) { | |
return (undefined); | |
} | |
else { | |
if (urlServer === undefined) { | |
urlServer = urlFeedlandCom; | |
} | |
urlServer = trimWhitespace (urlServer); | |
if (!endsWith (urlServer, "/")) { | |
urlServer += "/"; | |
} | |
if (catname !== undefined) { | |
catname = trimWhitespace (catname); | |
if (catname.length == 0) { | |
catname = undefined; | |
} | |
} | |
//set urlSocketServer | |
if (urlServer == urlFeedlandCom) { | |
urlSocketServer = "wss://feedland.com:443/_ws/"; | |
} | |
else { | |
urlSocketServer = replaceAll (urlServer, "https://", "wss://"); | |
} | |
//set urlFeedlandViewBlogroll | |
urlFeedlandViewBlogroll = urlServer + "?username=" + urlEncode (username); | |
if (catname !== undefined) { | |
urlFeedlandViewBlogroll += "&catname=" + urlEncode (catname); | |
} | |
//set urlBlogrollOpml | |
urlBlogrollOpml = urlServer + "opml?screenname=" + urlEncode (username); | |
if (catname !== undefined) { | |
urlBlogrollOpml += "&catname=" + urlEncode (catname); | |
} | |
return ({urlSocketServer, urlFeedlandViewBlogroll, urlBlogrollOpml}); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment