2 # -*- coding: utf-8 -*-
4 # Copyright 1999, 2000 Martin Pool <mbp@humbug.org.au>
5 # Copyright 2002 Gerardo Poggiali
6 # Copyright 2007, 2008, 2009 Bernie Innocenti <bernie@codewiz.org>
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 __version__ = '4.0-' + '$Id$'[4:11]
23 from time import clock
27 import cgi, sys, os, re, errno, stat
29 image_ext = 'png|gif|jpg|jpeg|bmp|ico'
30 video_ext = "ogg|ogv|oga" # Not supported by Firefox 3.5: mkv|mpg|mpeg|mp4|avi|asf|flv|wmv|qt
31 image_re = re.compile(r".*\.(" + image_ext + "|" + video_ext + ")", re.IGNORECASE)
32 video_re = re.compile(r".*\.(" + video_ext + ")", re.IGNORECASE)
33 # FIXME: we accept stuff like foo/../bar and we shouldn't
34 file_re = re.compile(r"([A-Za-z0-9_\-][A-Za-z0-9_\.\-/]*)")
35 url_re = re.compile(r"[a-z]{3,8}://[^\s'\"]+\S")
36 ext_re = re.compile(r"\.([^\./]+)$")
38 # CGI stuff ---------------------------------------------------------
40 return os.environ.get('SCRIPT_NAME', '')
43 path_info = os.environ.get('PATH_INFO', '')
44 if len(path_info) and path_info[0] == '/':
45 return path_info[1:] or 'FrontPage'
47 return os.environ.get('QUERY_STRING', '') or 'FrontPage'
49 def privileged_path():
50 return privileged_url or script_name()
53 user = os.environ.get('REMOTE_USER', '')
54 if user is None or user == '' or user == 'anonymous':
55 user = 'AnonymousCoward'
59 return os.environ.get('REMOTE_ADDR', '')
61 def get_hostname(addr):
63 from socket import gethostbyaddr
64 return gethostbyaddr(addr)[0] + ' (' + addr + ')'
68 def is_external_url(pathname):
69 return (url_re.match(pathname) or pathname.startswith('/'))
71 def relative_url(pathname, privileged=False):
72 if not is_external_url(pathname):
74 url = privileged_path()
77 pathname = url + '/' + pathname
78 return cgi.escape(pathname, quote=True)
81 return re.sub(' ', '-', re.sub('[^a-z0-9_ ]', '', s.lower()).strip())
84 return re.sub(r'(?:.*[/:]|)([^:/\.]+)(?:\.[^/:]+|)$', r'\1', s.replace('_', ' '))
86 # Split arg lists like "blah| blah blah| width=100 | align = center",
87 # return a list containing anonymous arguments and a map containing the named arguments
91 for arg in s.strip('<[{}]>').split('|'):
92 m = re.match('\s*(\w+)\s*=\s*(.+)\s*', arg)
94 kwargs[m.group(1)] = m.group(2)
96 args.append(arg.strip())
101 for k, v in kvargs.items():
102 argv.append(k + '=' + v)
104 return '?' + '&'.join(argv)
107 # Formatting stuff --------------------------------------------------
108 def emit_header(mime_type="text/html"):
109 print("Content-type: " + mime_type + "; charset=utf-8\n")
111 def send_guru(msg_text, msg_type):
112 if not msg_text: return
113 print('<pre id="guru" onclick="this.style.display = \'none\'" class="' + msg_type + '">')
114 if msg_type == 'error':
115 print(' Software Failure. Press left mouse button to continue.\n')
117 if msg_type == 'error':
118 print '\n Guru Meditation #DEADBEEF.ABADC0DE'
119 print('</pre><script language="JavaScript" type="text/javascript" src="%s" defer="defer"></script>' \
120 % relative_url('sys/GuruMeditation.js'))
122 def send_title(name, text="Limbo", msg_text=None, msg_type='error', writable=False):
124 if title_done: return
128 print('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"')
129 print(' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">')
130 print('<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">')
132 print("<head><title>%s: %s</title>" % (site_name, text))
133 print(' <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />')
135 print(' <meta name="robots" content="noindex,nofollow" />')
137 for meta in meta_urls:
138 http_equiv, content = meta
139 print(' <meta http-equiv="%s" content="%s" />' % (http_equiv, relative_url(content)))
141 for link in link_urls:
143 print(' <link rel="%s" href="%s" />' % (rel, relative_url(href)))
145 if name and writable and privileged_url is not None:
146 print(' <link rel="alternate" type="application/x-wiki" title="Edit this page" href="%s" />' \
147 % (privileged_path() + '?a=edit&q=' + name))
149 if history_url is not None:
150 print(' <link rel="alternate" type="application/rss+xml" title="RSS" href="%s" />' \
151 % relative_url(history_url + '?a=rss'))
156 if name and writable and privileged_url is not None:
157 print('<body ondblclick="location.href=\'' + privileged_path() + '?a=edit&q=' + name + '\'">')
162 send_guru(msg_text, msg_type)
165 print('<div class="nav">')
166 print link_tag('FrontPage', site_icon or 'Home', cssclass='navlink')
168 print(' <b>' + link_tag('?fullsearch=' + name, text, cssclass='navlink') + '</b> ')
170 print(' <b>' + text + '</b> ')
171 print(' | ' + link_tag('FindPage', 'Find Page', cssclass='navlink'))
172 if 'history_url' in globals():
173 print(' | <a href="' + relative_url(history_url) + '" class="navlink">Recent Changes</a>')
175 print(' | <a href="' + relative_url(history_url + '?a=history;f=' + name) + '" class="navlink">Page History</a>')
178 print(' | ' + link_tag(name + '?a=raw', 'Raw Text', cssclass='navlink'))
179 if privileged_url is not None:
181 print(' | ' + link_tag('?a=edit&q=' + name, 'Edit', cssclass='navlink', privileged=True))
183 print(' | ' + link_tag(name, 'Login', cssclass='navlink', privileged=True))
186 print(' | <i>Immutable Page</i>')
189 if user != 'AnonymousCoward':
190 print(' | <span class="login"><i><b>' + link_tag('User/' + user, user) + '</b></i></span>')
192 print('<hr /></div>')
194 def send_httperror(status="403 Not Found", query=""):
195 print("Status: %s" % status)
196 send_title(None, msg_text=("%s: on query '%s'" % (status, query)))
199 def link_tag(dest, text=None, privileged=False, **kvargs):
201 text = humanlink(dest)
202 elif image_re.match(text):
203 text = '<img border="0" src="' + relative_url(text) + '" alt="' + text + '" />'
205 link_class = kvargs.get('class', kvargs.get('cssclass', None))
207 if is_external_url(dest):
208 link_class = 'external'
209 elif file_re.match(dest) and Page(dest).exists():
210 link_class = 'wikilink'
212 text = nonexist_pfx + text
213 link_class = 'nonexistent'
215 # Prevent crawlers from following links potentially added by spammers or to generated pages
217 if link_class == 'external' or link_class == 'navlink':
218 nofollow = 'rel="nofollow" '
220 return '<a class="%s" %shref="%s">%s</a>' % (link_class, nofollow, relative_url(dest, privileged=privileged), text)
222 def link_inline(name, descr=None, kvargs={}):
223 if not descr: descr = humanlink(name)
224 url = relative_url(name)
225 if video_re.match(name):
226 return '<video controls="1" src="%s">Your browser does not support the HTML5 video tag</video>' % url
227 elif image_re.match(name):
228 return '<a href="%s"><img border="0" src="%s" alt="%s" /></a>' % (url, url + url_args(kvargs), descr)
229 elif file_re.match(name) and not ext_re.search(name): # FIXME: this guesses a wiki page
230 return Page(name).send_naked()
232 return '<iframe width="100%%" scrolling="auto" frameborder="0" src="%s"><a href="%s">%s</a></iframe>' \
235 # Search ---------------------------------------------------
237 def print_search_stats(hits, searched):
238 print("<p>%d hits out of %d pages searched.</p>" % (hits, searched))
240 def handle_fullsearch(query, form):
241 needle = form['q'].value
242 send_title(None, 'Full text search for "' + needle + '"')
244 needle_re = re.compile(needle, re.IGNORECASE)
246 all_pages = page_list()
247 for page_name in all_pages:
248 body = Page(page_name).get_raw_body()
249 count = len(needle_re.findall(body))
251 hits.append((count, page_name))
253 # The default comparison for tuples compares elements in order,
254 # so this sorts by number of hits
259 for (count, page_name) in hits:
260 print('<li><p>' + link_tag(page_name))
261 print(' . . . . ' + `count`)
262 print(['match', 'matches'][count != 1])
266 print_search_stats(len(hits), len(all_pages))
268 def handle_titlesearch(query, form):
269 needle = form['q'].value
270 send_title(None, 'Title search for "' + needle + '"')
272 needle_re = re.compile(needle, re.IGNORECASE)
273 all_pages = page_list()
274 hits = list(filter(needle_re.search, all_pages))
277 for filename in hits:
278 print('<li><p>' + link_tag(filename) + "</p></li>")
281 print_search_stats(len(hits), len(all_pages))
283 def handle_raw(pagename, form):
284 if not file_re.match(pagename):
285 send_httperror("403 Forbidden", pagename)
288 Page(pagename).send_raw()
290 def handle_edit(pagename, form):
291 if not file_re.match(pagename):
292 send_httperror("403 Forbidden", pagename)
295 pg = Page(form['q'].value)
297 if form['file'].value:
298 pg.save(form['file'].file.read(), form['changelog'].value)
300 pg.save(form['savetext'].value.replace('\r\n', '\n'), form['changelog'].value)
302 elif 'cancel' in form:
303 pg.msg_text = 'Editing canceled'
304 pg.msg_type = 'notice'
306 else: # preview or edit
308 if 'preview' in form:
309 text = form['savetext'].value
312 def handle_get(pagename, form):
313 if file_re.match(pagename):
314 # FIMXE: this is all bullshit, MimeTypes bases its guess on the extension!
315 from mimetypes import MimeTypes
316 mimetype, encoding = MimeTypes().guess_type(pagename)
318 Page(pagename).send_raw(mimetype=mimetype, args=form)
320 Page(pagename).format()
322 send_httperror("403 Forbidden", pagename)
324 # Used by macros/WordIndex and macros/TitleIndex
325 def make_index_key():
326 links = ['<a href="#%s">%s</a>' % (ch, ch) for ch in 'abcdefghijklmnopqrstuvwxyz']
327 return '<p style="text-align: center">' + ' | '.join(links) + '</p>'
329 def page_list(dirname=None, re=None):
331 # FIXME: WikiWord is too restrictive now!
332 re = re.compile(r"^\b((([A-Z][a-z0-9]+){2,}/)*([A-Z][a-z0-9]+){2,})\b$")
333 return sorted(filter(re.match, os.listdir(dirname or data_dir)))
335 def send_footer(mod_string=None):
336 if globals().get('debug_cgi', False):
337 cgi.print_arguments()
340 #FIXME link_inline("sys/footer")
342 <div id="footer"><hr />
343 <p class="copyright">
344 <a rel="license" href="http://creativecommons.org/licenses/by-sa/3.0/"><img class="license" alt="Creative Commons License" src="%s" /></a>
345 <span class="benchmark">generated in %0.3fs</span> by <a href="http://www.codewiz.org/wiki/GeekiGeeki">GeekiGeeki</a> version %s
347 ''' % (relative_url('cc-by-sa.png'), clock() - start_time, __version__))
349 print('<p class="modified">last modified %s</p>' % mod_string)
350 print('</div></body></html>')
353 """Object that turns Wiki markup into HTML.
355 All formatting commands can be parsed one line at a time, though
356 some state is carried over between lines.
358 def __init__(self, raw):
361 self.in_pre = self.in_html = self.in_table = self.in_li = False
362 self.in_header = True
363 self.list_indents = []
371 "^^": ["sup", False],
372 ",,": ["sub", False],
373 "''": ["em", False], # LEGACY
374 "'''": ["b", False], # LEGACY
375 "``": ["tt", False], # LEGACY
378 def _b_repl(self, word):
379 style = self.styles[word]
380 style[1] = not style[1]
381 return ['</', '<'][style[1]] + style[0] + '>'
383 def _tit_repl(self, word):
385 result = '</h%d><p>\n' % self.h_level
388 self.h_level = len(word) - 1
389 link = permalink(self.line)
390 result = '\n</p><h%d id="%s"><a class="heading" href="#%s">¶</a> ' % (self.h_level, link, link)
393 def _br_repl(self, word):
396 def _rule_repl(self, word):
397 return self._undent() + '\n<hr size="%d" noshade="noshade" />\n' % (len(word) - 2)
399 def _macro_repl(self, word):
401 args, kwargs = parse_args(word)
402 macro = globals().get('_macro_' + args[0])
404 exec(open("macros/" + name + ".py").read(), globals())
405 macro = globals().get('_macro_' + name)
406 return macro(*args, **kwargs)
408 msg = cgi.escape(word)
410 msg = '<strong class="error">' + msg + '</strong>'
413 def _hurl_repl(self, word):
414 args, kvargs = parse_args(word)
415 return link_tag(*args, **kvargs)
417 def _inl_repl(self, word):
418 args, kvargs = parse_args(word)
422 # This double div nonsense works around a limitation of the HTML block model
423 return '<div class="' + kvargs.get('class', 'thumb') + '">' \
424 + '<div class="innerthumb">' \
425 + link_inline(name, descr, kvargs) \
426 + '<div class="caption">' + descr + '</div></div></div>'
428 return link_inline(name, None, kvargs)
430 def _html_repl(self, word):
431 if not self.in_html and word.startswith('<div'): word = '</p>' + word
433 return word; # Pass through
435 def _htmle_repl(self, word):
437 if not self.in_html and word.startswith('</div'): word += '<p>'
438 return word; # Pass through
440 def _ent_repl(self, s):
442 return s; # Pass through
443 return {'&': '&',
447 def _img_repl(self, word): # LEGACY
448 return self._inl_repl('{{' + word + '}}')
450 def _word_repl(self, word): # LEGACY
451 if self.in_html: return word # pass through
452 return link_tag(word)
454 def _url_repl(self, word): # LEGACY
455 if self.in_html: return word # pass through
456 return link_tag(word)
458 def _email_repl(self, word): # LEGACY
459 if self.in_html: return word # pass through
460 return '<a href="mailto:%s">%s</a>' % (word, word)
462 def _li_repl(self, match):
469 def _pre_repl(self, word):
470 if word == '{{{' and not self.in_pre:
478 def _hi_repl(self, word):
479 return '<strong class="highlight ' + word + '">' + word + '</strong>'
481 def _tr_repl(self, word):
483 if not self.in_table:
486 out = '</p><table><tbody>\n'
488 out = out + '<tr class="' + ['even', 'odd'][self.tr_cnt % 2] + '">'
489 return out + ['<td>', '<th>'][word.strip() == '||=']
491 def _td_repl(self, word):
493 return ['</td><td>', '</th><th>'][word.strip() == '||=']
496 def _tre_repl(self, word):
498 return ['</td></tr>', '</th></tr>'][word.strip() == '||=']
501 def _indent_level(self):
502 return len(self.list_indents) and self.list_indents[-1]
504 def _indent_to(self, new_level):
505 if self._indent_level() == new_level:
508 while self._indent_level() > new_level:
509 del(self.list_indents[-1])
512 self.in_li = False # FIXME
514 while self._indent_level() < new_level:
515 self.list_indents.append(new_level)
522 res += '</ul>' * len(self.list_indents)
524 self.list_indents = []
527 def replace(self, match):
528 for rule, hit in list(match.groupdict().items()):
530 return getattr(self, '_' + rule + '_repl')(hit)
532 raise "Can't handle match " + repr(match)
534 def print_html(self):
535 print('<div class="wiki"><p>')
537 scan_re = re.compile(r"""(?:
538 # Styles and formatting
539 (?P<b> \*\*|'''|//|''|\#\#|``|__|\^\^|,,)
543 | (?P<hi> \b( FIXME | TODO | DONE )\b )
546 | (?P<macro> \<\<([^\s\|\>]+)(?:\s*\|\s*([^\>]+)|)\>\>)
547 | (?P<hurl> \[\[([^\s\|]+)(?:\s*\|\s*([^\]]+)|)\]\])
550 | (?P<html> <(br|hr|div|span|form|iframe|input|textarea|a|img|h[1-5])\b )
551 | (?P<htmle> ( /\s*> | </(br|hr|div|span|form|iframe|input|textarea|a|img|h[1-5])> ) )
554 # Auto links (LEGACY)
555 | (?P<img> \b[a-zA-Z0-9_/-]+\.(""" + image_ext + "|" + video_ext + r"""))
556 | (?P<word> \b(?:[A-Z][a-z]+){2,}\b)
557 | (?P<url> (http|https|ftp|mailto)\:[^\s'\"]+\S)
558 | (?P<email> [-\w._+]+\@[\w.-]+)
560 # Lists, divs, spans and inline objects
561 | (?P<li> ^\s+[\*\#]\s+)
562 | (?P<pre> \{\{\{|\s*\}\}\})
563 | (?P<inl> \{\{([^\s\|]+)(?:\s*\|\s*([^\]]+)|)\}\})
566 | (?P<tr> ^\s*\|\|(=|)\s*)
567 | (?P<tre> \s*\|\|(=|)\s*$)
568 | (?P<td> \s*\|\|(=|)\s*)
570 # TODO: highlight search words (look at referrer)
572 pre_re = re.compile("""(?:
576 blank_re = re.compile(r"^\s*$")
577 indent_re = re.compile(r"^\s*")
578 tr_re = re.compile(r"^\s*\|\|")
579 eol_re = re.compile(r"\r?\n")
580 # For each line, we scan through looking for magic strings, outputting verbatim any intervening text
581 #3.0: for self.line in eol_re.split(str(self.raw.expandtabs(), 'utf-8')):
582 for self.line in eol_re.split(str(self.raw.expandtabs())):
585 if self.line.startswith('#'):
587 self.in_header = False
590 print(re.sub(pre_re, self.replace, self.line))
592 if self.in_table and not tr_re.match(self.line):
593 self.in_table = False
594 print('</tbody></table><p>')
596 if blank_re.match(self.line):
599 indent = indent_re.match(self.line)
600 #3.0: print(self._indent_to(len(indent.group(0))), end=' ')
601 print(self._indent_to(len(indent.group(0))))
602 print(re.sub(scan_re, self.replace, self.line))
604 if self.in_pre: print('</pre>')
605 if self.in_table: print('</tbody></table><p>')
606 print(self._undent())
610 def __init__(self, page_name):
611 self.page_name = page_name
613 self.msg_type = 'error'
615 def split_title(self):
616 # look for the end of words and the start of a new word and insert a space there
617 return re.sub('([a-z])([A-Z])', r'\1 \2', self.page_name)
620 return os.path.join(data_dir, self.page_name)
622 def _tmp_filename(self):
623 return os.path.join(data_dir, ('#' + self.page_name.replace('/','_') + '.' + str(os.getpid()) + '#'))
627 os.stat(self._filename())
630 if err.errno == errno.ENOENT:
634 def get_raw_body(self, default=None):
636 return open(self._filename(), 'rb').read()
638 if err.errno == errno.ENOENT:
640 default = '//[[?a=edit&q=%s|Describe %s]]//' % (self.page_name, self.page_name)
642 if err.errno == errno.EISDIR:
643 return self.format_dir()
646 def format_dir(self):
649 for dirname in self.page_name.strip('/').split('/'):
650 pathname = (pathname + '/' + dirname) if pathname else dirname
651 out += '[[' + pathname + '|' + dirname + ']]/'
654 for filename in page_list(self._filename(), file_re):
655 if image_re.match(filename):
657 maxwidth_arg = ' | maxwidth=' + str(image_maxwidth)
658 out += '{{' + self.page_name + '/' + filename + ' | ' + humanlink(filename) + maxwidth_arg + ' | class=thumbleft}}\n'
660 out += ' * [[' + self.page_name + '/' + filename + ']]\n'
664 if not '_pragmas' in self.__dict__:
667 file = open(self._filename(), 'rt')
668 attr_re = re.compile(r"^#(\S*)(.*)$")
670 m = attr_re.match(line)
673 self._pragmas[m.group(1)] = m.group(2).strip()
674 #print "bernie: pragmas[" + m.group(1) + "] = " + m.group(2) + "<br>\n"
676 if err.errno != errno.ENOENT and err.errno != errno.EISDIR:
680 def pragma(self, name, default):
681 return self.pragmas().get(name, default)
683 def can(self, action, default=True):
686 #acl SomeUser:read,write All:read
687 acl = self.pragma("acl", None)
688 for rule in acl.split():
689 (user, perms) = rule.split(':')
690 if user == remote_user() or user == "All":
691 return action in perms.split(',')
695 self.msg_text = 'Illegal acl line: ' + acl
699 return self.can("write", True)
702 return self.can("read", True)
704 def send_naked(self):
706 WikiFormatter(self.get_raw_body()).print_html()
708 send_guru("Read access denied by ACLs", "notice")
712 value = self.pragma("css", None)
715 link_urls += [ [ "stylesheet", value ] ]
717 send_title(self.page_name, self.split_title(),
718 msg_text=self.msg_text, msg_type=self.msg_type, writable=self.can_write())
720 send_footer(self._last_modified())
722 def _last_modified(self):
724 from time import localtime, strftime
725 modtime = localtime(os.stat(self._filename())[stat.ST_MTIME])
727 if err.errno != errno.ENOENT:
730 return strftime(datetime_fmt, modtime)
732 def send_editor(self, preview=None):
733 send_title(None, 'Edit ' + self.split_title(), msg_text=self.msg_text, msg_type=self.msg_type)
734 if not self.can_write():
735 send_guru("Write access denied by ACLs", "error")
740 filename = form['file'].value
742 print(('<p><b>Editing ' + self.page_name
743 + ' for ' + cgi.escape(remote_user())
744 + ' from ' + cgi.escape(get_hostname(remote_host()))
746 print('<div class="editor"><form name="editform" method="post" enctype="multipart/form-data" action="%s">' % relative_url(self.page_name))
747 print('<input type="hidden" name="a" value="edit" /><input type="hidden" name="q" value="' + self.page_name + '" />')
748 print('<input type="input" id="editor" name="changelog" value="Edit page %s" accesskey="c" /><br />' % (self.page_name))
749 print('<textarea wrap="off" spellcheck="true" id="editor" name="savetext" rows="17" cols="100" accesskey="e">%s</textarea>' \
750 % cgi.escape(preview or self.get_raw_body(default='')))
751 print('<label for="file" accesskey="u">Or Upload a file:</label> <input type="file" name="file" value="%s" />' % filename)
754 <input type="submit" name="save" value="Save" accesskey="s">
755 <input type="submit" name="preview" value="Preview" accesskey="p" />
756 <input type="reset" value="Reset" />
757 <input type="submit" name="cancel" value="Cancel" />
760 <script language="javascript">
762 document.editform.savetext.focus()
766 print("<p>" + link_tag('EditingTips') + "</p>")
768 print("<div class='preview'>")
769 WikiFormatter(preview).print_html()
773 def send_raw(self, mimetype='text/plain', args=[]):
774 if not self.can_read():
775 send_title(None, msg_text='Read access denied by ACLs', msg_type='notice')
778 if 'maxwidth' in args:
780 emit_header(mimetype)
782 subprocess.check_call(['gm', 'convert', self._filename(),
783 '-scale', args['maxwidth'].value + ' >', '-'])
785 body = self.get_raw_body()
786 emit_header(mimetype)
789 def _write_file(self, data):
790 tmp_filename = self._tmp_filename()
791 open(tmp_filename, 'wb').write(data)
792 name = self._filename()
794 # Bad Bill! POSIX rename ought to replace. :-(
798 if err.errno != errno.ENOENT: raise err
799 path = os.path.split(name)[0]
800 if not os.path.exists(path):
802 os.rename(tmp_filename, name)
804 def save(self, newdata, changelog):
805 if not self.can_write():
806 self.msg_text = 'Write access denied by ACLs'
807 self.msg_type = 'error'
810 self._write_file(newdata)
814 cmd = [ post_edit_hook, data_dir + '/' + self.page_name, remote_user(), remote_host(), changelog]
815 child = subprocess.Popen(cmd, stdout=subprocess.PIPE, close_fds=True)
816 output = child.stdout.read()
819 self.msg_text += "Post-editing hook returned %d. Command was:\n'%s'\n" % (rc, "' '".join(cmd))
821 self.msg_text += 'Output follows:\n' + output
823 self.msg_text = 'Thank you for your contribution. Your attention to detail is appreciated.'
824 self.msg_type = 'success'
827 exec(open("geekigeeki.conf.py").read())
828 form = cgi.FieldStorage()
829 action = form.getvalue('a', 'get')
830 handler = globals().get('handle_' + action)
832 handler(query_string(), form)
834 send_httperror("403 Forbidden", query_string())
838 msg_text = traceback.format_exc()
840 send_guru(msg_text, "error")
842 send_title(None, msg_text=msg_text)