[Checkins] SVN: zope3org/trunk/src/zorg/wikification/ Added a hook for wikilink preprocessing. Fixed encoding some encoding and css issues.

Uwe Oestermeier uwe_oestermeier at iwm-kmrc.de
Fri Apr 28 15:06:58 EDT 2006


Log message for revision 67733:
  Added a hook for wikilink preprocessing. Fixed encoding some encoding and css issues.

Changed:
  U   zope3org/trunk/src/zorg/wikification/browser/README.txt
  U   zope3org/trunk/src/zorg/wikification/browser/style/main.css
  U   zope3org/trunk/src/zorg/wikification/browser/templates/wiki_folder.pt
  U   zope3org/trunk/src/zorg/wikification/browser/templates/wiki_newpage.pt
  U   zope3org/trunk/src/zorg/wikification/browser/templates/wiki_outdated.pt
  U   zope3org/trunk/src/zorg/wikification/browser/templates/wiki_rename.pt
  U   zope3org/trunk/src/zorg/wikification/browser/templates/wiki_upload.pt
  U   zope3org/trunk/src/zorg/wikification/browser/wikilink.py
  U   zope3org/trunk/src/zorg/wikification/browser/wikipage.py
  U   zope3org/trunk/src/zorg/wikification/parser.py

-=-
Modified: zope3org/trunk/src/zorg/wikification/browser/README.txt
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/README.txt	2006-04-28 19:05:43 UTC (rev 67732)
+++ zope3org/trunk/src/zorg/wikification/browser/README.txt	2006-04-28 19:06:57 UTC (rev 67733)
@@ -142,10 +142,10 @@
 
     >>> modified = index_page.getModificationStamp()
     >>> print index_page.wikiCommandForm('rename', 5, modified)
-    <div class="inline_form" id="create_folder5">
+    <div class="wiki-form" id="create_folder5">
         <form method="post" enctype="multipart/form-data" action="renameLink" onsubmit="WikiMenu.submitForm(this); return false;" onreset="WikiMenu.hideForm()">
     <BLANKLINE>
-            <div class="inline-title">Rename Link &quot;New Subject&quot;</div>
+            <div class="wiki-form-title">Rename Link &quot;New Subject&quot;</div>
             <input name="link_id" type="hidden"
                    value="wiki-link5" />
             <input name="cmd" type="hidden" value="rename" />
@@ -153,11 +153,12 @@
                    value="http://127.0.0.1/site/index.html" />
             <table>
                 <tr>
-                    <td valign="top" class="form-title">
+                    <td valign="top" class="wiki-field">
                         New Label:
                     </td>
                     <td valign="top">
-                        <input id="link_label" name="label"
+                        <input class="wiki-input"
+                               id="link_label" name="label"
                                type="text" size="40"
                                value="New Subject" />
                     </td>
@@ -181,7 +182,7 @@
 
     >>> print index_page.wikiCommandForm('rename', 5, "modified-timestamp")
     <div>
-        <form class="inline_form" onsubmit="window.reload(); return false;">
+        <form class="wiki-form" onsubmit="window.reload(); return false;">
             <span class="anylinkheader">The page has been edited. Please reloaad.
             </span>
             <input name="url" type="hidden"

Modified: zope3org/trunk/src/zorg/wikification/browser/style/main.css
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/style/main.css	2006-04-28 19:05:43 UTC (rev 67732)
+++ zope3org/trunk/src/zorg/wikification/browser/style/main.css	2006-04-28 19:06:57 UTC (rev 67733)
@@ -22,7 +22,7 @@
 	cursor: pointer;
 }
 
