当前位置: 首页>>代码示例>>Python>>正文


Python wiki.wiki_to_oneliner函数代码示例

本文整理汇总了Python中trac.wiki.wiki_to_oneliner函数的典型用法代码示例。如果您正苦于以下问题:Python wiki_to_oneliner函数的具体用法?Python wiki_to_oneliner怎么用?Python wiki_to_oneliner使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了wiki_to_oneliner函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_groups

    def get_groups(self, req, cursor, order_by = 'id', desc = False):
        # Get count of forums without group
        sql = "SELECT COUNT(f.id) FROM forum f WHERE f.forum_group = 0"
        self.log.debug(sql)
        cursor.execute(sql)
        no_group_forums = 0
        for row in cursor:
            no_group_forums = row[0]
        groups = [{'id' : 0, 'name' : 'None', 'description' : 'No Group',
          'forums' : no_group_forums}]

        # Get forum groups
        if order_by != 'forum':
            order_by = 'g.' + order_by
        columns = ('id', 'name', 'description', 'forums')
        sql = "SELECT g.id, g.name, g.description, f.forums FROM " \
          " forum_group g LEFT JOIN (SELECT COUNT(id) AS forums, " \
          " forum_group FROM forum GROUP BY forum_group) f ON g.id = " \
          " f.forum_group ORDER BY " + order_by + (" ASC",
          " DESC")[bool(desc)]
        self.log.debug(sql)
        cursor.execute(sql)
        for row in cursor:
            row = dict(zip(columns, row))
            row['name'] = wiki_to_oneliner(row['name'], self.env)
            row['description'] = wiki_to_oneliner(row['description'], self.env)
            groups.append(row)
        return groups
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:28,代码来源:api.py

示例2: get_forums

 def get_forums(self, req, cursor, order_by = 'ORDER BY subject ASC'):
     columns = ('id', 'name', 'author', 'time', 'moderators', 'group',
       'subject', 'description', 'topics', 'replies', 'lastreply',
       'lasttopic')
     sql = "SELECT id, name, author, time, moderators, forum_group," \
       " subject, description, (SELECT COUNT(id) FROM topic t WHERE" \
       " t.forum = forum.id) AS topics, (SELECT COUNT(id) FROM message m" \
       " WHERE m.forum = forum.id) AS replies, (SELECT MAX(time) FROM" \
       " message m WHERE m.forum = forum.id) AS lasttopic, (SELECT" \
       " MAX(time) FROM topic t WHERE t.forum = forum.id) AS lastreply" \
       " FROM forum " + order_by
     self.log.debug(sql)
     cursor.execute(sql)
     forums = []
     for row in cursor:
         row = dict(zip(columns, row))
         row['moderators'] = wiki_to_oneliner(row['moderators'], self.env)
         row['description'] = wiki_to_oneliner(row['description'], self.env)
         if row['lastreply']:
             row['lastreply'] = pretty_timedelta(row['lastreply'])
         else:
             row['lastreply'] = 'No replies'
         if row['lasttopic']:
             row['lasttopic'] = pretty_timedelta(row['lasttopic'])
         else:
             row['lasttopic'] = 'No topics'
         row['time'] = format_datetime(row['time'])
         forums.append(row)
     return forums
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:29,代码来源:api.py

示例3: get_timeline_events

    def get_timeline_events(self, req, start, stop, filters):
        if 'changeset' in filters:
            format = req.args.get('format')
            wiki_format = self.wiki_format_messages
            show_files = self.timeline_show_files
            db = self.env.get_db_cnx()
            repos = self.env.get_repository(req.authname)
            for chgset in repos.get_changesets(start, stop):
                message = chgset.message or '--'
                if wiki_format:
                    shortlog = wiki_to_oneliner(message, self.env, db,
                                                shorten=True)
                else:
                    shortlog = shorten_line(message)

                if format == 'rss':
                    title = Markup(u'변경사항 [%s]: %s', chgset.rev, shortlog)
                    href = req.abs_href.changeset(chgset.rev)
                    if wiki_format:
                        message = wiki_to_html(message, self.env, req, db,
                                               absurls=True)
                    else:
                        message = html.PRE(message)
                else:
                    title = Markup(u'변경사항 <em>[%s]</em> : %s에 의해 수정됨', chgset.rev,
                                   chgset.author)
                    href = req.href.changeset(chgset.rev)

                    if wiki_format:
                        if self.timeline_long_messages:
                            message = wiki_to_html(message, self.env, req, db,
                                                   absurls=True)
                        else:
                            message = wiki_to_oneliner(message, self.env, db,
                                                       shorten=True)
                    else:
                        message = shortlog

                if show_files and req.perm.has_permission('BROWSER_VIEW'):
                    files = []
                    for chg in chgset.get_changes():
                        if show_files > 0 and len(files) >= show_files:
                            files.append(html.LI(Markup('&hellip;')))
                            break
                        files.append(html.LI(html.DIV(class_=chg[2]),
                                             chg[0] or '/'))
                    message = html.UL(files, class_="changes") + message

                yield 'changeset', href, title, chgset.date, chgset.author,\
                      message
开发者ID:yeoupooh,项目名称:tow,代码行数:50,代码来源:changeset.py

示例4: get_topics

 def get_topics(self, req, cursor, forum_id, order_by = 'time', desc = False):
     if not order_by in ('replies', 'lastreply',):
         order_by = 't.' + order_by
     columns = ('id', 'forum', 'time', 'subject', 'body', 'author',
       'replies', 'lastreply')
     sql = "SELECT t.id, t.forum, t.time, t.subject, t.body, t.author," \
       " m.replies, m.lastreply FROM topic t LEFT JOIN (SELECT COUNT(id)" \
       " AS replies, MAX(time) AS lastreply, topic FROM message GROUP BY" \
       " topic) m ON t.id = m.topic WHERE t.forum = %s ORDER BY " \
       + order_by + (" ASC", " DESC")[bool(desc)]
     self.log.debug(sql % (forum_id,))
     cursor.execute(sql, (forum_id,))
     topics = []
     for row in cursor:
         row = dict(zip(columns, row))
         row['author'] = wiki_to_oneliner(row['author'], self.env)
         row['body'] = wiki_to_html(row['body'], self.env, req)
         if row['lastreply']:
             row['lastreply'] = pretty_timedelta(float(row['lastreply']))
         else:
             row['lastreply'] = 'No replies'
         if not row['replies']:
             row['replies'] = 0
         row['time'] = format_datetime(row['time'])
         topics.append(row)
     return topics
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:26,代码来源:api.py

示例5: get_timeline_events

    def get_timeline_events(self, req, start, stop, filters):
        self.log.debug("start: %s, stop: %s, filters: %s" % (start, stop, filters))
        if "downloads" in filters:
            # Create database context
            db = self.env.get_db_cnx()
            cursor = db.cursor()

            #  Get API component.
            api = self.env[DownloadsApi]

            format = req.args.get("format")
            self.log.debug("format: %s" % (format))

            # Get message events
            for download in api.get_new_downloads(req, cursor, start, stop):
                kind = "newticket"

                title = Markup("New download <em>%s</em> created by %s" % (download["file"], download["author"]))
                time = download["time"]
                author = download["author"]

                if format == "rss":
                    href = req.abs_href.downloads(download["id"])
                    message = wiki_to_html(download["description"], self.env, req)
                else:
                    href = req.href.downloads(download["id"])
                    message = wiki_to_oneliner(download["description"], self.env)

                yield kind, href, title, time, author, message
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:29,代码来源:timeline.py

示例6: get_messages

    def get_messages(self, req, cursor, topic, time, order_by = 'ORDER BY time ASC'):
        columns = ('id', 'replyto', 'time', 'author', 'body')
        sql = "SELECT id, replyto, time, author, body FROM message WHERE" \
          " topic = %s " + order_by
        self.log.debug(sql % (topic,))
        cursor.execute(sql, (topic,))
        messagemap = {}
        messages = []
        for row in cursor:
            row = dict(zip(columns, row))
            row['author'] = wiki_to_oneliner(row['author'], self.env)
            row['body'] = wiki_to_html(row['body'], self.env, req)
            if int(row['time']) > time:
                row['new'] = True
            row['time'] = format_datetime(row['time'])
            messagemap[row['id']] = row

            # Add top-level messages to the main list, in order of time
            if row['replyto'] == -1:
                messages.append(row)

        # Second pass, add replies
        for message in messagemap.values():
            if message['replyto'] != -1:
                parent = messagemap[message['replyto']]
                if 'replies' in parent:
                    parent['replies'].append(message)
                else:
                    parent['replies'] = [message]
        return messages;
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:30,代码来源:api.py

示例7: render_listtags

    def render_listtags(self, req, *tags, **kwargs):
        """ List tags. For backwards compatibility, can accept a list of tags.
            This will simply call ListTagged. Optional keyword arguments are
            tagspace=wiki, tagspaces=(wiki, ticket, ...) and shownames=true. """
        if tags:
            # Backwards compatibility
            return self.render_listtagged(req, *tags, **kwargs)

        page = self._current_page(req)
        engine = TagEngine(self.env)

        showpages = kwargs.get('showpages', None) or kwargs.get('shownames', 'false')

        if 'tagspace' in kwargs:
            tagspaces = [kwargs['tagspace']]
        else:
            tagspaces = kwargs.get('tagspaces', []) or \
                        list(TagEngine(self.env).tagspaces)

        out = StringIO()
        out.write('<ul class="listtags">\n')
        tag_details = {}
        for tag, names in sorted(engine.get_tags(tagspaces=tagspaces, detailed=True).iteritems()):
            href, title = engine.get_tag_link(tag)
            htitle = wiki_to_oneliner(title, self.env)
            out.write('<li><a href="%s" title="%s">%s</a> %s <span class="tagcount">(%i)</span>' % (href, title, tag, htitle, len(names)))
            if showpages == 'true':
                out.write('\n')
                out.write(self.render_listtagged(req, tag, tagspaces=tagspaces))
                out.write('</li>\n')

        out.write('</ul>\n')

        return out.getvalue()
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:34,代码来源:macros.py

示例8: get_downloads

    def get_downloads(self, req, cursor, order_by = 'id', desc = False):
        columns = ('id', 'file', 'description', 'size', 'time', 'count',
          'author', 'tags', 'component', 'version', 'architecture', 'platform',
          'type')
        sql = "SELECT id, file, description, size, time, count, author, tags," \
          " component, version, architecture, platform, type FROM download " \
          "ORDER BY " + order_by + (" ASC", " DESC")[bool(desc)]
        self.log.debug(sql)
        cursor.execute(sql)
        downloads = []
        for row in cursor:
            row = dict(zip(columns, row))
            row['description'] = wiki_to_oneliner(row['description'], self.env)
            row['size'] = pretty_size(row['size'])
            row['time'] = pretty_timedelta(row['time'])
            row['count'] = row['count'] or 0
            downloads.append(row)

        # Replace field ids with apropriate objects.
        for download in downloads:
            download['architecture'] = self.get_architecture(cursor,
              download['architecture'])
            download['platform'] = self.get_platform(cursor,
              download['platform'])
            download['type'] = self.get_type(cursor, download['type'])
        return downloads
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:26,代码来源:api.py

示例9: _prepare_message_list

    def _prepare_message_list(self, req, cursor, topic):
        # Get form values.
        new_author = req.args.get('author')
        new_subject = req.args.get('subject')
        new_body = req.args.get('body')

        # Get time when topic was visited from session.
        visited = eval(req.session.get('visited-topics') or '{}')
        if visited.has_key(topic['id']):
            visit_time = int(visited[topic['id']])
        else:
            visit_time = 0

        # Update this topic visit time and save to session.
        visited[topic['id']] = int(time.time())
        req.session['visited-topics'] = to_unicode(visited)

        # Mark new topic.
        if int(topic['time']) > visit_time:
            topic['new'] = True

        # Prepare display of topic
        if new_author:
            req.hdf['discussion.author'] = wiki_to_oneliner(new_author,
              self.env)
        if new_subject:
            req.hdf['discussion.subject'] = wiki_to_oneliner(new_subject,
              self.env)
        if new_body:
            req.hdf['discussion.body'] = wiki_to_html(new_body, self.env, req)

        # Prepare display of messages
        display = req.session.get('message-list-display') or \
          self.default_display
        req.hdf['discussion.display'] = display
        if display == 'flat-asc':
            req.hdf['discussion.messages'] = self.get_flat_messages(req, cursor,
              topic['id'], visit_time)
        elif display == 'flat-desc' or display == 'flat':
            req.hdf['discussion.messages'] = self.get_flat_messages(req, cursor,
              topic['id'], visit_time, 'ORDER BY time DESC')
        elif display == 'tree' or display == '':
            req.hdf['discussion.messages'] = self.get_messages(req, cursor,
             topic['id'], visit_time)
        else:
            raise TracError('Unsupported display mode: %s' % (display))
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:46,代码来源:api.py

示例10: render_listtagged

    def render_listtagged(self, req, *tags, **kwargs):
        """ List tagged objects. Optionally accepts a list of tags to match
            against.  The special tag '''. (dot)''' inserts the current Wiki page name.

            `[[ListTagged(<tag>, ...)]]`

            ||'''Argument'''||'''Description'''||
            ||`tagspace=<tagspace>`||Specify the tagspace the macro should operate on.||
            ||`tagspaces=(<tagspace>,...)`||Specify a set of tagspaces the macro should operate on.||
            ||`operation=intersection|union`||The set operation to perform on the discovered objects.||
            ||`showheadings=true|false`||List objects under the tagspace they occur in.||
        """

        if 'tagspace' in kwargs:
            tagspaces = [kwargs.get('tagspace', None)]
        else:
            tagspaces = kwargs.get('tagspaces', '') or \
                        list(TagEngine(self.env).tagspaces)
        showheadings = kwargs.get('showheadings', 'false')
        operation = kwargs.get('operation', 'intersection')
        if operation not in ('union', 'intersection'):
            raise TracError("Invalid tag set operation '%s'" % operation)

        engine = TagEngine(self.env)
        page_name = req.hdf.get('wiki.page_name')
        if page_name:
            tags = [tag == '.' and page_name or tag for tag in tags]

        taginfo = {}
        out = StringIO()
        out.write('<ul class="listtagged">')
        # Cull empty names
        tagged_names = [(tagspace, names) for tagspace, names in
                        engine.get_tagged_names(tags=tags, tagspaces=tagspaces,
                            operation=operation, detailed=True).iteritems()
                        if names]
        for tagspace, tagspace_names in sorted(tagged_names):
            if showheadings == 'true':
                out.write('<lh>%s tags</lh>' % tagspace)
            for name, tags in sorted(tagspace_names.iteritems()):
                if tagspace == 'wiki' and unicode(name).startswith('tags/'): continue
                tags = sorted(tags)
                taginfo = self._tag_details(taginfo, tags)
                href, link, title = engine.name_details(tagspace, name)
                htitle = wiki_to_oneliner(title, self.env)
                name_tags = ['<a href="%s" title="%s">%s</a>'
                              % (taginfo[tag][0], taginfo[tag][1], tag)
                              for tag in tags]
                if not name_tags:
                    name_tags = ''
                else:
                    name_tags = ' (' + ', '.join(sorted(name_tags)) + ')'
                out.write('<li>%s %s%s</li>\n' %
                          (link, htitle, name_tags))
        out.write('</ul>')

        return out.getvalue()
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:57,代码来源:macros.py

示例11: get_screenshots

 def get_screenshots(self, cursor, component, version):
     columns = ('id', 'name', 'description', 'time', 'author', 'tags',
       'large_file', 'medium_file', 'small_file')
     sql = "SELECT s.id, s.name, s.description, s.time, s.author, s.tags," \
       " s.large_file, s.medium_file, s.small_file FROM screenshot s," \
       " screenshot_component c, screenshot_version v WHERE c.component" \
       " = %s AND v.version = %s AND s.id = c.screenshot AND s.id =" \
       " v.screenshot;"
     self.log.debug(sql % (component, version))
     cursor.execute(sql, (component, version))
     screenshots = []
     for row in cursor:
         row = dict(zip(columns, row))
         row['name'] = wiki_to_oneliner(row['name'], self.env)
         row['description'] = wiki_to_oneliner(row['description'], self.env)
         row['author'] = wiki_to_oneliner(row['author'], self.env)
         screenshots.append(row)
     return screenshots
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:18,代码来源:api.py

示例12: get_task_markup

    def get_task_markup(self, req, ticket, task):
        if not task:
            return ''

        ticket_text = 'ticket #' + str(task['ticket'])
        if task['ticket'] == ticket:
            ticket_text = 'this ticket'
        timedelta = pretty_timedelta(task['starttime'], None);

        return '<li>%s</li>' % wiki_to_oneliner('You have been working on %s for %s' % (ticket_text, timedelta), self.env, req=req)
开发者ID:lexqt,项目名称:EduTracTicketWorklog,代码行数:10,代码来源:ticket_filter.py

示例13: get_timeline_events

    def get_timeline_events(self, req, start, stop, filters):
        format = req.args.get('format')

        status_map = {
            'new': ('newticket', u'créé'),
            'reopened': ('newticket', u'réouvert'),
            'closed': ('closedticket', u'fermé'),
            'edit': ('editedticket', u'mis à jour')
        }

        href = format == 'rss' and req.abs_href or req.href

        def produce((id, t, author, type, summary), status, fields, comment,
                    cid):
            if status == 'edit':
                if 'ticket_details' in filters:
                    info = u''
                    if len(fields) > 0:
                        info = u', '.join([u'<i>%s</i>' % f for f in \
                                          fields.keys()]) + u' modifié<br />'
                else:
                    return None
            elif 'ticket' in filters:
                if status == 'closed' and fields.has_key('resolution'):
                    info = fields['resolution']
                    if info and comment:
                        info = '%s: ' % info
                else:
                    info = ''
            else:
                return None
            kind, verb = status_map[status]
            if format == 'rss':
                title = u'Ticket #%s (%s %s): %s' % \
                        (id, translate(self.env, type).lower(), verb, summary)
            else:
                title = Markup(
                    u'Ticket <em title="%s">#%s</em> (%s) %s par %s', summary,
                    id, translate(self.env, type), verb, author)
            ticket_href = href.ticket(id)
            if cid:
                ticket_href += '#comment:' + cid
            if status == 'new':
                message = unicode(summary)
            else:
                message = Markup(info)
                if comment:
                    if format == 'rss':
                        message += wiki_to_html(
                            comment, self.env, req, db, absurls=True)
                    else:
                        message += wiki_to_oneliner(
                            comment, self.env, db, shorten=True)
            return kind, ticket_href, title, t, author, message
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:54,代码来源:web_ui.py

示例14: render_discussion

    def render_discussion(self, req, cursor):
        # Get request mode
        group, forum, topic, message = self._get_items(req, cursor)
        modes = self._get_modes(req, group, forum, topic, message)
        self.log.debug('modes: %s' % modes)

        # Determine moderator rights.
        if forum:
            is_moderator = (req.authname in forum['moderators']) or \
              req.perm.has_permission('DISCUSSION_ADMIN')
        else:
            is_moderator = req.perm.has_permission('DISCUSSION_ADMIN')

        # Perform mode actions
        self._do_action(req, cursor, modes, group, forum, topic, message,
          is_moderator)

        # Add CSS styles
        add_stylesheet(req, 'common/css/wiki.css')
        add_stylesheet(req, 'discussion/css/discussion.css')
        add_stylesheet(req, 'discussion/css/admin.css')

        # Fill up HDF structure and return template
        req.hdf['discussion.authname'] = req.authname
        req.hdf['discussion.is_moderator'] = is_moderator
        if group:
            group['name'] = wiki_to_oneliner(group['name'], self.env)
            group['description'] = wiki_to_oneliner(group['description'],
              self.env)
            req.hdf['discussion.group'] = group
        if forum:
            forum['name'] = wiki_to_oneliner(forum['name'], self.env)
            forum['description'] = wiki_to_oneliner(forum['description'],
              self.env)
            forum['subject'] = wiki_to_oneliner(forum['subject'], self.env)
            forum['time'] = format_datetime(forum['time'])
            req.hdf['discussion.forum'] = forum
        if topic:
            topic['subject'] = wiki_to_oneliner(topic['subject'], self.env)
            topic['author'] = wiki_to_oneliner(topic['author'], self.env)
            topic['body'] = wiki_to_html(topic['body'], self.env, req)
            topic['time'] = format_datetime(topic['time'])
            req.hdf['discussion.topic'] = topic
        if message:
            message['author'] = wiki_to_oneliner(message['author'], self.env)
            message['body'] = wiki_to_html(message['body'], self.env, req)
            message['time'] = format_datetime(message['time'])
            req.hdf['discussion.message'] = message
        req.hdf['discussion.mode'] = modes[-1]
        req.hdf['discussion.time'] = format_datetime(time.time())
        return modes[-1] + '.cs', None
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:51,代码来源:api.py

示例15: get_forums

 def get_forums(self, req, cursor, order_by = 'subject', desc = False):
     if not order_by in ('topics', 'replies', 'lasttopic', 'lastreply'):
         order_by = 'f.' + order_by
     columns = ('id', 'name', 'author', 'time', 'moderators', 'group',
       'subject', 'description', 'topics', 'replies', 'lasttopic',
       'lastreply')
     sql = "SELECT f.id, f.name, f.author, f.time, f.moderators, " \
       "f.forum_group, f.subject, f.description, ta.topics, ta.replies, " \
       "ta.lasttopic, ta.lastreply FROM forum f LEFT JOIN (SELECT " \
       "COUNT(t.id) AS topics, MAX(t.time) AS lasttopic, SUM(ma.replies) " \
       "AS replies, MAX(ma.lastreply) AS lastreply, t.forum AS forum FROM " \
       " topic t LEFT JOIN (SELECT COUNT(m.id) AS replies, MAX(m.time) AS " \
       "lastreply, m.topic AS topic FROM message m GROUP BY m.topic) ma ON " \
       "t.id = ma.topic GROUP BY forum) ta ON f.id = ta.forum ORDER BY " + \
       order_by + (" ASC", " DESC")[bool(desc)]
     self.log.debug(sql)
     cursor.execute(sql)
     forums = []
     for row in cursor:
         row = dict(zip(columns, row))
         row['moderators'] = wiki_to_oneliner(row['moderators'], self.env)
         row['description'] = wiki_to_oneliner(row['description'], self.env)
         if row['lastreply']:
             row['lastreply'] = pretty_timedelta(float(row['lastreply']))
         else:
             row['lastreply'] = 'No replies'
         if row['lasttopic']:
             self.log.debug('lasttopic: %s' % row['lasttopic'])
             row['lasttopic'] = pretty_timedelta(float(row['lasttopic']))
         else:
             row['lasttopic'] = 'No topics'
         if not row['topics']:
             row['topics'] = 0
         if not row['replies']:
             row['replies'] = 0
         else:
             # SUM on PosgreSQL returns float number.
             row['replies'] = int(row['replies'])
         row['time'] = format_datetime(row['time'])
         forums.append(row)
     return forums
开发者ID:nyuhuhuu,项目名称:trachacks,代码行数:41,代码来源:api.py


注:本文中的trac.wiki.wiki_to_oneliner函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。