1.1 --- a/TO_DO.txt Fri Jul 19 19:56:39 2013 +0200
1.2 +++ b/TO_DO.txt Sat Jul 20 00:16:34 2013 +0200
1.3 @@ -31,7 +31,7 @@
1.4 Consider incorporating activity information for each user using a macro
1.5 placed on user home pages
1.6
1.7 -Redirects
1.8 +Identifier-to-page redirects
1.9
1.10 Maybe redirect to specific revisions rather than to pages; thus the mapping
1.11 would be from identifiers to page names plus revision numbers
1.12 @@ -52,11 +52,6 @@
1.13 that would cause conflicts in the generated Moin markup should be translated
1.14 with spaces separating them
1.15
1.16 -Handle page renaming (add redirects, perhaps support comments on old revisions):
1.17 -
1.18 - DOC/Making Sure Your Lists Are Private (10715350) renamed from
1.19 - DOC/Making Sure Your List Is Private
1.20 -
1.21 DOC/I've set up Mailman%2C created a list%2C and added myself to the list%2C but I don't get any messages! (4030512)
1.22
1.23 @ in the text causes mailto: auto-linking
2.1 --- a/convert.py Fri Jul 19 19:56:39 2013 +0200
2.2 +++ b/convert.py Sat Jul 20 00:16:34 2013 +0200
2.3 @@ -355,7 +355,7 @@
2.4
2.5 f = codecs.open(manifest, "r", encoding="utf-8")
2.6 try:
2.7 - lines = [x.split("|") for x in f.readlines()]
2.8 + lines = [x.rstrip("\n").split("|") for x in f.readlines()]
2.9 lines.sort(cmp=lambda x, y: cmp(int(x[0]), int(y[0])))
2.10
2.11 # Reconstruct the lines, optionally changing the titles.
2.12 @@ -395,7 +395,7 @@
2.13 if action == "AddRevision":
2.14 columns = list(columns)
2.15 del columns[1]
2.16 - result.append("|".join(columns))
2.17 + result.append("|".join(columns) + "\n")
2.18
2.19 return "".join(result)
2.20
2.21 @@ -449,14 +449,34 @@
2.22
2.23 # Modify the content to include child pages and comments.
2.24
2.25 - for _action, _archive_filename, filename, new_title, username, comment in result:
2.26 - text = read(filename)
2.27 + last_title = None
2.28 + final_result = []
2.29 +
2.30 + for details in result:
2.31 + _action, _archive_filename, filename, new_title, username, comment = details
2.32 +
2.33 + # Detect renamed pages and add a redirect revision.
2.34 +
2.35 + if last_title and last_title != new_title and _action == "AddRevision":
2.36 + renaming_versionfile = filename + ".rename"
2.37 + final_result.append((_action, "_", renaming_versionfile, last_title, username, "Page renamed to %s" % new_title))
2.38 + write(renaming_versionfile, "#REDIRECT %s" % new_title)
2.39 +
2.40 + last_title = new_title
2.41 +
2.42 + # Add this revision to the manifest.
2.43 +
2.44 + final_result.append(details)
2.45 +
2.46 + # Obtain the text only if modifications are to be made.
2.47 +
2.48 + text = None
2.49
2.50 # Add an ACL to comment pages so that people cannot change other
2.51 # people's comments.
2.52
2.53 if type == "Comment":
2.54 - text = "#acl %s:read,write,delete,revert All:read\n%s" % (username, text)
2.55 + text = "#acl %s:read,write,delete,revert All:read\n%s" % (username, text or read(filename))
2.56
2.57 # Add child page information to the content.
2.58
2.59 @@ -476,25 +496,26 @@
2.60
2.61 child_pages.append(" * [[%s|%s]]" % (child_page_name, child_page_label))
2.62
2.63 - text += child_page_section % "\n".join(child_pages)
2.64 + text = (text or read(filename)) + child_page_section % "\n".join(child_pages)
2.65
2.66 # Add comments to the content.
2.67
2.68 if exists(comments) and title and not no_translate:
2.69 - text += comment_section % title
2.70 + text = (text or read(filename)) + comment_section
2.71
2.72 - # Rewrite the file.
2.73 + # Rewrite the file if necessary.
2.74
2.75 - write(filename, text)
2.76 + if text:
2.77 + write(filename, text)
2.78
2.79 # Add the attachments to the manifest.
2.80
2.81 if exists(attachments):
2.82 - result += _sort_manifest(attachments, title)
2.83 + final_result += _sort_manifest(attachments, title)
2.84
2.85 # Serialise the manifest.
2.86
2.87 - s = serialise_manifest(result)
2.88 + s = serialise_manifest(final_result)
2.89
2.90 if output is None:
2.91 write(manifest, s)