lol update

This commit is contained in:
wiktor 2023-03-05 23:56:28 +01:00
parent ee305d2804
commit a2137e1f8b
8 changed files with 254 additions and 10 deletions

View File

@ -11,14 +11,42 @@ GEM
specs:
addressable (2.7.0)
public_suffix (>= 2.0.2, < 5.0)
celluloid (0.18.0)
timers (~> 4)
celluloid-io (0.17.3)
celluloid (>= 0.17.2)
nio4r (>= 1.1)
timers (>= 4.1.1)
chunky_png (1.3.11)
color (1.8)
css_parser (1.7.1)
addressable
daemons (1.4.1)
domain_name (0.5.20190701)
unf (>= 0.0.5, < 1.0.0)
eventmachine (1.2.7)
excon (0.73.0)
ffi (1.15.5)
ffi-compiler (1.0.1)
ffi (>= 1.0.0)
rake
http (5.0.1)
addressable (~> 2.3)
http-cookie (~> 1.0)
http-form_data (~> 2.2)
llhttp-ffi (~> 0.3.0)
http-cookie (1.0.4)
domain_name (~> 0.5)
http-form_data (2.3.0)
http_parser.rb (0.8.0)
json (2.3.0)
llhttp-ffi (0.3.1)
ffi-compiler (~> 1.0)
rake (~> 13.0)
matrix (0.4.2)
mustermann (1.1.1)
ruby2_keywords (~> 0.0.1)
nio4r (2.5.8)
pdf-core (0.7.0)
prawn (2.2.2)
pdf-core (~> 0.7.0)
@ -27,9 +55,18 @@ GEM
css_parser (~> 1.6)
prawn (>= 0.11.1, < 3)
public_suffix (4.0.5)
puma (5.6.4)
nio4r (~> 2.0)
rack (2.2.2)
rack-protection (2.0.8.1)
rack
rake (13.0.6)
reel (0.6.1)
celluloid (>= 0.15.1)
celluloid-io (>= 0.15.0)
http (>= 0.6.0.pre)
http_parser.rb (>= 0.6.0)
websocket-driver (>= 0.5.1)
rmagick (4.1.2)
rqrcode (1.1.2)
chunky_png (~> 1.0)
@ -41,8 +78,20 @@ GEM
rack (~> 2.0)
rack-protection (= 2.0.8.1)
tilt (~> 2.0)
thin (1.8.1)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0, >= 1.0.4)
rack (>= 1, < 3)
tilt (2.0.10)
timers (4.3.3)
ttfunk (1.6.2.1)
unf (0.1.4)
unf_ext
unf_ext (0.0.8.1)
webrick (1.7.0)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
PLATFORMS
ruby
@ -50,12 +99,18 @@ PLATFORMS
DEPENDENCIES
color
excon
http
json
matrix
prawn
prawn-qrcode!
prawn-svg
puma
reel
rmagick
sinatra
thin
webrick
BUNDLED WITH
1.17.2

1
assets/dead.svg Normal file
View File

@ -0,0 +1 @@
<?xml version="1.0" ?><svg width="64px" height="64px" viewBox="0 0 64 64" xmlns="http://www.w3.org/2000/svg"><g data-name="Layer 27" id="Layer_27"><path d="M32,3A29,29,0,1,0,61,32,29,29,0,0,0,32,3Zm0,56A27,27,0,1,1,59,32,27,27,0,0,1,32,59ZM47.71,17.71,43.41,22l4.3,4.29a1,1,0,0,1,0,1.42,1,1,0,0,1-1.42,0L42,23.41l-4.29,4.3a1,1,0,0,1-1.42,0,1,1,0,0,1,0-1.42L40.59,22l-4.3-4.29a1,1,0,0,1,1.42-1.42L42,20.59l4.29-4.3a1,1,0,0,1,1.42,1.42ZM22,23.41l-4.29,4.3a1,1,0,0,1-1.42,0,1,1,0,0,1,0-1.42L20.59,22l-4.3-4.29a1,1,0,0,1,1.42-1.42L22,20.59l4.29-4.3a1,1,0,0,1,1.42,1.42L23.41,22l4.3,4.29a1,1,0,0,1,0,1.42,1,1,0,0,1-1.42,0ZM32,33c-3.31,0-6,3.36-6,7.5S28.69,48,32,48s6-3.36,6-7.5S35.31,33,32,33Zm0,13c-2.21,0-4-2.47-4-5.5S29.79,35,32,35s4,2.47,4,5.5S34.21,46,32,46Z"/></g></svg>

After

Width:  |  Height:  |  Size: 771 B

