コード例 #1
0
ファイル: api.py プロジェクト: thimalk/bloodhound-789
    def _get_system_wiki_list(self):
        """Helper function that enumerates all 'system' wikis. The
        list is combined of default wiki pages and pages that are
        bundled with Bloodhound dashboard and search plugins"""
        from bhdashboard import wiki

        paths = [resource_filename('trac.wiki',
                                   'default-pages')] + \
                [resource_filename('bhdashboard',
                                   'default-pages')] + \
                [resource_filename('bhsearch',
                                   'default-pages')]
        pages = []
        original_pages = []
        for path in paths:
            for page in os.listdir(path):
                filename = os.path.join(path, page)
                page = unicode_unquote(page.encode('utf-8'))
                if os.path.isfile(filename):
                    original_pages.append(page)
        for original_name in original_pages:
            if original_name.startswith('Trac'):
                new_name = wiki.new_name(original_name)
                if not new_name:
                    continue
                if new_name in original_pages:
                    continue
                name = new_name
                # original trac wikis should also be included in the list
                pages.append(original_name)
            else:
                name = original_name
            pages.append(name)
        return pages
コード例 #2
0
ファイル: api.py プロジェクト: tsanov/bloodhound
    def _get_system_wiki_list(self):
        """Helper function that enumerates all 'system' wikis. The
        list is combined of default wiki pages and pages that are
        bundled with Bloodhound dashboard and search plugins"""
        from bhdashboard import wiki

        paths = [resource_filename('trac.wiki',
                                   'default-pages')] + \
                [resource_filename('bhdashboard',
                                   'default-pages')] + \
                [resource_filename('bhsearch',
                                   'default-pages')]
        pages = []
        original_pages = []
        for path in paths:
            for page in os.listdir(path):
                filename = os.path.join(path, page)
                page = unicode_unquote(page.encode('utf-8'))
                if os.path.isfile(filename):
                    original_pages.append(page)
        for original_name in original_pages:
            if original_name.startswith('Trac'):
                new_name = wiki.new_name(original_name)
                if not new_name:
                    continue
                if new_name in original_pages:
                    continue
                name = new_name
                # original trac wikis should also be included in the list
                pages.append(original_name)
            else:
                name = original_name
            pages.append(name)
        return pages
コード例 #3
0
ファイル: admin.py プロジェクト: tsanov/bloodhound
 def _do_wiki_upgrade(self):
     """Move all wiki pages starting with Trac prefix to unbranded user
     guide pages.
     """
     wiki_admin = WikiAdmin(self.env)
     pages = wiki_admin.get_wiki_list()
     for old_name in pages:
         if old_name.startswith('Trac'):
             new_name = wiki.new_name(old_name)
             if not new_name:
                 continue
             if new_name in pages:
                 printout(
                     _(
                         'Ignoring %(page)s : '
                         'The page %(new_page)s already exists',
                         page=old_name,
                         new_page=new_name))
                 continue
             try:
                 wiki_admin._do_rename(old_name, new_name)
             except AdminCommandError, exc:
                 printout(
                     _('Error moving %(page)s : %(message)s',
                       page=old_name,
                       message=unicode(exc)))
             else:
                 # On success, rename links in other pages
                 self._do_wiki_rename_links(old_name, new_name)
                 # On success, insert redirection page
                 redirection = WikiPage(self.env, old_name)
                 redirection.text = _('See [wiki:"%(name)s"].',
                                      name=new_name)
                 comment = 'Bloodhound guide update'
                 redirection.save('bloodhound', comment, '0.0.0.0')
