diff --git a/examples/blog/app/views/posts/_comment.erb b/examples/blog/app/views/posts/_comment.erb new file mode 100644 index 0000000..ede337e --- /dev/null +++ b/examples/blog/app/views/posts/_comment.erb @@ -0,0 +1,28 @@ +
<%= comment.body %>
++ <%= t('likes.count', count: likes_count(comment)) %> + <% if user_signed_in? %> + <% own_like = current_user_like(comment) %> + <% if own_like %> + <%== button_to(t('likes.unlike'), "/likes/#{own_like.id}", method: :delete) %> + <% else %> + <%== button_to(t('likes.like'), "/likes?likeable_type=Comment&likeable_id=#{comment.id}") %> + <% end %> + <% end %> +
+ <% if current_user && current_user.id == comment.user_id %> + <%== link_to(t('comments.edit_link'), url_for(:edit_comment, post_id: post.to_param, id: comment.id)) %> + <%== button_to(t('comments.delete'), "/posts/#{post.to_param}/comments/#{comment.id}", method: :delete, data_confirm: t('comments.confirm_delete')) %> + <% end %> + <% if current_user && current_user.id == post.user_id && !comment.approved? %> + <%== button_to(t('comments.approve'), "/posts/#{post.to_param}/comments/#{comment.id}/approve", method: :patch) %> + <% end %> + <% if current_user && current_user.id == post.user_id && !comment.rejected? %> + <%== button_to(t('comments.reject'), "/posts/#{post.to_param}/comments/#{comment.id}/reject", method: :patch) %> + <% end %> +<%= t('posts.featured_badge') %>
+ <% end %> + <% if featured_only && post.featured && user_signed_in? && current_user.id == post.user_id %> ++ <% unless post.first_in_list? %> + <%== button_to(t('posts.move_up'), url_for(:move_up_post, slug: post.to_param), method: :patch) %> + <% end %> + <% unless post.last_in_list? %> + <%== button_to(t('posts.move_down'), url_for(:move_down_post, slug: post.to_param), method: :patch) %> + <% end %> +
+ <% end %> + <% if post.cover %> +<%= post.body %>
+<%= t('posts.comments_count', count: post.comments_count) %>
+<%= t('posts.last_activity', when: l(post.updated_at)) %>
+<%== link_to(t('posts.read_more'), url_for(:post, slug: post.to_param)) %>
+ <%== 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.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.update_submit')) %> + <%== f.submit(t('posts.preview_submit'), formaction: url_for(:preview_post, slug: post.to_param)) %> + +<%= t('posts.moderate_comments_empty') %>
+ <% else %> + <% f.fields_for(:comments, moderated_comments) do |cf| %> ++ <%== cf.hidden_field(:id) %> + <%== cf.label(:body, t('posts.moderate_comment_body_label')) %> + <%== cf.text_area(:body) %> + <%== cf.error_messages(:body) %> + +
+ <% end %> + <% end %> +<% end %> + +<%== link_to(t('posts.back_to_list'), url_for(:posts)) %>
diff --git a/examples/blog/app/views/posts/index.erb b/examples/blog/app/views/posts/index.erb index abbf442..3f6d10a 100644 --- a/examples/blog/app/views/posts/index.erb +++ b/examples/blog/app/views/posts/index.erb @@ -1,21 +1,77 @@ -<%= notice %>
<% end %> <% unless errors.empty? %> ++ <%== 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 %> + ++ <%== 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") %> +
+