1
assets/glider.svg Normal file
View File

@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="140" height="140"><g transform="matrix(20,0,0,20,10,10)"><path d="m0 0h6v6h-6zm0 2h6m-6 2h6m-4-4v6m2-6v6" style="fill:none;stroke:#000;stroke-width:.1;"/><circle cx="3" cy="1" r=".8"/><circle cx="5" cy="3" r=".8"/><circle cx="1" cy="5" r=".8"/><circle cx="3" cy="5" r=".8"/><circle cx="5" cy="5" r=".8"/></g></svg>

After

Width:  |  Height:  |  Size: 412 B

51
assets/hswro.svg Executable file
View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="Layer_1"
x="0px"
y="0px"
width="100"
height="100"
viewBox="0 0 99.999998 99.999998"
enable-background="new 0 0 595.28 841.89"
xml:space="preserve"
sodipodi:docname="hswro.svg"
inkscape:version="1.0.1 (3bc2e813f5, 2020-09-07)"><metadata
id="metadata941"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs939">
</defs><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1920"
inkscape:window-height="1027"
id="namedview937"
showgrid="false"
inkscape:zoom="2.8590332"
inkscape:cx="95.237875"
inkscape:cy="137.49347"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:current-layer="Layer_1" />
<path
d="m 72.207,33.822 5.733,-1.434 2.004,-20.054 h -29.143 -1 -9.233 l 0.816,29.389 -3.892,-1.245 -1.563,-28.144 h -8.99 -0.462 -6.421 l 6.043,58.737 0.023,0.225 5.458,3.898 7.323,-3.675 -0.71,-15.638 12.109,5.39 11.807,-5.294 -0.348,7.586 -4.04,2.103 -7.418,-3.604 -7.94,3.813 0.46,16.886 7.486,4.905 23.666,-16.522 3.162,-30.573 -8.386,-1.699 -9.732,2.948 0.537,-15.876 4.069,-0.606 -0.229,7.37 z M 34.982,13.334 36.49,40.465 29.323,42.257 27.018,13.334 Z m -2.924,60.5 -1.897,-21.528 7.009,3.12 0.704,15.49 z m -1.409,-30.878 6.346,-1.586 4.418,1.413 0.106,3.828 z m 27.649,23.536 4.434,-2.309 0.003,-0.073 5.993,2.912 -10.739,6.665 z m -7.998,-3.32 6.316,3.068 -6.314,3.287 -6.317,-3.321 z m 18.501,-23.27 5.902,1.196 -15.844,5.494 0.126,-3.717 z M 58.584,25.077 57.972,43.181 h 10e-4 L 57.808,48.014 76.014,41.701 73.027,70.587 50.799,86.105 V 70.397 l 6.474,-3.371 -0.364,8.51 12.826,-7.96 L 71.279,50.769 50.8,59.952 V 13.334 h 28.039 l -1.824,18.254 -4.288,1.073 0.731,-9.801 -9.389,1.399 v 0 z"
id="path932" />
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

