Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Static Public Attributes | Private Attributes
MoinMoin.macro.Navigation.Navigation Class Reference

List of all members.

Public Member Functions

def __init__
def dispatch
def badscheme
def do_children
def do_siblings
def do_slideshow
def do_slides

Public Attributes

 macro
 scheme
 depth
 pagename
 print_mode
 media
 querystr

Static Public Attributes

dictionary PROJECTION = {'action': 'print', 'media': 'projection', }

Private Attributes

 _

Detailed Description

Dispatcher class implementing the navigation schemes.

Definition at line 63 of file Navigation.py.


Constructor & Destructor Documentation

def MoinMoin.macro.Navigation.Navigation.__init__ (   self,
  macro,
  scheme,
  depth 
)
Prepare common values used during processing.

Definition at line 70 of file Navigation.py.

00070 
00071     def __init__(self, macro, scheme, depth):
00072         """ Prepare common values used during processing.
00073         """
00074         self.macro = macro
00075         self.scheme = scheme
00076         self.depth = depth
00077         self._ = self.macro.request.getText
00078 
00079         self.pagename = self.macro.formatter.page.page_name
00080         self.print_mode = self.macro.request.action == 'print'
00081         self.media = self.macro.request.values.get('media')
00082         self.querystr = self.print_mode and self.PROJECTION or {}
00083 


Member Function Documentation

Bad scheme argument.

Definition at line 94 of file Navigation.py.

00094 
00095     def badscheme(self):
00096         """ Bad scheme argument.
00097         """
00098         _ = self._
00099         return (self.macro.formatter.sysmsg(1) +
00100                 self.macro.formatter.text(
00101             _("Unsupported navigation scheme '%(scheme)s'!") %
00102             {'scheme': self.scheme}) +
00103                 self.macro.formatter.sysmsg(0))
00104 

Here is the caller graph for this function:

Return None if in plain print mode (no navigational
    elements in printouts), else the proper HTML code.

Definition at line 84 of file Navigation.py.

00084 
00085     def dispatch(self):
00086         """ Return None if in plain print mode (no navigational
00087             elements in printouts), else the proper HTML code.
00088         """
00089         if self.print_mode and self.media != 'projection':
00090             return None
00091 
00092         return getattr(self, 'do_%s' % self.scheme, self.badscheme)()
00093 

Here is the call graph for this function:

Here is the caller graph for this function:

Navigate to subpages from a parent page.

Definition at line 105 of file Navigation.py.

00105 
00106     def do_children(self):
00107         """ Navigate to subpages from a parent page.
00108         """
00109         # delegate to siblings code, setting the parent explicitely
00110         return self.do_siblings(root=self.pagename)
00111 

Here is the call graph for this function:

def MoinMoin.macro.Navigation.Navigation.do_siblings (   self,
  root = None 
)
Navigate from a subpage to its siblings.

Definition at line 112 of file Navigation.py.

00112 
00113     def do_siblings(self, root=None):
00114         """ Navigate from a subpage to its siblings.
00115         """
00116         _ = self._
00117         request = self.macro.request
00118         # get parent page name
00119         parent = root or _getParent(self.pagename)
00120         if not parent:
00121             return (self.macro.formatter.sysmsg(1) +
00122                     self.macro.formatter.text(_('No parent page found!'))+
00123                     self.macro.formatter.sysmsg(0))
00124 
00125         # iterate over children, adding links to all of them
00126         result = []
00127         children = _getPages(request, '^%s/' % re.escape(parent))
00128         for child in children:
00129             # display short page name, leaving out the parent path
00130             # (and make sure the name doesn't get wrapped)
00131             shortname = child[len(parent):]
00132 
00133             # possibly limit depth
00134             if self.depth and shortname.count('/') > self.depth:
00135                 continue
00136 
00137             if child == self.pagename:
00138                 # do not link to focus
00139                 result.append(self.macro.formatter.text(shortname))
00140             else:
00141                 # link to sibling / child
00142                 result.append(Page(request, child).link_to(request, text=shortname, querystr=self.querystr))
00143             result.append('   ')
00144 
00145         return ''.join(result)
00146 

