Index: documentViewer.py
===================================================================
--- documentViewer.py	(revision 45)
+++ documentViewer.py	(revision 46)
@@ -1,2 +1,4 @@
+
+
 from OFS.Folder import Folder
 from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
@@ -17,4 +19,5 @@
 import urllib
 import zLOG
+import urlparse 
 
 def getInt(number, default=0):
@@ -26,4 +29,5 @@
 
 def getTextFromNode(nodename):
+    """get the cdata content of a node"""
     if nodename is None:
         return ""
@@ -56,5 +60,6 @@
 class documentViewer(Folder):
     """document viewer"""
-
+    textViewerUrl="http://127.0.0.1:8080/HFQP/testXSLT/getPage?"
+    
     meta_type="Document viewer"
     
@@ -75,9 +80,11 @@
 
     
-    def __init__(self,id,imageViewerUrl,title="",digilibBaseUrl=None,thumbcols=2,thumbrows=10,authgroups="mpiwg"):
+    def __init__(self,id,imageViewerUrl,textViewerUrl=None,title="",digilibBaseUrl=None,thumbcols=2,thumbrows=10,authgroups="mpiwg"):
         """init document viewer"""
         self.id=id
         self.title=title
         self.imageViewerUrl=imageViewerUrl
+        self.textViewerUrl=textViewerUrl
+        
         if not digilibBaseUrl:
             self.digilibBaseUrl = self.findDigilibUrl()
@@ -93,9 +100,11 @@
 
     security.declareProtected('View','index_html')
-    def index_html(self,mode,url,start=None,pn=1):
+    def index_html(self,mode,url,viewMode="images",start=None,pn=1):
         '''
         view it
         @param mode: defines which type of document is behind url
         @param url: url which contains display information
+        @param viewMode: if images display images, if text display text, default is images
+        
         '''
         
@@ -112,5 +121,5 @@
         pageinfo = self.getPageinfo(start=start,current=pn,docinfo=docinfo)
         pt = getattr(self.template, 'viewer_main')
-        return pt(docinfo=docinfo,pageinfo=pageinfo)
+        return pt(docinfo=docinfo,pageinfo=pageinfo,viewMode=viewMode)
   
   
@@ -206,5 +215,5 @@
             if not metaUrl.endswith("index.meta"):
                 metaUrl += "/index.meta"
-        
+        print metaUrl
         for cnt in range(num_retries):
             try:
@@ -234,5 +243,5 @@
         if dom is None:
             dom = self.getIndexMeta(getParentDir(path))
-            
+       
         acctype = dom.xpath("//access-conditions/access/@type")
         if acctype and (len(acctype)>0):
@@ -460,5 +469,10 @@
         """try to get the digilib URL from zogilib"""
         url = self.imageViewerUrl[:-1] + "/getScalerUrl"
+        print urlparse.urlparse(url)[0]
+        print urlparse.urljoin(self.absolute_url(),url)
         try:
+            if urlparse.urlparse(url)[0]=='': #relative path
+                url=urlparse.urljoin(self.absolute_url()+"/",url)
+                
             scaler = urlopen(url).read()
             return scaler.replace("/servlet/Scaler?", "")
@@ -466,8 +480,9 @@
             return None
     
-    def changeDocumentViewer(self,imageViewerUrl,title="",digilibBaseUrl=None,thumbrows=2,thumbcols=10,authgroups='mpiwg',RESPONSE=None):
+    def changeDocumentViewer(self,imageViewerUrl,textViewerUrl,title="",digilibBaseUrl=None,thumbrows=2,thumbcols=10,authgroups='mpiwg',RESPONSE=None):
         """init document viewer"""
         self.title=title
         self.imageViewerUrl=imageViewerUrl
+        self.textViewerUrl=textViewerUrl
         self.digilibBaseUrl = digilibBaseUrl
         self.thumbrows = thumbrows
@@ -487,7 +502,7 @@
     return pt()
   
-def manage_AddDocumentViewer(self,id,imageViewerUrl="",title="",RESPONSE=None):
+def manage_AddDocumentViewer(self,id,imageViewerUrl="",textViewerUrl="",title="",RESPONSE=None):
     """add the viewer"""
-    newObj=documentViewer(id,imageViewerUrl,title)
+    newObj=documentViewer(id,imageViewerUrl,title=title,textViewerUrl=textViewerUrl)
     self._setObject(id,newObj)
     
Index: zpt/image_main.zpt
===================================================================
--- zpt/image_main.zpt	(revision 30)
+++ zpt/image_main.zpt	(revision 46)
@@ -1,3 +1,4 @@
-<tal:block tal:define="docinfo options/docinfo; pageinfo options/pageinfo">
- <iframe height="100%" width="100%" tal:attributes="src string:${here/imageViewerUrl}fn=${docinfo/imagePath}&pn=${pageinfo/current}"/>
+<tal:block tal:define="docinfo options/docinfo; pageinfo options/pageinfo; mode python:options.get('viewMode','images')">
+ <iframe tal:condition="python:mode=='images'" height="100%" width="100%" tal:attributes="src string:${here/imageViewerUrl}fn=${docinfo/imagePath}&pn=${pageinfo/current}"/>
+ <iframe tal:condition="python:mode=='text'" height="100%" width="100%" tal:attributes="src string:${here/textViewerUrl}fn=${docinfo/textURL}&_pn=${pageinfo/current}"/>
 </tal:block>
