changeset 68:b8457fc33446

piclens rss/support
author dwinter
date Wed, 25 Jun 2008 12:47:58 +0200
parents 0fa278fb82b5
children 3b3c7cadd013
files documentViewer.py zpt/thumbs_main_rss.zpt
diffstat 2 files changed, 65 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/documentViewer.py	Wed Jan 16 19:13:26 2008 +0100
+++ b/documentViewer.py	Wed Jun 25 12:47:58 2008 +0200
@@ -83,6 +83,7 @@
     docuviewer_css = PageTemplateFile('css/docuviewer.css', globals())
     info_xml = PageTemplateFile('zpt/info_xml', globals())
 
+    thumbs_main_rss = PageTemplateFile('zpt/thumbs_main_rss', globals())
     security.declareProtected('View management screens','changeDocumentViewerForm')    
     changeDocumentViewerForm = PageTemplateFile('zpt/changeDocumentViewer', globals())
 
@@ -106,6 +107,37 @@
         self.manage_addFolder('template')
 
 
+    security.declareProtected('View','thumbs_rss')
+    def thumbs_rss(self,mode,url,viewMode="auto",start=None,pn=1):
+        '''
+        view it
+        @param mode: defines how to access the document behind url 
+        @param url: url which contains display information
+        @param viewMode: if images display images, if text display text, default is images (text,images or auto)
+        
+        '''
+        logging.info("HHHHHHHHHHHHHH:load the rss")
+        logger("documentViewer (index)", logging.INFO, "mode: %s url:%s start:%s pn:%s"%(mode,url,start,pn))
+        
+        if not hasattr(self, 'template'):
+            # create template folder if it doesn't exist
+            self.manage_addFolder('template')
+            
+        if not self.digilibBaseUrl:
+            self.digilibBaseUrl = self.findDigilibUrl() or "http://nausikaa.mpiwg-berlin.mpg.de/digitallibrary"
+            
+        docinfo = self.getDocinfo(mode=mode,url=url)
+        pageinfo = self.getPageinfo(start=start,current=pn,docinfo=docinfo)
+        pt = getattr(self.template, 'thumbs_main_rss')
+        
+        if viewMode=="auto": # automodus gewaehlt
+            if docinfo.get("textURL",'') and self.textViewerUrl: #texturl gesetzt und textViewer konfiguriert
+                viewMode="text"
+            else:
+                viewMode="images"
+               
+        return pt(docinfo=docinfo,pageinfo=pageinfo,viewMode=viewMode)
+  
     security.declareProtected('View','index_html')
     def index_html(self,mode,url,viewMode="auto",start=None,pn=1):
         '''
@@ -153,7 +185,21 @@
         url=self.REQUEST['URL1']+"?"+ps
         return url
 
-
+    def getLinkAmp(self,param=None,val=None):
+        """link to documentviewer with parameter param set to val"""
+        params=self.REQUEST.form.copy()
+        if param is not None:
+            if val is None:
+                if params.has_key(param):
+                    del params[param]
+            else:
+                params[param] = str(val)
+                
+        # quote values and assemble into query string
+        logging.info("XYXXXXX: %s"%repr(params.items()))
+        ps = "&".join(["%s=%s"%(k,urllib.quote(v)) for (k, v) in params.items()])
+        url=self.REQUEST['URL1']+"?"+ps
+        return url
     def getInfo_xml(self,url,mode):
         """returns info about the document as XML"""
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/zpt/thumbs_main_rss.zpt	Wed Jun 25 12:47:58 2008 +0200
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<rss version="2.0" 
+     xmlns:media="http://search.yahoo.com/mrss"
+     xmlns:tal="http://xml.zope.org/namespaces/tal">
+
+<channel tal:define="docinfo options/docinfo; pageinfo options/pageinfo; viewMode options/viewMode; start pageinfo/start; end pageinfo/end; rows pageinfo/rows; cols pageinfo/cols;  current pageinfo/current; grpsize pageinfo/groupsize; pages docinfo/numPages">
+ 
+    <item tal:repeat="idx python:range(1,pages)">
+      <title tal:content="string:$idx">title</title>
+      <link tal:content="structure python:here.getLinkAmp(param='pn',val=idx)">link</link>
+    
+      <media:thumbnail tal:attributes="url string:${docinfo/imageURL}&amp;pn=$idx&amp;dw=100&amp;dh=100"/>
+      <media:content tal:attributes="url string:${docinfo/imageURL}&amp;pn=$idx&amp;dw=500&amp;dh=500"/>
+
+  </item>
+
+</channel>
+</rss>
\ No newline at end of file