Edgewall Software

Ticket #1791: 1791-wikiformatting-text-textarea-r7548.patch

File 1791-wikiformatting-text-textarea-r7548.patch, 7.5 KB (added by rblank, 3 years ago)

Updated patch

  • trac/htdocs/css/report.css

    diff --git a/trac/htdocs/css/report.css b/trac/htdocs/css/report.css
    a b  
    5050/* Styles for the report list and the report results table 
    5151   (extends the styles for "table.listing") */ 
    5252.reports td.title { width: 100% } 
    53 .reports tbody td :link, .reports tbody td :visited, 
    54 .tickets tbody td :link, .tickets tbody td :visited { display: block } 
    5553.tickets { border-bottom: none } 
    5654.tickets thead th { text-transform: capitalize; white-space: nowrap; } 
    5755.tickets tbody td, .reports tbody td { padding: .1em .5em !important } 
  • trac/htdocs/css/ticket.css

    diff --git a/trac/htdocs/css/ticket.css b/trac/htdocs/css/ticket.css
    a b  
    5656 width: 20%; 
    5757} 
    5858#ticket table.properties td { width: 30% } 
     59#ticket table.properties td p:first-child { margin-top: 0 } 
     60#ticket table.properties td p:last-child { margin-bottom: 0 } 
    5961#ticket table.properties .description { border-top: 1px solid #dd9 } 
    6062 
    6163#ticket .description h3 { 
  • trac/ticket/api.py

    diff --git a/trac/ticket/api.py b/trac/ticket/api.py
    a b  
    271271                if '' in field['options']: 
    272272                    field['optional'] = True 
    273273                    field['options'].remove('') 
     274            elif field['type'] == 'text': 
     275                field['format'] = config.get(name + '.format', 'plain') 
    274276            elif field['type'] == 'textarea': 
     277                field['format'] = config.get(name + '.format', 'plain') 
    275278                field['width'] = config.getint(name + '.cols') 
    276279                field['height'] = config.getint(name + '.rows') 
    277280            fields.append(field) 
  • trac/ticket/query.py

    diff --git a/trac/ticket/query.py b/trac/ticket/query.py
    a b  
    573573 
    574574        cols = self.get_columns() 
    575575        labels = dict([(f['name'], f['label']) for f in self.fields]) 
     576        wikify = dict((f['name'], f['type'] == 'text' and f.get('format') == 'wiki') for f in self.fields) 
    576577 
    577578        # TODO: remove after adding time/changetime to the api.py 
    578579        labels['changetime'] = _('Modified') 
     
    580581 
    581582        headers = [{ 
    582583            'name': col, 'label': labels.get(col, _('Ticket')), 
     584            'wikify': wikify.get(col, False), 
    583585            'href': self.get_href(context.href, order=col, 
    584586                                  desc=(col == self.order and not self.desc)) 
    585587        } for col in cols] 
  • trac/ticket/templates/query_results.html

    diff --git a/trac/ticket/templates/query_results.html b/trac/ticket/templates/query_results.html
    a b  
    6262                      <py:when test="name == 'reporter'">${authorinfo(value)}</py:when> 
    6363                      <py:when test="name == 'cc'">${format_emails(ticket_context, value)}</py:when> 
    6464                      <py:when test="name == 'owner' and value">${authorinfo(value)}</py:when> 
     65                      <py:when test="header.wikify">${wiki_to_oneliner(ticket_context, value)}</py:when> 
    6566                      <py:otherwise>$value</py:otherwise> 
    6667                    </td> 
    6768                  </py:with> 
  • trac/ticket/templates/ticket.html

    diff --git a/trac/ticket/templates/ticket.html b/trac/ticket/templates/ticket.html
    a b  
    324324                    </select> 
    325325                    <textarea py:when="'textarea'" id="field-${field.name}" name="field_${field.name}" 
    326326                              cols="${field.width}" rows="${field.height}" 
     327                              class="${field.format == 'wiki' and 'wikitext' or None}" 
    327328                              py:content="value"></textarea> 
    328329                    <span py:when="'checkbox'"> 
    329330                      <input type="checkbox" id="field-${field.name}" name="field_${field.name}" 
  • trac/ticket/tests/api.py

    diff --git a/trac/ticket/tests/api.py b/trac/ticket/tests/api.py
    a b  
    2424        self.env.config.set('ticket-custom', 'test', 'text') 
    2525        self.env.config.set('ticket-custom', 'test.label', 'Test') 
    2626        self.env.config.set('ticket-custom', 'test.value', 'Foo bar') 
     27        self.env.config.set('ticket-custom', 'test.format', 'wiki') 
    2728        fields = TicketSystem(self.env).get_custom_fields() 
    2829        self.assertEqual({'name': 'test', 'type': 'text', 'label': 'Test', 
    29                           'value': 'Foo bar', 'order': 0}, 
     30                          'value': 'Foo bar', 'order': 0, 'format': 'wiki'}, 
    3031                         fields[0]) 
    3132 
    3233    def test_custom_field_select(self): 
     
    5758        self.env.config.set('ticket-custom', 'test.value', 'Foo bar') 
    5859        self.env.config.set('ticket-custom', 'test.cols', '60') 
    5960        self.env.config.set('ticket-custom', 'test.rows', '4') 
     61        self.env.config.set('ticket-custom', 'test.format', 'wiki') 
    6062        fields = TicketSystem(self.env).get_custom_fields() 
    6163        self.assertEqual({'name': 'test', 'type': 'textarea', 'label': 'Test', 
    6264                          'value': 'Foo bar', 'width': 60, 'height': 4, 
    63                           'order': 0}, 
     65                          'order': 0, 'format': 'wiki'}, 
    6466                         fields[0]) 
    6567 
    6668    def test_custom_field_order(self): 
  • trac/ticket/web_ui.py

    diff --git a/trac/ticket/web_ui.py b/trac/ticket/web_ui.py
    a b  
    4848from trac.web.chrome import add_link, add_script, add_stylesheet, \ 
    4949                            add_warning, add_ctxtnav, prevnext_nav, Chrome, \ 
    5050                            INavigationContributor, ITemplateProvider 
    51 from trac.wiki.formatter import format_to 
     51from trac.wiki.formatter import format_to, format_to_html, format_to_oneliner 
    5252 
    5353class InvalidTicket(TracError): 
    5454    """Exception raised when a ticket fails validation.""" 
     
    580580 
    581581        return 'ticket.html', data, None 
    582582 
    583     def _prepare_data(self, req, ticket, absurls=False): 
     583    def _get_preserve_newlines(self): 
    584584        preserve_newlines = self.preserve_newlines 
    585585        if preserve_newlines == 'default': 
    586586            preserve_newlines = self.env.get_version(initial=True) >= 21 # 0.11 
    587         preserve_newlines = preserve_newlines in _TRUE_VALUES 
     587        return preserve_newlines in _TRUE_VALUES 
     588         
     589    def _prepare_data(self, req, ticket, absurls=False): 
    588590        return {'ticket': ticket, 
    589591                'context': Context.from_request(req, ticket.resource, 
    590592                                                absurls=absurls), 
    591                 'preserve_newlines': preserve_newlines} 
     593                'preserve_newlines': self._get_preserve_newlines()} 
    592594 
    593595    def _toggle_cc(self, req, cc): 
    594596        """Return an (action, recipient) tuple corresponding to a change 
     
    11491151                value = ticket.values.get(name) 
    11501152                if value in ('1', '0'): 
    11511153                    field['rendered'] = value == '1' and _('yes') or _('no') 
    1152                    
     1154            elif type_ == 'text': 
     1155                if field.get('format') == 'wiki': 
     1156                    field['rendered'] = format_to_oneliner(self.env, context, 
     1157                                                           ticket[name]) 
     1158            elif type_ == 'textarea': 
     1159                if field.get('format') == 'wiki': 
     1160                    field['rendered'] = \ 
     1161                        format_to_html(self.env, context, ticket[name], 
     1162                                escape_newlines=self._get_preserve_newlines()) 
     1163             
    11531164            # ensure sane defaults 
    11541165            field.setdefault('optional', False) 
    11551166            field.setdefault('options', [])