print '<p class="modified">last modified %s</p>' % mod_string
print '</div></body></html>'
-# Macros ------------------------------------------------------------
-def _macro_HttpGet(argv):
- if argv[1] in form:
- return form[argv[1]].value
- elif len(argv) > 2:
- return argv[2] # default value
- return ''
-
-def _macro_WordIndex(argv):
- s = make_index_key()
- pages = list(page_list())
- map = {}
- word_re = re.compile('[A-Z][a-z]+')
- for name in pages:
- for word in word_re.findall(name):
- try:
- map[word].append(name)
- except KeyError:
- map[word] = [name]
-
- all_words = map.keys()
- all_words.sort()
- last_letter = None
- # set title
- for word in all_words:
- letter = word[0].lower()
- if letter != last_letter:
- s = s + '; <a name="%s"><h3>%s</h3></a>' % (letter, letter)
- last_letter = letter
-
- s = s + '<b>%s</b><ul>' % word
- links = map[word]
- links.sort()
- last_page = None
- for name in links:
- if name == last_page: continue
- s = s + '<li>' + Page(name).link_to()
- s = s + '</ul>'
- return s
-
-def _macro_TitleIndex(argv):
- s = make_index_key()
- pages = list(page_list())
- pages.sort()
- current_letter = None
- for name in pages:
- letter = name[0].lower()
- if letter != current_letter:
- s += '<a name="%s"><h3>%s</h3></a>' % (letter, letter)
- current_letter = letter
- else:
- s += '<br />'
- s += Page(name).link_to()
- return s
-
class PageFormatter:
"""Object that turns Wiki markup into HTML.
argv = map(str.strip, argv)
macro = globals().get('_macro_' + name)
+ if not macro:
+ execfile("macros/" + name + ".py", globals())
+ macro = globals().get('_macro_' + name)
if macro:
return macro(argv)
else:
def can_read(self):
return self.can("read", True)
+ def send_naked(self):
+ if self.can_read():
+ PageFormatter(self.get_raw_body()).print_html()
+ else:
+ send_guru("Read access denied by ACLs", "notice")
+
def send_page(self):
page_name = None
if self.can_write():
css_url = self.get_attr("css", "").split() + css_url
send_title(page_name, self.split_title(), msg_text=self.msg_text, msg_type=self.msg_type)
- if self.can_read():
- PageFormatter(self.get_raw_body()).print_html()
- else:
- send_guru("Read access denied by ACLs", "notice")
+ self.send_naked()
send_footer(page_name, self._last_modified())
def _last_modified(self):
--- /dev/null
+def _macro_TitleIndex(argv):
+ s = make_index_key()
+ pages = list(page_list())
+ pages.sort()
+ current_letter = None
+ for name in pages:
+ letter = name[0].lower()
+ if letter != current_letter:
+ s += '<a name="%s"><h3>%s</h3></a>' % (letter, letter)
+ current_letter = letter
+ else:
+ s += '<br />'
+ s += Page(name).link_to()
+ return s
--- /dev/null
+def _macro_WordIndex(argv):
+ s = make_index_key()
+ pages = list(page_list())
+ map = {}
+ word_re = re.compile('[A-Z][a-z]+')
+ for name in pages:
+ for word in word_re.findall(name):
+ try:
+ map[word].append(name)
+ except KeyError:
+ map[word] = [name]
+
+ all_words = map.keys()
+ all_words.sort()
+ last_letter = None
+ # set title
+ for word in all_words:
+ letter = word[0].lower()
+ if letter != last_letter:
+ s = s + '; <a name="%s"><h3>%s</h3></a>' % (letter, letter)
+ last_letter = letter
+
+ s = s + '<b>%s</b><ul>' % word
+ links = map[word]
+ links.sort()
+ last_page = None
+ for name in links:
+ if name == last_page: continue
+ s = s + '<li>' + Page(name).link_to()
+ s = s + '</ul>'
+ return s