Re: Experiencing problems to connect to common-lisp.net over ssh.
Philippe Brochard <[email protected]>
| Newsgroups | gmane.lisp.common-lisp-net.devel |
|---|---|
| Message-ID | <[email protected]> |
Mark Evenson <[email protected]> writes: > On 2015/9/1 10:10, Philippe Brochard wrote: >> Erik Huelsmann <[email protected]> writes: > > […] >>> Is this a project that's currently stored in Git already? If not, do >>> you need help converting from Subversion/Darcs/Bazaar/...? >>> >> Yes, the project is CLFSWM and it uses git for quite some time. The use >> of gitlab for the project is working fine. >> I just need to update the project page with updated information about >> how to clone the code from gitlab. >> >> I'd like to use the gitlab wiki instead of trac. I have found some way >> to convert pages from trac.db to gitlab markdown. But if you have >> already done this for other projects you can also do it for CLFSWM. >> On the other way, I'll can share the procedure to convert a trac wiki to >> a gitlab wiki (if I can do it). > > Yes, please share such a procedure if possible no matter how > rudimentary. There are other projects who could benefit from such a > migration. We'd be especially interested in HTTP rewrites that would > bounce old links to new locations. > Ok, I've converted the CLFSWM trac wiki to Gitlab wiki. Here is the procedure I have used: Copy trac.db in a directory In the same directory, fetch trac2down.py (or one of its fork) from: https://gist.github.com/sgk/1286682#file-trac2down-py I have modified it a little to fit the CLFSWM trac (the script is attached with this email). And then in this directory: $ git clone [email protected]:clfswm/clfswm.wiki.git $ cd clfswm.wiki/ $ ls --- empty directory --- $ ../trac2down.py $ ls BindingHook.md CLFSWM.md DescribeHook.md GIT.md InFrench.md MenuCustomization.md Patches.md Setup.md UserAPI.md Bugs.md Contribute.md English.md Home.md InitHook.md NewIdeas.md SVN.md Start.md UserConfiguration.md BuildClisp.md Customize.md FAQ.md Hooks.md KeybindingCustomization.md NewWindowHook.md Sandbox.md TipsAndTricks.md start-french.md $ git add * $ git commit -a -m "Convert Trac to Gitlab" [ Check if all is ok with gollum ] $ git push origin HEAD Here is the result: From: https://trac.common-lisp.net/clfswm/wiki/WikiStart To: https://gitlab.common-lisp.net/clfswm/clfswm/wikis/home The page Outline is not (maybe yet) converted to a table of content. Hope this helps. Best regards, Philippe PS: Feel free to ask if you have any remarks.
trac2down.py
(text/x-python, 2.3 KB)
#!/usr/bin/python2
# vim:set fileencoding=utf-8 sw=2 ai:
import sqlite3
import datetime
import re
SQL = '''
select
name, version, time, author, text
from
wiki w
where
version = (select max(version) from wiki where name = w.name)
'''
conn = sqlite3.connect('../trac.db')
result = conn.execute(SQL)
for row in result:
name = row[0]
if name == "WikiStart":
name = "Home"
version = row[1]
time = row[2]
author = row[3]
text = row[4]
if author != "trac":
#fp = file('%s.orig' % name, 'w')
#fp.write(text.encode('utf-8'))
#fp.close()
text = re.sub('\r\n', '\n', text)
text = re.sub(r'{{{(.*?)}}}', r'`\1`', text)
def indent4(m):
return '\n ' + m.group(1).replace('\n', '\n ')
text = re.sub(r'{{{|}}}', r'```', text)
text = re.sub(r'(?m)^====\s+(.*?)\s+====$', r'#### \1', text)
text = re.sub(r'(?m)^===\s+(.*?)\s+===$', r'### \1', text)
text = re.sub(r'(?m)^==\s+(.*?)\s+==$', r'## \1', text)
text = re.sub(r'(?m)^=\s+(.*?)\s+=$', r'# \1', text)
text = re.sub(r'^ * ', r'****', text)
text = re.sub(r'^ * ', r'***', text)
text = re.sub(r'^ * ', r'**', text)
text = re.sub(r'^ * ', r'*', text)
text = re.sub(r'^ \d+. ', r'1.', text)
text = re.sub(r'(?m)\[\[BR\]\]$', ' ', text)
text = re.sub(r'(\[\[PageOutline\]\])', r'<!-- \1 -->', text)
a = []
for line in text.split('\n'):
if not line.startswith(' '):
line = re.sub(r'\[(https?://[^\s\[\]]+)\s([^\[\]]+)\]', r'[\2](\1)', line)
line = re.sub(r'\[(https?://[^\s\[\]]+)\]', r'<\1>', line)
line = re.sub(r'\[wiki:([^\s\[\]]+)\s([^\[\]]+)\]', r'[\2](\1)', line)
line = re.sub(r'\[wiki:([^\s\[\]]+)\]', r'[\1](\1)', line)
line = re.sub(r'\!(([A-Z][a-z0-9]+){2,})', r'\1', line)
line = re.sub(r'\'\'\'(.*?)\'\'\'', r'*\1*', line)
line = re.sub(r'\'\'(.*?)\'\'', r'_\1_', line)
a.append(line)
text = '\n'.join(a)
fp = file('%s.md' % name, 'w')
print >>fp, '<!-- Name: %s -->' % name
print >>fp, '<!-- Version: %d -->' % version
print >>fp, '<!-- Last-Modified: %s -->' % datetime.datetime.fromtimestamp(time/1000000).strftime('%Y/%m/%d %H:%M:%S')
print >>fp, '<!-- Author: %s -->' % author
fp.write(text.encode('utf-8'))
fp.close()