main.rb: rename base URLs

labelmaker-in-tree
Stan Drozd 2021-03-07 03:29:40 +01:00
parent 546a4f026b
commit 9a7c2271e7
No known key found for this signature in database
GPG Key ID: E96EA51A5D7F84E7
1 changed files with 9 additions and 8 deletions

View File

@ -37,11 +37,11 @@ module Excon
end
end
BACKEND_URL = ENV['BACKEND_URL'] || 'https://inventory.waw.hackerspace.pl/api/1/'
CODE_PREFIX = ENV['CODE_PREFIX'] || 'HTTP://I/'
SPEJSTORE_BASE_URL = ENV['SPEJSTORE_BASE_URL'] || 'https://inventory.waw.hackerspace.pl/api/1/'
QR_BASE_URL = ENV['QR_BASE_URL'] || 'HTTP://I/'
def api(uri)
Excon.get(BACKEND_URL + uri + "/").json!
Excon.get(SPEJSTORE_BASE_URL + uri + "/").json!
end
def render_identicode(data, id, extent)
@ -76,11 +76,12 @@ def render_label(item_or_label_id, size: DYMO_LABEL_SIZE)
pdf = Prawn::Document.new(page_size: size.map { |x| mm2pt(x) },
margin: [2, 2, 2, 6].map { |x| mm2pt(x) }) do
base_dir = File.dirname(__FILE__)
font_families.update("DejaVuSans" => {
normal: "fonts/DejaVuSans.ttf",
italic: "fonts/DejaVuSans-Oblique.ttf",
bold: "fonts/DejaVuSans-Bold.ttf",
bold_italic: "fonts/DejaVuSans-BoldOblique.ttf"
normal: base_dir + "/fonts/DejaVuSans.ttf",
italic: base_dir + "/fonts/DejaVuSans-Oblique.ttf",
bold: base_dir + "/fonts/DejaVuSans-Bold.ttf",
bold_italic: base_dir + "/fonts/DejaVuSans-BoldOblique.ttf"
})
font 'DejaVuSans'
@ -90,7 +91,7 @@ def render_label(item_or_label_id, size: DYMO_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,
print_qr_code QR_BASE_URL + item['short_id'], stroke: false,
foreground_color: '000000',
extent: bounds.width, margin: 0, pos: bounds.top_left