Option Public Option Declare Use "BlogCalendar" Sub Initialize Dim s As NotesSession Dim doc As NotesDocument Dim db As NotesDatabase Dim blogConfig As NotesDocument Set s = New NotesSession Set db = s.CurrentDatabase Set doc = s.DocumentContext Set blogConfig = db.GetProfileDocument("BlogConfig") doc.FinalStoryText = doc.StoryText(0) doc.FinalReadMoretext = doc.StoryText_1(0) ' 13May2003 Joe Litton. Strip HTML from post doc.txtStoryNoHTML = stripHtmlFromString( doc.StoryText(0) ) doc.txtRSSAbstract = createRSSAbstract( doc.txtStoryNoHTML(0) ) doc.txtDocID = doc.UniversalID ' -- 29-Sep-2003 Joe Litton ' -- Fix problem with StoryDate field from web form Dim dt As NotesDateTime ' StoryDate from doc Dim dtNew As NotesDateTime ' New DateTime that we'll build Dim dtCurrentTime As NotesDateTime ' Current DateTime - we'll use the time value Dim strTimeOnly As String Dim strDateOnly As String Set dt = doc.GetFirstItem("StoryDate").DateTimeValue ' Get dateTime value of StoryDate field strTimeOnly = dt.TimeOnly ' Time portion of StoryDate field If strTimeOnly = "" Then ' No time portion for StoryDate, so we need to fix this field strDateOnly = dt.DateOnly ' Date portion of StoryDate field Set dtCurrentTime = New NotesDateTime( "" ) ' Get current date/time Call dtCurrentTime.SetNow strTimeOnly = dtCurrentTime.TimeOnly ' Time portion of current date/time ' Set StoryDate = date portion of StoryDate and TIME portion of current date/time Set dtNew = New NotesDateTime( strDateOnly & " " & strTimeOnly ) Call doc.ReplaceItemValue("StoryDate", dtNew) End If ' -- End 29-Sep-2003 Joe Litton. ' -- 28-Apr-2004 Joe Litton. Fix RSS date Dim dtLocal As NotesDateTime Dim dtGMT As NotesDateTime Set dtLocal = New NotesDateTime( doc.GetFirstItem("StoryDate").Text ) Set dtGMT = New NotesDateTime( Left$(dtLocal.GMTTime, 22) ) doc.rssStoryDate = Format$(dtGMT.LSLocalTime, "yyyy-mm-ddThh:nn:ssZ") ' -- End 28-Apr-2004 Joe Litton. Call doc.save(True,True) If blogConfig.conf_Basic_Weblogs(0) = "Always" Then Dim agent As NotesAgent Set agent = db.GetAgent("XmlRpcPing") agent.Run End If Call InitCalendar(doc.storydate(0)) Call doc.Save(True, True) End Sub Function stripHtmlFromString(strHTML As String) As String Dim posOpen As Integer Dim posClose As Integer Dim strHTMLStart As String Dim strHTMLEnd As String posOpen = Instr(strHTML, "<") posClose = Instr(strHTML, ">") Do While posOpen > 0 Or posClose > 0 If posOpen > posClose Then If posClose = 0 Then 'Strip out < orphan strHTMLStart = Left(strHTML, posOpen - 1) strHTMLEnd = Right(strHTML, (Len(strHTML) - posOpen)) strHTML = strHTMLStart + strHTMLEnd Else 'Strip out > orphan strHTMLStart = Left(strHTML, posClose -1) strHTMLEnd = Right(strHTML, (Len(strHTML) - posClose)) strHTML = strHTMLStart + strHTMLEnd End If Else If posOpen = 0 Then 'Strip out > orphan strHTMLStart = Left(strHTML, posClose -1) strHTMLEnd = Right(strHTML, (Len(strHTML) - posClose)) strHTML = strHTMLStart + strHTMLEnd Else 'Strip out HTML tag strHTMLStart = Left(strHTML, posOpen - 1) strHTMLEnd = Right(strHTML, (Len(strHTML) - posClose)) strHTML = strHTMLStart + strHTMLEnd End If End If posOpen = Instr(strHTML, "<") posClose = Instr(strHTML, ">") Loop stripHtmlFromString = strHTML End Function Function createRSSAbstract( strFullStory As String) As String Dim intLenAbstract As Integer Dim i As Integer Dim strTemp As String ' Edit this line to change the length of the abstract intLenAbstract = 260 'Check to see if there is a space character remaining in the string If Instr(strTemp," ") = 0 Then createRSSAbstract = Trim$( strTemp & "..." ) Exit Function End If strTemp = Left$( strFullStory, intLenAbstract ) i = Len( strTemp ) ' Cut off the final characters until we get to a space While Mid$( strTemp, i, 1) <> " " i = i-1 strTemp = Left$( strTemp, i ) Wend createRSSAbstract = Trim$( strTemp & "..." ) End Function
This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at nsftools.com.