Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activity.py2
-rw-r--r--py/mwlib/expander.pycbin17502 -> 17261 bytes
-rw-r--r--py/mwlib/htmlwriter.pycbin13899 -> 13940 bytes
-rw-r--r--py/server.py23
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
index 9590837..b9e030f 100644
--- a/py/mwlib/expander.pyc
+++ b/py/mwlib/expander.pyc
Binary files differ
diff --git a/py/mwlib/htmlwriter.pyc b/py/mwlib/htmlwriter.pyc
index a5decd8..1e1ee49 100644
--- a/py/mwlib/htmlwriter.pyc
+++ b/py/mwlib/htmlwriter.pyc
Binary files differ
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: