docbrown/app/views/admin/articles/_individual_article.html.erb
Michael Kohl 7c31a9cc98
Remove buffer gem and related code: step 1 (#12993)
* Remove buffer gem and related code

* Remove more Buffer-related code

* Remove one more Buffer spec

* Remove DUS

* Remove more Buffer code
2021-03-24 09:58:38 +07:00

153 lines
6.4 KiB
Text

<style>
.article-body-html img {
max-width: 100%;
}
</style>
<div class="card my-3"
data-controller="article"
data-article-bg-highlighted-class="bg-highlighted"
data-article-border-highlighted-class="border-highlighted">
<div class="card-header">
<h2>
<a href="<%= article.path %>" target="_blank" rel="noopener">
<%= article.title %>
</a>
</h2>
<div>
<a href="<%= article.path %>/edit" target="_blank" rel="noopener"><span class="btn btn-sm btn-primary">Edit</span></a>
<button class="btn btn-sm btn-success" data-action="article#increaseFeaturedNumber">Boost</button>
<a class="btn btn-sm btn-secondary" href="<%= admin_user_path(article.user_id) %>" target="_blank" rel="noopener">Manage User</a>
<a href="<%= admin_user_path(article.user_id) %>" class="badge badge-light">@<%= article.user&.username %></a>
<span class="badge badge-light">❤️ <%= article.public_reactions_count %> 💬 <%= article.comments_count %></span>
<span class="badge badge-light">
<% if article.published_from_feed? && !article.published? %>
RSS Import <%= article.created_at.strftime("%b %d, %Y") %>
Originally Published <%= article.published_at&.strftime("%b %d, %Y") %>
<% elsif article.crossposted_at? %>
Crossposted <%= article.crossposted_at.strftime("%b %d, %Y") %> & Published
<%= article.published_at&.strftime("%b %d, %Y") %>
<% else %>
<%= article.published_at&.strftime("%b %d, %Y") %>
<% end %>
</span>
<% article.decorate.cached_tag_list_array.each do |tag| %>
<a class="badge badge-secondary" href='<%= tag_path(tag) %>'>#<%= tag %></a>
<% end %>
</div>
</div>
<% featured = article.featured ? "bg-featured" : "" %>
<% approved = article.approved ? "bg-approved" : featured %>
<% background_color = approved %>
<div
data-article-target="cardBody"
class="card-body <%= background_color %> <%= "bg-danger" if !article.published? && article.published_from_feed? %>">
<% if article.video %>
<h2>Contains Video</h2>
<% end %>
<% cache "admin-user-info-#{article.user_id}-#{article.user&.updated_at}", expires_in: 4.hours do %>
<% if article.user&.warned %>
<h2><span class="badge badge-warning">USER WARNED</span></h2>
<% end %>
<% if article.user&.notes&.any? %>
<h2>User Notes (<%= article.user&.notes&.size %> total)</h2>
<% article.user&.notes&.last(3)&.each do |note| %>
<p>
<em><%= note.created_at.strftime("%d %B %Y %H:%M UTC") %> by
<%= note.author_id ? User.find(note.author_id).username : "No Author" %></em> - <%= note.content %>
</p>
<% end %>
<p><a href="<%= admin_user_path(article.user_id) %>">View All</a></p>
<% end %>
<% end %>
<% if article.main_image.present? %>
<div style="max-height:450px;overflow:hidden;">
<img src="<%= cloud_cover_url(article.main_image) %>" style="width:100%;max-width:380px;border-radius:8px;background:<%= article.main_image_background_hex_color %>;" alt="cover image" /><br />
</div>
<% end %>
<%= form_with url: admin_article_path(article.id), model: article, local: true do |f| %>
<div class="form-group">
<input name="utf8" type="hidden" value="✓">
<input type="hidden" name="authenticity_token" value="<%= form_authenticity_token %>" />
<input type="hidden" name="_method" value="patch" />
</div>
<div class="row">
<div class="form-group col">
<label for="featured_number_<%= article.id %>">Featured Number:</label>
<input id="featured_number_<%= article.id %>"
class="form-control"
name="article[featured_number]"
value="<%= article.featured_number %>"
data-article-target="featuredNumber">
</div>
<div class="form-group col">
<label for="author_id_<%= article.id %>">Author ID:</label>
<input id="author_id_<%= article.id %>" class="form-control" size="6" name="article[user_id]"
value="<%= article.user_id %>">
</div>
<div class="form-group col">
<label for="co_author_ids_list_<%= article.id %>">Co-Author IDs (comma separated):</label>
<input id="co_author_ids_list_<%= article.id %>" class="form-control" size="6" name="article[co_author_ids_list]"
value="<%= article.co_author_ids&.join(", ") %>">
</div>
</div>
<% if article.published? %>
<div class="row">
<div class="form-group col">
<label for="published_at_<%= article.id %>">Published at:</label>
<%= f.datetime_select :published_at, required: true, include_blank: true, include_seconds: true, class: "form-control" %> UTC
</div>
</div>
<% end %>
<div class="row">
<div class="form-check col">
<%= f.check_box :featured, id: "featured-#{article.id}" %>
<label for="featured-<%= article.id %>">Featured</label>
</div>
<div class="form-check col">
<%= f.check_box :approved, id: "approved-#{article.id}" %>
<label for="approved-<%= article.id %>">Approved</label>
</div>
<div class="form-check col">
<%= f.check_box :boosted_additional_articles, id: "boosted_additional_articles-#{article.id}" %>
<label for="boosted_additional_articles-<%= article.id %>">Boosted</label>
</div>
<div class="col">
<button class="btn btn-primary float-right">Submit</button>
</div>
</div>
<% end %>
<% if article.boosted_dev_digest_email %>
<br /><br />
<% phrase = "#{article.path}?booster_org=#{article.organization&.slug || 'generic'}" %>
<b>BOOSTED IN <%= EmailMessage.where("subject LIKE ?", "%#{phrase}%").where.not(opened_at: nil).size %> EMAILS</b>
<br />
<b>BOOSTED IN
<%= EmailMessage.where("subject LIKE ?", "%#{phrase}%").where.not(opened_at: nil).where("sent_at > ?", 1.week.ago).size %>
EMAILS IN THE PAST WEEK</b>
<br /><br />
<b>BOOSTED IN
<%= EmailMessage.where("subject LIKE ?", "%#{phrase}%").where.not(opened_at: nil).where.not(opened_at: nil).size %>
OPENED EMAILS</b>
<br />
<b>BOOSTED IN
<%= EmailMessage.where("subject LIKE ?", "%#{phrase}%").where.not(opened_at: nil).where.not(opened_at: nil).where("sent_at > ?", 1.week.ago).size %>
OPENED EMAILS IN THE PAST WEEK</b>
<% end %>
</div>
</div>