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)
doc.txtStoryNoHTML = stripHtmlFromString( doc.StoryText(0) )
doc.txtRSSAbstract = createRSSAbstract( doc.txtStoryNoHTML(0) )
doc.txtDocID = doc.UniversalID
Dim dt As NotesDateTime
Dim dtNew As NotesDateTime
Dim dtCurrentTime As NotesDateTime
Dim strTimeOnly As String
Dim strDateOnly As String
Set dt = doc.GetFirstItem("StoryDate").DateTimeValue
strTimeOnly = dt.TimeOnly
If strTimeOnly = "" Then
strDateOnly = dt.DateOnly
Set dtCurrentTime = New NotesDateTime( "" )
Call dtCurrentTime.SetNow
strTimeOnly = dtCurrentTime.TimeOnly
Set dtNew = New NotesDateTime( strDateOnly & " " & strTimeOnly )
Call doc.ReplaceItemValue("StoryDate", dtNew)
End If
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")
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
strHTMLStart = Left(strHTML, posOpen - 1)
strHTMLEnd = Right(strHTML, (Len(strHTML) - posOpen))
strHTML = strHTMLStart + strHTMLEnd
Else
strHTMLStart = Left(strHTML, posClose -1)
strHTMLEnd = Right(strHTML, (Len(strHTML) - posClose))
strHTML = strHTMLStart + strHTMLEnd
End If
Else
If posOpen = 0 Then
strHTMLStart = Left(strHTML, posClose -1)
strHTMLEnd = Right(strHTML, (Len(strHTML) - posClose))
strHTML = strHTMLStart + strHTMLEnd
Else
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
intLenAbstract = 260
If Instr(strTemp," ") = 0 Then
createRSSAbstract = Trim$( strTemp & "..." )
Exit Function
End If
strTemp = Left$( strFullStory, intLenAbstract )
i = Len( strTemp )
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.