Mercurial > moin > 1.9
changeset 6020:b59cef3f6e09
mail import: use relative attachment link markup instead of absolute links (enables some renaming operations without changing the markup)
[[attachment:foo.txt|foo.txt]] is used on the (sub)page where the attachments are put
[[attachment:/SubPage/foo.txt|foo.txt]] is used in the parent page table (optional)
author | Thomas Waldmann <tw AT waldmann-edv DOT de> |
---|---|
date | Mon, 03 Feb 2014 17:14:05 +0100 |
parents | 926d83725c3a |
children | 54dc774ff49b |
files | MoinMoin/mail/mailimport.py docs/CHANGES |
diffstat | 2 files changed, 11 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/MoinMoin/mail/mailimport.py Mon Feb 03 14:32:40 2014 +0100 +++ b/MoinMoin/mail/mailimport.py Mon Feb 03 17:14:05 2014 +0100 @@ -256,7 +256,9 @@ i += 1 # build an attachment link table for the page with the e-mail - attachment_links = [""] + [u'''[[attachment:%s|%s]]''' % ("%s/%s" % (pagename, att), att) for att in attachments] + # use relative attachment link markup here, so the page can be easily + # renamed and the links don't break + attachment_links = [""] + [u'''[[attachment:%s|%s]]''' % (att, att) for att in attachments] # assemble old page content and new mail body together old_content = Page(request, pagename).get_raw_body() @@ -278,7 +280,12 @@ raise ProcessingError("Access denied for page %r" % pagename) if generate_summary and "/" in pagename: - parent_page = u"/".join(pagename.split("/")[:-1]) + splitted = pagename.split("/") + parent_page = u"/".join(splitted[:-1]) + child_page = splitted[-1] + # here, use relative links also, but we need to include the child_page + # name in the relative link as the markup gets put onto the parent_page + attachment_links = [u'''[[attachment:%s|%s]]''' % ("/%s/%s" % (child_page, att), att) for att in attachments] old_content = Page(request, parent_page).get_raw_body().splitlines() found_table = None
--- a/docs/CHANGES Mon Feb 03 14:32:40 2014 +0100 +++ b/docs/CHANGES Mon Feb 03 17:14:05 2014 +0100 @@ -72,6 +72,8 @@ AttachFile view). Be careful: in the same way as you could delete a single attachment with one click, you can now delete all attachments of a page with one click (we don't ask for a 2nd confirmation, so think first). + * mailimport: use relative attachment link markup instead of absolute links, + enables some page renaming operations without needing to edit the markup. Fixes: * do not create empty pagedirs (with empty edit-log). To clean up all the