Mercurial > moin > 1.9
changeset 36:eb3b18ffb28b
fixed some english strings, better converter debugging msgs, move lineno anchors to formatter
imported from: moin--main--1.5--patch-37
author | Thomas Waldmann <tw@waldmann-edv.de> |
---|---|
date | Sun, 25 Sep 2005 17:47:45 +0000 |
parents | f0af060fb82b |
children | cbbf74e430db |
files | MoinMoin/PageEditor.py MoinMoin/PageGraphicalEditor.py MoinMoin/converter/text_html_text_x_moin.py MoinMoin/formatter/base.py MoinMoin/formatter/text_gedit.py MoinMoin/formatter/text_html.py MoinMoin/parser/wiki.py MoinMoin/util/diff.py |
diffstat | 8 files changed, 114 insertions(+), 83 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/PageEditor.py Sun Sep 25 14:45:38 2005 +0000 +++ b/MoinMoin/PageEditor.py Sun Sep 25 17:47:45 2005 +0000 @@ -195,7 +195,7 @@ if not ok: # failed to get the lock if preview is not None: - edit_lock_message = _('The lock you held timed out, be prepared for editing conflicts!' + edit_lock_message = _('The lock you held timed out. Be prepared for editing conflicts!' ) + "<br>" + edit_lock_message else: msg = edit_lock_message
--- a/MoinMoin/PageGraphicalEditor.py Sun Sep 25 14:45:38 2005 +0000 +++ b/MoinMoin/PageGraphicalEditor.py Sun Sep 25 17:47:45 2005 +0000 @@ -79,7 +79,7 @@ if not ok: # failed to get the lock if preview is not None: - edit_lock_message = _('The lock you held timed out, be prepared for editing conflicts!' + edit_lock_message = _('The lock you held timed out. Be prepared for editing conflicts!' ) + "<br>" + edit_lock_message else: msg = edit_lock_message
--- a/MoinMoin/converter/text_html_text_x_moin.py Sun Sep 25 14:45:38 2005 +0000 +++ b/MoinMoin/converter/text_html_text_x_moin.py Sun Sep 25 17:47:45 2005 +0000 @@ -230,7 +230,7 @@ elif name in ('ol', 'ul',): self.process_list(node) else: - raise MoinMoin.error.ConvertError("Don't support %s element" % name) + raise MoinMoin.error.ConvertError("visit_element: Don't support %s element" % name) def process_br(self, node): self.text.append('\n') # without this, std multi-line text below some heading misses a whitespace @@ -371,7 +371,7 @@ elif name in ('br',): self.process_br(i) else: - raise MoinMoin.error.ConvertError("Don't support %s element" % name) + raise MoinMoin.error.ConvertError("process_blockquote: Don't support %s element" % name) self.depth -= 1 def process_page(self, node): @@ -423,7 +423,7 @@ self.text.append(text) # so we just drop the header markup and keep the text return else: - raise MoinMoin.error.ConvertError("Don't support %s element" % name) + raise MoinMoin.error.ConvertError("process_inline: Don't support %s element" % name) self.text.append(command) for i in node.childNodes: @@ -630,8 +630,10 @@ elif name == 'caption': self.process_caption(node, i, style) style = '' + elif name == 'a': # maybe one of our line-XXX anchors + pass else: - raise MoinMoin.error.ConvertError("Don't support %s element" % name) + raise MoinMoin.error.ConvertError("process_table: Don't support %s element" % name) #else: # raise MoinMoin.error.ConvertError("Unexpected node: %r" % i) self.text.append("\n") @@ -707,7 +709,7 @@ self.process_table_data(i, style=style) style = "" else: - raise MoinMoin.error.ConvertError("Don't support %s element" % name) + raise MoinMoin.error.ConvertError("process_table_record: Don't support %s element" % name) self.text.append("||\n") def _unquote_url(self, url): # XXX is it necessary to have "yet another unquote function"? @@ -719,85 +721,95 @@ scriptname = self.request.getScriptname() if scriptname == "": scriptname = "/" - href = self._unquote_url(node.attributes.get("href").nodeValue) - title = class_ = interwikiname = None + # can either be a link (with href) or an anchor (with e.g. id) + href = node.attributes.get("href", None) + if href: + href = self._unquote_url(href.nodeValue) + id = node.attributes.get("id", None) + if id: + id = id.nodeValue + + if href: + title = class_ = interwikiname = None - if node.attributes.has_key("title"): - title = node.attributes.get("title").nodeValue - if node.attributes.has_key("class"): - class_ = node.attributes.get("class").nodeValue + if node.attributes.has_key("title"): + title = node.attributes.get("title").nodeValue + if node.attributes.has_key("class"): + class_ = node.attributes.get("class").nodeValue - text = self.node_list_text_only(node.childNodes) - text = text.replace("\n", " ").lstrip() + text = self.node_list_text_only(node.childNodes) + text = text.replace("\n", " ").lstrip() - # interwiki link - if class_ == "interwiki": - wikitag, wikiurl, wikitail, err = wikiutil.resolve_wiki( - self.request, title + ":") - if not err and href.startswith(wikiurl): - pagename = href[len(wikiurl):].lstrip('/') - interwikiname = "%s:%s" % (wikitag, pagename) - else: - raise MoinMoin.error.ConvertError("Invalid InterWiki link: '%s'" % href) - elif class_ == "badinterwiki" and title: - pagename = href - interwikiname = "%s:%s" % (title, href) - if interwikiname and pagename == text: # XXX interwiki can be undefined here!? - self.text.append("%s" % interwikiname) - return - elif title == 'Self': - self.text.append("[:%s:%s]" % (href, text)) - return - elif interwikiname: - self.text.append("[wiki:%s %s]" % (interwikiname, text)) - return - - # fix links generated by a broken copy & paste of gecko based browsers - brokenness = '../../../..' - if href.startswith(brokenness): - href = href[len(brokenness):] # just strip it away! - # TODO: IE pastes complete http://server/Page/SubPage as href and as text, too + # interwiki link + if class_ == "interwiki": + wikitag, wikiurl, wikitail, err = wikiutil.resolve_wiki( + self.request, title + ":") + if not err and href.startswith(wikiurl): + pagename = href[len(wikiurl):].lstrip('/') + interwikiname = "%s:%s" % (wikitag, pagename) + else: + raise MoinMoin.error.ConvertError("Invalid InterWiki link: '%s'" % href) + elif class_ == "badinterwiki" and title: + pagename = href + interwikiname = "%s:%s" % (title, href) + if interwikiname and pagename == text: # XXX interwiki can be undefined here!? + self.text.append("%s" % interwikiname) + return + elif title == 'Self': + self.text.append("[:%s:%s]" % (href, text)) + return + elif interwikiname: + self.text.append("[wiki:%s %s]" % (interwikiname, text)) + return + + # fix links generated by a broken copy & paste of gecko based browsers + brokenness = '../../../..' + if href.startswith(brokenness): + href = href[len(brokenness):] # just strip it away! + # TODO: IE pastes complete http://server/Page/SubPage as href and as text, too - # Attachments - if title and title.startswith("attachment:"): - url = self._unquote_url(title[len("attachment:"):]) - if url != text: - self.text.append("[%s %s]" % (title, text)) - else: - self.text.extend([self.white_space, title, self.white_space]) - # wiki link - elif href.startswith(scriptname): - pagename = href[len(scriptname):].replace('_', ' ') - pagename = pagename.lstrip('/') # XXX temp fix for generated pagenames starting with / - if text == pagename: - self.text.append(wikiutil.pagelinkmarkup(pagename)) - # relative link /SubPage - elif href.endswith(text): - if pagename.startswith(self.pagename): # is this a subpage of us? - self.text.append(wikiutil.pagelinkmarkup(pagename[len(self.pagename):])) + # Attachments + if title and title.startswith("attachment:"): + url = self._unquote_url(title[len("attachment:"):]) + if url != text: + self.text.append("[%s %s]" % (title, text)) else: + self.text.extend([self.white_space, title, self.white_space]) + # wiki link + elif href.startswith(scriptname): + pagename = href[len(scriptname):].replace('_', ' ') + pagename = pagename.lstrip('/') # XXX temp fix for generated pagenames starting with / + if text == pagename: self.text.append(wikiutil.pagelinkmarkup(pagename)) - # relative link ../ - elif href.endswith(text.lstrip("..").lstrip("/")): - self.text.append(wikiutil.pagelinkmarkup(text)) + # relative link /SubPage + elif href.endswith(text): + if pagename.startswith(self.pagename): # is this a subpage of us? + self.text.append(wikiutil.pagelinkmarkup(pagename[len(self.pagename):])) + else: + self.text.append(wikiutil.pagelinkmarkup(pagename)) + # relative link ../ + elif href.endswith(text.lstrip("..").lstrip("/")): + self.text.append(wikiutil.pagelinkmarkup(text)) + # labeled link + else: + self.text.append("[:%s:%s]" % (pagename, text)) + # mailto link + elif href.startswith("mailto:"): + if href[len("mailto:"):] == text: + self.text.extend([self.white_space, text, self.white_space]) + else: + self.text.append("[%s %s]" % (href, text)) + # simple link + elif href == text: + self.text.append("%s" % href) + # imagelink + elif text == "" and wikiutil.isPicture(href): + self.text.append("[%s]" % href) # labeled link else: - self.text.append("[:%s:%s]" % (pagename, text)) - # mailto link - elif href.startswith("mailto:"): - if href[len("mailto:"):] == text: - self.text.extend([self.white_space, text, self.white_space]) - else: self.text.append("[%s %s]" % (href, text)) - # simple link - elif href == text: - self.text.append("%s" % href) - # imagelink - elif text == "" and wikiutil.isPicture(href): - self.text.append("[%s]" % href) - # labeled link - else: - self.text.append("[%s %s]" % (href, text)) + elif id: + pass # we dont support anchors yet def process_img(self, node): src = None
--- a/MoinMoin/formatter/base.py Sun Sep 25 14:45:38 2005 +0000 +++ b/MoinMoin/formatter/base.py Sun Sep 25 17:47:45 2005 +0000 @@ -91,9 +91,15 @@ def anchordef(self, name): return "" + def line_anchordef(self, lineno): + return "" + def anchorlink(self, on, name='', id=None): return "" + def line_anchorlink(self, on, lineno=0): + return "" + def image(self, **kw): """ Take HTML <IMG> tag attributes in `attr`.
--- a/MoinMoin/formatter/text_gedit.py Sun Sep 25 14:45:38 2005 +0000 +++ b/MoinMoin/formatter/text_gedit.py Sun Sep 25 17:47:45 2005 +0000 @@ -237,3 +237,10 @@ if on: return self.open(tag, attr=attrs) return self.close(tag) + + def line_anchordef(self, lineno): + return '' # not needed for gui editor feeding + + def line_anchorlink(self, on, lineno=0): + return '' # not needed for gui editor feeding +
--- a/MoinMoin/formatter/text_html.py Sun Sep 25 14:45:38 2005 +0000 +++ b/MoinMoin/formatter/text_html.py Sun Sep 25 17:47:45 2005 +0000 @@ -286,12 +286,18 @@ def anchordef(self, id): return '<a id="%s"></a>\n' % (id, ) - def anchorlink(self, on, name='', id = None): + def line_anchordef(self, lineno): + return self.anchordef("line-%d" % lineno) + + def anchorlink(self, on, name='', id=None): extra = '' if id: extra = ' id="%s"' % id return ['<a href="#%s"%s>' % (name, extra), '</a>'][not on] + def line_anchorlink(self, on, lineno=0): + return self.anchorlink(on, name="line-%d" % lineno) + # Attachments ###################################################### def attachment_link(self, url, text, **kw):
--- a/MoinMoin/parser/wiki.py Sun Sep 25 14:45:38 2005 +0000 +++ b/MoinMoin/parser/wiki.py Sun Sep 25 17:47:45 2005 +0000 @@ -932,7 +932,7 @@ # Main loop for line in self.lines: self.lineno += 1 - self.request.write('<a id="line-%d"></a>' % self.lineno) # TODO move to formatter + self.request.write(self.formatter.line_anchordef(self.lineno)) self.table_rowstart = 1 self.line_was_empty = self.line_is_empty self.line_is_empty = 0
--- a/MoinMoin/util/diff.py Sun Sep 25 14:45:38 2005 +0000 +++ b/MoinMoin/util/diff.py Sun Sep 25 17:47:45 2005 +0000 @@ -29,7 +29,6 @@ """ _ = request.getText t_line = _("Line") + " %d" - target = '#line-%d' seq1 = old.splitlines() seq2 = new.splitlines() @@ -69,13 +68,14 @@ result += """ <tr class="diff-title"> <td> -<a href="%s">%s</a>: +%s: </td> <td> -<a href="%s">%s</a>: +%s: </td> </tr> -""" % ( target % llineno, t_line % llineno, target % rlineno, t_line % rlineno) +""" % ( request.formatter.line_anchorlink(1, llineno) + request.formatter.text(t_line % llineno) + request.formatter.line_anchorlink(0), + request.formatter.line_anchorlink(1, rlineno) + request.formatter.text(t_line % rlineno) + request.formatter.line_anchorlink(0)) leftpane = '' rightpane = ''