[Moin-devel] CVS: MoinMoin Page.py,1.129,1.130
J?rgen Hermann
jhermann at users.sourceforge.net
Thu Jun 20 15:37:04 EDT 2002
Update of /cvsroot/moin/MoinMoin
In directory usw-pr-cvs1:/tmp/cvs-serv8499/MoinMoin
Modified Files:
Page.py
Log Message:
LikePages shows similar pages (using difflib.get_close_matches);
Page creation shows LikePages that already exist
Index: Page.py
===================================================================
RCS file: /cvsroot/moin/MoinMoin/Page.py,v
retrieving revision 1.129
retrieving revision 1.130
diff -C2 -r1.129 -r1.130
*** Page.py 18 Jun 2002 18:08:45 -0000 1.129
--- Page.py 20 Jun 2002 22:36:55 -0000 1.130
***************
*** 386,416 ****
# new page?
if not self.exists() and self.default_formatter and not content_only:
! # generate the default page content for new pages
! print wikiutil.link_tag(wikiutil.quoteWikiname(self.page_name)+'?action=edit',
! _("Create this page"))
!
! # look for template pages
! templates = filter(lambda page, u = wikiutil: u.isTemplatePage(page),
! wikiutil.getPageList(config.text_dir))
! if templates:
! print self.formatter.paragraph(1)
! print self.formatter.text(_('Alternatively, use one of these templates:'))
! print self.formatter.paragraph(0)
!
! # send list of template pages
! print self.formatter.bullet_list(1)
! for page in templates:
! print self.formatter.listitem(1)
! print wikiutil.link_tag("%s?action=edit&template=%s" % (
! wikiutil.quoteWikiname(self.page_name),
! wikiutil.quoteWikiname(page)),
! page)
! print self.formatter.listitem(0)
! print self.formatter.bullet_list(0)
!
! print self.formatter.paragraph(1)
! print self.formatter.text(_('To create you own templates, ' +
! 'add a page with a name ending in Template.'))
! print self.formatter.paragraph(0)
else:
# parse the text and send the page content
--- 386,390 ----
# new page?
if not self.exists() and self.default_formatter and not content_only:
! self._emptyPageText(request)
else:
# parse the text and send the page content
***************
*** 444,447 ****
--- 418,460 ----
request.clock.stop('send_page')
+
+
+ def _emptyPageText(self, request):
+ from MoinMoin.action import LikePages
+
+ # generate the default page content for new pages
+ print wikiutil.link_tag(wikiutil.quoteWikiname(self.page_name)+'?action=edit',
+ _("Create this page"))
+
+ # look for template pages
+ templates = filter(lambda page, u = wikiutil: u.isTemplatePage(page),
+ wikiutil.getPageList(config.text_dir))
+ if templates:
+ print self.formatter.paragraph(1)
+ print self.formatter.text(_('Alternatively, use one of these templates:'))
+ print self.formatter.paragraph(0)
+
+ # send list of template pages
+ print self.formatter.bullet_list(1)
+ for page in templates:
+ print self.formatter.listitem(1)
+ print wikiutil.link_tag("%s?action=edit&template=%s" % (
+ wikiutil.quoteWikiname(self.page_name),
+ wikiutil.quoteWikiname(page)),
+ page)
+ print self.formatter.listitem(0)
+ print self.formatter.bullet_list(0)
+
+ print self.formatter.paragraph(1)
+ print self.formatter.text(_('To create you own templates, ' +
+ 'add a page with a name ending in Template.'))
+ print self.formatter.paragraph(0)
+
+ # list similar pages that already exist
+ start, end, matches = LikePages.findMatches(self.page_name, request)
+ if matches and not isinstance(matches, type('')):
+ print self.formatter.rule()
+ print _('<p>The following pages with similar names already exist...</p>')
+ LikePages.showMatches(self.page_name, start, end, matches)
More information about the Moin-devel
mailing list