diff --git a/app/views/admin/e_paper_criterias/emailer.html.erb b/app/views/admin/e_paper_criterias/emailer.html.erb index b02694e..6ac6295 100644 --- a/app/views/admin/e_paper_criterias/emailer.html.erb +++ b/app/views/admin/e_paper_criterias/emailer.html.erb @@ -163,12 +163,41 @@ <% + def fix_local_url(siteurl, contents) + doc = Nokogiri::HTML.fragment(contents, encoding = 'UTF-8') + doc.css('img[src], script[src]').each do |src_tag| + src = src_tag.attribute('src').value + next if src.blank? + if src.match(/^\/[^\/]+/) + src_tag.attribute('src').value = siteurl + src + end + end + doc.css('a[href], link[href]').each do |link_tag| + href = link_tag.attribute('href').value + next if href.blank? + if href.match(/^\/[^\/]+/) + link_tag.attribute('href').value = siteurl + href + end + end + doc.to_html + end + have_papaers = papers_data.present? if paper.image.present? - img_src = siteurl + "/" + paper.image.url + img_src = siteurl + paper.image.url 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 %>
@@ -192,9 +221,9 @@ <%= t('e_paper.description') %>: - <%= paper.description.html_safe %> + <%= paper_description %>
- <%= paper.content.html_safe %> + <%= paper_content %>
@@ -230,7 +259,7 @@ <% end %>
- <%= paper.content.html_safe %> + <%= paper_content %>
<% end %>