def testSystemPage(self): """wikiutil: good system page names accepted, bad rejected""" for name in self.systemPages: self.assert_(wikiutil.isSystemPage(self.request, name), '"%(name)s" is a system page' % locals()) for name in self.notSystemPages: self.failIf(wikiutil.isSystemPage(self.request, name), '"%(name)s" is NOT a system page' % locals())
def group_filter(name): # aw crap, SystemPagesGroup is not a system page if name == 'SystemPagesGroup': return False if wikiutil.isSystemPage(request, name): return False return request.user.may.read(name)
def search(self, page): logging.debug("DomainSearch searching page %r for (negated = %r) %r" % (page.page_name, self.negated, self._pattern)) checks = {'underlay': page.isUnderlayPage, 'standard': page.isStandardPage, 'system': lambda page=page: wikiutil.isSystemPage(page.request, page.page_name), } try: match = checks[self.pattern]() except KeyError: match = False # Decide what to do with the results. if self.negated: if match: result = None else: result = [Match()] # represents "matched" (but as it was a negative match, we have nothing to show) else: # not negated if match: result = [Match()] # represents "matched" (but we have nothing to show) else: result = None logging.debug("DomainSearch returning %r" % result) return result
def sitemap_url(request, page): """ return a sitemap <url>..</url> fragment for page object <page> """ url = page.url(request) pagename = page.page_name lastmod = page.mtime_printable(request) if lastmod == "0": # can happen in case of errors lastmod = now() # page's changefreq, priority and lastmod depends on page type / name if pagename in [u"RecentChanges", u"TitleIndex", ]: # important dynamic pages with macros changefreq = "hourly" priority = "0.9" lastmod = now() # the page text mtime never changes, but the macro output DOES elif pagename in [request.cfg.page_front_page, ]: # important user edited pages changefreq = "hourly" priority = "1.0" elif wikiutil.isSystemPage(request, pagename): # other system pages are rather boring changefreq = "yearly" priority = "0.1" else: # these are the content pages: changefreq = "daily" priority = "0.5" return make_url_xml(request, locals())
def xmlrpc_getAllPagesEx(self, opts=None): """ Get all pages readable by current user. Not an WikiRPC method. @param opts: dictionary that can contain the following arguments: include_system:: set it to false if you do not want to see system pages include_revno:: set it to True if you want to have lists with [pagename, revno] include_deleted:: set it to True if you want to include deleted pages exclude_non_writable:: do not include pages that the current user may not write to include_underlay:: return underlay pagenames as well prefix:: the page name must begin with this prefix to be included mark_deleted:: returns the revision number -rev_no if the page was deleted. Makes only sense if you enable include_revno and include_deleted. @rtype: list @return: a list of all pages. """ from MoinMoin.wikisync import normalise_pagename options = {"include_system": True, "include_revno": False, "include_deleted": False, "exclude_non_writable": False, "include_underlay": True, "prefix": "", "pagelist": None, "mark_deleted": False} if opts is not None: options.update(opts) if not options["include_system"]: p_filter = lambda name: not wikiutil.isSystemPage(self.request, name) else: p_filter = lambda name: True if options["exclude_non_writable"]: p_filter = lambda name, p_filter=p_filter: p_filter(name) and self.request.user.may.write(name) if options["prefix"] or options["pagelist"]: def p_filter(name, p_filter=p_filter, prefix=(options["prefix"] or ""), pagelist=options["pagelist"]): if not p_filter(name): return False n_name = normalise_pagename(name, prefix) if not n_name: return False if not pagelist: return True return n_name in pagelist pagelist = self.request.rootpage.getPageList(filter=p_filter, exists=not options["include_deleted"], include_underlay=options["include_underlay"], return_objects=options["include_revno"]) if options['include_revno']: pages = [] for page in pagelist: revno = page.get_real_rev() if options["mark_deleted"] and not page.exists(): revno = -revno pages.append([self._outstr(page.page_name), revno]) return pages else: return [self._outstr(page) for page in pagelist]
def testAllCreate(self): package = PackagePages(self.request.rootpage.page_name, self.request) temp = tempfile.NamedTemporaryFile(suffix='.zip') package.collectpackage(self.request.rootpage.getPageList( include_underlay=False, filter=lambda name: not wikiutil.isSystemPage(self.request, name)), temp) if not package: py.test.skip("No user created pages in wiki!") assert zipfile.is_zipfile(temp.name)
def mainloop(self): """ moin-package's main code. """ # Initalize request self.init_request() request = self.request _ = self.request.getText # Check our command line args if self.options.pages and self.options.search: script.fatal(_("Options --pages and --search are mutually exclusive!")) elif not self.options.output: script.fatal(_("You must specify an output file!")) elif not self.options.pages and not self.options.search: script.log(_("No pages specified using --pages or --search, assuming full package.")) include_attachments = self.options.attachment or False if include_attachments: script.log(_("All attachments included into the package.")) # Sanity checks if os.path.exists(self.options.output): script.fatal(_("Output file already exists! Cowardly refusing to continue!")) # Check for user if self.options.package_user: request.user = user.User(request, name=self.options.package_user) # Import PackagePages here, as we now have an initalized request. from MoinMoin.action.PackagePages import PackagePages # Perform actual packaging. package = PackagePages(request.rootpage.page_name, request) packageoutput = open(self.options.output, "wb") if self.options.search: packagedata = package.collectpackage( package.searchpackage(request, self.options.search), packageoutput, include_attachments=include_attachments, ) elif self.options.pages: packagedata = package.collectpackage( self.options.pages.split(","), packageoutput, include_attachments=include_attachments ) else: packagedata = package.collectpackage( request.rootpage.getPageList( include_underlay=False, filter=lambda name: not wikiutil.isSystemPage(request, name) ), packageoutput, include_attachments=include_attachments, ) if packagedata: script.fatal(packagedata)
def testAllCreate(self): package = PackagePages(self.request.rootpage.page_name, self.request) temp = tempfile.NamedTemporaryFile(suffix='.zip') package.collectpackage( self.request.rootpage.getPageList( include_underlay=False, filter=lambda name: not wikiutil.isSystemPage( self.request, name)), temp) if not package: py.test.skip("No user created pages in wiki!") assert zipfile.is_zipfile(temp.name)
def _get_domains(self, page): """ Returns a generator with all the domains the page belongs to @param page: page """ if page.isUnderlayPage(): yield 'underlay' if page.isStandardPage(): yield 'standard' if wikiutil.isSystemPage(self.request, page.page_name): yield 'system'
def _get_matches(self, page): checks = {'underlay': page.isUnderlayPage, 'standard': page.isStandardPage, 'system': lambda page=page: wikiutil.isSystemPage(page.request, page.page_name), } try: match = checks[self.pattern]() except KeyError: match = False if match: return [Match()] else: return []
def mainloop(self): """ moin-package's main code. """ # Initalize request self.init_request() request = self.request _ = self.request.getText # Check our command line args if self.options.pages and self.options.search: script.fatal(_("Options --pages and --search are mutually exclusive!")) elif not self.options.output: script.fatal(_("You must specify an output file!")) elif not self.options.pages and not self.options.search: script.log(_("No pages specified using --pages or --search, assuming full package.")) include_attachments = self.options.attachment or False if include_attachments: script.log(_("All attachments included into the package.")) # Sanity checks if os.path.exists(self.options.output): script.fatal(_("Output file already exists! Cowardly refusing to continue!")) # Check for user if self.options.package_user: request.user = user.User(request, name=self.options.package_user) # Import PackagePages here, as we now have an initalized request. from MoinMoin.action.PackagePages import PackagePages # Perform actual packaging. package = PackagePages(request.rootpage.page_name, request) packageoutput = open(self.options.output, "wb") if self.options.search: packagedata = package.collectpackage(package.searchpackage(request, self.options.search), packageoutput, include_attachments=include_attachments) elif self.options.pages: packagedata = package.collectpackage(self.options.pages.split(","), packageoutput, include_attachments=include_attachments) else: packagedata = package.collectpackage(request.rootpage.getPageList( include_underlay=False, filter=lambda name: not wikiutil.isSystemPage(request, name)), packageoutput, include_attachments=include_attachments) if packagedata: script.fatal(packagedata)
def searchpackage(self, request, searchkey): """ Search MoinMoin for the string specified and return a list of matching pages, provided they are not system pages and not present in the underlay. @param request: current request @param searchkey: string to search for @rtype: list @return: list of pages matching searchkey """ pagelist = searchPages(request, searchkey) titles = [] for title in pagelist.hits: if not wikiutil.isSystemPage(request, title.page_name) or not title.page.getPageStatus()[0]: titles.append(title.page_name) return titles
def sitemap_url(request, page): """ return a sitemap <url>..</url> fragment for page object <page> """ url = page.url(request) pagename = page.page_name lastmod = page.mtime_printable(request) if lastmod == "0": # can happen in case of errors lastmod = now() # page's changefreq, priority and lastmod depends on page type / name if pagename in [ u"RecentChanges", u"TitleIndex", ]: # important dynamic pages with macros changefreq = "hourly" priority = "0.9" lastmod = now( ) # the page text mtime never changes, but the macro output DOES elif pagename in [ request.cfg.page_front_page, ]: # important user edited pages changefreq = "hourly" priority = "1.0" elif wikiutil.isSystemPage(request, pagename): # other system pages are rather boring changefreq = "yearly" priority = "0.1" else: # these are the content pages: changefreq = "daily" priority = "0.5" return make_url_xml(request, locals())
def testSystemPage(self): """wikiutil: good system page names accepted, bad rejected""" for name in self.systemPages: assert wikiutil.isSystemPage(self.request, name) for name in self.notSystemPages: assert not wikiutil.isSystemPage(self.request, name)
def _macro_SystemInfo(self, args): import operator, sys from StringIO import StringIO from MoinMoin import parser, processor, version from MoinMoin.logfile import editlog, eventlog _ = self._ # check for 4XSLT try: import Ft ftversion = Ft.__version__ except ImportError: ftversion = None except AttributeError: ftversion = 'N/A' # Get the full pagelist in the wiki pagelist = self.request.rootpage.getPageList(user='') totalsize = reduce(operator.add, [Page(self.request, name).size() for name in pagelist]) buf = StringIO() row = lambda label, value, buf=buf: buf.write( u'<dt>%s</dt><dd>%s</dd>' % (label, value)) buf.write(u'<dl>') row(_('Python Version'), sys.version) row(_('MoinMoin Version'), _('Release %s [Revision %s]') % (version.release, version.revision)) if ftversion: row(_('4Suite Version'), ftversion) row(_('Number of pages'), str(len(pagelist))) systemPages = [page for page in pagelist if wikiutil.isSystemPage(self.request, page)] row(_('Number of system pages'), str(len(systemPages))) row(_('Accumulated page sizes'), str(totalsize)) edlog = editlog.EditLog(self.request) row(_('Entries in edit log'), _("%(logcount)s (%(logsize)s bytes)") % {'logcount': edlog.lines(), 'logsize': edlog.size()}) # !!! This puts a heavy load on the server when the log is large, # and it can appear on normal pages ==> so disable it for now. eventlogger = eventlog.EventLog(self.request) nonestr = _("NONE") row('Event log', "%s bytes" % eventlogger.size()) row(_('Global extension macros'), ', '.join(macro.extension_macros) or nonestr) row(_('Local extension macros'), ', '.join(wikiutil.wikiPlugins('macro', self.cfg)) or nonestr) ext_actions = [] for a in action.extension_actions: if not a in self.request.cfg.excluded_actions: ext_actions.append(a) row(_('Global extension actions'), ', '.join(ext_actions) or nonestr) row(_('Local extension actions'), ', '.join(wikiaction.getPlugins(self.request)[1]) or nonestr) row(_('Installed parsers'), ', '.join(parser.modules) or nonestr) row(_('Installed processors (DEPRECATED -- use Parsers instead)'), ', '.join(processor.processors) or nonestr) state = (_('Disabled'), _('Enabled')) row(_('Lupy search'), state[self.request.cfg.lupy_search]) buf.write(u'</dl') return self.formatter.rawHTML(buf.getvalue())
def macro_WantedPages(macro): request = macro.request _ = request.getText # prevent recursion if request.mode_getpagelinks: return '' if request.isSpiderAgent: # reduce bot cpu usage return '' # Get allpages switch from the form allpages = int(request.values.get('allpages', 0)) != 0 # Control bar - filter the list of pages # TODO: we should make this a widget and use on all page listing pages label = (_('Include system pages'), _('Exclude system pages'))[allpages] page = macro.formatter.page controlbar = macro.formatter.div(1, css_class="controlbar") + \ page.link_to(request, label, querystr={'allpages': '%s' % (allpages and '0' or '1')}) + \ macro.formatter.div(0) # Get page dict readable by current user pages = request.rootpage.getPageDict() # build a dict of wanted pages wanted = {} deprecated_links = [] for name, page in pages.items(): # Skip system pages, because missing translations are not wanted pages, # unless you are a translator and clicked "Include system pages" if not allpages and wikiutil.isSystemPage(request, name): continue # Add links to pages which do not exist in pages dict links = page.getPageLinks(request) is_deprecated = page.parse_processing_instructions( ).get('deprecated', False) for link in links: if not link in pages and request.user.may.read(link): if is_deprecated: deprecated_links.append(link) if link in wanted: wanted[link][name] = 1 else: wanted[link] = {name: 1} for link in deprecated_links: if len(wanted[link]) == 1: del wanted[link] # Check for the extreme case when there are no wanted pages if not wanted: return u"%s<p>%s</p>" % (controlbar, _("No wanted pages in this wiki.")) # Return a list of page links wantednames = wanted.keys() wantednames.sort() result = [] result.append(macro.formatter.number_list(1)) for name in wantednames: if not name: continue result.append(macro.formatter.listitem(1)) # Add link to the wanted page result.append(macro.formatter.pagelink(1, name, generated=1)) result.append(macro.formatter.text(name)) result.append(macro.formatter.pagelink(0, name)) # Add links to pages that want this page, highliting # the link in those pages. where = wanted[name].keys() where.sort() if macro.formatter.page.page_name in where: where.remove(macro.formatter.page.page_name) wherelinks = [pages[pagename].link_to(request, querystr={'highlight': name}, rel='nofollow') for pagename in where] result.append(": " + ', '.join(wherelinks)) result.append(macro.formatter.listitem(0)) result.append(macro.formatter.number_list(0)) return u'%s%s' % (controlbar, u''.join(result))
def has_children(what): me = what+"/" for p in all_pages: if p.startswith(me): return True return False all_pages = _get_all_pages(macro.request) hits = [] hits_dict = {} nm_dict = {} cfg = macro.request.cfg for page in all_pages: is_syspage = wikiutil.isSystemPage(macro.request, page) is_special = ( \ name_matches(cfg.page_category_regex) or \ name_matches(cfg.page_dict_regex) or \ name_matches(cfg.page_group_regex) or \ name_matches(cfg.page_template_regex) \ ) and not "/" in page is_regular = not (is_syspage or is_special) locs = { # functions: 'name_contains': name_contains, 'name_is': name_is, 'name_startswith': name_startswith, 'name_endswith': name_endswith, 'name_matches': name_matches,
def filter(name): return not wikiutil.isSystemPage(self.request, name)
def getInfo(self): _ = self.request.getText request = self.request buf = StringIO() row = lambda label, value, buf=buf: buf.write(u'<dt>%s</dt><dd>%s</dd>' % (label, value)) buf.write(u'<dl>') row(_('Python Version'), sys.version) row(_('MoinMoin Version'), _('Release %s [Revision %s]') % (version.release, version.revision)) if not request.user.valid: # for an anonymous user it ends here. buf.write(u'</dl>') return buf.getvalue() if request.user.isSuperUser(): # superuser gets all page dependent stuff only try: import Ft ftversion = Ft.__version__ except ImportError: ftversion = None except AttributeError: ftversion = 'N/A' if ftversion: row(_('4Suite Version'), ftversion) # TODO add python-xml check and display it # Get the full pagelist of the wiki pagelist = request.rootpage.getPageList(user='') systemPages = [] totalsize = 0 for page in pagelist: if wikiutil.isSystemPage(request, page): systemPages.append(page) totalsize += Page(request, page).size() row(_('Number of pages'), str(len(pagelist)-len(systemPages))) row(_('Number of system pages'), str(len(systemPages))) row(_('Accumulated page sizes'), self.formatInReadableUnits(totalsize)) data_dir = request.cfg.data_dir row(_('Disk usage of %(data_dir)s/pages/') % {'data_dir': data_dir}, self.formatInReadableUnits(self.getDirectorySize(os.path.join(data_dir, 'pages')))) row(_('Disk usage of %(data_dir)s/') % {'data_dir': data_dir}, self.formatInReadableUnits(self.getDirectorySize(data_dir))) edlog = editlog.EditLog(request) row(_('Entries in edit log'), "%s (%s)" % (edlog.lines(), self.formatInReadableUnits(edlog.size()))) # This puts a heavy load on the server when the log is large eventlogger = eventlog.EventLog(request) row('Event log', self.formatInReadableUnits(eventlogger.size())) nonestr = _("NONE") # a valid user gets info about all installed extensions row(_('Global extension macros'), ', '.join(macro.modules) or nonestr) row(_('Local extension macros'), ', '.join(wikiutil.wikiPlugins('macro', self.macro.cfg)) or nonestr) glob_actions = [x for x in action.modules if not x in request.cfg.actions_excluded] row(_('Global extension actions'), ', '.join(glob_actions) or nonestr) loc_actions = [x for x in wikiutil.wikiPlugins('action', self.macro.cfg) if not x in request.cfg.actions_excluded] row(_('Local extension actions'), ', '.join(loc_actions) or nonestr) row(_('Global parsers'), ', '.join(parser.modules) or nonestr) row(_('Local extension parsers'), ', '.join(wikiutil.wikiPlugins('parser', self.macro.cfg)) or nonestr) try: import xapian xapVersion = 'Xapian %s' % xapian.version_string() except ImportError: xapian = None xapVersion = _('Xapian and/or Python Xapian bindings not installed') xapian_enabled = request.cfg.xapian_search xapState = (_('Disabled'), _('Enabled')) xapRow = '%s, %s' % (xapState[xapian_enabled], xapVersion) if xapian and xapian_enabled: from MoinMoin.search.Xapian.indexing import XapianIndex idx = XapianIndex(request) idxState = (_('index unavailable'), _('index available')) idx_exists = idx.exists() xapRow += ', %s' % idxState[idx_exists] if idx_exists: xapRow += ', %s' % (_('last modified: %s') % request.user.getFormattedDateTime(idx.mtime())) row(_('Xapian search'), xapRow) if xapian and xapian_enabled: stems = xapian.Stem.get_available_languages() row(_('Stemming for Xapian'), xapState[request.cfg.xapian_stemming] + " (%s)" % (stems or nonestr)) try: from threading import activeCount t_count = activeCount() except ImportError: t_count = None row(_('Active threads'), t_count or _('N/A')) buf.write(u'</dl>') return buf.getvalue()
def macro_WantedPages(macro): request = macro.request _ = request.getText # prevent recursion if request.mode_getpagelinks: return "" if request.isSpiderAgent: # reduce bot cpu usage return "" # Get allpages switch from the form allpages = int(request.form.get("allpages", [0])[0]) != 0 # Control bar - filter the list of pages # TODO: we should make this a widget and use on all page listing pages label = (_("Include system pages"), _("Exclude system pages"))[allpages] page = macro.formatter.page controlbar = ( macro.formatter.div(1, css_class="controlbar") + page.link_to(request, label, querystr={"allpages": "%s" % (allpages and "0" or "1")}) + macro.formatter.div(0) ) # Get page dict readable by current user pages = request.rootpage.getPageDict() # build a dict of wanted pages wanted = {} for name, page in pages.items(): # Skip system pages, because missing translations are not wanted pages, # unless you are a translator and clicked "Include system pages" if not allpages and wikiutil.isSystemPage(request, name): continue # Add links to pages which do not exist in pages dict links = page.getPageLinks(request) for link in links: if not link in pages and request.user.may.read(link): if link in wanted: wanted[link][name] = 1 else: wanted[link] = {name: 1} # Check for the extreme case when there are no wanted pages if not wanted: return u"%s<p>%s</p>" % (controlbar, _("No wanted pages in this wiki.")) # Return a list of page links wantednames = wanted.keys() wantednames.sort() result = [] result.append(macro.formatter.number_list(1)) for name in wantednames: if not name: continue result.append(macro.formatter.listitem(1)) # Add link to the wanted page result.append(macro.formatter.pagelink(1, name, generated=1)) result.append(macro.formatter.text(name)) result.append(macro.formatter.pagelink(0, name)) # Add links to pages that want this page, highliting # the link in those pages. where = wanted[name].keys() where.sort() if macro.formatter.page.page_name in where: where.remove(macro.formatter.page.page_name) wherelinks = [ pages[pagename].link_to(request, querystr={"highlight": name}, rel="nofollow") for pagename in where ] result.append(": " + ", ".join(wherelinks)) result.append(macro.formatter.listitem(0)) result.append(macro.formatter.number_list(0)) return u"%s%s" % (controlbar, u"".join(result))
def xmlrpc_getAllPagesEx(self, opts=None): """ Get all pages readable by current user. Not an WikiRPC method. @param opts: dictionary that can contain the following arguments: include_system:: set it to false if you do not want to see system pages include_revno:: set it to True if you want to have lists with [pagename, revno] include_deleted:: set it to True if you want to include deleted pages exclude_non_writable:: do not include pages that the current user may not write to include_underlay:: return underlay pagenames as well prefix:: the page name must begin with this prefix to be included mark_deleted:: returns the revision number -rev_no if the page was deleted. Makes only sense if you enable include_revno and include_deleted. @rtype: list @return: a list of all pages. """ from MoinMoin.wikisync import normalise_pagename options = { "include_system": True, "include_revno": False, "include_deleted": False, "exclude_non_writable": False, "include_underlay": True, "prefix": "", "pagelist": None, "mark_deleted": False } if opts is not None: options.update(opts) if not options["include_system"]: p_filter = lambda name: not wikiutil.isSystemPage( self.request, name) else: p_filter = lambda name: True if options["exclude_non_writable"]: p_filter = lambda name, p_filter=p_filter: p_filter( name) and self.request.user.may.write(name) if options["prefix"] or options["pagelist"]: def p_filter(name, p_filter=p_filter, prefix=(options["prefix"] or ""), pagelist=options["pagelist"]): if not p_filter(name): return False n_name = normalise_pagename(name, prefix) if not n_name: return False if not pagelist: return True return n_name in pagelist pagelist = self.request.rootpage.getPageList( filter=p_filter, exists=not options["include_deleted"], include_underlay=options["include_underlay"], return_objects=options["include_revno"]) if options['include_revno']: pages = [] for page in pagelist: revno = page.get_real_rev() if options["mark_deleted"] and not page.exists(): revno = -revno pages.append([self._outstr(page.page_name), revno]) return pages else: return [self._outstr(page) for page in pagelist]
def nosyspage(name): return not wikiutil.isSystemPage(request, name)
def execute(macro, args): request = macro.request _ = request.getText # prevent recursion if request.mode_getpagelinks: return '' # Get allpages switch from the form allpages = int(request.form.get('allpages', [0])[0]) != 0 # Control bar - filter the list of pages # TODO: we should make this a widget and use on all page listing pages controlbar = '''<div class="controlbar"> <a href="%(qpagename)s?allpages=%(allpages)d">%(label)s</a> </div>''' % { 'qpagename': wikiutil.quoteWikinameURL(macro.formatter.page.page_name), 'allpages': not allpages, 'label': (_('Include system pages'), _('Exclude system pages'))[allpages], } # Get page dict readable by current user pages = request.rootpage.getPageDict() # build a dict of wanted pages wanted = {} for name, page in pages.items(): # Skip system pages, because missing translations are not wanted pages, # unless you are a translator and clicked "Include system pages" if not allpages and wikiutil.isSystemPage(request, name): continue # Add links to pages which does not exists in pages dict links = page.getPageLinks(request) for link in links: if not link in pages: if link in wanted: wanted[link][name] = 1 else: wanted[link] = {name: 1} # Check for the extreme case when there are no wanted pages if not wanted: return u"%s<p>%s</p>" % (controlbar ,_("No wanted pages in this wiki.")) # Return a list of page links wantednames = wanted.keys() wantednames.sort() result = [] result.append(macro.formatter.number_list(1)) for name in wantednames: if not name: continue result.append(macro.formatter.listitem(1)) # Add link to the wanted page result.append(macro.formatter.pagelink(1, name, generated=1)) result.append(macro.formatter.text(name)) result.append(macro.formatter.pagelink(0, name)) # Add links to pages that want this page, highliting # the link in those pages. where = wanted[name].keys() where.sort() if macro.formatter.page.page_name in where: where.remove(macro.formatter.page.page_name) querystr='highlight=%s' % wikiutil.url_quote_plus(name) wherelinks = [pages[pagename].link_to(request, querystr=querystr) for pagename in where] result.append(": " + ', '.join(wherelinks)) result.append(macro.formatter.listitem(0)) result.append(macro.formatter.number_list(0)) return u'%s%s' % (controlbar, u''.join(result))
def getInfo(self): _ = self.request.getText request = self.request buf = StringIO() row = lambda label, value, buf=buf: buf.write(u'<dt>%s</dt><dd>%s</dd>' % (label, value)) buf.write(u'<dl>') row(_('Python Version'), sys.version) row( _('MoinMoin Version'), _('Release %s [Revision %s]') % (version.release, version.revision)) if not request.user.valid: # for an anonymous user it ends here. buf.write(u'</dl>') return buf.getvalue() if request.user.isSuperUser(): # superuser gets all page dependent stuff only try: import Ft ftversion = Ft.__version__ except ImportError: ftversion = None except AttributeError: ftversion = 'N/A' if ftversion: row(_('4Suite Version'), ftversion) # TODO add python-xml check and display it # Get the full pagelist of the wiki pagelist = request.rootpage.getPageList(user='') systemPages = [] totalsize = 0 for page in pagelist: if wikiutil.isSystemPage(request, page): systemPages.append(page) totalsize += Page(request, page).size() row(_('Number of pages'), str(len(pagelist) - len(systemPages))) row(_('Number of system pages'), str(len(systemPages))) row(_('Accumulated page sizes'), self.formatInReadableUnits(totalsize)) data_dir = request.cfg.data_dir row( _('Disk usage of %(data_dir)s/pages/') % {'data_dir': data_dir}, self.formatInReadableUnits( self.getDirectorySize(os.path.join(data_dir, 'pages')))) row( _('Disk usage of %(data_dir)s/') % {'data_dir': data_dir}, self.formatInReadableUnits(self.getDirectorySize(data_dir))) edlog = editlog.EditLog(request) row( _('Entries in edit log'), "%s (%s)" % (edlog.lines(), self.formatInReadableUnits(edlog.size()))) # This puts a heavy load on the server when the log is large eventlogger = eventlog.EventLog(request) row('Event log', self.formatInReadableUnits(eventlogger.size())) nonestr = _("NONE") # a valid user gets info about all installed extensions row(_('Global extension macros'), ', '.join(macro.modules) or nonestr) row( _('Local extension macros'), ', '.join(wikiutil.wikiPlugins('macro', self.macro.cfg)) or nonestr) glob_actions = [ x for x in action.modules if not x in request.cfg.actions_excluded ] row(_('Global extension actions'), ', '.join(glob_actions) or nonestr) loc_actions = [ x for x in wikiutil.wikiPlugins('action', self.macro.cfg) if not x in request.cfg.actions_excluded ] row(_('Local extension actions'), ', '.join(loc_actions) or nonestr) row(_('Global parsers'), ', '.join(parser.modules) or nonestr) row( _('Local extension parsers'), ', '.join(wikiutil.wikiPlugins('parser', self.macro.cfg)) or nonestr) try: import xapian xapVersion = 'Xapian %s' % xapian.version_string() except ImportError: xapian = None xapVersion = _( 'Xapian and/or Python Xapian bindings not installed') xapian_enabled = request.cfg.xapian_search xapState = (_('Disabled'), _('Enabled')) xapRow = '%s, %s' % (xapState[xapian_enabled], xapVersion) if xapian and xapian_enabled: from MoinMoin.search.Xapian.indexing import XapianIndex idx = XapianIndex(request) idxState = (_('index unavailable'), _('index available')) idx_exists = idx.exists() xapRow += ', %s' % idxState[idx_exists] if idx_exists: xapRow += ', %s' % ( _('last modified: %s') % request.user.getFormattedDateTime(idx.mtime())) row(_('Xapian search'), xapRow) if xapian and xapian_enabled: stems = xapian.Stem.get_available_languages() row( _('Stemming for Xapian'), xapState[request.cfg.xapian_stemming] + " (%s)" % (stems or nonestr)) try: from threading import activeCount t_count = activeCount() except ImportError: t_count = None row(_('Active threads'), t_count or _('N/A')) buf.write(u'</dl>') return buf.getvalue()