noesya/osuny

View on GitHub
app/views/admin/communication/blocks/templates/posts/layouts/_grid.html.erb

Summary

Maintainability
Test Coverage
<%
heading_level = block.heading_rank_children
date_format = "%e %B %Y"
%>
<div class="grid">
  <% block.template.selected_posts.each do |post|
    next if post.nil?
    post_l10n = post.localization_for(block.language)
    permalink = post_l10n.current_permalink_url_in_website(@website)
  %>
    <article class="post" itemprop="blogPosts" itemscope itemtype="http://schema.org/BlogPosting">
      <div class="post-content">
        <h<%= heading_level %> class='post-title' itemprop='headline'>
          <%= link_to_if permalink, post_l10n, permalink %>
        </h<%= heading_level %>>
        <% if post_l10n.summary.present? && block.template.option_summary %>
          <p itemprop="articleBody"><%= post_l10n.summary %></p>
        <% end %>
        <% if block.template.option_author || block.template.option_date %>
          <div class="post-meta">
            <% if block.template.option_date %>
              <time itemprop="datePublished" datetime="<%= post_l10n.published_at %>"><%= l(post_l10n.published_at, format: date_format) %></time>
            <% end %>
            <% if block.template.option_author %>
              <div class="post-author" itemscope itemtype="https://schema.org/Person" itemprop="author">
                <p itemprop="name"><%= post.author&.to_s_in(block.language) %></p>
              </div>
            <% end %>
          </div>
        <% end %>
        <% if !post.categories.empty? && block.template.option_categories %>
          <ul class="post-categories">
            <% post.categories.each do |category| %>
              <%
              category_l10n = category.localization_for(block.language)
              next if category_l10n.nil?
              %>
              <%= link_to category_l10n, category_l10n.current_permalink_url_in_website(@website) %>
            <% end %>
          </ul>
        <% end %>
      </div>
      <% if block.template.option_image %>
        <div class="media">
          <% if post_l10n.best_featured_image.attached? %>
            <%= kamifusen_tag post_l10n.best_featured_image %>
          <% end %>
        </div>
      <% end %>
    </article>
  <% end %>
</div>