Forgejo actions config
Some checks failed
ci / docker (push) Failing after 17s
/ Test (push) Successful in 2s
/ Checkout (push) Successful in 10s
/ Build (push) Failing after 5s

This commit is contained in:
david 2024-07-22 01:29:09 +02:00
parent 6e4f8937eb
commit 80d09eee99
6 changed files with 55 additions and 24 deletions

View file

@ -1,14 +1,17 @@
module PdfDocuments
class Base
attr_reader :params
def initialize(prawn_document, **params)
@prawn_document = prawn_document
@prawn_document.markup_options = markup_options
@prawn_document.font_families.update('Lexend' => {
normal: 'vendor/assets/fonts/Lexend-Light.ttf',
bold: 'vendor/assets/fonts/Lexend-Bold.ttf',
italic: 'vendor/assets/fonts/Lexend-Regular.ttf'
})
@prawn_document.font 'Lexend'
# @prawn_document.font_families.update('Lexend' => {
# normal: 'vendor/assets/fonts/Lexend-Light.ttf',
# bold: 'vendor/assets/fonts/Lexend-Bold.ttf',
# exta_bold: 'vendor/assets/fonts/Lexend-ExtraBold.ttf',
# italic: 'vendor/assets/fonts/Lexend-Regular.ttf'
# })
@prawn_document.font 'Helvetica', size: 12
@params = OpenStruct.new(params)
end
@ -24,14 +27,14 @@ module PdfDocuments
end
def heading1(text)
@prawn_document.markup "<h1><u>#{text}</u></h1>"
@prawn_document.markup "<h1>#{text}</h1>"
end
def heading2(text)
@prawn_document.markup "<h2>#{text}</h2>"
end
def heading2(text)
def heading3(text)
@prawn_document.markup "<h3>#{text}</h3>"
end
@ -43,18 +46,27 @@ module PdfDocuments
@prawn_document.markup prepare_rich_text(text)
end
def hr
@prawn_document.markup '<hr>'
end
def markup_options
{
text: { size: 10, margin_bottom: 10 },
heading1: { style: :bold, size: 24, margin_bottom: 10, margin_top: 20 },
heading2: { style: :bold, size: 18, margin_bottom: 10, margin_top: 15 },
heading3: { style: :bold, size: 16, margin_bottom: 10, margin_top: 10 },
heading4: { style: :bold, size: 14, margin_bottom: 10, margin_top: 5 },
heading5: { style: :bold, size: 14, margin_bottom: 10, margin_top: 5 },
heading6: { style: :thin, size: 14, margin_bottom: 10, margin_top: 5 }
text: { size: 12, margin_bottom: 5 },
heading1: { style: :bold, size: 26, margin_bottom: 10, margin_top: 0 },
heading2: { style: :bold, size: 17, margin_bottom: 10, margin_top: 5 },
heading3: { style: :bold, size: 13, margin_bottom: 10, margin_top: 5 },
heading4: { style: :bold, size: 12, margin_bottom: 10, margin_top: 5 },
heading5: { style: :bold, size: 12, margin_bottom: 10, margin_top: 5 },
heading6: { style: :thin, size: 12, margin_bottom: 10, margin_top: 5 }
}
end
def logo
@prawn_document.image 'app/assets/images/logo-apfelschule.png', width: 150
@prawn_document.move_down 30
end
def prepare_rich_text(rich_text)
{ h1: 'h4' }.each do |tag, replacement|
rich_text = rich_text.to_s.gsub("<#{tag}", "<#{replacement}")
@ -63,5 +75,17 @@ module PdfDocuments
rich_text
end
def font(...)
@prawn_document.font(...)
end
def formatted_text(...)
@prawn_document.formatted_text(...)
end
def move_down(...)
@prawn_document.move_down(...)
end
end
end