Diff'ing two Notes documents the hard way & an IBM Blog Tempate Bug?


This post is a little long sorry for that It's a bit dry - wait don't go yet.....
 
Read this paragraph and then decide. I found a little 'bug' in the IBM Template (unless I've missed something of course).  In trying to find the problem I started by comparing the contents of two documents and finally two HTML sources.  I didn't have access to expensive tools and what follows is how I compared the documents with some simple Lotuscript and TextPad, followed by a description of the bug and a fix.  The bug appears when you edit a block template in your IBM Blog and include some onload scripting and then use the web interface to add content.....

(peers out into the audience to see if anyone's still there.......)

OK if you're still reading I'm hoping you know of an easier way of finding the differences between two Notes documents without spending hundreds of pounds on Ytria or Teamstudio tools (good as they are) than this:

Background (feel free to skip if you just care about the diff):
I had a problem with the IBM blog template today  I'd customised one of the block templates so that it incorporates some code in an onload event (more of that later).  After I'd customised the block template and updated the webadmin page template the editor stopped working.  I had no idea why but I began troubleshooting by comparing a working template and my new broken one and then comparing the HTML rendered by the rendering engine.

Diffing two documents the hard way:
I copied the two documents I wanted to 'diff' into a blank database and wrote a little view action (borrowing some code from the nice help db) to export the documents as DXL:
Dim uiw As New NotesUiWorkspace
 Dim session As New NotesSession
 Dim dbThis As NotesDatabase
 Dim uiv As NotesUIView
 Dim ndc As NotesDocumentCollection
 Dim nd As NotesDocument
 
 REM Open xml file named after current database
 Dim stream As NotesStream
 
 REM Export current database as DXL
 Dim exporter As NotesDXLExporter
 Set exporter = session.CreateDXLExporter
 
 Set uiv = uiw.CurrentView
 Set ndc = uiv.Documents
 
 Set nd = ndc.GetFirstDocument
 While Not(nd Is Nothing)
  
  Set stream = session.CreateStream
  filename$ = "c:\dxl\" & Left(nd.UniversalID, 8) & ".dxl"
  If Not stream.Open(filename$) Then
   Messagebox "Cannot open " & filename$,, "Error"
   Exit Sub
  End If
  Call stream.Truncate
  
  Call exporter.SetInput(nd)
  Call exporter.SetOutput(stream)
  Call exporter.Process
  
  Set nd = ndc.GetNextDocument(nd)
 Wend
I called this code from a view action with the two documents selected.  The code exports the two documents into files on the file system.  I then opened both files in a text editor (I have a license for TextPad so I used that) and compared the two files which showed me the differences between the two.  I still couldn't see the problem. 

I agree that both Ytrias' ScanEZ and Teamstudios' Delta do a better job but both seem really expensive to me.  Do you have a better solution than mine for as little money?  I know the Ytria tool does loads more than simple diffing.

So as it happens Delta and ScanEZ wouldn't have helped me.  I had to compare the HTML that the template rendered and to do that I copied the source of a working page and my new broken page and saved them as text files and compared them using TextPad.  At that point I saw the problem read on.....

IBM Blog Template:
As promised more about the template.  As I mentioned I modified one of the block templates that is responsible for the body tag so that it incorporated some code in the onload event.  After the modification the "Add content" form stopped loading the editor.  After some debugging I found the problem:  when you use the <$DXEditor$> tag in a page template that tag triggers a modification of the body tag to incorporate an onload event.  The script that performs the modification assumes that you never want to add your own onload scripts and simply adds onload="webEditOnload();" to whatever you have so..

<body onload="myFunction();"> becomes <body onload="myFunction();" onload="webEditOnload()">

and when your page loads the first onload event is triggered and the second is ignored (and the editor isn't loaded).

So what was my fix?  I edited the DXWebAdmin script library and modified the renderWATemplate function so that the function checks for any existing onload string and if found effectively inserts webEditOnload(); to the existing onload event like this:

Old code:

        rText=R5replacesubstring(rText,bdy2,Left(bdy,x3-1)+ " onload=""webEditOnload();"">"+formhtml) 


New code:

    If (Instr(1,bdy2,"onload",5) >0) Then ' is there an existing onload event?
     rText=R5replacesubstring(rText,bdy2, R5replacesubstring(Left(bdy,x3-1), { onload="}, { onload="webEditOnload();}) + ">"+formhtml)      
    Else
     rText=R5replacesubstring(rText,bdy2,Left(bdy,x3-1)+ " onload=""webEditOnload();"">"+formhtml) 
    End If


Sorry for the rather long post if you made it this far I hope it was worth it (I tried not to ramble too much).......

 
Trackbacks
  • Trackbacks are closed for this entry.
Comments

Leave a comment

Comments are closed.