diff options
-rw-r--r-- | activity.py | 2 | ||||
-rw-r--r-- | py/mwlib/expander.pyc | bin | 17502 -> 17261 bytes | |||
-rw-r--r-- | py/mwlib/htmlwriter.pyc | bin | 13899 -> 13940 bytes | |||
-rw-r--r-- | py/server.py | 23 |
4 files changed, 19 insertions, 6 deletions
diff --git a/activity.py b/activity.py index c4b363f..bde06a8 100644 --- a/activity.py +++ b/activity.py @@ -31,7 +31,7 @@ from searchtoolbar import SearchToolbar # Default settings. HTTP_PORT = '8000' -WIKIDB = '40ormore.xml.bz2' +WIKIDB = 'mad_withtemplates.xml.bz2' HOME_PAGE = '/static/index.html' # Activity class, extends WebActivity. diff --git a/py/mwlib/expander.pyc b/py/mwlib/expander.pyc Binary files differindex 9590837..b9e030f 100644 --- a/py/mwlib/expander.pyc +++ b/py/mwlib/expander.pyc diff --git a/py/mwlib/htmlwriter.pyc b/py/mwlib/htmlwriter.pyc Binary files differindex a5decd8..1e1ee49 100644 --- a/py/mwlib/htmlwriter.pyc +++ b/py/mwlib/htmlwriter.pyc diff --git a/py/server.py b/py/server.py index 768ce2b..5f71be6 100644 --- a/py/server.py +++ b/py/server.py @@ -39,15 +39,28 @@ class WPWikiDB: """Retrieves article contents for mwlib.""" def getRawArticle(self, title): - # Capitalize the first letter of the article -- Trac #6991. - title = title[0].capitalize() + title[1:] - # Replace underscores with spaces in title. - title = title.replace("_", " ") - article_text = wp.wp_load_article(title.encode('utf8')) + print "getRawArticle: %s" % title + + # Retrieve article text, recursively following #redirects. + while True: + # Capitalize the first letter of the article -- Trac #6991. + title = title[0].capitalize() + title[1:] + # Replace underscores with spaces in title. + title = title.replace("_", " ") + article_text = wp.wp_load_article(title.encode('utf8')) + + # To see unmodified article_text, uncomment here. + # print article_text + + m = re.match(r'^\s*\#?redirect\s*\[\[(.*)\]\]', article_text, re.IGNORECASE|re.MULTILINE) + if not m: break + title = m.group(1) + article_text = unicode(article_text, 'utf8') return article_text def getTemplate(self, title, followRedirects=False): + print "getTemplate: %s" % title return self.getRawArticle(title) class WPImageDB: |