Docs: make nav sidebar work

This commit is contained in:
Aldo Cortesi 2013-01-01 15:30:02 +13:00
parent 8b66681929
commit 6f1fa30bc6
2 changed files with 40 additions and 31 deletions

View File

@ -19,42 +19,42 @@
<ul class="nav nav-list"> <ul class="nav nav-list">
<li><a href="@!urlTo("intro.html")!@">Introduction</a></li> $!nav("intro.html", this, state)!$
<li><a href="@!urlTo("install.html")!@">Installation</a></li> $!nav("install.html", this, state)!$
<li><a href="@!urlTo("mitmproxy.html")!@">mitmproxy</a></li> $!nav("mitmproxy.html", this, state)!$
<li><a href="@!urlTo("mitmdump.html")!@">mitmdump</a></li> $!nav("mitmdump.html", this, state)!$
<li><a href="@!urlTo("faq.html")!@">FAQ</a></li> $!nav("faq.html", this, state)!$
<li class="nav-header">Features</li> <li class="nav-header">Features</li>
<li><a href="@!urlTo("clientreplay.html")!@">Client-side replay</a></li> $!nav("clientreplay.html", this, state)!$
<li><a href="@!urlTo("serverreplay.html")!@">Server-side replay</a></li> $!nav("serverreplay.html", this, state)!$
<li><a href="@!urlTo("sticky.html")!@">Sticky cookies and auth</a></li> $!nav("sticky.html", this, state)!$
<li><a href="@!urlTo("reverseproxy.html")!@">Reverse proxy mode</a></li> $!nav("reverseproxy.html", this, state)!$
<li><a href="@!urlTo("upstreamcerts.html")!@">Upstream Certs</a></li> $!nav("upstreamcerts.html", this, state)!$
<li><a href="@!urlTo("replacements.html")!@">Replacements</a></li> $!nav("replacements.html", this, state)!$
<li><a href="@!urlTo("anticache.html")!@">Anticache</a></li> $!nav("anticache.html", this, state)!$
<li><a href="@!urlTo("filters.html")!@">Filter expressions</a></li> $!nav("filters.html", this, state)!$
<li class="nav-header">Scripting mitmproxy</li>
<li><a href="@!urlTo("scripting/inlinescripts.html")!@">Inline Scripts</a></li>
<li><a href="@!urlTo("scripting/libmproxy.html")!@">libmproxy</a></li>
<li class="nav-header">SSL interception</li> <li class="nav-header">SSL interception</li>
<li><a href="@!urlTo("ssl.html")!@">Overview</a></li> $!nav("ssl.html", this, state)!$
<li><a href="@!urlTo("certinstall/firefox.html")!@">Firefox</a></li> $!nav("certinstall/firefox.html", this, state)!$
<li><a href="@!urlTo("certinstall/osx.html")!@">OSX</a></li> $!nav("certinstall/osx.html", this, state)!$
<li><a href="@!urlTo("certinstall/windows7.html")!@">Windows 7</a></li> $!nav("certinstall/windows7.html", this, state)!$
<li><a href="@!urlTo("certinstall/ios.html")!@">iPhone/iPad</a></li> $!nav("certinstall/ios.html", this, state)!$
<li><a href="@!urlTo("certinstall/android.html")!@">Android</a></li> $!nav("certinstall/android.html", this, state)!$
<li class="nav-header">Transparent Proxying</li> <li class="nav-header">Transparent Proxying</li>
<li><a href="@!urlTo("transparent.html")!@">Overview</a></li> $!nav("transparent.html", this, state)!$
<li><a href="@!urlTo("transparent/linux.html")!@">Linux</a></li> $!nav("transparent/linux.html", this, state)!$
<li><a href="@!urlTo("transparent/osx.html")!@">OSX</a></li> $!nav("transparent/osx.html", this, state)!$
<li class="nav-header">Tutorials</li> <li class="nav-header">Tutorials</li>
<li> <a href="@!urlTo("tutorials/30second.html")!@">Client replay: a 30 second example</a> </li> $!nav("tutorials/30second.html", this, state)!$
<li> <a href="@!urlTo("tutorials/gamecenter.html")!@">Setting highscores on Apple's GameCenter</a> </li> $!nav("tutorials/gamecenter.html", this, state)!$
<li class="nav-header">Scripting mitmproxy</li>
$!nav("scripting/inlinescripts.html", this, state)!$
$!nav("scripting/libmproxy.html", this, state)!$
</ul> </ul>

View File

@ -1,6 +1,6 @@
import os, sys import os, sys
import countershape import countershape
from countershape import Page, Directory, PythonModule, markup from countershape import Page, Directory, PythonModule, markup, model
import countershape.template import countershape.template
sys.path.insert(0, "..") sys.path.insert(0, "..")
from libmproxy import filt from libmproxy import filt
@ -64,6 +64,15 @@ filt_help.extend(
ns.filt_help = filt_help ns.filt_help = filt_help
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
pages = [ pages = [
Page("index.html", "docs"), Page("index.html", "docs"),
@ -79,8 +88,8 @@ pages = [
Page("reverseproxy.html", "Reverse proxy mode"), Page("reverseproxy.html", "Reverse proxy mode"),
Page("anticache.html", "Anticache"), Page("anticache.html", "Anticache"),
Page("filters.html", "Filter expressions"), Page("filters.html", "Filter expressions"),
Page("ssl.html", "Setting up SSL interception"), Page("ssl.html", "SSL Overview"),
Page("transparent.html", "Transparent Proxying"), Page("transparent.html", "Transparent Overview"),
Directory("certinstall"), Directory("certinstall"),
Directory("scripting"), Directory("scripting"),
Directory("tutorials"), Directory("tutorials"),