diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 0e2c05446..6cdbcc477 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -49,9 +49,9 @@ module ApplicationHelper raw %{#{text}} end - def format_text(text, options = {}) - if options[:ragel] - raw(DTextRagel.parse(text)) + def format_text(text, ragel: true, **options) + if ragel + raw DTextRagel.parse(text, **options) else DText.parse(text) end diff --git a/app/views/user_mailer/dmail_notice.html.erb b/app/views/user_mailer/dmail_notice.html.erb index fce085ff2..2256b87ef 100644 --- a/app/views/user_mailer/dmail_notice.html.erb +++ b/app/views/user_mailer/dmail_notice.html.erb @@ -1,10 +1,10 @@ -

<%= h @dmail.from.name %> said:

+

<%= @dmail.from.name %> said:

-
- <%= DText.parse(@dmail.body) %> +
+ <%= format_text(@dmail.body, base_url: root_url) %>

<%= link_to "View message", dmail_url(@dmail, :host => Danbooru.config.hostname, :only_path => false) %> | <%= link_to "Unsubscribe", maintenance_user_email_notification_url(:user_id => @dmail.owner.id, :sig => email_sig(@dmail.owner), :host => Danbooru.config.hostname, :only_path => false) %>

diff --git a/config/application.rb b/config/application.rb index ba75484cc..b5627814a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -29,6 +29,12 @@ module Danbooru else config.x.git_hash = nil end + + config.after_initialize do + Rails.application.routes.default_url_options = { + host: Danbooru.config.hostname, + } + end end I18n.enforce_available_locales = false diff --git a/test/mailers/previews/user_mailer_preview.rb b/test/mailers/previews/user_mailer_preview.rb new file mode 100644 index 000000000..ec87e1e02 --- /dev/null +++ b/test/mailers/previews/user_mailer_preview.rb @@ -0,0 +1,6 @@ +class UserMailerPreview < ActionMailer::Preview + def dmail_notice + dmail = User.admins.first.dmails.first + UserMailer.dmail_notice(dmail) + end +end