Exemplo n.º 1
0
 def expand_macro(self, formatter, name, content, args=None):
     style_args = {'fg': 'color', 'bg': 'background-color',
                   'size': 'font-size'}
     style_values = {'color': '', 'background-color': '', 'font-size': ''}
     space_start = ''
     space_end = ''
     if args:
         text = content
         for k in args.keys():
             style = style_args[k] if k in style_args else k
             style_values[style] = args.get(k)
         html = format_to_html(self.env, formatter.context, text)
     else:
         args = content.split(',')
         text = ','.join(args[:-1])
         args = args[-1].split('/') + ['']*3
         style_values['color'] = args.pop(0).strip()
         # background color is optional
         arg = args.pop(0).strip()
         if len(arg) > 0 and arg[0].isdigit():
             style_values['font-size'] = arg
         else:
             style_values['background-color'] = arg
             style_values['font-size'] = args.pop(0).strip()
         html = format_to_oneliner(self.env, formatter.context, text)
         if text.startswith(u' '):
             space_start = Markup('&nbsp')
         if text.endswith(u' '):
             space_end = Markup('&nbsp')
     if style_values['font-size'].isdigit():
         style_values['font-size'] += '%'
     style = ';'.join('%s:%s' % (k, v) for (k, v) in
                      style_values.iteritems() if v)
     return tag.span(space_start, html, space_end, style=style)
Exemplo n.º 2
0
    def _format_reminder(self,
                         req,
                         ticket,
                         id,
                         time,
                         author,
                         origin,
                         description,
                         delete_button=True):
        now = to_datetime(None)
        time = to_datetime(time)
        if now >= time:
            when = tag(tag.strong("Right now"), " (pending)")
        else:
            when = tag("In ", tag.strong(pretty_timedelta(time)), " (",
                       format_date(time), ")")

        if description:
            context = Context.from_request(req, ticket.resource)
            desc = tag.div(format_to_oneliner(self.env, context, description),
                           class_="description")
        else:
            desc = tag()

        return tag(
            self._reminder_delete_form(req, id) if delete_button else None,
            when, " - added by ",
            tag.em(Chrome(self.env).authorinfo(req, author)), " ",
            tag.span(pretty_timedelta(origin),
                     title=format_datetime(
                         origin, req.session.get('datefmt', 'iso8601'),
                         req.tz)), " ago.", desc)
Exemplo n.º 3
0
 def expand_macro(self, formatter, name, content, args=None):
     style_args = {"fg": "color", "bg": "background-color", "size": "font-size"}
     style_values = {"color": "", "background-color": "", "font-size": ""}
     space_start = ""
     space_end = ""
     if args:
         text = content
         for k in args.keys():
             style = style_args[k] if k in style_args else k
             style_values[style] = args.get(k)
         html = format_to_html(self.env, formatter.context, text)
     else:
         args = content.split(",")
         text = ",".join(args[:-1])
         args = args[-1].split("/") + [""] * 3
         style_values["color"] = args.pop(0).strip()
         # background color is optional
         arg = args.pop(0).strip()
         if len(arg) > 0 and arg[0].isdigit():
             style_values["font-size"] = arg
         else:
             style_values["background-color"] = arg
             style_values["font-size"] = args.pop(0).strip()
         html = format_to_oneliner(self.env, formatter.context, text)
         if text.startswith(u" "):
             space_start = Markup("&nbsp")
         if text.endswith(u" "):
             space_end = Markup("&nbsp")
     if style_values["font-size"].isdigit():
         style_values["font-size"] = "%s%%" % style_values["font-size"]
     style = ";".join("%s:%s" % (k, v) for (k, v) in style_values.iteritems() if v)
     return tag.span(space_start, html, space_end, style=style)
