changeset 191:e5ca7fa46f2e

fixed Page(Graphical)Editor so that template param doesnt destroy existing pages imported from: moin--main--1.5--patch-193
author Thomas Waldmann <tw@waldmann-edv.de>
date Sat, 05 Nov 2005 16:17:28 +0000
parents 63d33f46ebea
children 509d6bfc1680
files MoinMoin/PageEditor.py MoinMoin/PageGraphicalEditor.py
diffstat 2 files changed, 20 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/PageEditor.py	Fri Nov 04 08:12:43 2005 +0000
+++ b/MoinMoin/PageEditor.py	Sat Nov 05 16:17:28 2005 +0000
@@ -287,10 +287,16 @@
         )
         
         self.request.write(self.request.formatter.startContent("content"))
-        
-        # get the text body for the editor field
-        if form.has_key('template'):
-            # "template" parameter contains the name of the template page
+
+        # Get the text body for the editor field.
+        # TODO: what about deleted pages? show the text of the last revision or use the template?
+        raw_body = ''
+        if self.exists():
+            # If the page exists, we get the text from the page.
+            # TODO: maybe warn if template argument was ignored because the page exists?
+            raw_body = self.get_raw_body()
+        elif form.has_key('template'):
+            # If the page does not exists, we try to get the content from the template parameter.
             template_page = wikiutil.unquoteWikiname(form['template'][0])
             if self.request.user.may.read(template_page):
                 raw_body = Page(self.request, template_page).get_raw_body()
@@ -299,10 +305,7 @@
                 else:
                     self.request.write(_("[Template %s not found]") % (template_page,), '<br>')
             else:
-                raw_body = ''
                 self.request.write(_("[You may not read %s]") % (template_page,), '<br>')
-        else:
-            raw_body = self.get_raw_body()
 
         # Make backup on previews - but not for new empty pages
         if preview and raw_body:
@@ -312,14 +315,6 @@
         if not raw_body:
             raw_body = _('Describe %s here.') % (self.page_name,)
 
-        # send text above text area
-        #self.request.write(wikiutil.getSysPage(self.request, 'HelpOnFormatting').link_to(self.request))
-        #self.request.write(" | ", wikiutil.getSysPage(self.request, 'InterWiki').link_to(self.request))
-        #if preview is not None and not staytop:
-        #    self.request.write(' | <a href="#preview">%s</a>' % _('Skip to preview'))
-        #self.request.write(' ')
-        #self.request.write(_('[current page size \'\'\'%(size)d\'\'\' bytes]') % {'size': self.size()})
-        
         # send form
         self.request.write('<form id="editor" method="post" action="%s/%s#preview" onSubmit="flgChange = false;">' % (
             self.request.getScriptname(),
--- a/MoinMoin/PageGraphicalEditor.py	Fri Nov 04 08:12:43 2005 +0000
+++ b/MoinMoin/PageGraphicalEditor.py	Sat Nov 05 16:17:28 2005 +0000
@@ -166,10 +166,16 @@
         )
         
         self.request.write(self.request.formatter.startContent("content"))
-        
-        # get the text body for the editor field
-        if form.has_key('template'):
-            # "template" parameter contains the name of the template page
+
+        # Get the text body for the editor field.
+        # TODO: what about deleted pages? show the text of the last revision or use the template?
+        raw_body = ''
+        if self.exists():
+            # If the page exists, we get the text from the page.
+            # TODO: maybe warn if template argument was ignored because the page exists?
+            raw_body = self.get_raw_body()
+        elif form.has_key('template'):
+            # If the page does not exists, we try to get the content from the template parameter.
             template_page = wikiutil.unquoteWikiname(form['template'][0])
             if self.request.user.may.read(template_page):
                 raw_body = Page(self.request, template_page).get_raw_body()
@@ -178,10 +184,7 @@
                 else:
                     self.request.write(_("[Template %s not found]") % (template_page,), '<br>')
             else:
-                raw_body = ''
                 self.request.write(_("[You may not read %s]") % (template_page,), '<br>')
-        else:
-            raw_body = self.get_raw_body()
 
         # Make backup on previews - but not for new empty pages
         if preview and raw_body:
@@ -191,16 +194,6 @@
         if not raw_body:
             raw_body = _('Describe %s here.') % (self.page_name,)
 
-        # send text above text area
-        #self.request.write('<p>')
-        #self.request.write(wikiutil.getSysPage(self.request, 'HelpOnFormatting').link_to(self.request))
-        #self.request.write(" | ", wikiutil.getSysPage(self.request, 'InterWiki').link_to(self.request))
-        #if preview is not None and not staytop:
-        #    self.request.write(' | <a href="#preview">%s</a>' % _('Skip to preview'))
-        #self.request.write(' ')
-        #self.request.write(_('[current page size \'\'\'%(size)d\'\'\' bytes]') % {'size': self.size()})
-        #self.request.write('</p>')
-        
         # send form
         self.request.write('<form id="editor" method="post" action="%s/%s#preview">' % (
             self.request.getScriptname(),