diff --git a/app/lib/snail_mail/assets/fonts/times.ttf b/app/lib/snail_mail/assets/fonts/times.ttf new file mode 100644 index 0000000..19f5624 Binary files /dev/null and b/app/lib/snail_mail/assets/fonts/times.ttf differ diff --git a/app/lib/snail_mail/assets/images/hackatime/7_day_streak.png b/app/lib/snail_mail/assets/images/hackatime/7_day_streak.png new file mode 100644 index 0000000..46888e1 Binary files /dev/null and b/app/lib/snail_mail/assets/images/hackatime/7_day_streak.png differ diff --git a/app/lib/snail_mail/assets/images/hackatime/this_is_fine.png b/app/lib/snail_mail/assets/images/hackatime/this_is_fine.png new file mode 100644 index 0000000..b4ec3b0 Binary files /dev/null and b/app/lib/snail_mail/assets/images/hackatime/this_is_fine.png differ diff --git a/app/lib/snail_mail/components/half_letter_component.rb b/app/lib/snail_mail/components/half_letter_component.rb index a1d3384..1cb5e8e 100644 --- a/app/lib/snail_mail/components/half_letter_component.rb +++ b/app/lib/snail_mail/components/half_letter_component.rb @@ -1,6 +1,8 @@ module SnailMail module Components class HalfLetterComponent < TemplateBase + def address_font = "f25" + def self.abstract? true end @@ -23,13 +25,13 @@ module SnailMail def render_back render_postage render_imb(bounds.right - 217, 25, 207) - render_return_address(5, bounds.top - 5, 190, 90, size: 8, font: "f25") + render_return_address(5, bounds.top - 5, 190, 90, size: 8, font: address_font) render_destination_address( (bounds.right/2)-256/2, (bounds.top/2)+107/2, 256, 107, - size: 18, valign: :center, align: :left + size: 18, valign: :center, align: :left, font: address_font ) render_qr_code(2, 52, 50) end diff --git a/app/lib/snail_mail/components/page_component.rb b/app/lib/snail_mail/components/page_component.rb index cbc0ed0..de93b0f 100644 --- a/app/lib/snail_mail/components/page_component.rb +++ b/app/lib/snail_mail/components/page_component.rb @@ -17,6 +17,7 @@ module SnailMail "imb" => { normal: font_path("imb.ttf") }, "gohu" => { normal: font_path("gohu.ttf") }, "noto" => { normal: font_path("noto sans regular.ttf") }, + "times" => { normal: font_path("times.ttf") }, ) end diff --git a/app/lib/snail_mail/components/templates/hackatime_7_day_streak_template.rb b/app/lib/snail_mail/components/templates/hackatime_7_day_streak_template.rb new file mode 100644 index 0000000..3e3e4f1 --- /dev/null +++ b/app/lib/snail_mail/components/templates/hackatime_7_day_streak_template.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: true + +module SnailMail + module Components + module Templates + class Hackatime7DayStreakTemplate < HalfLetterComponent + def self.abstract? = false + + def address_font = "times" + + def self.template_name + "Hackatime 7 Day Streak" + end + + def self.template_size + :half_letter + end + + + def render_front + image( + image_path("hackatime/7_day_streak.png"), + at: [10, bounds.top - 10], + height: bounds.top - 20, + ) + + ca = letter.metadata.dig("attributes", "created_at") + ca = Date.parse(ca) rescue nil if ca.present? + + text = <<~EOM + Dearest #{letter.address.first_name.upcase} #{letter.address.last_name[0]&.upcase}., + + #{ca.present? ? "On the #{ca.day.ordinalize} of #{Date::MONTHNAMES[ca.month]}" : "Recently"} you joined the ranks of those who have logged coding time on Hackatime 7 days in a row. + + In recognition of your achievement, we'd like to present you with this postcard. + + It is yours. You have earned it. + + Thank you for making your hours count. + We've enjoyed counting your hours. + + Best of luck to you in all your future endeavors. + + We'll be watching. + + Warmly, + the Hackatime Advisory Council + EOM + + font "times" do text_box text, at: [280, bounds.top-15], width: bounds.right - 280 - 20 end + end + + def render_back + super + image( + image_path("hackatime/this_is_fine.png"), + at: [0,130], + height: 140 + ) + end + end + end + end +end diff --git a/app/lib/test_print.pdf b/app/lib/test_print.pdf index e9bc4f9..6b8ed26 100644 Binary files a/app/lib/test_print.pdf and b/app/lib/test_print.pdf differ