Exemplo n.º 4
0
    def _format_reminder(self, req, ticket, id, time, author, origin, description, delete_button=True):
        now = to_datetime(None)
        time = to_datetime(time)
        if now >= time:
            when = tag(tag.strong("Right now"), " (pending)")
        else:
            when = tag("In ", tag.strong(pretty_timedelta(time)), " (", format_date(time), ")")

        if description:
            context = Context.from_request(req, ticket.resource)
            desc = tag.div(format_to_oneliner(self.env, context, description), class_="description")
        else:
            desc = tag()

        return tag(self._reminder_delete_form(req, id) if delete_button else None, when, " - added by ", tag.em(Chrome(self.env).authorinfo(req, author)), " ", tag.span(pretty_timedelta(origin), title=format_datetime(origin, req.session.get('datefmt', 'iso8601'), req.tz)), " ago.", desc)
Exemplo n.º 5
0
        def to_html(text):
            """
            Format the parsed text from the rows into HTML.
            """
            if not text:
                return ''

            # simple check to determine whether format_to_html or 
            # format_to_oneliner should be used. If there are multiple
            # lines, use format_to_html, otherwise use format_to_oneliner

            stripped_text = text.strip()
            splitlines = stripped_text.splitlines()

            if len(splitlines) > 1:
                formatted_text = format_to_html(self.env, formatter.context, text)
            else:
                formatted_text = '<br />'.join( [format_to_oneliner(self.env, formatter.context, line) \
                    for line in text.splitlines()] ) 
            return Markup( formatted_text )
Exemplo n.º 6
0
    def process_request(self, req):
        """This is the 'main' of this module."""
        #db = self.env.get_db_cnx()
        #ticketlist = {}  # dict of ticket->???
        #revlist = {} # dict of revision->
        repos = self.env.get_repository()
        context = Context.from_request(req, False)

        new_path = req.args.get('new_path')
        new_rev = req.args.get('new')
        old_path = req.args.get('old_path')
        old_rev = req.args.get('old')

        new_path = repos.normalize_path(new_path)
        new_rev = repos.normalize_rev(new_rev)
        old_path = repos.normalize_path(old_path)
        old_rev = repos.normalize_rev(old_rev)
        

#        if not req.perm.has_permission('TICKET_MODIFY'):
#            return req.redirect(req.href.browser())

        old_rev = int(old_rev)
        new_rev = int(new_rev)
        
        ticket = req.args.get('ticket')
        try:
            ticket = int(ticket)
        except Exception:
            ticket = 0
#        req.hdf['review.ticket'] = ticket
#        req.hdf['review.tickethtml'] = tag.a(ticket, req.href.ticket(ticket))

        data = {}

        data['overall_y'] = 0
        data['ticket_id'] = req.args['ticket']
        data['ticket_summary'] = ''
        data['ticket_href'] = req.href.ticket(req.args['ticket'])

        ticket_mgr = TicketManager(self.compmgr)

        db = self.env.get_db_cnx()
        repos = self.env.get_repository()

        revs = ticket_mgr.tkt2revs(self.log, db, repos, req, req.args['ticket'])
        
        if (not revs or len(revs)==0):
            # nothing to review. shouldn't happen
            return ('nothing.html', data, 'text/html')
        elif(len(revs)==1):
            # only one change - just do a changeset view
            return req.redirect(req.href.changeset(revs[0]))

        revcount = 0
        branches = {}         # track each branch separately.
        files = {}            # track all of the files which are affected
        # may be 0 revs.
        revisions = []        # array of munged revisions
        
        for rev in revs:
            chgset = repos.get_changeset(rev)
            # q: (u'trunk/Locale.java', 'file', 'add', None, u'-1')  from r3
            # q: (u'trunk/util.c', 'file', 'edit', u'trunk/util.c', u'2')  from r4
            message = chgset.message or '--'
            revcount = revcount + 1
            revision = {}
            revision['rev'] =  tag.a(rev, req.href.changeset(rev))
            revision['author'] = chgset.author
            revision['num'] =  rev
            revision['comment'] =  message #wiki_to_oneliner( message, self.env, db, shorten=False )
            try:
                revision['comment_wiki'] = format_to_oneliner( self.env, context, message, shorten=False )
            except Exception, e:
                self.env.log.warn(e)
                revision['comment_wiki'] = "%s (could not format - %s)" % (message, str(e))

            rbranches = revision['branches'] = []
            # walk through all changes in this Changeset and apply them to the files[] array
            for chg in chgset.get_changes():
                path = chg[0] # new path
                if path in files:
                    item = files[path] # known file
                else:
                    item = []
                    files[path] = item; # new file
                item.append(self.changeToRange(rev,chg,repos))
                branch_name = self.pathToBranchName(path)
                if branch_name not in rbranches:
                    # first time we have seen this branch
                    rbranches.append(branch_name)
            revisions.append(revision)
