<% content_for(:sidebar) do %> <%# Deliberately NOT keyed on current_user, unlike the fresh_when etag on this same action: the 5 most recent post titles/links are identical for every viewer, and the signed-in-as banner + new-post form that DO vary per viewer render outside this block, never inside the cached fragment. See prism-postep.md session 62/64. %> <% cache(:recent_posts_sidebar, expires_in: 60) do %>

<%= t('posts.recent_heading') %>

<% end %> <% end %> <% if notice %>

<%= notice %>

<% end %> <% unless errors.empty? %>

<%= t('posts.errors_heading') %>

<% end %> <% if user_signed_in? %>

<%= t('posts.new_post_heading') %>

<% form_for(new_post, url: url_for(:posts), html: { enctype: 'multipart/form-data' }) do |f| %>

<%== f.label(:title, t('posts.title_label')) %> <%== f.text_field(:title) %> <%== f.error_messages(:title) %>

<%== f.label(:body, t('posts.body_label')) %> <%== f.text_area(:body) %> <%== f.error_messages(:body) %>

<%== f.label(:cover, t('posts.cover_label')) %> <%== f.tag(:input, type: 'file', name: 'post[cover]', id: 'post_cover') %>

<%== f.check_box(:featured) %> <%== f.label(:featured, t('posts.featured_label')) %>

<%== f.label(:giveaway_slots, t('claims.giveaway_slots_label')) %> <%== f.text_field(:giveaway_slots) %> <%== f.error_messages(:giveaway_slots) %>

<%== f.submit(t('posts.submit')) %> <% end %>

<%= t('posts.import_heading') %>

<% form_for(Post.new, url: url_for(:import_posts), method: :post, html: { enctype: 'multipart/form-data' }) do |f| %>

<%== f.label(:file, t('posts.import_label')) %> <%== f.tag(:input, type: 'file', name: 'file', id: 'post_file', accept: '.csv,text/csv') %>

<%== f.submit(t('posts.import_submit')) %> <% end %> <% end %>

<%== link_to(t('posts.filter_all'), url_for(:posts)) %> | <%== link_to(t('posts.filter_recent', days: 7), "#{url_for(:posts)}?days=7") %> | <%== link_to(t('posts.filter_recent', days: 30), "#{url_for(:posts)}?days=30") %> | <%== link_to(t('posts.filter_featured'), "#{url_for(:posts)}?featured=1") %>

<%== paginate(posts, path: ->(page) { "#{url_for(:posts)}?page=#{page}#{days.positive? ? "&days=#{days}" : ''}#{featured_only ? '&featured=1' : ''}" }) %>