master
parent
972220412f
commit
0e8f7c336d
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
I modified the script a bit so categories and tags would actually show up in the output file.
|
I modified the script a bit so categories and tags would actually show up in the output file.
|
||||||
|
|
||||||
|
-----
|
||||||
<pre>
|
<pre>
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ I modified the script a bit so categories and tags would actually show up in the
|
||||||
Usage: run --help as an argument with this script.
|
Usage: run --help as an argument with this script.
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
I added some extra bits to include the [[!tag foo]] stuff in the post,
|
I added some extra bits to include the \[[!tag foo]] stuff in the post,
|
||||||
as it wasn't before, at all. I'll diff the versions out so you can see
|
as it wasn't before, at all. I'll diff the versions out so you can see
|
||||||
the mess I made :).
|
the mess I made :).
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ def main(name, email, subdir, branch='master'):
|
||||||
commit_msg = """Importing WordPress post "%s" [%s]""" % (x.title.string, x.guid.string)
|
commit_msg = """Importing WordPress post "%s" [%s]""" % (x.title.string, x.guid.string)
|
||||||
timestamp = time.mktime(time.strptime(x.find('wp:post_date_gmt').string, "%Y-%m-%d %H:%M:%S"))
|
timestamp = time.mktime(time.strptime(x.find('wp:post_date_gmt').string, "%Y-%m-%d %H:%M:%S"))
|
||||||
|
|
||||||
content = '[[!meta title="%s"]]\n\n' % (x.title.string.replace('"', r'\"'))
|
content = '\[[!meta title="%s"]]\n\n' % (x.title.string.replace('"', r'\"'))
|
||||||
content += x.find('content:encoded').string.replace('\r\n', '\n')
|
content += x.find('content:encoded').string.replace('\r\n', '\n')
|
||||||
|
|
||||||
# categories = x.findAll('category')
|
# categories = x.findAll('category')
|
||||||
|
@ -76,8 +76,8 @@ def main(name, email, subdir, branch='master'):
|
||||||
"""
|
"""
|
||||||
We do it differently here because we have duplicates otherwise.
|
We do it differently here because we have duplicates otherwise.
|
||||||
Take a look:
|
Take a look:
|
||||||
<category><![CDATA[Health]]></category>
|
<category><![CDATA[Health]]></category>
|
||||||
<category domain="category" nicename="health"><![CDATA[Health]]></category>
|
<category domain="category" nicename="health"><![CDATA[Health]]></category>
|
||||||
|
|
||||||
If we do the what original did, we end up with all tags and cats doubled.
|
If we do the what original did, we end up with all tags and cats doubled.
|
||||||
Therefore we only pick out nicename="foo". Our 'True' below is our 'foo'.
|
Therefore we only pick out nicename="foo". Our 'True' below is our 'foo'.
|
||||||
|
@ -90,14 +90,14 @@ def main(name, email, subdir, branch='master'):
|
||||||
for cat in categories:
|
for cat in categories:
|
||||||
# remove 'tags/' because we have a 'tagbase' set.
|
# remove 'tags/' because we have a 'tagbase' set.
|
||||||
# your choice: 'tag', or 'taglink'
|
# your choice: 'tag', or 'taglink'
|
||||||
# content += "\n[[!tag %s]]" % (cat.string.replace(' ', '-'))
|
# content += "\n\[[!tag %s]]" % (cat.string.replace(' ', '-'))
|
||||||
content += "\n[[!taglink %s]]" % (cat.string.replace(' ', '-'))
|
content += "\n\[[!taglink %s]]" % (cat.string.replace(' ', '-'))
|
||||||
# print >>sys.stderr, cat.string.replace(' ', '-')
|
# print >>sys.stderr, cat.string.replace(' ', '-')
|
||||||
|
|
||||||
# moved this thing down
|
# moved this thing down
|
||||||
data = content.encode('ascii', 'html_replace')
|
data = content.encode('ascii', 'html_replace')
|
||||||
print "commit refs/heads/%s" % branch
|
print "commit refs/heads/%s" % branch
|
||||||
print "committer %s <%s> %d +0000" % (name, email, timestamp)
|
print "committer %s <%s> %d +0000" % (name, email, timestamp)
|
||||||
print "data %d" % len(commit_msg)
|
print "data %d" % len(commit_msg)
|
||||||
print commit_msg
|
print commit_msg
|
||||||
print "M 644 inline %s" % os.path.join(subdir, "%s.mdwn" % stub)
|
print "M 644 inline %s" % os.path.join(subdir, "%s.mdwn" % stub)
|
||||||
|
@ -111,12 +111,15 @@ if __name__ == "__main__":
|
||||||
main(*sys.argv[1:])
|
main(*sys.argv[1:])
|
||||||
|
|
||||||
</pre>
|
</pre>
|
||||||
|
-----
|
||||||
|
|
||||||
(I don't know why the tag down there says %s other than it's reading in from the <pre>'d script...)
|
(I don't know why the tag down there says %s other than it's reading in from the <pre>'d script...)
|
||||||
|
|
||||||
I have another version of the script, which scans for <pubDate> and inserts that as a \[[!meta date="foodate"]]. Still work in progress since I just got back to it today, after adding in a rough idea. I'll post a link to it here when it's "good enough for me".
|
I have another version of the script, which scans for <pubDate> and inserts that as a \[[!meta date="foodate"]]. Still work in progress since I just got back to it today, after adding in a rough idea. I'll post a link to it here when it's "good enough for me".
|
||||||
|
|
||||||
|
(Hopefully I've escaped everything properly; if I missed something, check the source.)
|
||||||
|
|
||||||
[[!tag wordpress]]
|
[[!tag wordpress]]
|
||||||
[[!tag python]]
|
[[!tag python]]
|
||||||
[[!tag conversion]]
|
[[!tag conversion]]
|
||||||
|
[[!tag ikiwiki]]
|
||||||
|
|
Loading…
Reference in New Issue