1
assets/money.svg Normal file
View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 100 100" enable-background="new 0 0 100 100" xml:space="preserve"><g><path fill-rule="evenodd" clip-rule="evenodd" d="M27.629,77.803c0-4.808,3.903-8.711,8.711-8.711c4.796,0,8.699,3.903,8.699,8.711 c0,4.797-3.903,8.698-8.699,8.698C31.532,86.501,27.629,82.6,27.629,77.803z"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M83.373,58.725l-7.477,12.952l-16.203-9.354c-2.117,3.223-5.76,5.358-9.894,5.358 c-5.466,0-10.063-3.721-11.427-8.752L12.3,65.918L20.094,95l68.111-18.244L83.373,58.725z M36.34,89.64 c-6.536,0-11.85-5.313-11.85-11.837c0-6.536,5.313-11.838,11.85-11.838c6.524,0,11.838,5.302,11.838,11.838 C48.178,84.326,42.864,89.64,36.34,89.64z"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M41.089,55.843c0-4.808,3.902-8.711,8.71-8.711c4.796,0,8.7,3.903,8.7,8.711 c0,4.797-3.904,8.698-8.7,8.698C44.992,64.541,41.089,60.64,41.089,55.843z"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M31.026,50.294c0,5.679-4.608,10.275-10.274,10.275 c-5.678,0-10.274-4.597-10.274-10.275c0-5.666,4.596-10.274,10.274-10.274C26.418,40.02,31.026,44.628,31.026,50.294z"></path><g><path fill-rule="evenodd" clip-rule="evenodd" d="M51.281,36.246l-1.846,3.198c0.635,0.199,1.164,0.234,1.6,0.094 c0.434-0.141,0.75-0.388,0.951-0.752c0.188-0.307,0.236-0.659,0.176-1.047C52.092,37.352,51.799,36.847,51.281,36.246z"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M28.464,5L13.405,31.074l28.164,16.262c2.133-2.065,5.034-3.343,8.231-3.343 c6.524,0,11.839,5.313,11.839,11.85c0,0.99-0.137,1.948-0.369,2.869l13.193,7.617l15.059-26.086L28.464,5z M59.463,33.483 l-4.02-1.551c0.082-0.564,0.094-0.987,0.045-1.258c-0.045-0.271-0.188-0.6-0.422-0.976l-1.668,2.879 c1.715,1.705,2.738,3.046,3.066,4.033c0.436,1.316,0.295,2.598-0.422,3.832c-0.412,0.717-0.965,1.293-1.635,1.704 c-0.67,0.423-1.363,0.682-2.104,0.8c-0.73,0.117-1.435,0.105-2.105-0.047c-0.67-0.142-1.422-0.436-2.257-0.87l-1.093,1.893 l-1.446-0.835l1.093-1.893c-0.917-0.646-1.623-1.258-2.092-1.834c-0.482-0.575-0.823-1.199-1.023-1.857 c-0.211-0.657-0.294-1.281-0.271-1.893c0.036-0.599,0.176-1.27,0.447-1.998l4.268,1.846c-0.259,0.729-0.365,1.293-0.33,1.705 c0.036,0.41,0.223,0.857,0.553,1.352L50.082,35c-1.128-1.151-1.893-2.021-2.292-2.609c-0.399-0.6-0.635-1.316-0.706-2.151 c-0.059-0.834,0.153-1.692,0.659-2.551c0.682-1.188,1.658-1.928,2.938-2.245c1.293-0.317,2.776-0.047,4.456,0.8l0.553-0.977 l1.445,0.835l-0.564,0.976c1.436,0.952,2.363,1.963,2.799,3.021C59.803,31.156,59.84,32.284,59.463,33.483z"></path><path fill-rule="evenodd" clip-rule="evenodd" d="M52.467,28.829c-0.281,0.105-0.504,0.306-0.656,0.576 c-0.176,0.294-0.236,0.599-0.188,0.905c0.033,0.317,0.223,0.669,0.551,1.045l1.469-2.538C53.15,28.711,52.75,28.711,52.467,28.829 z"></path></g></g></svg>

After

Width:  |  Height:  |  Size: 2.8 KiB

4
assets/person.svg Normal file
View File

@ -0,0 +1,4 @@
<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48">
<path d="M24 24c4.42 0 8-3.59 8-8 0-4.42-3.58-8-8-8s-8 3.58-8 8c0 4.41 3.58 8 8 8zm0 4c-5.33 0-16 2.67-16 8v4h32v-4c0-5.33-10.67-8-16-8z"/>
<path d="M0 0h48v48h-48z" fill="none"/>
</svg>

After

Width:  |  Height:  |  Size: 279 B

