add ht 7ds template

This commit is contained in:
24c02 2025-07-09 15:34:27 -04:00
parent ece585abc5
commit c59e2136f5
7 changed files with 69 additions and 2 deletions

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 167 KiB

View file

@ -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

View file

@ -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

View file

@ -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

Binary file not shown.