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

275 lines
6.9 KiB
Plaintext
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<% paper = PaperCriteria.find(@data["paper_id"]) rescue nil %>
<% paper = @data["paper"] if paper.nil? && @data["paper"] != nil %>
<% page = @data["page"] %>
<% siteurl = @data["siteurl"] %>
<% papers_data = @data["papers_data"] %>
<!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;
}
.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;
width: 80%;
margin: 0 0 5px;
color: #888;
}
.epaper-show .ep-info-period {
float: right;
width: 80%;
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;
}
.epaper-show .ep-info-description span {
float: left;
line-height: 1.5;
}
.epaper-show .ep-content-item {
float: left;
width: calc(80% - 20px);
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 {
width: 80%;
float: left;
display: block;
}
.epaper-form .btn-white {
background: none;
width: 80%;
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;
width: 80%;
margin: 10px;
}
.epaper-show img {
max-width: 100%;
}
</style>
</head>
<%
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
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.html_safe
end
have_papaers = papers_data.present?
if paper.banner_image.present?
img = EPaperImage.find(paper.banner_image)
img_src = siteurl + img.image.url
else
img_src = nil
end
paper_description = fix_local_url(siteurl, paper.description)
paper_content = fix_local_url(siteurl, paper.content)
%>
<body>
<div class="epaper-show">
<% if have_papaers %>
<% if img_src %>
<img src="<%= img_src %>" alt="<%= paper.title %>" title="<%= paper.title %>" />
<% end %>
<div class="ep-info">
<% 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>
<%= paper_description %>
<br>
<%= paper_content %>
</span>
</div>
</div>
<div class="ep-content">
<% papers_data.each do |papers_data_hash| %>
<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">
<%
if topic.image.present?
topic_img_url = siteurl + topic.image.thumb.url
else
topic_img_url = nil
end
%>
<a class="ep-content-title" href="<%= page + "/" + topic.to_param %>" target="_blank"><%= topic.title %></a>
<div class="ep-img" style="width: 40%; float:left;">
<% if topic_img_url %>
<img src="<%= topic_img_url %>" style="width: 100%;">
<% end %>
</div>
<div class="ep-con" style="width: 58%; float: right;">
<%= fix_local_url(siteurl, topic.description) %>
<a class="ep-content-more" href="<%= page + "/" + topic.to_param %>" target="_blank">more</a>
</div>
</div>
<% end %>
<% end %>
</div>
<% else %>
<% if img_src %>
<img src="<%= img_src %>" alt="<%= paper.title %>" title="<%= paper.title %>" />
<% end %>
<div class="ep-info">
<% 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 %>
<div class="ep-info-description">
<%= paper_content %>
</div>
</div>
<% end %>
</div>
</body>
</html>