"""
Copyright 2006-2008 SpringSource (http://springsource.com), All Rights Reserved
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import re
intrawikiR = re.compile("\[\[(?P.*?)(\|(?P.*?))?\]\](?P[a-zA-Z0-9]*)")
externalLinkR = re.compile("\[(?P.*?)\s(?P.*)\]")
header1R = re.compile("=(?P.*)=")
header2R = re.compile("==(?P.*)==")
header3R = re.compile("===(?P.*)===")
header4R = re.compile("====(?P.*)====")
header5R = re.compile("=====(?P.*)=====")
class Page(object):
def __init__(self, article, wikitext, controller):
self.article = article
self.wikitext = wikitext
self.controller = controller
def makeAList(self, wikitext):
keyCharR = re.compile("(([*#]+)(.*))")
tokens = wikitext.split("\n")
bulletCount = 0
currentLevel = 0
tagStack = []
for i in range(1,len(tokens)):
if tokens[i]:
match = keyCharR.match(tokens[i])
if match:
token = match.groups()[1]
text = match.groups()[2]
if len(token) > currentLevel:
tokens[i] = ""
for j in range(currentLevel, len(token)):
if token[j] == "*":
tagStack.append("")
tokens[i] += "
Diff selection: mark the radio boxes of the versions to compare and hit enter or the button at the bottom.
Legend: (cur) = difference with current version,
(last) = difference with preceding version, M = minor edit.
"""
return results
def html(self):
results = self.header()
results += """
"""
results += self.generateHistory()
results += """
"""
results += self.footer(selected="history")
return results
class OldPage(Page):
def __init__(self, article, wikitext, controller):
Page.__init__(self, article, wikitext, controller)
class NoPage(Page):
def __init__(self, article, controller):
Page.__init__(self, article, "This page does not yet exist.", controller)
class DeletePage(Page):
def __init__(self, article, controller):
Page.__init__(self, article, "This page does not yet exist.", controller)
def header(self):
"""Standard header used for all pages"""
return """
SpringWiki :: a Spring Python demonstration
""" + self.article + """
From Springwiki
(Deleting "%s")
""" % self.article
def html(self):
results = self.header()
results += """
"""
results += """
Warning: The page you are about to delete has a history
You are about to permanently delete a page or image along with all of its history from the database.
Please confirm that you intend to do this, that you understand the consequences.