mitmproxy/doc-src/index.py

85 lines
2.2 KiB
Python
Raw Normal View History

2011-03-17 20:04:49 +00:00
import os, sys
2010-02-16 04:09:07 +00:00
import countershape
2013-01-01 02:30:02 +00:00
from countershape import Page, Directory, PythonModule, markup, model
import countershape.template
2011-03-17 20:04:49 +00:00
sys.path.insert(0, "..")
from libmproxy import filt
#MITMPROXY_SRC = "~/git/public/mitmproxy"
MITMPROXY_SRC = "/Users/jason/Development/virtualenvs/mitmproxy-github/mitmproxy"
if ns.options.website:
this.layout = countershape.Layout("_websitelayout.html")
else:
this.layout = countershape.Layout("_layout.html")
ns.title = countershape.template.Template(None, "<h1>@!this.title!@</h1>")
this.titlePrefix = "mitmproxy 0.9 - "
this.markup = markup.Markdown(extras=["footnotes"])
2010-02-16 04:09:07 +00:00
ns.docMaintainer = "Aldo Cortesi"
ns.docMaintainerEmail = "aldo@corte.si"
ns.copyright = u"\u00a9 mitmproxy project, 2013"
2010-02-16 04:09:07 +00:00
def mpath(p):
p = os.path.join(MITMPROXY_SRC, p)
return os.path.expanduser(p)
ns.index_contents = file(mpath("README.mkd")).read()
def example(s):
2013-03-10 22:49:36 +00:00
d = file(mpath(s)).read().rstrip()
2011-08-05 01:26:39 +00:00
extemp = """<div class="example">%s<div class="example_legend">(%s)</div></div>"""
return extemp%(countershape.template.Syntax("py")(d), s)
ns.example = example
2013-03-10 22:49:36 +00:00
2011-03-17 20:04:49 +00:00
filt_help = []
for i in filt.filt_unary:
filt_help.append(
("~%s"%i.code, i.help)
)
for i in filt.filt_rex:
filt_help.append(
("~%s regex"%i.code, i.help)
)
for i in filt.filt_int:
filt_help.append(
("~%s int"%i.code, i.help)
)
filt_help.sort()
filt_help.extend(
[
("!", "unary not"),
("&", "and"),
("|", "or"),
("(...)", "grouping"),
]
)
ns.filt_help = filt_help
2013-01-01 02:30:02 +00:00
def nav(page, current, state):
if current.match(page, False):
pre = '<li class="active">'
else:
pre = "<li>"
p = state.application.getPage(page)
return pre + '<a href="%s">%s</a></li>'%(model.UrlTo(page), p.title)
ns.nav = nav
2010-02-16 04:09:07 +00:00
pages = [
Page("index.html", "Introduction"),
2012-04-09 03:15:41 +00:00
Page("install.html", "Installation"),
Page("mitmproxy.html", "mitmproxy"),
Page("mitmdump.html", "mitmdump"),
Page("howmitmproxy.html", "How mitmproxy works"),
Page("ssl.html", "Overview"),
Directory("certinstall"),
2012-09-16 23:04:57 +00:00
Directory("scripting"),
Directory("tutorials"),
Page("transparent.html", "Overview"),
2013-01-01 01:09:43 +00:00
Directory("transparent"),
2010-02-16 04:09:07 +00:00
]