refactor result generation

This commit is contained in:
DocuSeal
2023-10-11 21:05:42 +03:00
parent 761bb07ee6
commit 3dd7c47558
12 changed files with 40 additions and 25 deletions
+4
View File
@@ -58,6 +58,10 @@ module Docuseal
end
end
def product_name
PRODUCT_NAME
end
def refresh_default_url_options!
@default_url_options = nil
end
+1 -2
View File
@@ -1,12 +1,11 @@
# frozen_string_literal: true
module GenerateCertificate
NAME = Docuseal::PRODUCT_NAME
SIZE = 2**11
module_function
def call(name = NAME)
def call(name = Docuseal.product_name)
root_cert, root_key = generate_root_ca(name)
sub_cert, sub_key = generate_sub_ca(name, root_cert, root_key)
+14 -10
View File
@@ -17,7 +17,7 @@ module Submissions
'Helvetica'
end
INFO_CREATOR = "#{Docuseal::PRODUCT_NAME} (#{Docuseal::PRODUCT_URL})".freeze
INFO_CREATOR = "#{Docuseal.product_name} (#{Docuseal::PRODUCT_URL})".freeze
SIGN_REASON = 'Signed with DocuSeal.co'
VERIFIED_TEXT = if Docuseal.multitenant?
'Verified by DocuSeal'
@@ -62,15 +62,7 @@ module Submissions
composer.new_page
composer.column(columns: 1) do |column|
column.image(PdfIcons.logo_io, width: 40, height: 40, position: :float)
column.formatted_text([{ text: 'DocuSeal',
link: Docuseal::PRODUCT_URL }],
font_size: 20,
font: [FONT_BOLD_NAME, { variant: :bold }],
width: 100,
padding: [12, 0, 0, 8],
position: :float, position_hint: :left)
add_logo(column)
column.text('Audit Log',
font_size: 16,
@@ -270,6 +262,18 @@ module Submissions
record: submission
)
end
def add_logo(column)
column.image(PdfIcons.logo_io, width: 40, height: 40, position: :float)
column.formatted_text([{ text: 'DocuSeal',
link: Docuseal::PRODUCT_URL }],
font_size: 20,
font: [FONT_BOLD_NAME, { variant: :bold }],
width: 100,
padding: [12, 0, 0, 8],
position: :float, position_hint: :left)
end
# rubocop:enable Metrics
end
end
+11 -3
View File
@@ -10,7 +10,7 @@ module Submissions
'Helvetica'
end
INFO_CREATOR = "#{Docuseal::PRODUCT_NAME} (#{Docuseal::PRODUCT_URL})".freeze
INFO_CREATOR = "#{Docuseal.product_name} (#{Docuseal::PRODUCT_URL})".freeze
SIGN_REASON = 'Signed by %<email>s with DocuSeal.co'
TEXT_LEFT_MARGIN = 1
@@ -203,9 +203,9 @@ module Submissions
def save_signed_pdf(pdf:, submitter:, pkcs:, uuid:, name:)
io = StringIO.new
pdf.trailer.info[:Creator] = INFO_CREATOR
pdf.trailer.info[:Creator] = info_creator
pdf.sign(io, reason: format(SIGN_REASON, email: submitter.email),
pdf.sign(io, reason: sign_reason(submitter.email),
certificate: pkcs.certificate,
key: pkcs.key,
certificate_chain: pkcs.ca_certs || [])
@@ -269,6 +269,14 @@ module Submissions
pdf
end
def sign_reason(email)
format(SIGN_REASON, email:)
end
def info_creator
INFO_CREATOR
end
def h
Rails.application.routes.url_helpers
end