Exemplo n.º 7
0
 def to_html(text):
     if not text:
         return ''
     return Markup('<br>'.join([format_to_oneliner(self.env, formatter.context, line) \
                         for line in text.splitlines()]))
Exemplo n.º 8
0
    def process_request(self, req):
        """This is the 'main' of this module."""
        #db = self.env.get_db_cnx()
        #ticketlist = {}  # dict of ticket->???
        #revlist = {} # dict of revision->
        repos = self.env.get_repository()
        context = Context.from_request(req, False)

        new_path = req.args.get('new_path')
        new_rev = req.args.get('new')
        old_path = req.args.get('old_path')
        old_rev = req.args.get('old')

        new_path = repos.normalize_path(new_path)
        new_rev = repos.normalize_rev(new_rev)
        old_path = repos.normalize_path(old_path)
        old_rev = repos.normalize_rev(old_rev)
        

#        if not req.perm.has_permission('TICKET_MODIFY'):
#            return req.redirect(req.href.browser())

        old_rev = int(old_rev)
        new_rev = int(new_rev)
        
        ticket = req.args.get('ticket')
        try:
            ticket = int(ticket)
        except Exception:
            ticket = 0
#        req.hdf['review.ticket'] = ticket
#        req.hdf['review.tickethtml'] = tag.a(ticket, req.href.ticket(ticket))

        data = {}

        data['overall_y'] = 0
        data['ticket_id'] = req.args['ticket']
        data['ticket_summary'] = ''
        data['ticket_href'] = req.href.ticket(req.args['ticket'])

        ticket_mgr = TicketManager(self.compmgr)

        db = self.env.get_db_cnx()
        repos = self.env.get_repository()

        revs = ticket_mgr.tkt2revs(self.log, db, repos, req, req.args['ticket'])
        
        if (not revs or len(revs)==0):
            # nothing to review. shouldn't happen
            return ('nothing.html', data, 'text/html')
        elif(len(revs)==1):
            # only one change - just do a changeset view
            return req.redirect(req.href.changeset(revs[0]))

        revcount = 0
        branches = {}         # track each branch separately.
        files = {}            # track all of the files which are affected
        # may be 0 revs.
        revisions = []        # array of munged revisions
        
        for rev in revs:
            chgset = repos.get_changeset(rev)
            # q: (u'trunk/Locale.java', 'file', 'add', None, u'-1')  from r3
            # q: (u'trunk/util.c', 'file', 'edit', u'trunk/util.c', u'2')  from r4
            message = chgset.message or '--'
            revcount = revcount + 1
            revision = {}
            revision['rev'] =  tag.a(rev, req.href.changeset(rev))
            revision['author'] = chgset.author
            revision['num'] =  rev
            revision['comment'] =  message #wiki_to_oneliner( message, self.env, db, shorten=False )
            try:
                revision['comment_wiki'] = format_to_oneliner( self.env, context, message, shorten=False )
            except Exception, e:
                self.env.log.warn(e)
                revision['comment_wiki'] = "%s (could not format - %s)" % (message, str(e))

            rbranches = revision['branches'] = []
            # walk through all changes in this Changeset and apply them to the files[] array
            for chg in chgset.get_changes():
                path = chg[0] # new path
                if path in files:
                    item = files[path] # known file
                else:
                    item = []
                    files[path] = item; # new file
                item.append(self.changeToRange(rev,chg,repos))
                branch_name = self.pathToBranchName(path)
                if branch_name not in rbranches:
                    # first time we have seen this branch
                    rbranches.append(branch_name)
            revisions.append(revision)