-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.py
executable file
·65 lines (48 loc) · 1.64 KB
/
init.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/python
# -*- coding: utf-8 -*-
import hatta
from flup.server.fcgi import WSGIServer
from wsgibrotli.br import BrotliMiddleware
from wsgigzip.gzip import GzipMiddleware
class SMGLWikiParser(hatta.WikiParser):
""" WikiParser with support for Creole Additions from
http://www.wikicreole.org/wiki/CreoleAdditions """
markup_rules = hatta.WikiParser.markup_rules
punct = hatta.WikiParser.punct
# replaced by subscript
punct.pop(r",,")
@markup_rules(r"\^\^", 41)
def _line_superscript(self):
if 'sup' in self.stack:
return self.pop_to('sup')
else:
self.stack.append('sup')
return "<sup>"
@markup_rules(r",,", 42)
def _line_subscript(self):
if 'sub' in self.stack:
return self.pop_to('sub')
else:
self.stack.append('sub')
return "<sub>"
class SMGLWikiPageWiki(hatta.WikiPageWiki):
def __init__(self, *args, **kw):
super(SMGLWikiPageWiki, self).__init__(*args, **kw)
self.parser = SMGLWikiParser
class SMGLWiki(hatta.Wiki):
hatta.Wiki.mime_map['text/x-wiki'] = SMGLWikiPageWiki
config = hatta.WikiConfig(
site_name = 'Source Mage GNU/Linux',
front_page = 'News',
pages_path = '/var/www/smgl/web/site/pages',
cache_path = '/var/www/smgl/web/site/cache',
template_path = '/var/www/smgl/web/site/templates',
pygments_style = 'autumn',
math_url = 'mathjax',
subdirectories = True
)
config.parse_args()
config.parse_files()
config.sanitize()
wiki = SMGLWiki(config)
WSGIServer(GzipMiddleware(BrotliMiddleware(wiki.application, etag_alter=True))).run()