Monday, November 08, 2010 at 12:05 AM.
system.verbs.builtins.radio.weblog.initPost
on initPost (adrpost) {
<<Changes
<<4/10/02; 11:58:29 PM by JES
<<If adrpost^.text doesn't exist, create it, instead of overwriting adrpost^ with a wp text object.
<<1/26/02; 8:00:20 PM by JES
<<Created. Initialize all of the sub-items of a weblog post table. Returns true.
<<At this time, required sub-items are as follows:
<<text -- a wpText containing the text for the post
<<when -- the date the post was created
<<flNotOnHomePage -- a boolean: true if the post is not on the home page -- defaults false
<<categories -- a table containing booleans for each category in which the post appears
if not defined (adrpost^) {
new (tableType, adrpost)};
if not defined (adrpost^.text) {
new (wpTextType, adrpost^.text)};
if not defined (adrpost^.when) {
local (ix = indexOf (adrpost^));
if ix < sizeOf (parentOf (adrpost^)^) { //whoops! -- it's not the last post in the table
<<We come up with a fudged date in this case. This code is from radio.macros.weblogRecentPosts, which was the wrong place for it.
if ix > 1 { //set to one second after the previous post
adrpost^.when = date (adrdata^.posts[ix - 1].when + 1)}
else { //set to one second before the next post
if sizeOf (adrdata^.posts) > 1 {
adrpost^.when = date (adrdata^.posts[ix + 1].when - 1)}
else {
adrpost^.when = clock.now ()}}}
else { //set to the create-date for the adrpost^.text wpText object
local (flDateSet = false);
if typeOf (adrpost^.text) == wpTextType {
local (d = timeCreated (adrpost^.text));
if ix > 1 {
local (adrposts = parentOf (adrpost^));
if d >= adrposts[ix-1].when {
adrpost^.when = d;
flDateSet = true}}};
if not flDateSet { //set it to now (adrpost^.text is not a wpText, or its createDate is too early)
adrpost^.when = clock.now ()}}};
if not defined (adrpost^.flNotOnHomePage) {
adrpost^.flNotOnHomePage = false};
if not defined (adrpost^.categories) {
new (tableType, @adrpost^.categories)};
return (true)}
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.