Monday, November 08, 2010 at 12:05 AM.
system.verbs.builtins.radio.weblog.getUrlForPost
on getUrlForPost (adrpost, adrurl, catname="", adrdata=radio.weblog.init ()) { <<Changes <<10/2/02; 2:16:06 PM by JES <<Pass in true for flCreateFolders when calling radio.weblog.file.getArchiveFilePath, to ensure that folders on the path to the post exist. This should fix the "#prefs.txt not found" bug when creating the first titled post of the month. <<3/12/02; 3:31:07 PM by JES <<Added the ability to get the URL for posts whose archive pages have not yet been published. Removed an unused local variable. <<3/12/02; 2:02:16 PM by JES <<Created. Gets the url of the permanent link for a given weblog post. Returns true if the post's url was able to be determined, or false if not. radio.weblog.initPost (adrpost); local (folder); if catname == "" { //get the weblog archive relative folder path if adrpost^.flNotOnHomePage { //post is not in weblog archive return (false)}; local (homeRelPath = adrdata^.prefs.homePageFilePath); local (homeFileName = string.nthField (homeRelPath, "/", string.countFields (homeRelPath, "/"))); local (relFolder = string.mid (homeRelPath, 1, sizeOf (homeRelPath) - sizeOf (homeFileName))); folder = radio.file.getAbsolutePath (relFolder)} else { //get the category archive relative folder path if not radio.weblog.isPostInCategory (adrpost, catname) { //post is not in category return (false)}; local (adrcat = @adrdata^.categories.[catname]); if not defined (adrcat^) { //category doesn't exist return (false)}; if not adrcat^.flRenderHtml { //category not rendered -- post has no url return (false)}; folder = radio.weblog.file.getCategoryFolder (catname, adrdata)}; local (f = radio.weblog.file.getArchiveFilePath (folder, adrpost^.when, true) ); local (pageurl = ""); local (adrfile = @user.radio.settings.files.[f]); if defined (adrfile^) { if adrfile^.upstream.url != "" { pageurl = adrfile^.upstream.url}}; if pageurl == "" { //get upstreamed file extension local (extension = ".html"); local (atts, directives); new (tableType, @directives); radio.webserver.gatherAttributes (f, @atts, @directives); if defined (directives.renderedFileExtension) { extension = directives.renderedFileExtension}; if not (extension beginsWith ".") { //ensure leading '.' extension = "." + extension}; f = string.popSuffix (f) + extension; pageurl = radio.upstream.getFileUrl (f); if defined (adrfile^) { //cache the url adrfile^.upstream.url = pageurl}}; adrurl^ = pageurl + "#a" + number (nameOf (adrpost^)); return (true)}; <<bundle //debugging <<getUrlForPost (@weblogData.posts[sizeOf (weblogData.posts)], @url)
This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.