Skip to content

Commit

Permalink
Merge pull request #4256 from tulibraries/BL-1834-Send-To-Email_templ…
Browse files Browse the repository at this point in the history
…ate_accessibility

BL-1834 Send To Email template accessibility
  • Loading branch information
cdoyle-temple committed Feb 28, 2024
2 parents 4c3cfe6 + 13b2a8e commit 519d0d8
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 9 deletions.
8 changes: 8 additions & 0 deletions app/helpers/record_mailer_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# frozen_string_literal: true

module RecordMailerHelper
def record_mailer_link(document, url_gen_params)
url = polymorphic_url(document, @url_gen_params)
link_to(url, url)
end
end
12 changes: 12 additions & 0 deletions app/views/record_mailer/email_record.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<h1>Temple University Libraries record(s):</h1>

<p>
<%= t('blacklight.email.text.message', :message => @message) %>
</p>

<% @documents.each do |document| %>
<%= document.to_email_text %><br>
<%= t('blacklight.email.html.url') %>
<%= record_mailer_link(document, @url_gen_params) %>
<br>
<% end %>
9 changes: 0 additions & 9 deletions app/views/record_mailer/email_record.text.erb

This file was deleted.

2 changes: 2 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ en:
subject:
one: "Temple University Libraries record: %{title}"
other: "Temple University Libraries records"
html:
url: "URL:"

sms:
form:
Expand Down
46 changes: 46 additions & 0 deletions spec/mailers/previews/record_mailer_preview.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# frozen_string_literal: true

# Preview all emails at http://localhost:3000/rails/mailers/record_mailer.rb
class RecordMailerPreview < ActionMailer::Preview
def record_email
RecordMailer.email_record(documents, details, url)
end

def details
{
message: "Hello World",
config: PrimoCentralController.new.blacklight_config
}
end

def url
{ host: "localhost",
port: 3000,
protocol: "http://" }
end

def documents
[ document ]
end

def document
PrimoCentralDocument.new(

{
"pnxId" => "example_1234567890",
"title" => "Be Excellent",
"issn" => [
"8769-3369",
"0069-0069"
],
"isPartOf" => "Transactions of the Timetravel, 2024-02, Vol.33, p.69",
"creator" => [
"Preston, Bill S.",
"Logan, Ted 'Theodore'",
],
"date" => [
"1989"
],
})
end
end

0 comments on commit 519d0d8

Please sign in to comment.