posts: refactor post previews to use ViewComponent.

Refactor the post preview html to use the ViewComponent framework. This
lets us encapsulate all the HTML, CSS, and helper methods for a UI
component in a single place.

See https://viewcomponent.org.
This commit is contained in:
evazion
2021-01-12 02:04:38 -06:00
parent 097220fd88
commit 1b30b71a07
40 changed files with 449 additions and 364 deletions

View File

@@ -4,9 +4,7 @@
<%= link_to "Uploads", posts_path(:tags => "user:#{user.name}") %>
</h2>
<div>
<% presenter.uploads.each do |post| %>
<%= PostPresenter.preview(post, :tags => "user:#{user.name}") %>
<% end %>
<%= post_previews_html(presenter.uploads, tags: "user:#{user.name}") %>
</div>
</div>
<% end %>
@@ -17,9 +15,7 @@
<%= link_to "Favorites", posts_path(tags: "ordfav:#{user.name}") %>
</h2>
<div>
<% presenter.favorites.each do |post| %>
<%= PostPresenter.preview(post, tags: "ordfav:#{user.name}") %>
<% end %>
<%= post_previews_html(presenter.favorites, tags: "ordfav:#{user.name}") %>
</div>
</div>
<% end %>
@@ -33,9 +29,7 @@
</h2>
<div class="box">
<% presenter.posts_for_saved_search_category(label).each do |post| %>
<%= PostPresenter.preview(post, :tags => "search:#{label}") %>
<% end %>
<%= post_previews_html(presenter.posts_for_saved_search_category, tags: "search:#{label}") %>
</div>
</div>
<% end %>