From 4d8eca8c234926b3770f3fc4d150128ad18cea87 Mon Sep 17 00:00:00 2001 From: Bernie Innocenti Date: Wed, 19 Aug 2009 11:27:53 +0200 Subject: [PATCH] Move macros into the wiki --- geekigeeki.py | 4 ++-- macros/CgiVar.py | 7 ------- macros/HttpGet.py | 6 ------ macros/HttpPost.py | 6 ------ macros/TitleIndex.py | 14 -------------- macros/WordIndex.py | 31 ------------------------------- 6 files changed, 2 insertions(+), 66 deletions(-) delete mode 100644 macros/CgiVar.py delete mode 100644 macros/HttpGet.py delete mode 100644 macros/HttpPost.py delete mode 100644 macros/TitleIndex.py delete mode 100644 macros/WordIndex.py diff --git a/geekigeeki.py b/geekigeeki.py index f906c07..01027ee 100755 --- a/geekigeeki.py +++ b/geekigeeki.py @@ -331,7 +331,7 @@ def handle_get(pagename, form): 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 = ['%s' % (ch, ch) for ch in 'abcdefghijklmnopqrstuvwxyz'] return '

' + ' | '.join(links) + '

' @@ -415,7 +415,7 @@ class WikiFormatter: 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: diff --git a/macros/CgiVar.py b/macros/CgiVar.py deleted file mode 100644 index 9e80e38..0000000 --- a/macros/CgiVar.py +++ /dev/null @@ -1,7 +0,0 @@ -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]] diff --git a/macros/HttpGet.py b/macros/HttpGet.py deleted file mode 100644 index bc122a9..0000000 --- a/macros/HttpGet.py +++ /dev/null @@ -1,6 +0,0 @@ -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]) diff --git a/macros/HttpPost.py b/macros/HttpPost.py deleted file mode 100644 index bf2ed01..0000000 --- a/macros/HttpPost.py +++ /dev/null @@ -1,6 +0,0 @@ -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]) diff --git a/macros/TitleIndex.py b/macros/TitleIndex.py deleted file mode 100644 index f35651a..0000000 --- a/macros/TitleIndex.py +++ /dev/null @@ -1,14 +0,0 @@ -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 += '

%s

' % (letter, letter) - current_letter = letter - else: - s += '
' - s += link_tag(name) - return s diff --git a/macros/WordIndex.py b/macros/WordIndex.py deleted file mode 100644 index b64a317..0000000 --- a/macros/WordIndex.py +++ /dev/null @@ -1,31 +0,0 @@ -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 += '

%s

' % (letter, letter) - last_letter = letter - - s += '%s' - return s -- 2.25.1