コード例 #4
0
ファイル: admin.py プロジェクト: Stackato-Apps/bloodhound
 def _do_wiki_upgrade(self):
     """Move all wiki pages starting with Trac prefix to unbranded user
     guide pages.
     """
     wiki_admin = WikiAdmin(self.env)
     pages = wiki_admin.get_wiki_list()
     for old_name in pages:
         if old_name.startswith('Trac'):
             new_name = wiki.new_name(old_name)
             if not new_name:
                 continue
             if new_name in pages:
                 printout(_('Ignoring %(page)s : '
                            'The page %(new_page)s already exists',
                            page=old_name, new_page=new_name))
                 continue
             try:
                 wiki_admin._do_rename(old_name, new_name)
             except AdminCommandError, exc:
                 printout(_('Error moving %(page)s : %(message)s',
                            page=old_name, message=unicode(exc)))
             else:
                 # On success, rename links in other pages
                 self._do_wiki_rename_links(old_name, new_name)
                 # On success, insert redirection page
                 redirection = WikiPage(self.env, old_name)
                 redirection.text = _('See [wiki:"%(name)s"].', name=new_name)
                 comment = 'Bloodhound guide update'
                 redirection.save('bloodhound', comment, '0.0.0.0')
コード例 #5
0
ファイル: theme.py プロジェクト: tsanov/bloodhound
 def new_name(name):
     new_name = wiki.new_name(name)
     if new_name != name:
         if not self._wiki_pages:
             wiki_admin = WikiAdmin(self.env)
             self._wiki_pages = wiki_admin.get_wiki_list()
         if new_name in self._wiki_pages:
             return new_name
     return name
コード例 #6
0
    def filter_stream(self, req, method, filename, stream, data):
        """Insert default Bootstrap CSS classes if rendering 
        legacy templates (i.e. determined by template name prefix) 
        and renames wiki guide links.
        """
        tx = Transformer('body')

        def add_classes(classes):
            """Return a function ensuring CSS classes will be there for element.
            """
            def attr_modifier(name, event):
                attrs = event[1][1]
                class_list = attrs.get(name, '').split()
                self.log.debug('BH Theme : Element classes ' + str(class_list))

                out_classes = ' '.join(set(class_list + classes))
                self.log.debug('BH Theme : Inserting class ' + out_classes)
                return out_classes

            return attr_modifier

        # Insert default bootstrap CSS classes if necessary
        for xpath, classes in self.BOOTSTRAP_CSS_DEFAULTS:
            tx = tx.end().select(xpath) \
                .attr('class', add_classes(classes))

        # Rename wiki guide links
        tx = tx.end() \
            .select("body//a[contains(@href,'/wiki/%s')]" % wiki.GUIDE_NAME) \
            .map(lambda text: wiki.new_name(text), TEXT)

        # Rename trac error
        app_short = self.labels_application_short
        tx = tx.end() \
            .select("body//div[@class='error']/h1") \
            .map(lambda text: text.replace("Trac", app_short), TEXT)

        return stream | tx
コード例 #7
0
ファイル: theme.py プロジェクト: mohsadki/dargest
    def filter_stream(self, req, method, filename, stream, data):
        """Insert default Bootstrap CSS classes if rendering
        legacy templates (i.e. determined by template name prefix)
        and renames wiki guide links.
        """
        tx = Transformer('body')

        def add_classes(classes):
            """Return a function ensuring CSS classes will be there for element.
            """
            def attr_modifier(name, event):
                attrs = event[1][1]
                class_list = attrs.get(name, '').split()
                self.log.debug('BH Theme : Element classes ' + str(class_list))

                out_classes = ' '.join(set(class_list + classes))
                self.log.debug('BH Theme : Inserting class ' + out_classes)
                return out_classes
            return attr_modifier

        # Insert default bootstrap CSS classes if necessary
        for xpath, classes in self.BOOTSTRAP_CSS_DEFAULTS:
            tx = tx.end().select(xpath) \
                .attr('class', add_classes(classes))

        # Rename wiki guide links
        tx = tx.end() \
            .select("body//a[contains(@href,'/wiki/%s')]" % wiki.GUIDE_NAME) \
            .map(lambda text: wiki.new_name(text), TEXT)

        # Rename trac error
        app_short = self.labels_application_short
        tx = tx.end() \
            .select("body//div[@class='error']/h1") \
            .map(lambda text: text.replace("Trac", app_short), TEXT)

        return stream | tx