Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3928 letter download #3958

Merged
merged 2 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions app/controllers/dashboard_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,23 @@ def your_hours
def download_hours_letter
load_user_data
markdown_text = generate_markdown_text

# write the string to a temp directory
temp_dir = File.join(Rails.root, 'public', 'printable')
Dir.mkdir(temp_dir) unless Dir.exist? temp_dir

time_stub = Time.now.gmtime.iso8601.gsub(/\D/,'')
temp_dir = File.join(temp_dir, time_stub)
Dir.mkdir(temp_dir) unless Dir.exist? temp_dir

file_stub = "letter_#{time_stub}"
md_file = File.join(temp_dir, "#{file_stub}.md")
output_file = File.join(temp_dir, "#{file_stub}.pdf")

generate_pdf(md_file, output_file, markdown_text)

input_path = Rails.root.join('tmp', 'input.md').to_s
output_path = Rails.root.join('tmp', 'letter.pdf').to_s

generate_pdf(input_path, output_path, markdown_text)

send_generated_pdf(output_path)
send_generated_pdf(output_file)

end

# Owner Dashboard - list of works
Expand Down
2 changes: 1 addition & 1 deletion config/locales/dashboard/dashboard-en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ en:
institutions_separator: "|--------------|------------|-------------:|"
regards_text: Regards,
to_whom_it_may_concern: 'To Whom It May Concern:'
volunteer_text: Each volunteer helps make history more accessible. We appreciate %{user_display_name} contribution to our crowdsourcing effort!
volunteer_text: Each volunteer helps make history more accessible. We appreciate %{user_display_name}\'s contribution to our crowdsourcing effort!
worked_on_collections: "%{user_name} has worked on the following collections by the following institutions:"
landing_page:
all_collections: All Collections
Expand Down