Mercurial > moin > 1.9
changeset 529:20f8bda12a7b
fix table *bgcolor trouble, cleanup style synth, fix html_gedit api
imported from: moin--main--1.5--patch-533
author | Thomas Waldmann <tw@waldmann-edv.de> |
---|---|
date | Fri, 07 Apr 2006 19:23:56 +0000 |
parents | 92faed4fbd76 |
children | ab842e426102 |
files | ChangeLog MoinMoin/formatter/text_gedit.py MoinMoin/formatter/text_html.py MoinMoin/parser/wiki.py docs/CHANGES |
diffstat | 5 files changed, 65 insertions(+), 50 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Fri Apr 07 17:35:19 2006 +0000 +++ b/ChangeLog Fri Apr 07 19:23:56 2006 +0000 @@ -2,6 +2,22 @@ # arch-tag: automatic-ChangeLog--arch@arch.thinkmo.de--2003-archives/moin--main--1.5 # +2006-04-07 20:23:56 GMT Thomas Waldmann <tw@waldmann-edv.de> patch-533 + + Summary: + fix table *bgcolor trouble, cleanup style synth, fix html_gedit api + Revision: + moin--main--1.5--patch-533 + + fix table *bgcolor trouble, cleanup style synth, fix html_gedit api + + + modified files: + ChangeLog MoinMoin/formatter/text_gedit.py + MoinMoin/formatter/text_html.py MoinMoin/parser/wiki.py + docs/CHANGES + + 2006-04-07 18:35:19 GMT Thomas Waldmann <tw@waldmann-edv.de> patch-532 Summary:
--- a/MoinMoin/formatter/text_gedit.py Fri Apr 07 17:35:19 2006 +0000 +++ b/MoinMoin/formatter/text_gedit.py Fri Apr 07 19:23:56 2006 +0000 @@ -17,7 +17,7 @@ # Block elements #################################################### - def heading(self, on, depth, id=None, **kw): + def heading(self, on, depth, **kw): # remember depth of first heading, and adapt counting depth accordingly if not self._base_depth: self._base_depth = depth @@ -29,7 +29,7 @@ if not on: return self._close('h%d' % heading_depth) else: - return self._open('h%d' % heading_depth) + return self._open('h%d' % heading_depth, **kw) # Links ############################################################## @@ -51,7 +51,7 @@ @keyword title: override using the interwiki wikiname as title """ if not on: - return '</a>' + return self.url(0) # return '</a>' html_class = 'badinterwiki' # we use badinterwiki in any case to simplify reverse conversion href = wikiutil.quoteWikinameURL(pagename) title = kw.get('title', interwiki) @@ -67,9 +67,7 @@ _ = self.request.getText pagename = self.page.page_name target = AttachFile.getAttachUrl(pagename, url, self.request) - return (self.url( - 1, target, - title="attachment:%s" % wikiutil.quoteWikinameURL(url)) + + return (self.url(1, target, title="attachment:%s" % wikiutil.quoteWikinameURL(url)) + self.text(text) + self.url(0)) @@ -153,6 +151,12 @@ attrs = text_html.Formatter._checkTableAttr(self, attrs, prefix) return self._style_to_attributes(attrs) + _allowed_table_attrs = { + 'table': ['class', 'id', 'style', 'bgcolor', ], + 'row': ['class', 'id', 'style', 'bgcolor', ], + '': ['colspan', 'rowspan', 'class', 'id', 'style', 'bgcolor', ], + } + def table(self, on, attrs=None, **kw): """ Create table @@ -170,7 +174,9 @@ #result.append(self.rawHTML("<!-- ATTRS1: %s -->" % repr(attrs))) attrs = self._checkTableAttr(attrs, 'table') #result.append(self.rawHTML("<!-- ATTRS2: %s -->" % repr(attrs))) - result.append(self._open('table', newline=1, attr=attrs)) + result.append(self._open('table', newline=1, attr=attrs, + allowed_attrs=self._allowed_table_attrs['table'], + **kw)) else: # Close table then div result.append(self._close('table')) @@ -179,41 +185,26 @@ def comment(self, text, **kw): text = text.rstrip() # workaround for growing amount of blanks at EOL - return self.preformatted(1, attr={'class': 'comment'}) + text + self.preformatted(0) + return self.preformatted(1, css_class='comment') + text + self.preformatted(0) - def underline(self, on, **kw): - tag = 'u' - if on: - return self._open(tag) - return self._close(tag) - def strong(self, on, **kw): tag = 'b' if on: - return self._open(tag) + return self._open(tag, allowed_attrs=[], **kw) return self._close(tag) def emphasis(self, on, **kw): tag = 'i' if on: - return self._open(tag) + return self._open(tag, allowed_attrs=[], **kw) return self._close(tag) - def code(self, on, css=None, **kw): - if not css and kw.has_key('css_class'): - css = kw['css_class'] - tag = 'tt' - # Maybe we don't need this, because we have tt will be in inlineStack. - self._in_code = on - if css: - attrs = {"css":css} - else: - attrs = None - + def underline(self, on, **kw): + tag = 'u' if on: - return self._open(tag, attr=attrs) + return self._open(tag, allowed_attrs=[], **kw) return self._close(tag) - + def line_anchordef(self, lineno): return '' # not needed for gui editor feeding
--- a/MoinMoin/formatter/text_html.py Fri Apr 07 17:35:19 2006 +0000 +++ b/MoinMoin/formatter/text_html.py Fri Apr 07 19:23:56 2006 +0000 @@ -1240,7 +1240,7 @@ return {} result = {} - s = "" # we collect synthesized style in s + s = [] # we collect synthesized style in s for key, val in attrs.items(): # Ignore keys that don't start with prefix if prefix and key[:len(prefix)] != prefix: @@ -1249,25 +1249,31 @@ val = val.strip('"') # remove invalid attrs from dict and synthesize style if key == 'width': - s += "width: %s;" % val + s.append("width: %s" % val) elif key == 'height': - s += "height: %s;" % val + s.append("height: %s" % val) elif key == 'bgcolor': - s += "background-color: %s;" % val + s.append("background-color: %s" % val) elif key == 'align': - s += "text-align: %s;" % val + s.append("text-align: %s" % val) elif key == 'valign': - s += "vertical-align: %s;" % val + s.append("vertical-align: %s" % val) # Ignore unknown keys if key not in self._allowed_table_attrs[prefix]: continue result[key] = val - if s: - if result.has_key('style'): - result['style'] += s - else: - result['style'] = s - #self.request.log("_checkTableAttr returns %r" % result) + st = result.get('style', '').split(';') + st = '; '.join(st + s) + st = st.strip(';') + st = st.strip() + if not st: + try: + del result['style'] # avoid empty style attr + except: + pass + else: + result['style'] = st + self.request.log("_checkTableAttr returns %r" % result) return result
--- a/MoinMoin/parser/wiki.py Fri Apr 07 17:35:19 2006 +0000 +++ b/MoinMoin/parser/wiki.py Fri Apr 07 19:23:56 2006 +0000 @@ -688,7 +688,8 @@ # scan attributes attr, msg = wikiutil.parseAttributes(self.request, attrdef, '>', table_extension) - if msg: msg = '<strong class="highlight">%s</strong>' % msg + if msg: + msg = '<strong class="highlight">%s</strong>' % msg #self.request.log("parseAttributes returned %r" % attr) return attr, msg
--- a/docs/CHANGES Fri Apr 07 17:35:19 2006 +0000 +++ b/docs/CHANGES Fri Apr 07 19:23:56 2006 +0000 @@ -35,30 +35,31 @@ Version 1.5.3-current: New Features: - * modified SystemInfo macro to give human readable units and disk usage + * Modified SystemInfo macro to give human readable units and disk usage * cfg.editor_quickhelp makes the quick help below the editor configurable (at least as far as the default_markup is concerned). If set to None, it doesn't display any quickhelp. Thanks to Seth Falcon for the patch. Bugfixes: - * fixed double class attribute for nonexistent links - * fixed double </a> with qm_noexist option - * fixed table xxx="yyy" style attribute parsing - * if not (editor_force and editor_default == 'text') then display GUI mode + * Fixed double class attribute for nonexistent links + * Fixed double </a> with qm_noexist option + * Fixed table xxx="yyy" style attribute parsing + * If not (editor_force and editor_default == 'text') then display GUI mode switch button (this is only a partial fix, but enough to deny the GUI mode to your users completely) * Fixed XSS issue which could lead to cookie theft etc. * Fixed definition list "same level" indenting. * Fixed pagename in log for PackagePages action. - * made <p> self-closing and line-anchors more well-behaved, thanks to + * Made <p> self-closing and line-anchors more well-behaved, thanks to Martin Wilck for the patch. I didn't apply the <ol> patch, because this is no real problem, just a problem of a bad standard. + * Fixed gui editor *bgcolor crash. Other changes: - * moved back UserPreferences action link from menu to top of page (renaming + * Moved back UserPreferences action link from menu to top of page (renaming it to "Preferences"), added "Cancel" button to make it possible to return to the previous page without saving preferences. - * removed formatter.url "attrs" keyword arg that took premade html, we use + * Removed formatter.url "attrs" keyword arg that took premade html, we use separate kw args per attribute now. Version 1.5.3-rc1: