Hide "go" button if crafting is off. Use configured crafting anchor point.

This commit is contained in:
Aldo Cortesi 2012-07-24 23:38:41 +12:00
parent ab59d6dccf
commit 8f0ebb405d
5 changed files with 13 additions and 7 deletions

View File

@ -28,6 +28,8 @@ def api():
def render(s, **kwargs):
kwargs["noapi"] = app.config["pathod"].noapi
kwargs["nocraft"] = app.config["pathod"].nocraft
kwargs["craftanchor"] = app.config["pathod"].craftanchor
return render_template(s, **kwargs)
@ -87,13 +89,13 @@ def response_preview():
except rparse.ParseException, v:
args["syntaxerror"] = str(v)
args["marked"] = v.marked()
return render("preview_response.html", **args)
return render("response_preview.html", **args)
s = cStringIO.StringIO()
r.preview_safe()
r.serve(s, check=app.config["pathod"].check_size)
args["output"] = utils.escape_unprintables(s.getvalue())
return render("preview_response.html", **args)
return render("response_preview.html", **args)
@app.route('/request_preview')
@ -110,10 +112,10 @@ def request_preview():
except rparse.ParseException, v:
args["syntaxerror"] = str(v)
args["marked"] = v.marked()
return render("preview_request.html", **args)
return render("request_preview.html", **args)
s = cStringIO.StringIO()
r.preview_safe()
r.serve(s, check=app.config["pathod"].check_size, host="example.com")
args["output"] = utils.escape_unprintables(s.getvalue())
return render("preview_request.html", **args)
return render("request_preview.html", **args)

View File

@ -434,7 +434,7 @@ class DisconnectAt:
@classmethod
def expr(klass):
e = pp.Literal("d").suppress()
e = e + pp.MatchFirst(
e += e + pp.MatchFirst(
[
v_integer,
pp.Literal("r")

View File

@ -1,12 +1,16 @@
<form class="form-inline" method="GET" action="/response_preview">
<input id="spec" name="spec" class="input-medium search-query" value="{{spec}}">
<input type="submit" class="btn" value="preview">
<a href="#" id="submitspec" class="btn">go</a>
{% if not nocraft %}
<a href="#" id="submitspec" class="btn">go to</a>
{% endif %}
</form>
<script>
$(function(){
{% if not nocraft %}
$("#submitspec").click(function(){
document.location = "/p/" + $("#spec").val()
document.location = "{{craftanchor}}" + $("#spec").val()
});
{% endif %}
});
</script>