Refactor cmd_view(): move line formatting to a helper method.
This commit is contained in:
parent
9c3848b39b
commit
154c08894b
|
@ -31,10 +31,15 @@ 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]
|
||||
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)
|
||||
|
@ -42,11 +47,8 @@ class WikiPage:
|
|||
word = self.mklink("new", word, word + "*")
|
||||
else:
|
||||
word = escape(word)
|
||||
words[i] = word
|
||||
print "".join(words)
|
||||
print "<hr>"
|
||||
print "<p>", self.mklink("edit", self.name, "Edit this page") + ";"
|
||||
print self.mklink("view", "FrontPage", "go to front page") + "."
|
||||
words.append(word)
|
||||
return "".join(words)
|
||||
|
||||
def cmd_edit(self, form, label="Change"):
|
||||
print "<h1>", label, self.name, "</h1>"
|
||||
|
|
Loading…
Reference in New Issue