forked from hswaw/labelmaker
removed delay from python script and localized javascript cdn's
This commit is contained in:
parent
62eff09749
commit
c820741a11
6 changed files with 23 additions and 15 deletions
|
@ -11,12 +11,7 @@ import pangocffi as pango
|
||||||
import pangocairocffi as pangocairo
|
import pangocairocffi as pangocairo
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
class App(flask.Flask):
|
app = flask.Flask(__name__)
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super(App, self).__init__(*args, **kwargs)
|
|
||||||
self.last = 0
|
|
||||||
|
|
||||||
app = App(__name__)
|
|
||||||
|
|
||||||
class Renderer(object):
|
class Renderer(object):
|
||||||
INCH_PER_MM = 0.039
|
INCH_PER_MM = 0.039
|
||||||
|
@ -87,10 +82,6 @@ def stuff_preview(size):
|
||||||
DELAY = 5
|
DELAY = 5
|
||||||
@app.route('/api/print/<int:size>/', methods=['POST'])
|
@app.route('/api/print/<int:size>/', methods=['POST'])
|
||||||
def stuff_print(size):
|
def stuff_print(size):
|
||||||
last = app.last
|
|
||||||
print(last, time.time() - last)
|
|
||||||
if time.time() - last < DELAY:
|
|
||||||
return 'Please wait {} more seconds before next print.'.format(int(DELAY - (time.time() - last)))
|
|
||||||
text = flask.request.args.get('text')
|
text = flask.request.args.get('text')
|
||||||
html = flask.request.args.get('html') == '1'
|
html = flask.request.args.get('html') == '1'
|
||||||
renderer = Renderer()
|
renderer = Renderer()
|
||||||
|
@ -101,7 +92,6 @@ def stuff_print(size):
|
||||||
r = requests.post(os.environ.get('PRINTSERVANT_HOST') + '/print', params=payload)
|
r = requests.post(os.environ.get('PRINTSERVANT_HOST') + '/print', params=payload)
|
||||||
print('Printing job response', r.text)
|
print('Printing job response', r.text)
|
||||||
|
|
||||||
app.last = time.time()
|
|
||||||
return 'ok'
|
return 'ok'
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|
5
labelmaker/templates/bootstrap.min.css
vendored
Normal file
5
labelmaker/templates/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
7
labelmaker/templates/bootstrap.min.js
vendored
Normal file
7
labelmaker/templates/bootstrap.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
|
@ -5,7 +5,7 @@
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>Hackerspace Printing System For Printing</title>
|
<title>Hackerspace Printing System For Printing</title>
|
||||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
|
<link rel="stylesheet" href="bootstrap.min.css">
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
html {
|
html {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
@ -93,9 +93,9 @@ $ curl -d "" http://label.waw.hackerspace.pl/api/print/60/?text=foobar&html=
|
||||||
on <a href="https://code.hackerspace.pl/hswaw/labelmaker">code.hackerspace.pl/hswaw/labelmaker</a></p>
|
on <a href="https://code.hackerspace.pl/hswaw/labelmaker">code.hackerspace.pl/hswaw/labelmaker</a></p>
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
<script src="https://code.jquery.com/jquery-2.1.4.min.js"></script>
|
<script src="jquery-2.1.4.min.js"></script>
|
||||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
|
<script src="bootstrap.min.js"></script>
|
||||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-growl/1.0.0/jquery.bootstrap-growl.min.js"></script>
|
<script src="jquery.bootstrap-growl.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
var generatePreview = function () {
|
var generatePreview = function () {
|
||||||
|
|
4
labelmaker/templates/jquery-2.1.4.min.js
vendored
Normal file
4
labelmaker/templates/jquery-2.1.4.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
2
labelmaker/templates/jquery.bootstrap-growl.min.js
vendored
Normal file
2
labelmaker/templates/jquery.bootstrap-growl.min.js
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
/* https://github.com/ifightcrime/bootstrap-growl */
|
||||||
|
(function(e){e.bootstrapGrowl=function(t,n){var n=e.extend({},e.bootstrapGrowl.default_options,n),r=e("<div>");r.attr("class","bootstrap-growl alert"),n.type&&r.addClass("alert-"+n.type),n.allow_dismiss&&r.append('<a class="close" data-dismiss="alert" href="#">×</a>'),r.append(t),n.top_offset&&(n.offset={from:"top",amount:n.top_offset});var i=e(".bootstrap-growl",n.ele);offsetAmount=n.offset.amount,e.each(i,function(){offsetAmount=offsetAmount+e(this).outerHeight()+n.stackup_spacing}),css={position:"absolute",margin:0,"z-index":"9999",display:"none"},css[n.offset.from]=offsetAmount+"px",r.css(css),n.width!=="auto"&&r.css("width",n.width+"px"),e(n.ele).append(r);switch(n.align){case"center":r.css({left:"50%","margin-left":"-"+r.outerWidth()/2+"px"});break;case"left":r.css("left","20px");break;default:r.css("right","20px")}r.fadeIn(),n.delay>=0&&r.delay(n.delay).fadeOut("slow",function(){e(this).remove()})},e.bootstrapGrowl.default_options={ele:"body",type:null,offset:{from:"top",amount:20},align:"right",width:250,delay:4e3,allow_dismiss:!0,stackup_spacing:10}})(jQuery);
|
Loading…
Reference in a new issue