Tags:
create new tag
, view all tags

ZwikiToTWikiAddOnDev Discussion: Page for developer collaboration, enhancement requests, patches and improved versions on ZwikiToTWikiAddOn contributed by the TWikiCommunity.
• Please let us know what you think of this extension.
• For support, check the existing questions, or ask a new support question in the Support web!
• Please report bugs below

Feedback on ZwikiToTWikiAddOn

-- PaulWise - 02 Feb 2005

A late "thank you Paul" for sharing this converter!

I added a SHORTDESCRIPTION to the "Add-On Info" section so that this add-on is represented properly in the AddOnPackage topic and query topics. Please feel free to take this into the next release.

-- PeterThoeny - 04 Nov 2006

An even later thank you from me. I've updated and expanded the script a bit so that it should now work with TWiki 4.3.1. The main additional features are:

  • add the .txt ending to all files replace non-CamelCase Zwiki links ([ ...] ) so that they work in TWiki ( [[...]])
  • try to name files correctly so that they work in TWiki (e.g. if Zwiki page names contain dots or spaces)
  • format numbered and bulleted lists so that they are correctly displayed in TWiki
  • also format headings for bulleted/numbered lists as Zwiki would do (ie. make them bold)

here is the script

#!/usr/bin/python
import sys
import os
import re
import string

f = file(sys.argv[1])
data = f.read().strip()
stuff = data.split("-----------------------------------------------------------")
bits = []
for bit in stuff:
   bits.append(bit.split("\n----\n"))
try:
   os.mkdir('zwiki')
except:
   pass
for bit in bits:
   path = bit[0].strip()
   if re.search("-",path):
    temp = re.split("-",path,1)
    temp[1] = string.capwords(temp[1])
    #replace dots in first bit
    temp[0] = re.sub("\.","-",temp[0])
    path=string.join(temp,"-")
    
   path = re.sub("\s","",path)
   #print path
   path = os.path.join('zwiki',path)
   path2 = path + ".txt"
    
   try:
      f1 = file(path,'wb')
   except:
      continue

   #make links from [link] to [[link]]    
   body = bit[1].strip()
   body=re.sub("\[","[[",body)
   body=re.sub("\]","]]",body)

   #getting better formatting
   #########################

   #get bold headings for bulleted list
   p = re.compile('\n(\S.*?)\n\n \*')
   body=p.sub('\n---+++ \g<1>\n\n *',body)

   #format bulleted lists    
   body=re.sub("\n     \*","               *",body)
   body=re.sub("\n    \*","            *",body)   
   body=re.sub("\n   \*","         *",body)
   body=re.sub("\n  \*","      *",body)
   body=re.sub("\n \*","\n   *",body)

   #format numbered lists
   body=re.sub("\n     \d\.","               1",body)
   body=re.sub("\n    \d\.","            1",body)
   body=re.sub("\n   \d\.","         1",body)
   body=re.sub("\n  \d\.","      1",body)
   body=re.sub("\n \d\.","\n   1",body)

   #body = str.encode(body,'utf_16')    
   f1.write(body)
   f1.close()
   os.rename(path,path2)


use it in this way:

  • run the script on the pages you've downloaded, e.g. ./zwiki-split.py your-directories/my-export-script
  • it will create a folder called zwiki containing text files for each page in your orginal Zwiki but formatted to (hopefully) work and display properly in your new TWiki Web
  • it is best to create a new empty TWiki Web
  • copy all the files from the zwiki folder into the new TWiki Web by moving them into path-to-your-Twiki/data/your-new-web
  • chown apache:apache all the files in the TwikiWeb directory

-- TobiasEscher - 2009-07-02

Thanks Tobias!

It would be helpful to package your script as ZwikiToTWikiAddOn.zip and attach it to the add-on page. The reports in the Plugins web assume a <package>.zip name for the download links. See also AddOnPackageHowTo.

-- PeterThoeny - 2009-07-02

Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2009-07-02 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.