Support for WikiTemplate plugin
|Reported by:||Owned by:||Noah Kantrowitz|
To start with, nice plugin, it's been immensly helpful in helping us keep our documentation organized. Follows a small patch to add support for the Include macro, by also renaming Include calls (yes, shameless copy/paste of your own code).
At the end of utils.py, add the following
# Get a list of all wiki pages containing Includes to the old page if debug: env.log.debug( "WikiRename: Trying to fix includes" ) sql = 'SELECT w1.version,w1.name,w1.text' + sqlbase + "AND w1.text like '%%[Include(%s)%%'" % oldname if debug: env.log.debug( "WikiRename: Running query '%s'" % sql ) cursor.execute(sql) # Rewrite all links to the old page, such as to point to the new page for row in list(cursor): if debug: env.log.debug( "WikiRename: Found a page with an Include in it: %s (v%s)" % (row,row) ) newtext = sre.sub('\[Include\(%s\)'%oldname,'[Include(%s)'%newname,row) cursor.execute('UPDATE wiki SET text=%s WHERE name=%s AND version=%s', (newtext,row,row)) if handle_commit: db.commit()
if handle_commit: db.commit()
You might also feel like merging this query with the previous one and replace "
wiki:" calls at the same time as "
Include()" calls, but I actually prefer to keep them seperate.
I also suggest replacing the "
if debug: print(" calls with "
if debug: env.log.debug(" calls.
Thanks in advance,
- Jorge Pereira