Here is the call graph for this function:

Here is the caller graph for this function:

def MoinMoin.macro.Navigation.Navigation.do_slides (   self,
  root = None 
)
Navigate within a slide show.

Definition at line 183 of file Navigation.py.

00183 
00184     def do_slides(self, root=None):
00185         """ Navigate within a slide show.
00186         """
00187         _ = self._
00188         request = self.macro.request
00189         parent = root or _getParent(self.pagename)
00190         if not parent:
00191             return (self.macro.formatter.sysmsg(1) +
00192                     self.macro.formatter.text(_('No parent page found!')) +
00193                     self.macro.formatter.sysmsg(0))
00194 
00195         # prepare link generation
00196         result = []
00197         labels = ['^', '|<', '<<', '>>', '>|']
00198         filter_regex = '^%s/' % re.escape(parent)
00199         pos, size, links = _getLinks(request, self.pagename, filter_regex)
00200         pos += 1
00201         links = zip(labels, (parent, ) + links)
00202 
00203         # generate links to neighborhood
00204         for label, name in links:
00205             result.append(' ')
00206             if name:
00207                 # active link
00208                 result.append(Page(request, name).link_to(request, text=label, querystr=self.querystr))
00209             else:
00210                 # ghosted link
00211                 result.append(self.macro.formatter.text(label))
00212             result.append(' ')
00213 
00214             # position indicator in the middle
00215             if label == labels[2]:
00216                 result.append(_('Slide %(pos)d of %(size)d') % {'pos': pos, 'size': size})
00217 
00218         return self.do_slideshow(focus=self.pagename) + ''.join(result)
00219 

Here is the call graph for this function:

def MoinMoin.macro.Navigation.Navigation.do_slideshow (   self,
  focus = None 
)
Slideshow master page links.

    If `focus` is set, it is the name of a slide page; these only
    get the mode toggle and edit links.

Definition at line 147 of file Navigation.py.

00147 
00148     def do_slideshow(self, focus=None):
00149         """ Slideshow master page links.
00150 
00151             If `focus` is set, it is the name of a slide page; these only
00152             get the mode toggle and edit links.
00153         """
00154         _ = self._
00155         curpage = focus or self.pagename
00156         result = []
00157         request = self.macro.request
00158         pg = Page(request, curpage)
00159         if self.print_mode:
00160             # projection mode
00161             label = _('Wiki')
00162             toggle = {}
00163             result.append(pg.link_to(request, text=_('Edit'), querystr={'action': 'edit'}))
00164             result.append(' &nbsp; ')
00165         else:
00166             # wiki mode
00167             label = _('Slideshow')
00168             toggle = self.PROJECTION
00169 
00170         # add mode toggle link
00171         result.append(pg.link_to(request, text=label, querystr=toggle))
00172 
00173         # leave out the following on slide pages
00174         if focus is None:
00175             children = _getPages(request, '^%s/' % re.escape(self.pagename))
00176             if children:
00177                 # add link to first child if one exists
00178                 result.append(' &nbsp; ')
00179                 result.append(Page(request, children[0]).link_to(request, text=_('Start'), querystr=self.querystr))
00180 
00181         return ''.join(result)
00182 

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 76 of file Navigation.py.

Definition at line 75 of file Navigation.py.

Definition at line 73 of file Navigation.py.

Definition at line 80 of file Navigation.py.

Definition at line 78 of file Navigation.py.

Definition at line 79 of file Navigation.py.

dictionary MoinMoin.macro.Navigation.Navigation.PROJECTION = {'action': 'print', 'media': 'projection', } [static]

Definition at line 68 of file Navigation.py.

Definition at line 81 of file Navigation.py.

Definition at line 74 of file Navigation.py.


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