Anonymous
Domino 2.0 Rich Internet Applications with IBM Lotus Notes/Domino
You are here: Today » Document history and compare
« Document roll back
Document versioning »

Document history and compare

For the display of the stored versions of my WikiPages, I've made a view called 'versions':

LotusScript: show history

The routine to show the document history is part of my 'DwSession' class. Objects like 'view' and 'wikidoc' are private variables I have already. 'Content' is a stringbuffer to hold the page content. On previous versions, a link is added to compare this version with the current one:

    Sub addHistory
        On Error Goto catch
        Dim db2 As NotesDatabase
        Dim vc As NotesViewEntryCollection
        Dim entry As NotesViewEntry
        Dim v As Variant, i As Integer, sCompare As String
        Dim out As New stringbuffer(20)
        
        Set db2=s.GetDatabase("", OVERFLOW_DB)
        Set view=db2.GetView("versions")
        Set vc=view.GetAllEntriesByKey(wikidoc.UniversalID)
        
        content.add |<ul>|
        Set entry=vc.GetFirstEntry
        While Not entry Is Nothing
            v=entry.ColumnValues
            If i>0 Then
                sCompare=| - <a href="/domino/wiki/| & wikidoc.wikikey(0) & |?open&amp;view=history&amp;compare=| & entry.UniversalID & |">[compare]</a>|
            End If
            content.add |<li>version | & v(1) & | - | & v(2) & | - | & v(3) & sCompare & |</li>|
            Set entry=vc.GetNextEntry(entry)
            i=i+1
        Wend
        content.add |<ul>|
        
        Goto finally
catch:
        doError "Error " & Err & " in line " & Erl & ": " & Error$
        Resume finally
finally:
    End Sub

LotusScript: compare versions

To compare two versions, I simply show them side by side in a table. Again, this is a routine in my 'DwSession' class. A helper routine 'addRow' adds a table row with two cells:

    Sub addRow(Byval sVal As String, Byval sVal2 As String)
        content.add |<tr><td>| & sVal & |</td><td>| & sVal2 & |</td></tr>|
    End Sub
    
    Sub addCompare
        On Error Goto catch
        Dim db2 As NotesDatabase
        Dim doc2 As NotesDocument
        
        Set db2=s.GetDatabase("", OVERFLOW_DB)
        Set doc2=db2.GetDocumentByUNID(query.getValue("compare"))
        content.add |<a href="[%db%]wiki/| & wikidoc.wikikey(0) & |?open&amp;view=history">« History</a>|        
        content.add |<table class="compare">|
        addRow doc2.subject(0) & | (| & doc2.pubdatetext(0) & |)|, wikidoc.subject(0) & | (current)|
        addRow Join(doc2.description, NEWLINE),Join(wikidoc.description, NEWLINE)
        addRow Join(doc2.HtmlContent, NEWLINE),Join(wikidoc.HtmlContent, NEWLINE)
        content.add |<table>|
        Goto finally
catch:
        doError "Error " & Err & " in line " & Erl & ": " & Error$
        Resume finally
finally:        
    End Sub

Showing the appropriate information

In my WikiPage queryopen agent, I branch to show the different parts based on the parameters passed in the URL:

Select Case ds.getQuery("view")
Case "discussion"
    ds.addTitle doc.subject(0) & "- Discussion"
Case "history"
    If ds.getQuery("compare")="" Then
        ds.addTitle doc.subject(0) & "- History"
        ds.addHistory
    Else
        ds.addTitle doc.subject(0) & "- Compare"
        ds.addCompare
    End If
Case Else
'... rest of the code: page in read or edit mode etc.

What next?

You can see the code in action in my d-wiki sample. I've only done versioning here so far. I still have to copy the code to resolve the WikiLinks, enable the comments, etc. A vital part of the versioning is also still missing: doing a roll back. So much to do, so little time.

Star rating

100%

Comments

To add a comment, log in or register as new user. It's free and safe.