damoiser / qr-bills

Ruby Gem to generate QR-Bills for Swiss payments
BSD 3-Clause "New" or "Revised" License
21 stars 15 forks source link

Add SVG support #23

Closed danielpuglisi closed 2 years ago

danielpuglisi commented 2 years ago

This PR adds SVG support (#22).

To support both SVG and PNG during the HTML layout generation I added image data url support: https://github.com/damoiser/qr-bills/compare/master...codegestalt:svg-support?expand=1#diff-1707220acf1a40ad0f84d3991ef6d6f567c0b9b63b390548a0ef7e1047d17989R11

The parameter qrcode_filepath has been removed. Using base64 encryption we don't need to touch the file system for the png format anymore and can use the existing layout without having to add additional format logic.

The parameter qrcode_format has been added. As when generating HTML with params[:output_params][:format] there was no way of specifying the qr code format. params[:qrcode_format] solves this. Although I think this is a bit smelly. Imo QRBills.generate should just focus on generating the entire HTML payslip and remove support for creating png / svg qr codes and leave that logic to QRGenerator.create. I would even go so far as to remove QRBills.generate entirely and tell people to use QRHTMLayout.create for generating an entire payslip and QRGenerator.create for just qr codes.

danielpuglisi commented 2 years ago

Added some SVG optimizations based on:

damoiser commented 2 years ago

thx for the PR! I would need to do some more deep checks on the svg changes, in the meantime, can you please check my feedback and fix the merge conflicts?

danielpuglisi commented 2 years ago

Merge conflicts are fixed. I don't see any other feedback regarding this PR. Did you add comments somewhere that I might have missed?

Regarding the code changes: There are some potential backwards incompatibilities if existing users call the following methods directly in their code base:

damoiser commented 2 years ago

sorry forget to publish the feedbacks, you should see now @danielpuglisi

danielpuglisi commented 2 years ago

Latest commit addresses your comments:

damoiser commented 2 years ago

thx a lot for the great PR @danielpuglisi !

danielpuglisi commented 2 years ago

You're welcome, thx for merging 🙏😊