32
assets/warning.svg Normal file
View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1"
id="svg2" xmlns:svg="http://www.w3.org/2000/svg" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:cc="http://creativecommons.org/ns#" inkscape:version="0.48.3.1 r9886" sodipodi:docname="warning_sign_font_awesome.svg"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="603px" height="555.25px"
viewBox="137.445 6.89 603 555.25" enable-background="new 137.445 6.89 603 555.25" xml:space="preserve">
<sodipodi:namedview inkscape:cy="243.77216" inkscape:cx="156.80493" guidetolerance="10" showgrid="false" borderopacity="1" inkscape:zoom="0.13169643" gridtolerance="10" pagecolor="#ffffff" bordercolor="#666666" objecttolerance="10" id="namedview8" inkscape:current-layer="svg2" inkscape:window-maximized="1" inkscape:window-y="25" inkscape:window-x="0" inkscape:pageopacity="0" inkscape:window-height="719" inkscape:pageshadow="2" inkscape:window-width="1024">
</sodipodi:namedview>
<g id="g4" transform="matrix(1,0,0,-1,7.5932254,1333.7966)">
<g id="path6" inkscape:connector-curvature="0">
<path d="M431.547,1293.104c2.243,0,4.021-0.492,5.942-1.645c2.004-1.202,3.416-2.683,4.58-4.802l252.559-463.022l0.056-0.103
l0.057-0.101c2.502-4.505,2.438-7.015-0.316-11.703c-1.087-1.854-2.439-3.181-4.392-4.306c-1.899-1.095-3.721-1.583-5.903-1.583
H178.964c-2.183,0-4.003,0.488-5.908,1.587c-1.947,1.121-3.3,2.448-4.401,4.327c-2.739,4.663-2.804,7.173-0.301,11.678
l0.056,0.101l0.056,0.103l252.572,463.047c1.162,2.105,2.572,3.58,4.567,4.777
C427.525,1292.612,429.303,1293.104,431.547,1293.104 M431.547,1323.104c-7.674,0-14.8-1.973-21.377-5.92
c-6.578-3.947-11.73-9.318-15.458-16.115L142.128,838c-7.674-13.813-7.455-27.627,0.658-41.439
c3.727-6.359,8.825-11.402,15.293-15.129c6.468-3.729,13.429-5.592,20.884-5.592h505.165c7.455,0,14.416,1.863,20.885,5.592
c6.469,3.727,11.566,8.77,15.293,15.129c8.113,13.813,8.332,27.626,0.658,41.439l-252.584,463.068
c-3.727,6.797-8.879,12.168-15.457,16.115S439.221,1323.104,431.547,1323.104L431.547,1323.104z"/>
</g>
</g>
<g id="g4_1_" transform="matrix(1,0,0,-1,7.5932254,1333.7966)">
<path id="path6_1_" inkscape:connector-curvature="0" d="M473.645,870.749v62.488c0,3.069-1.043,5.646-3.125,7.729
c-2.084,2.083-4.549,3.124-7.4,3.124h-63.146c-2.851,0-5.317-1.041-7.399-3.124c-2.084-2.083-3.125-4.659-3.125-7.729v-62.488
c0-3.069,1.041-5.646,3.125-7.729c2.082-2.083,4.549-3.124,7.399-3.124h63.146c2.852,0,5.316,1.041,7.4,3.124
C472.602,865.104,473.645,867.68,473.645,870.749z M472.986,993.752l5.92,150.958c0,2.631-1.096,4.714-3.289,6.249
c-2.85,2.412-5.482,3.618-7.893,3.618h-72.355c-2.412,0-5.043-1.206-7.893-3.618c-2.193-1.535-3.289-3.837-3.289-6.907l5.591-150.3
c0-2.193,1.097-4.002,3.289-5.427s4.823-2.138,7.894-2.138h60.844c3.068,0,5.645,0.713,7.729,2.138
C471.615,989.75,472.768,991.559,472.986,993.752z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.2 KiB

119
main.rb
View File

