From a44c4667d404ab21e145c1cb5d4ce1f5232eab4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B1=E5=8D=9A=E4=BA=9E?= Date: Wed, 11 Sep 2024 13:07:40 +0800 Subject: [PATCH] Fix local url in email. --- .../admin/e_paper_criterias/emailer.html.erb | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/app/views/admin/e_paper_criterias/emailer.html.erb b/app/views/admin/e_paper_criterias/emailer.html.erb index 6ac6295..0c52fdd 100644 --- a/app/views/admin/e_paper_criterias/emailer.html.erb +++ b/app/views/admin/e_paper_criterias/emailer.html.erb @@ -160,10 +160,14 @@ width: 80%; margin: 10px; } + .epaper-show img { + max-width: 100%; + } <% def fix_local_url(siteurl, contents) + return nil if contents.blank? doc = Nokogiri::HTML.fragment(contents, encoding = 'UTF-8') doc.css('img[src], script[src]').each do |src_tag| src = src_tag.attribute('src').value @@ -179,7 +183,7 @@ link_tag.attribute('href').value = siteurl + href end end - doc.to_html + doc.to_html.html_safe end have_papaers = papers_data.present? @@ -188,16 +192,8 @@ else img_src = nil end - if paper.description.present? - paper_description = fix_local_url(siteurl, paper.description).html_safe - else - paper_description = nil - end - if paper.content.present? - paper_content = fix_local_url(siteurl, paper.content).html_safe - else - paper_content = nil - end + paper_description = fix_local_url(siteurl, paper.description) + paper_content = fix_local_url(siteurl, paper.content) %>
@@ -236,10 +232,10 @@
" target="_blank"><%= topic.title %>
- " style="width: 100%;"> +
- <%= topic.description %> + <%= fix_local_url(siteurl, topic.description) %> " target="_blank">more