HSWro retrofitting

This commit is contained in:
wiktor 2022-05-22 00:57:16 +02:00
parent b49426a9df
commit 687bb6bdf1
3 changed files with 18 additions and 4 deletions

8
Dockerfile Normal file
View File

@ -0,0 +1,8 @@
FROM ruby:latest
RUN mkdir /code
WORKDIR /code
ADD Gemfile /code/
ADD . /code/
RUN bundle install
CMD bundle exec ruby main.rb

View File

@ -8,3 +8,9 @@ gem 'color'
gem 'excon'
gem 'rmagick'
gem 'json'
gem 'matrix'
gem 'thin'
gem 'puma'
gem 'reel'
gem 'http'
gem 'webrick'

View File

@ -37,7 +37,7 @@ module Excon
end
end
BACKEND_URL = 'https://inventory.waw.hackerspace.pl/api/1/'
BACKEND_URL = 'http://spejstore:8000/api/1/'
CODE_PREFIX = "HTTP://I/"
def api(uri)
@ -68,9 +68,9 @@ def render_identicode(data, id, extent)
end
DYMO_LABEL_SIZE = [89, 36]
ZEBRA_LABEL_SIZE = [100, 60]
ZEBRA_LABEL_SIZE = [50, 30]
def render_label(item_or_label_id, size: DYMO_LABEL_SIZE)
def render_label(item_or_label_id, size: ZEBRA_LABEL_SIZE)
item = api("items/#{item_or_label_id}")
pdf = Prawn::Document.new(page_size: size.map { |x| mm2pt(x) },
@ -131,5 +131,5 @@ post '/api/1/print/:id' do
temp = Tempfile.new('labelmaker')
temp.write(render_label(params["id"]))
temp.close
system("lpr -P DYMO_LabelWriter_450 #{temp.path}")
system("echo lpr -P DYMO_LabelWriter_450 #{temp.path}")
end