Moin Title Patch

About

The following patches for Moin provide an additional #title instruction that if inserted at the top of a page will change the title for the given page.

Example

The current page is using this feature, as follows:

#title Moin Title Patch

Patch for 1.6.1

   1 --- MoinMoin/Page.py    2008-03-02 15:00:52 +0000
   2 +++ MoinMoin/Page.py    2008-03-02 16:31:48 +0000
   3 @@ -734,6 +734,10 @@
   4          @return: pagename of this page, splitted into space separated words
   5          """
   6          request = self.request
   7 +
   8 +        if self.pi.get("title"):
   9 +            return self.pi["title"]
  10 +
  11          if not force and not request.user.wikiname_add_spaces:
  12              return self.page_name
  13  
  14 @@ -963,6 +967,9 @@
  15                  else:
  16                      request.setPragma(key, val)
  17  
  18 +            elif verb == "title":
  19 +                pi["title"] = args
  20 +
  21          pi['acl'] = security.AccessControlList(request.cfg, acl)
  22          return pi
  23  

Patch for 1.5.4

   1 --- MoinMoin/Page.py    
   2 +++ MoinMoin/Page.py    
   3 @@ -352,6 +352,21 @@
   4          @rtype: unicode
   5          @return: pagename of this page, splitted into space separated words
   6          """
   7 +        if hasattr(self, "pi_title"):
   8 +            if self.pi_title:
   9 +                return self.pi_title
  10 +        else:
  11 +            header = self.getPageHeader()
  12 +            if header and "#title " in header:
  13 +                for line in header.splitlines():
  14 +                    verb, args = (line[1:]+' ').split(' ', 1)
  15 +                    verb = verb.lower()
  16 +                    args = args.strip()
  17 +                    if verb == "title":
  18 +                        self.pi_title = args
  19 +                return self.pi_title
  20 +            else:
  21 +                self.pi_title = None
  22          if not force and not request.user.wikiname_add_spaces:
  23              return self.page_name
  24  
  25 @@ -1004,6 +1019,7 @@
  26          # default is wiki markup
  27          pi_format = self.cfg.default_markup or "wiki"
  28          pi_formatargs = ''
  29 +        pi_title = None
  30          pi_redirect = None
  31          pi_refresh = None
  32          pi_formtext = []
  33 @@ -1044,6 +1060,9 @@
  34                  pi_format, pi_formatargs = (args+' ').split(' ',1)
  35                  pi_format = pi_format.lower()
  36                  pi_formatargs = pi_formatargs.strip()
  37 +            elif verb == "title":
  38 +                # page title
  39 +                pi_title = args
  40              elif verb == "refresh":
  41                  if self.cfg.refresh:
  42                      try:
  43 @@ -1114,6 +1133,7 @@
  44  
  45          # Save values for later use
  46          self.pi_format = pi_format
  47 +        self.pi_title = pi_title
  48  
  49          # start document output
  50          doc_leader = self.formatter.startDocument(self.page_name)


CategorySnippet

snippets/moin-title (last edited 2008-03-03 03:50:57 by GustavoNiemeyer)