diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..0a35d2e --- /dev/null +++ b/Dockerfile @@ -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 diff --git a/Gemfile b/Gemfile index 111df68..6a51ffe 100644 --- a/Gemfile +++ b/Gemfile @@ -8,3 +8,9 @@ gem 'color' gem 'excon' gem 'rmagick' gem 'json' +gem 'matrix' +gem 'thin' +gem 'puma' +gem 'reel' +gem 'http' +gem 'webrick' diff --git a/main.rb b/main.rb index 65a7403..3f531eb 100644 --- a/main.rb +++ b/main.rb @@ -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