diff --git a/app/services/voting_poster_creation.rb b/app/services/voting_poster_creation.rb index c7f91aac..7c44cf38 100644 --- a/app/services/voting_poster_creation.rb +++ b/app/services/voting_poster_creation.rb @@ -10,6 +10,7 @@ class VotingPosterCreation < ApplicationService def initialize(exhibit) @exhibit = exhibit @url = new_vote_url(@exhibit) + @stroke_bounds = false end def call @@ -17,26 +18,39 @@ def call end def filename - type = @exhibit.is_collab? ? 'COLLAB' : 'MOC'; + type = @exhibit.is_collab? ? 'COLLAB' : 'MOC' "#{type}-voting-#{@exhibit.id}-#{@exhibit.platform_position}.pdf" end private def voting_poster - throw "Exhibit #{@exhibit.to_s} is not votable" if not @exhibit.votable? - pdf = Prawn::Document.new(margin: 7, page_size: 'A6', page_layout: :landscape, print_scaling: :none) + throw "Exhibit #{@exhibit.to_s} is not votable" unless @exhibit.votable? + + pdf = Prawn::Document.new(margin: 7, page_size: 'A6', page_layout: :portrait, print_scaling: :none) + width = pdf.bounds.width height = pdf.bounds.height + name_top = height - 40 + name_height = 75 + instructions_top = name_top - name_height + instructions_height = 60 + qr_top = instructions_top - instructions_height + qr_height = 220 + logo_url = @exhibit.attendance.event.logo_url unless logo_url.blank? pdf.image URI.parse(logo_url).open, - position: :center, vposition: :top, width: width * 0.9, height: height * 0.2 + position: :center, vposition: :top, width: width * 0.9 + else + pdf.text @exhibit.event_title, align: :center, style: :bold, size: 14 end - pdf.text @exhibit.event_title, align: :center, style: :bold, size: 12 pdf.float do - pdf.image StringIO.new(qr_png.to_datastream.to_s), position: :right, vposition: :bottom, scale: 1.20 + pdf.bounding_box([0, qr_top], width: width, height: qr_height) do + pdf.stroke_bounds if @stroke_bounds + pdf.image StringIO.new(qr_png.to_datastream.to_s), position: :center, fit: [width, qr_height] + end end pdf.float do @@ -45,35 +59,39 @@ def voting_poster end pdf.float do - pdf.bounding_box([0, 110], width: 275, height: 70) do + pdf.bounding_box([0, instructions_top], width: width, height: instructions_height) do + pdf.stroke_bounds if @stroke_bounds current_locale = I18n.locale - I18n.locale = :de - pdf.text I18n.t('voting_poster_intro'), align: :right - pdf.text I18n.t('voting_poster_instruction'), align: :right - pdf.move_down 5.mm - I18n.locale = :en - pdf.text I18n.t('voting_poster_intro'), align: :right - pdf.text I18n.t('voting_poster_instruction'), align: :right + [:de, :en].each do |locale| + I18n.locale = locale + pdf.move_down 1.mm + pdf.text I18n.t('voting_poster_intro'), align: :center, style: :bold + pdf.text I18n.t('voting_poster_instruction'), align: :center + end I18n.locale = current_locale end end pdf.float do + pdf.bounding_box([0, name_top], width: width, height: name_height) do + pdf.stroke_bounds if @stroke_bounds + end pdf.text_box "#{@exhibit.name}" + "#{'
(' + @exhibit.installation.name + ')' if @exhibit.installation}" + "#{'
(Gemeinschaftsprojekt / Collab)' if @exhibit.is_collab?}", inline_format: true, - at: [0, 210], + at: [0, name_top], width: width, - height: 80, + height: name_height, overflow: :shrink_to_fit, style: :bold, size: 24, align: :center, valign: :center end pdf.float do - pdf.bounding_box([0, 40], width: 275, height: 40) do - pdf.text @exhibit.platform_position, style: :bold, size: 24, valign: :bottom + pdf.bounding_box([0, 20], width: width * 0.6, height: 20) do + pdf.stroke_bounds if @stroke_bounds + pdf.text @exhibit.platform_position, style: :bold, size: 18, valign: :bottom end end @@ -81,6 +99,7 @@ def voting_poster end def qr_png - RQRCode::QRCode.new(@url).as_png + RQRCode::QRCode.new(@url).as_png(size: 100) end + end diff --git a/config/locales/application.de.yml b/config/locales/application.de.yml index 00897d06..bce0c792 100644 --- a/config/locales/application.de.yml +++ b/config/locales/application.de.yml @@ -195,8 +195,8 @@ de: no_file_added: "Keine Datei angegeben" only_csv_files_allowed: "Nur CSV-Dateien können importiert werden" vote_for: "Ich möchte abstimmen für das MOC" - voting_poster_intro: "Wähle dieses Modell als einen Deiner Favoriten" - voting_poster_instruction: "Zur Stimmabgabe den QR Code scannen" + voting_poster_intro: "Gefällt Dir das Modell?" + voting_poster_instruction: "Dann scanne den Code und gibt Deine Stimme ab!" exhibit_voting_results_for: "Ergebnisse der MOC-Wahl für" no_votes: "Keine abgegebenen Stimmen" number_of_votes: "Es wurden %{size} Stimmen abgegeben" diff --git a/config/locales/application.en.yml b/config/locales/application.en.yml index 9d7723ab..456f4d63 100644 --- a/config/locales/application.en.yml +++ b/config/locales/application.en.yml @@ -195,8 +195,8 @@ en: no_file_added: "No file added" only_csv_files_allowed: "Only CSV files allowed" vote_for: "I'd like to vote for MOC" - voting_poster_intro: "Vote for this model as one of your favorites" - voting_poster_instruction: "To vote scan the QR code" + voting_poster_intro: "You like the model?" + voting_poster_instruction: "Then scan the code and cast your vote!" exhibit_voting_results_for: "Results of the MOC voting for" no_votes: "No votes" number_of_votes: "We got %{size} votes"