else:
send_httperror("403 Forbidden", pagename)
-# Used by macros/WordIndex and macros/TitleIndex
+# Used by sys/macros/WordIndex and sys/macros/TitleIndex
def make_index_key():
links = ['<a href="#%s">%s</a>' % (ch, ch) for ch in 'abcdefghijklmnopqrstuvwxyz']
return '<p style="text-align: center">' + ' | '.join(links) + '</p>'
return self.kvargs[args[0]]
macro = globals().get('_macro_' + args[0])
if not macro:
- exec(open("macros/" + args[0] + ".py").read(), globals())
+ exec(open("sys/macros/" + args[0] + ".py").read(), globals())
macro = globals().get('_macro_' + args[0])
return macro(*args, **kvargs)
except Exception, e:
+++ /dev/null
-def _macro_CgiVar(*args, **kvargs):
- return {
- 'REMOTE_USER': remote_user(),
- 'REMOTE_HOST': get_hostname(remote_host()),
- 'REMOTE_ADDR': remote_host(),
- 'QUERY_STRING': relative_url(query_string()),
- }[args[1]]
+++ /dev/null
-def _macro_HttpGet(*args, **kvargs):
- if args[1] in form:
- return form[args[1]].value
- elif len(args) > 2:
- return args[2] # default value
- raise Exception("Undefined argument " + args[1])
+++ /dev/null
-def _macro_HttpPost(*args, **kvargs):
- if args[1] in form:
- return form[argv[1]].value
- elif len(args) > 2:
- return args[2] # default value
- raise Exception("Undefined argument " + args[1])
+++ /dev/null
-def _macro_TitleIndex(*args, **kvargs):
- 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 += link_tag(name)
- return s
+++ /dev/null
-def _macro_WordIndex(*args, **kvargs):
- 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 = list(map.keys())
- all_words.sort()
- last_letter = None
- # set title
- for word in all_words:
- letter = word[0].lower()
- if letter != last_letter:
- s += '<a name="%s"><h3>%s</h3></a>' % (letter, letter)
- last_letter = letter
-
- s += '<b>%s</b><ul>' % word
- links = map[word]
- links.sort()
- last_page = None
- for name in links:
- if name == last_page: continue
- s += '<li>' + link_tag(name) + '</li>'
- s += '</ul>'
- return s