<% 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"] %> <%= paper.title %> <% 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 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 %>
<% if have_papaers %> <% if img_src %> <%= paper.title %> <% end %>
<% if paper.title.present? %>
<%= t('e_paper.title') %>:

" target="_blank"><%= paper.title %>

<% end %>
<%= t('e_paper.description') %>: <%= paper_description %>
<%= paper_content %>
<% papers_data.each do |papers_data_hash| %>

" style="color: #fff;text-decoration: none;"><%= papers_data_hash["category_title"] %>

<% 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| %>
" target="_blank"><%= topic.title %>
" style="width: 100%;">
<%= topic.description %> " target="_blank">more
<% end %> <% end %>
<% else %> <% if img_src %> <%= paper.title %> <% end %>
<% if paper.title.present? %> <% end %>
<%= paper_content %>
<% end %>