-.inline_form {
+.wiki-form {
     border: 1px solid #666666;
     padding: 4px;
     font:normal 10px Verdana;
@@ -31,6 +31,19 @@
     width: 400px;
 }
 
+.wiki-field
+{
+	font: normal 10px Verdana;
+	white-space: nowrap;
+}
+
+.wiki-input
+{
+	width: 300px;
+}
+
+
+
 #wiki_link_form {
     position:absolute;
     z-index: 100;

Modified: zope3org/trunk/src/zorg/wikification/browser/templates/wiki_folder.pt
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/templates/wiki_folder.pt	2006-04-28 19:05:43 UTC (rev 67732)
+++ zope3org/trunk/src/zorg/wikification/browser/templates/wiki_folder.pt	2006-04-28 19:06:57 UTC (rev 67733)
@@ -1,10 +1,10 @@
-<div class="inline_form" tal:attributes="id string:create_folder${view/index}">
+<div class="wiki-form" tal:attributes="id string:create_folder${view/index}">
     <form method="post"
            enctype="multipart/form-data"
            onsubmit="WikiMenu.submitForm(this); return false;"
            onreset="WikiMenu.hideForm()" >
   
-        <div class="inline-title">Create Folder for Link &quot;<span tal:replace="view/unicodeLabel">Name</span>&quot;</div>
+        <div class="wiki-form-title">Create Folder for Link &quot;<span tal:replace="view/unicodeLabel">Name</span>&quot;</div>
         <input name="link_id" type="hidden" tal:attributes="value string:${view/link_id}" />
         <input name="cmd" type="hidden" value="folder" />
         <input name="reference" type="hidden" value="001" 
@@ -13,35 +13,35 @@
 
         <table>
             <tr>
-                <td valign="top" class="form-title">
-                    Folder Name:
+                <td valign="top" class="wiki-field">
+                    Foldername:
                 </td>
-                <td valign="top" >
-                    <input id="folder_name" name="name" type="text" size="40" value="FolderName" tal:attributes="value python: view.upload_name or view.unicodeLabel()" />
+                <td valign="top">
+                    <input class="wiki-input" id="folder_name" name="name" type="text" size="38" value="FolderName" tal:attributes="value python: view.upload_name or view.unicodeLabel()" />
                 </td>
             </tr>
             <tr>
-                <td valign="top" class="form-title">
+                <td valign="top" class="wiki-field">
                     Title:
                 </td>
-                <td valign="top" >
-                    <input id="file_title" name="title" type="text" size="40" value=""/>
+                <td valign="top">
+                    <input class="wiki-input" id="file_title" name="title" type="text" size="38" value=""/>
                 </td>
             </tr>
             <tr>
-                <td valign="top" class="form-title">
+                <td valign="top" class="wiki-field">
                     Description: 
                 </td>
-                <td valign="top" >
-                    <textarea id="description" name="description"
+                <td valign="top">
+                    <textarea class="wiki-input" id="description" name="description"
                                    cols="37" rows="8" value="123"></textarea>
                 </td>
             </tr>
             <tr tal:condition="not: view/isUnique"> 
-                <td valign="top" class="form-title">
+                <td valign="top" class="wiki-field">
                     Scope: 
                 </td>
-                <td valign="top" class="form-title">
+                <td valign="top" class="wiki-field">
                     <input name="scope" id="scope" type="checkbox">
                     Apply to all links named &quot;<span tal:replace="view/unicodeLabel">Name</span>&quot;.
                 </td>   

Modified: zope3org/trunk/src/zorg/wikification/browser/templates/wiki_newpage.pt
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/templates/wiki_newpage.pt	2006-04-28 19:05:43 UTC (rev 67732)
+++ zope3org/trunk/src/zorg/wikification/browser/templates/wiki_newpage.pt	2006-04-28 19:06:57 UTC (rev 67733)
@@ -1,9 +1,9 @@
-<div class="inline_form" tal:attributes="id string:add_page_form${view/index}">
+<div class="wiki-form" tal:attributes="id string:add_page_form${view/index}">
     <form method="post"
            enctype="multipart/form-data"
            onsubmit="WikiMenu.submitForm(this); return false;"
            onreset="WikiMenu.hideForm();">
-        <div class="inline-title">Add Page for Link &quot;<span tal:replace="view/unicodeLabel">Name</span>&quot;</div>
+        <div class="wiki-form-title">Add Page for Link &quot;<span tal:replace="view/unicodeLabel">Name</span>&quot;</div>
         <input name="link_id" type="hidden" tal:attributes="value string:${view/link_id}" />
         <input name="cmd" type="hidden" value="newpage" />
         <input name="reference" type="hidden" value="001" 
@@ -11,36 +11,36 @@
                 value string:${view/processor/reference}" />
         <table>
             <tr>
-                <td valign="top" class="form-title">
+                <td valign="top" class="wiki-field">
                     Filename:
                 </td>
-                <td valign="top" >
-                    <input id="page_name" name="name" type="text" size="40" value="FileName"  tal:attributes="value python: view.unicodeLabel() + u'.html'" />
+                <td valign="top">
+                    <input class="wiki-input" id="page_name" name="name" type="text" size="40" value="FileName"  tal:attributes="value python: view.unicodeLabel() + u'.html'" />
                 </td>
             </tr>
             <tr>
-                <td valign="top" class="form-title">
+                <td valign="top" class="wiki-field">
                     Title:
                 </td>
-                <td valign="top" >
-                    <input id="page_title" name="title" type="text" size="40" value=""/>
+                <td valign="top">
+                    <input class="wiki-input" id="page_title" name="title" type="text" size="40" value=""/>
                 </td>
             </tr>
             <tr>
-                <td valign="top" class="form-title">
+                <td valign="top" class="wiki-field">
                     Abstract: 
                 </td>
-                <td valign="top" >
-                    <textarea id="description" name="description"
+                <td valign="top">
+                    <textarea class="wiki-input" id="description" name="description"
                                    cols="37" rows="8" value="123"></textarea>
                 </td>
             </tr>
 
             <tr tal:condition="not: view/isUnique"> 
-                <td valign="top" class="form-title">
+                <td valign="top" class="wiki-field">
                     Scope: 
                 </td>
-                <td valign="top" class="form-title">
+                <td valign="top" class="wiki-field">
                     <input name="scope" id="scope" type="checkbox">
                     Apply to all links named &quot;<span tal:replace="view/unicodeLabel">Name</span>&quot;.
                 </td>   

Modified: zope3org/trunk/src/zorg/wikification/browser/templates/wiki_outdated.pt
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/templates/wiki_outdated.pt	2006-04-28 19:05:43 UTC (rev 67732)
+++ zope3org/trunk/src/zorg/wikification/browser/templates/wiki_outdated.pt	2006-04-28 19:06:57 UTC (rev 67733)
@@ -1,5 +1,5 @@
 <div>
-    <form class="inline_form" onsubmit="window.reload(); return false;">
+    <form class="wiki-form" onsubmit="window.reload(); return false;">
         <span class="anylinkheader">The page has been edited. Please reloaad.
         </span>
         <input name="reference" type="hidden" value="001" 

Modified: zope3org/trunk/src/zorg/wikification/browser/templates/wiki_rename.pt
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/templates/wiki_rename.pt	2006-04-28 19:05:43 UTC (rev 67732)
+++ zope3org/trunk/src/zorg/wikification/browser/templates/wiki_rename.pt	2006-04-28 19:06:57 UTC (rev 67733)
@@ -1,9 +1,9 @@
-<div class="inline_form" tal:attributes="id string:create_folder${view/index}">
+<div class="wiki-form" tal:attributes="id string:create_folder${view/index}">
     <form method="post" enctype="multipart/form-data" action="renameLink"
         onsubmit="WikiMenu.submitForm(this); return false;"
         onreset="WikiMenu.hideForm()" >
         
-        <div class="inline-title">Rename Link &quot;<span tal:replace="view/unicodeLabel">Name</span>&quot;</div>
+        <div class="wiki-form-title">Rename Link &quot;<span tal:replace="view/unicodeLabel">Name</span>&quot;</div>
         <input name="link_id" type="hidden" tal:attributes="value string:${view/link_id}" />
         <input name="cmd" type="hidden" value="rename" />
         <input name="reference" type="hidden" value="001" 
@@ -11,18 +11,18 @@
                 value string:${view/processor/reference}" />
         <table>
             <tr>
-                <td valign="top" class="form-title">
+                <td valign="top" class="wiki-field">
                     New Label:
                 </td>
-                <td valign="top" >
-                    <input id="link_label" name="label" type="text" size="40" value="Label" tal:attributes="value python: view.unicodeLabel()" />
+                <td valign="top">
+                    <input class="wiki-input" id="link_label" name="label" type="text" size="40" value="Label" tal:attributes="value python: view.unicodeLabel()" />
                 </td>
             </tr>
             <tr tal:condition="not: view/isUnique"> 
-                <td valign="top" class="form-title">
+                <td valign="top" class="wiki-field">
                     Scope: 
                 </td>
-                <td valign="top" class="form-title">
+                <td valign="top" class="wiki-field">
                     <input name="scope" id="scope" type="checkbox">
                     Apply to all links named &quot;<span tal:replace="view/unicodeLabel">Name</span>&quot;.
                 </td>   

Modified: zope3org/trunk/src/zorg/wikification/browser/templates/wiki_upload.pt
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/templates/wiki_upload.pt	2006-04-28 19:05:43 UTC (rev 67732)
+++ zope3org/trunk/src/zorg/wikification/browser/templates/wiki_upload.pt	2006-04-28 19:06:57 UTC (rev 67733)
@@ -1,9 +1,9 @@
-<div class="inline_form" tal:attributes="id string:upload_form${view/index}">
+<div class="wiki-form" tal:attributes="id string:upload_form${view/index}">
     <form method="post"
            enctype="multipart/form-data"
            action="uploadFile"
            onreset="WikiMenu.hideForm();">
-        <div class="inline-title">Upload File for Link &quot;<span tal:replace="view/unicodeLabel">Name</span>&quot;</div>
+        <div class="wiki-form-title">Upload File for Link &quot;<span tal:replace="view/unicodeLabel">Name</span>&quot;</div>
         <input name="link_id" type="hidden" tal:attributes="value string:${view/link_id}" />
         <input name="cmd" type="hidden" value="upload" />
         <input name="reference" type="hidden" value="001" 
@@ -11,32 +11,32 @@
                 value string:${view/processor/reference}" />
         <table>
             <tr>
-                <td valign="top" class="form-title">
+                <td valign="top" class="wiki-field">
                     File Name:
                 </td>
-                <td valign="top" >
-                    <input id="folder_name" name="name" type="text" size="40" value="FileName" tal:attributes="value string:${view/upload_name}" />
+                <td valign="top">
+                    <input class="wiki-input" id="folder_name" name="name" type="text" size="40" value="FileName" tal:attributes="value string:${view/upload_name}" />
                 </td>
             </tr>
             <tr>
-                <td valign="top" class="form-title">
+                <td valign="top" class="wiki-field">
                     Title:
                 </td>
-                <td valign="top" >
-                    <input id="file_title" name="title" type="text" size="40" value=""/>
+                <td valign="top">
+                    <input class="wiki-input" id="file_title" name="title" type="text" size="40" value=""/>
                 </td>
             </tr>
             <tr>
-                <td valign="top" class="form-title">
+                <td valign="top" class="wiki-field">
                     Description: 
                 </td>
-                <td valign="top" >
-                    <textarea id="description" name="description"
+                <td valign="top">
+                    <textarea class="wiki-input" id="description" name="description"
                                    cols="37" rows="8" value="123"></textarea>
                 </td>
             </tr>
             <tr>
-                <td valign="top" class="form-title">
+                <td valign="top" class="wiki-field">
                     File: 
                 </td>
                 <td>
@@ -44,10 +44,10 @@
                 </td>
             </tr>
             <tr tal:condition="not: view/isUnique"> 
-                <td valign="top" class="form-title">
+                <td valign="top" class="wiki-field">
                     Scope: 
                 </td>
-                <td valign="top" class="form-title">
+                <td valign="top" class="wiki-field">
                     <input name="scope" id="scope" type="checkbox">
                     Apply to all links named &quot;<span tal:replace="view/unicodeLabel">Name</span>&quot;.
                 </td>   

Modified: zope3org/trunk/src/zorg/wikification/browser/wikilink.py
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/wikilink.py	2006-04-28 19:05:43 UTC (rev 67732)
+++ zope3org/trunk/src/zorg/wikification/browser/wikilink.py	2006-04-28 19:06:57 UTC (rev 67733)
@@ -291,7 +291,6 @@
     adapts(IWikiPage)
         
     command = None
-   
 
     def __init__(self, page) :
         BaseHTMLProcessor.__init__(self)
@@ -493,7 +492,7 @@
         placeholder = self.createPlaceholder(label, name)
         self.placeholder = None
         return placeholder.textLink()
-        
+                
     def output(self) :
         """ Returns the processing result.
         

Modified: zope3org/trunk/src/zorg/wikification/browser/wikipage.py
===================================================================
--- zope3org/trunk/src/zorg/wikification/browser/wikipage.py	2006-04-28 19:05:43 UTC (rev 67732)
+++ zope3org/trunk/src/zorg/wikification/browser/wikipage.py	2006-04-28 19:06:57 UTC (rev 67733)
@@ -252,7 +252,7 @@
         if file is None :
             return self._new()
         else :
-            return unicode(file.data, encoding="utf-8")
+            return unicode(file.data, encoding="utf-8", errors='replace')
         
     def getFile(self) :
         return self.context.get(u"index.html")
@@ -272,7 +272,7 @@
         body = self.getBody()
         if body is not None :
             wikified = self.wikify(body)
-            return unicode(wikified, encoding="utf-8")
+            return unicode(wikified, encoding='utf-8', errors='replace')
             
         return self._noindex()
        
@@ -301,7 +301,7 @@
         body = self.getBody()
         if body is not None :
             wikified = self.wikify(body)
-            return unicode(wikified, encoding="utf-8")
+            return unicode(wikified, encoding='utf-8', errors='replace')
   
         return u"Sorry, not wikifiable at the moment."
             
@@ -456,7 +456,7 @@
         
             if file.contentType == "text/html" :
                 html = self.editableHTML(file.data)
-                return unicode(html, encoding="utf-8")
+                return unicode(html, encoding="utf-8", errors='replace')
                 
             if file.contentType == "text/plain" :
                 return zorg.restsupport.rest2html(file.data)
@@ -466,9 +466,9 @@
             if file.contentType == "text/html" :
                 body = html_body(file.data)
                 rest = zorg.restsupport.html2rest(body, fragment=True)
-                return unicode(rest, encoding="utf-8")
+                return unicode(rest, encoding="utf-8", errors='replace')
             if file.contentType == "text/plain" :
-                return unicode(file.data, encoding="utf-8")   
+                return unicode(file.data, encoding="utf-8", errors='replace')   
         
         return _("unknown format: cannot show file content. """)
         

Modified: zope3org/trunk/src/zorg/wikification/parser.py
===================================================================
--- zope3org/trunk/src/zorg/wikification/parser.py	2006-04-28 19:05:43 UTC (rev 67732)
+++ zope3org/trunk/src/zorg/wikification/parser.py	2006-04-28 19:06:57 UTC (rev 67733)
@@ -88,12 +88,18 @@
         # Reconstruct original DOCTYPE
         self.pieces.append("<!%(text)s>" % locals())
         
+    def prepare(self, html) :
+        """ A handler for preprocessing steps. Called after the conversion 
+            into utf-8
+        """
+        return html
         
     def feed(self, html) :
         """ Specialization that remembers whether we process unicode or not. """
         if isinstance(html, unicode) :
             html = html.encode('utf-8')
             self.unicode_html = True
+        html = self.prepare(html)
         SGMLParser.feed(self, html)
         
     def output(self) :



More information about the Checkins mailing list