[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [bridgedb/develop] Provide an Advanced Options page for easier bridge selection
commit 59e8b4684a99537bf7f4def43ede7d6c4dc33eb3
Author: Matthew Finkel <Matthew.Finkel@xxxxxxxxx>
Date: Mon Feb 3 02:37:48 2014 +0000
Provide an Advanced Options page for easier bridge selection
The options page allows the user to select a specific pluggable
transport type and if they require IPv6 addresses.
All pages inheriting from the base template will provide navigation
buttons.
---
lib/bridgedb/HTTPServer.py | 35 +++++++++++++++++++++++++++++--
lib/bridgedb/templates/base.html | 5 +++++
lib/bridgedb/templates/index.html | 11 ++++------
lib/bridgedb/templates/options.html | 39 +++++++++++++++++++++++++++++++++++
4 files changed, 81 insertions(+), 9 deletions(-)
diff --git a/lib/bridgedb/HTTPServer.py b/lib/bridgedb/HTTPServer.py
index ad69e1b..610249a 100644
--- a/lib/bridgedb/HTTPServer.py
+++ b/lib/bridgedb/HTTPServer.py
@@ -208,7 +208,35 @@ class CaptchaProtectedResource(twisted.web.resource.Resource):
return redirectTo(request.uri, request)
-class WebResource(twisted.web.resource.Resource):
+class WebResourceOptions(twisted.web.resource.Resource):
+ """This resource is used by Twisted Web to give a web page with
+ additional options that the user may use to specify the criteria
+ the returned bridges should meet.
+ """
+ isLeaf = True
+
+ def __init__(self):
+ """Create a new WebResource for the Options page"""
+ gettext.install("bridgedb", unicode=True)
+ twisted.web.resource.Resource.__init__(self)
+
+ def render_GET(self, request):
+ rtl = False
+
+ try:
+ rtl = usingRTLLang(request)
+ except Exception as err:
+ logging.exception(err)
+ logging.error("The gettext files were not properly installed.")
+ logging.info("To install translations, try doing `python " \
+ "setup.py compile_catalog`.")
+
+ request.setHeader("Content-Type", "text/html; charset=utf-8")
+ return lookup.get_template('options.html').render(rtl=rtl)
+
+ render_POST = render_GET
+
+class WebResourceBridges(twisted.web.resource.Resource):
"""This resource is used by Twisted Web to give a web page with some
bridges in response to a request."""
isLeaf = True
@@ -433,11 +461,14 @@ def addWebServer(cfg, dist, sched):
httpdist.putChild('assets',
static.File(os.path.join(template_root, 'assets/')))
- resource = WebResource(dist, sched, cfg.HTTPS_N_BRIDGES_PER_ANSWER,
+ resource = WebResourceBridges(dist, sched, cfg.HTTPS_N_BRIDGES_PER_ANSWER,
cfg.HTTP_USE_IP_FROM_FORWARDED_HEADER,
includeFingerprints=cfg.HTTPS_INCLUDE_FINGERPRINTS,
domains=cfg.EMAIL_DOMAINS)
+ resource_options = WebResourceOptions()
+
+ httpdist.putChild('options', resource_options)
if cfg.RECAPTCHA_ENABLED:
protected = CaptchaProtectedResource(
recaptchaPrivKey=cfg.RECAPTCHA_PRIV_KEY,
diff --git a/lib/bridgedb/templates/base.html b/lib/bridgedb/templates/base.html
index 9f8a70a..441f3b6 100644
--- a/lib/bridgedb/templates/base.html
+++ b/lib/bridgedb/templates/base.html
@@ -71,6 +71,11 @@ ${self.body()}
${_("Get IPv6 bridges")}
</button>
</a>
+ <a href="./options">
+ <button class="btn btn-default" type="button">
+ ${_("Advanced Options")}
+ </button>
+ </a>
</div>
</div>
</div>
diff --git a/lib/bridgedb/templates/index.html b/lib/bridgedb/templates/index.html
index 82522c8..a97e21d 100644
--- a/lib/bridgedb/templates/index.html
+++ b/lib/bridgedb/templates/index.html
@@ -14,13 +14,10 @@
</div>
<div class="step row">
- <div class="bdb_span7 step-text">
- <span class="lead">
- <span class="step-title">
- ${_("Step 2")} </span>
- <span style="margin-left: 20px;">
- ${_("Get %s bridges %s") % ("""<a href="/bridges">""", "</a>")}</span>
- </span></div>
+ <div class="span1">
+ <p class="lead"><span class="step-title"> ${_("Step 2")} </span></p></div>
+ <div class="span5 step-text">
+ ${_("Get %s bridges %s") % ("""<a href="/options">""", "</a>")}</div>
</div>
<div class="step row">
diff --git a/lib/bridgedb/templates/options.html b/lib/bridgedb/templates/options.html
new file mode 100644
index 0000000..82d1213
--- /dev/null
+++ b/lib/bridgedb/templates/options.html
@@ -0,0 +1,39 @@
+## -*- coding: utf-8 -*-
+<%inherit file="base.html"/>
+
+<br />
+<br />
+<p><h2><a href="bridges">${_("""Just Give Me Bridges!""")}</a></h2>
+</p>
+<br /><br /><br />
+<hr />
+<p>
+<h3> ${_("""Advanced Options""")}</h3>
+<form action="bridges" method="GET">
+<div style="float: left;">
+<p>${_("""Do you need IPv6 addresses?""")}
+</p>
+## TRANSLATORS: Translate "Yes!" as in "Yes! I do need IPv6 addresses"
+<input type="checkbox" name="ipv6" value="yes">${_("""Yes!""")}</input>
+<br />
+<br />
+</div><div style="float: right;">
+<p>${_("""Do you need a specific pluggable transport?""")}</p>
+<select name="transport">
+<option name="none" value="0">
+## TRANSLATORS: Please do not translate the pluggable transport names
+## (obfs2, obfs3, etc)
+ ${_("""No""")}
+</option>
+<option value="obfs2">${_("""Yes, obfs2""")}</option>
+<option value="obfs3">${_("""Yes, obfs3""")}</option>
+<!--<option value="scramblesuit">${_("""Yes, scramblesuit""")}</option>-->
+</select>
+</div>
+<br />
+<br />
+<br />
+<br />
+<p><button>${_("""Get Bridges""")}</button></p>
+</form>
+<hr>
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits