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): def render(s, **kwargs):
kwargs["noapi"] = app.config["pathod"].noapi kwargs["noapi"] = app.config["pathod"].noapi
kwargs["nocraft"] = app.config["pathod"].nocraft
kwargs["craftanchor"] = app.config["pathod"].craftanchor
return render_template(s, **kwargs) return render_template(s, **kwargs)
@ -87,13 +89,13 @@ def response_preview():
except rparse.ParseException, v: except rparse.ParseException, v:
args["syntaxerror"] = str(v) args["syntaxerror"] = str(v)
args["marked"] = v.marked() args["marked"] = v.marked()
return render("preview_response.html", **args) return render("response_preview.html", **args)
s = cStringIO.StringIO() s = cStringIO.StringIO()
r.preview_safe() r.preview_safe()
r.serve(s, check=app.config["pathod"].check_size) r.serve(s, check=app.config["pathod"].check_size)
args["output"] = utils.escape_unprintables(s.getvalue()) args["output"] = utils.escape_unprintables(s.getvalue())
return render("preview_response.html", **args) return render("response_preview.html", **args)
@app.route('/request_preview') @app.route('/request_preview')
@ -110,10 +112,10 @@ def request_preview():
except rparse.ParseException, v: except rparse.ParseException, v:
args["syntaxerror"] = str(v) args["syntaxerror"] = str(v)
args["marked"] = v.marked() args["marked"] = v.marked()
return render("preview_request.html", **args) return render("request_preview.html", **args)
s = cStringIO.StringIO() s = cStringIO.StringIO()
r.preview_safe() r.preview_safe()
r.serve(s, check=app.config["pathod"].check_size, host="example.com") r.serve(s, check=app.config["pathod"].check_size, host="example.com")
args["output"] = utils.escape_unprintables(s.getvalue()) 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 @classmethod
def expr(klass): def expr(klass):
e = pp.Literal("d").suppress() e = pp.Literal("d").suppress()
e = e + pp.MatchFirst( e += e + pp.MatchFirst(
[ [
v_integer, v_integer,
pp.Literal("r") pp.Literal("r")

View File

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