<ol class="script-list">
  <% @scripts.each do |script| %>
    <% disallowed_keywords = ads_disallowed_keywords_used(script) %>
    <li>
      <article>
        <h2>
          <%= render_script(script) %>
          (<%= script.page_views %>)
        </h2>
        <div>
          <span class="script-description"><%= script.description(request_locale) %></span>
        </div>
        <p>
          <%= script.site_applications.map { |s| s.domain? ? link_to(s.text, "http://#{s.text}") : s.text}.join(', ').html_safe %>
        </p>
        <% if disallowed_keywords.any? %>
          <p style="margin: 0.5em 0">
            <b>Disallowed keywords: <%= disallowed_keywords.join(', ') %></b>
          </p>
        <% end %>
        <p style="margin: 0.5em 0">
          <%= form_with(model: script, url: approve_admin_ad_path(script, return_to: @return_to), method: :patch, html: { style: 'display: inline;' }, data: disallowed_keywords.any? ? { turbo: true, turbo_confirm: 'Approve despite keywords?' } : {}) do %>
            <button>Approve</button>
          <% end %>
          <% unless script.adsense_approved == false %>
            <%= form_with(model: script, url: reject_admin_ad_path(script, return_to: @return_to), method: :patch, html: { style: 'display: inline;' }) do %>
              <button>Reject</button>
            <% end %>
          <% end %>
        </p>
        <%= render partial: 'screenshots/show', locals: { attachable: script.newest_saved_script_version } %>
      </article>
    </li>
  <% end %>
</ol>