@ -37,7 +37,7 @@ module Excon
end
end
BACKEND_URL = 'http://spejstore:8000/api/1/'
BACKEND_URL = 'http://192.168.75.155:8000/api/1/'
CODE_PREFIX = "HTTP://I/"
def api(uri)
@ -70,8 +70,12 @@ end
DYMO_LABEL_SIZE = [89, 36]
ZEBRA_LABEL_SIZE = [50, 30]
def render_label(item_or_label_id, size: ZEBRA_LABEL_SIZE)
item = api("items/#{item_or_label_id}")
def render_label(dict_or_api, is_qr, item_or_label_id, size: ZEBRA_LABEL_SIZE)
if dict_or_api
item = item_or_label_id
else
item = api("items/#{item_or_label_id}")
end
pdf = Prawn::Document.new(page_size: size.map { |x| mm2pt(x) },
margin: [2, 2, 2, 6].map { |x| mm2pt(x) }) do
@ -89,9 +93,12 @@ def render_label(item_or_label_id, size: ZEBRA_LABEL_SIZE)
# Right side
bounding_box([bounds.right - qr_size, bounds.top], width: qr_size) do
print_qr_code CODE_PREFIX + item['short_id'], stroke: false,
foreground_color: '000000',
extent: bounds.width, margin: 0, pos: bounds.top_left
if is_qr
print_qr_code CODE_PREFIX + item['short_id'], stroke: false,
foreground_color: '000000',
extent: bounds.width, margin: 0, pos: bounds.top_left
end
owner_text = item["owner"] ? "owner: #{item['owner']}\n\n" : ""
metadata_text = owner_text # todo: creation date?
@ -111,17 +118,43 @@ def render_label(item_or_label_id, size: ZEBRA_LABEL_SIZE)
pdf.render
end
def render_hack(data, size: ZEBRA_LABEL_SIZE)
pdf = Prawn::Document.new(page_size: size.map { |x| mm2pt(x) },
margin: [2, 2, 2, 6].map { |x| mm2pt(x) }) do
font_families.update("DejaVuSans" => {
normal: "fonts/DejaVuSans.ttf",
italic: "fonts/DejaVuSans-Oblique.ttf",
bold: "fonts/DejaVuSans-Bold.ttf",
bold_italic: "fonts/DejaVuSans-BoldOblique.ttf"
})
font 'DejaVuSans'
image_size = [bounds.height / 2, 27].max
svg IO.read(data['image']), width: image_size, position: :right
bounding_box(bounds.top_left, width: bounds.width - image_size) do
text_box data['text'],
size: 40, align: :center, valign: :center, width: bounds.width-10,
inline_format: true, overflow: :shrink_to_fit, disable_wrap_by_char: true
end
end
pdf.render
end
set :bind, '0.0.0.0'
get '/api/1/preview/:id.pdf' do
headers["Content-Type"] = "application/pdf; charset=utf8"
render_label params["id"]
render_label(false,true,params["id"])
end
get '/api/1/preview/:id.png' do
headers["Content-Type"] = "image/png"
img = Magick::ImageList.new()
img = img.from_blob(render_label(params["id"])){ self.density = 200 }.first
img = img.from_blob(render_label(false,true,params["id"])){ self.density = 200 }.first
img.format = 'png'
img.background_color = 'white'
img.to_blob
@ -129,7 +162,73 @@ end
post '/api/1/print/:id' do
temp = Tempfile.new('labelmaker')
temp.write(render_label(params["id"]))
temp.write(render_label(false,true, params["id"]))
temp.close
system("lpr -P DYMO_LabelWriter_450 #{temp.path}")
system("lpr -P Zebra #{temp.path}")
end
get '/api/1/testprint' do
test = {"owner" => "grzegorz_brzęczyszczykiewicz", "short_id" => "wszczebrzeszyniechrzaszczbrzmiwtrzcinie", "name" => "pchnąć w tę łódź jeża lub ośm skrzyń fig"}
temp = Tempfile.new('labelmaker')
temp.write(render_label(true,true,test))
temp.close
system("lpr -P Zebra #{temp.path}")
end
get '/api/1/testshow' do
test = {"owner" => "grzegorz_brzęczyszczykiewicz", "short_id" => "wszczebrzeszyniechrzaszczbrzmiwtrzcinie", "name" => "pchnąć w tę łódź jeża lub ośm skrzyń fig"}
headers["Content-Type"] = "application/pdf; charset=utf8"
render_label(true, true, test)
end
templates = {
"prywatne" => { "text" => "Ten przedmiot jest własnością prywatną", "image" => "assets/person.svg"},
"hsowe" => { "text" => "Ten przedmiot należy do HSWro", "image" => "assets/hswro.svg"},
"hackuj" => { "text" => "Hackuj ile dusza zapragnie", "image" => "assets/glider.svg"},
"zepsute" => { "text" => "Ten przedmiot jest zepsuty", "image" => "assets/dead.svg"},
"eksploatuje" => { "text" => "Ten przedmiot eksploatuje materiały", "image" => "assets/money.svg"},
"niehackuj" => { "text" => "Nie hackuj tego przedmiotu", "image" => "assets/glider.svg"},
# meme
"bhp" => { "text" => "Gdy ci smutno, gdy ci źle, użyj pasty BHP", "image" => "assets/hswro.svg"},
}
get '/api/1/templates/preview/:id' do
headers["Content-Type"] = "application/pdf; charset=utf8"
render_hack(templates[params["id"]])
end
get '/api/1/templates/print/:id' do
temp = Tempfile.new('labelmaker')
temp.write(render_hack(templates[params["id"]]))
temp.close
system("lpr -P Zebra #{temp.path}")
end
get '/api/1/nametag/preview/:id' do
headers["Content-Type"] = "application/pdf; charset=utf8"
render_hack({"text" => params['id'], "image" => "assets/hswro.svg"})
end
get '/api/1/nametag/print/:id' do
temp = Tempfile.new('labelmaker')
temp.write(render_hack({"text" => params['id'], "image" => "assets/hswro.svg"}))
temp.close
system("lpr -P Zebra #{temp.path}")
end
get '/api/1/customitem/preview/:owner/:name' do
test = {"owner" => params["owner"], "short_id" => "test", "name" => params["name"]}
headers["Content-Type"] = "application/pdf; charset=utf8"
render_label(true,false,test)
end
get '/api/1/customitem/print/:owner/:name' do
test = {"owner" => params["owner"], "short_id" => "test", "name" => params["name"]}
temp = Tempfile.new('labelmaker')
temp.write(render_label(true,false,test))
temp.close
system("lpr -P Zebra #{temp.path}")
end