diff options
-rw-r--r-- | Demo/cgi/wiki.py | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/Demo/cgi/wiki.py b/Demo/cgi/wiki.py index c04b57e..ee094a8 100644 --- a/Demo/cgi/wiki.py +++ b/Demo/cgi/wiki.py @@ -31,23 +31,25 @@ class WikiPage: line = line.rstrip() if not line: print "<p>" - continue - words = re.split('(\W+)', line) - for i in range(len(words)): - word = words[i] - if self.iswikiword(word): - if os.path.isfile(self.mkfile(word)): - word = self.mklink("view", word, word) - else: - word = self.mklink("new", word, word + "*") - else: - word = escape(word) - words[i] = word - print "".join(words) + else: + print self.formatline(line) print "<hr>" print "<p>", self.mklink("edit", self.name, "Edit this page") + ";" print self.mklink("view", "FrontPage", "go to front page") + "." + def formatline(self, line): + words = [] + for word in re.split('(\W+)', line): + if self.iswikiword(word): + if os.path.isfile(self.mkfile(word)): + word = self.mklink("view", word, word) + else: + word = self.mklink("new", word, word + "*") + else: + word = escape(word) + words.append(word) + return "".join(words) + def cmd_edit(self, form, label="Change"): print "<h1>", label, self.name, "</h1>" print '<form method="POST" action="%s">' % self.scripturl |