epaper/app/views/admin/e_paper_criterias/emailer.html.erb

269 lines
6.7 KiB
Plaintext
Raw Normal View History

2020-11-30 15:59:51 +00:00
<% paper = PaperCriteria.find(@data["paper_id"]) rescue nil %>
<% paper = @data["paper"] if paper.nil? && @data["paper"] != nil %>
2019-05-28 15:54:32 +00:00
<% page = @data["page"] %>
2019-09-02 04:34:07 +00:00
<% siteurl = @data["siteurl"] %>
<% papers_data = @data["papers_data"] %>
2019-05-28 15:54:32 +00:00
<!DOCTYPE html>
<html>
<head>
<title><%= paper.title %></title>
<style type="text/css">
.epaper-show .epaper-show-title {
border-bottom: 2px solid #ddd;
padding: 0 0 10px;
margin: 10px 0 20px;
color: #881f05;
}
.epaper-show .ep-info {
background: #fff;
border-radius: 3px;
margin: 10px 0 25px;
2019-05-28 15:54:32 +00:00
}
.epaper-show .ep-info-title {
border-bottom: 1px solid #eee;
padding: 0 0 5px;
margin: 0 0 8px;
font-size: 18px;
}
.epaper-show .ep-info-date {
float: left;
2020-08-04 05:59:39 +00:00
width: 80%;
2019-05-28 15:54:32 +00:00
margin: 0 0 5px;
color: #888;
}
.epaper-show .ep-info-period {
float: right;
2020-08-04 05:59:39 +00:00
width: 80%;
2019-05-28 15:54:32 +00:00
margin: 0 0 5px;
text-align: right;
padding: 0 10px 0 0;
color: #888;
}
.epaper-show .ep-info-description {
clear: both;
padding: 10px 0 0;
overflow: hidden;
width: 80%;
}
.epaper-show .field-head {
font-size: 18px;
margin-right: 2em;
2019-05-28 15:54:32 +00:00
}
.epaper-show .ep-info-description span {
float: left;
2019-05-28 15:54:32 +00:00
line-height: 1.5;
}
.epaper-show .ep-content-item {
float: left;
2020-08-04 05:59:39 +00:00
width: calc(80% - 20px);
2019-05-28 15:54:32 +00:00
border: 1px solid #ccc;
vertical-align: top;
min-height: 200px;
padding: 20px;
margin: 10px;
}
.epaper-show .ep-content-title {
color: #881f05;
font-size: 20px;
border-left: 4px solid #881f05;
display: block;
padding: 0 0 0 10px;
margin: 0 0 10px;
}
.epaper-show p.ep-content-text {
color: #666;
font-size: 15px;
}
.epaper-show a.ep-content-more {
background: #881f05;
color: #fff;
padding: 2px 10px;
border-radius: 5px;
font-size: 12px;
}
.ep-topic-show .ep-topic-title {
margin: 10px 0;
color: #881f05;
}
.ep-topic-show .ep-topic-date {
background: #fff;
padding: 10px;
border-radius: 3px;
margin: 0 0 10px;
}
.ep-topic-show .ep-topic-content {
font-size: 15px;
line-height: 2;
}
.epaper-form {
background: #fff;
padding: 20px;
width: 100%;
max-width: 300px;
margin: auto;
border-radius: 5px;
box-shadow: 0 0 30px rgba(0, 0, 0, 0.05);
}
.epaper-form input.input-mail {
display: block;
width: 100%;
margin: 0 0 20px;
padding: 5px 10px;
border: 1px solid #ccc;
border-radius: 5px;
color: #333;
}
.epaper-form .btn-primary {
2020-08-04 05:59:39 +00:00
width: 80%;
2019-05-28 15:54:32 +00:00
float: left;
display: block;
}
.epaper-form .btn-white {
background: none;
2020-08-04 05:59:39 +00:00
width: 80%;
2019-05-28 15:54:32 +00:00
outline: none;
float: right;
color: #888;
}
.epaper-form .btn-white:active {
outline: none;
box-shadow: none;
}
.epaper-form .btn-white:hover {
text-decoration: underline;
}
.epaper-form .ep-form-title {
font-size: 20px;
margin: 0 0 15px;
}
.epaper-form h3.ep-form-title .en {
display: none;
}
.epaper-form form {
overflow: hidden;
}
.school-heading{
padding: 20px;
text-align: center;
border-bottom: 1px solid #c8c8c8;
}
.category_title{
clear: both;
margin: 50px -15px 0;
background: #96210f;
padding: 20px 10px;
text-align: center;
font-weight: 700;
border-radius: 10px 10px 0 0;
2020-08-04 05:59:39 +00:00
width: 80%;
margin: 10px;
}
2019-05-28 15:54:32 +00:00
</style>
</head>
2024-09-11 00:16:48 +00:00
<%
2024-09-11 00:38:00 +00:00
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
2024-09-11 00:16:48 +00:00
have_papaers = papers_data.present?
if paper.image.present?
2024-09-11 00:38:00 +00:00
img_src = siteurl + paper.image.url
2024-09-11 00:16:48 +00:00
else
img_src = nil
end
2024-09-11 00:38:00 +00:00
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
2024-09-11 00:16:48 +00:00
%>
2019-05-28 15:54:32 +00:00
<body>
<div class="epaper-show">
2024-09-11 00:16:48 +00:00
<% if have_papaers %>
<% if img_src %>
<img src="<%= img_src %>" alt="<%= paper.title %>" title="<%= paper.title %>" />
<% end %>
2019-05-28 15:54:32 +00:00
<div class="ep-info">
2024-09-11 00:21:27 +00:00
<% if paper.title.present? %>
<div class="ep-info-title">
<span class="field-head">
<%= t('e_paper.title') %>
</span>
<h3 class="epaper-show-title">
<a class="ep-content-title" href="<%= page + "/" + paper.to_param + "?method=topics" %>" target="_blank"><span><%= paper.title %></span></a>
</h3>
</div>
<% end %>
<div class="ep-info-description">
<span class="field-head">
<%= t('e_paper.description') %>
</span>
<span>
2024-09-11 00:38:00 +00:00
<%= paper_description %>
2024-09-11 00:16:48 +00:00
<br>
2024-09-11 00:38:00 +00:00
<%= paper_content %>
</span>
</div>
2019-05-28 15:54:32 +00:00
</div>
<div class="ep-content">
<% papers_data.each do |papers_data_hash| %>
2020-12-01 16:19:58 +00:00
<h3 class="category_title"><a class="category_title_link" href="<%=page + "/#{paper.to_param}?method=topics&category=#{papers_data_hash["category_id"].nil? ? papers_data_hash["category"].id : papers_data_hash["category_id"]}" %>" style="color: #fff;text-decoration: none;"><%= papers_data_hash["category_title"] %></a></h3>
<% topics = (papers_data_hash["topic_ids"].nil? ? papers_data_hash["topics"] : EPaperTopic.where(:id.in=>papers_data_hash["topic_ids"]).to_a) %>
<% topics.each do |topic| %>
<div class="ep-content-item">
<a class="ep-content-title" href="<%= page + "/" + topic.to_param %>" target="_blank"><%= topic.title %></a>
<div class="ep-img" style="width: 40%; float:left;">
2021-10-06 02:44:29 +00:00
<img src="<%= (siteurl + "/" + topic.image.thumb.url rescue nil) %>" style="width: 100%;">
</div>
<div class="ep-con" style="width: 58%; float: right;">
<%= topic.description %>
<a class="ep-content-more" href="<%= page + "/" + topic.to_param %>" target="_blank">more</a>
</div>
</div>
<% end %>
2019-05-28 15:54:32 +00:00
<% end %>
</div>
2024-09-11 00:16:48 +00:00
<% else %>
<% if img_src %>
<img src="<%= img_src %>" alt="<%= paper.title %>" title="<%= paper.title %>" />
<% end %>
<div class="ep-info">
2024-09-11 00:21:27 +00:00
<% if paper.title.present? %>
<div class="ep-info-title">
<h3 class="epaper-show-title">
<a class="ep-content-title" href="<%= page + "/" + paper.to_param + "?method=topics" %>" target="_blank"><span><%= paper.title %></span></a>
</h3>
</div>
<% end %>
2024-09-11 00:16:48 +00:00
<div class="ep-info-description">
2024-09-11 00:38:00 +00:00
<%= paper_content %>
2024-09-11 00:16:48 +00:00
</div>
</div>
<% end %>
2019-05-28 15:54:32 +00:00
</div>
</body>
</html>