Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes
MoinMoin.macro.NewPage.NewPage Class Reference

List of all members.

Public Member Functions

def __init__
def renderInPage

Public Attributes

 macro
 request
 formatter
 template
 label
 parent
 nametemplate

Detailed Description

NewPage - create new pages

Let you create new page using optional template, button text
and parent page (for automatic subpages).

Usage:

    <<NewPage(template, buttonLabel, parentPage)>>

Examples:

    <<NewPage>>

        Create an input field with 'Create New Page' button. The new
        page will not use a template.

    <<NewPage(BugTemplate, Create New Bug, MoinMoinBugs)>>

        Create an input field with button labeled 'Create New
        Bug'.  The new page will use the BugTemplate template,
        and create the page as a subpage of MoinMoinBugs.

Definition at line 20 of file NewPage.py.


Constructor & Destructor Documentation

def MoinMoin.macro.NewPage.NewPage.__init__ (   self,
  macro,
  template = u'',
  button_label = u'',
  parent_page = u'',
  name_template = u'%s' 
)

Definition at line 45 of file NewPage.py.

00045 
00046                  parent_page=u'', name_template=u'%s'):
00047         self.macro = macro
00048         self.request = macro.request
00049         self.formatter = macro.formatter
00050         self.template = template
00051         _ = self.request.getText
00052         if button_label:
00053             # Try to get a translation, this will probably not work in
00054             # most cases, but better than nothing.
00055             self.label = self.request.getText(button_label)
00056         else:
00057             self.label = _("Create New Page")
00058         if parent_page == '@ME' and self.request.user.valid:
00059             self.parent = self.request.user.name
00060         elif parent_page == '@SELF':
00061             self.parent = self.formatter.page.page_name
00062         else:
00063             self.parent = parent_page
00064         self.nametemplate = name_template


Member Function Documentation

Render macro in page context

The parser should decide what to do if this macro is placed in a
paragraph context.

Definition at line 65 of file NewPage.py.

00065 
00066     def renderInPage(self):
00067         """ Render macro in page context
00068 
00069         The parser should decide what to do if this macro is placed in a
00070         paragraph context.
00071         """
00072         f = self.formatter
00073         _ = self.request.getText
00074 
00075         requires_input = '%s' in self.nametemplate
00076 
00077 
00078         # TODO: better abstract this using the formatter
00079         html = [
00080             u'<form class="macro" method="POST" action="%s"><div>' % self.request.href(self.formatter.page.page_name),
00081             u'<input type="hidden" name="action" value="newpage">',
00082             u'<input type="hidden" name="parent" value="%s">' % wikiutil.escape(self.parent, 1),
00083             u'<input type="hidden" name="template" value="%s">' % wikiutil.escape(self.template, 1),
00084             u'<input type="hidden" name="nametemplate" value="%s">' % wikiutil.escape(self.nametemplate, 1),
00085         ]
00086 
00087         if requires_input:
00088             html += [
00089                 u'<input type="text" name="pagename" size="30">',
00090             ]
00091         html += [
00092             u'<input type="submit" value="%s">' % wikiutil.escape(self.label, 1),
00093             u'</div></form>',
00094             ]
00095         return self.formatter.rawHTML('\n'.join(html))

Here is the call graph for this function:


Member Data Documentation

Definition at line 48 of file NewPage.py.

Definition at line 54 of file NewPage.py.

Definition at line 46 of file NewPage.py.

Definition at line 63 of file NewPage.py.

Definition at line 58 of file NewPage.py.

Definition at line 47 of file NewPage.py.

Definition at line 49 of file NewPage.py.


The documentation for this class was generated from the following file: