Esempio n. 1
0
    def render_macro(self, req, name, content):
        from trac.util import sorted
        from trac.util.html import html as _
        interwikis = []
        for k in sorted(self.keys()):
            prefix, url, title = self[k]
            interwikis.append({
                'prefix':
                prefix,
                'url':
                url,
                'title':
                title,
                'rc_url':
                self._expand_or_append(url, ['RecentChanges']),
                'description':
                title == prefix and url or title
            })

        return _.TABLE(_.TR(_.TH(_.EM("Prefix")), _.TH(_.EM("Site"))), [
            _.TR(_.TD(_.A(w['prefix'], href=w['rc_url'])),
                 _.TD(_.A(w['description'], href=w['url'])))
            for w in interwikis
        ],
                       class_="wiki interwiki")
Esempio n. 2
0
    def expand_macro(self, formatter, name, args):
        env = formatter.env
        req = formatter.req

        arg = args.split('||')
        duedate = arg[0].strip()
        summary = arg[1].strip()
        effort = arg[2].strip()
        user = req.args['user']
        project = req.args['project']

        db = env.get_db_cnx()
        cursor = db.cursor()

        sql = "SELECT id, owner, summary, description, status FROM ticket WHERE summary=%s"
        cursor.execute(sql, [summary])

        row = cursor.fetchone()
        if row == None:
            link = html.A(
                escape(summary),
                href=
                "%s?field_summary=%s&field_type=task&field_duedate=%s&field_effort=%s&field_owner=%s&field_project=%s"
                % (env.href.newticket(), escape(summary), escape(duedate),
                   escape(effort), escape(user), escape(project)))
        else:
            user = row[1]
            link = html.A("#%s %s" % (row[0], escape(row[2])),
                          href=env.href.ticket(row[0]),
                          class_=row[4])

        req.args['effort'] = req.args['effort'] + float(effort)

        return html.TR(html.TD(escape(user)), html.TD(duedate), html.TD(link),
                       html.TD(effort))
Esempio n. 3
0
 def generate_prefix(prefix):
     intertrac = intertracs[prefix]
     if isinstance(intertrac, basestring):
         yield html.TR(html.TD(html.B(prefix)),
                       html.TD('Alias pour ', html.B(intertrac)))
     else:
         url = intertrac.get('url', '')
         if url:
             title = intertrac.get('title', url)
             yield html.TR(html.TD(html.A(html.B(prefix),
                                          href=url + '/timeline')),
                           html.TD(html.A(title, href=url)))
Esempio n. 4
0
    def render_macro(self, req, name, filter):
        from trac.config import Option
        from trac.wiki.formatter import wiki_to_html, wiki_to_oneliner
        filter = filter or ''

        sections = set([section for section, option in Option.registry.keys()
                        if section.startswith(filter)])

        return html.DIV(class_='tracini')(
            [(html.H2('[%s]' % section, id='%s-section' % section),
              html.TABLE(class_='wiki')(
                  html.TBODY([html.TR(html.TD(html.TT(option.name)),
                                      html.TD(wiki_to_oneliner(option.__doc__,
                                                               self.env)))
                              for option in Option.registry.values()
                              if option.section == section])))
             for section in sorted(sections)])
Esempio n. 5
0
    def render_macro(self, req, name, content):
        found = []
        output = {}
        imgMacro = ImageMacro(self.env)

        for path in (self.env_htdocs, ):
            if not os.path.exists(path):
                continue
            for filename in [
                    filename for filename in os.listdir(path)
                    if filename.lower().endswith('.png') or filename.lower().
                    endswith('.gif') or filename.lower().endswith('.jpg')
            ]:
                found.append(filename)
        for item in found:
            output['Use: [[Image(htdocs:' + item +
                   ')]]'] = imgMacro.render_macro(req, 'Image',
                                                  'htdocs:' + item)

        return html.TABLE(class_='wiki')(html.TBODY([
            html.TR(html.TD(html.TT(output[key])), html.TD(key))
            for key in sorted(output.keys())
        ]))