Browse Source

feat: show posts on homepage

master
Inhji Y. 10 months ago
parent
commit
170c4995ca
  1. 2
      apps/tomie_web/lib/tomie_web/controllers/home_controller.ex
  2. 43
      apps/tomie_web/lib/tomie_web/templates/home/index.html.eex

2
apps/tomie_web/lib/tomie_web/controllers/home_controller.ex

@ -10,12 +10,14 @@ defmodule TomieWeb.HomeController do
def index(conn, _params) do
bookmarks = Bookmarks.list_bookmarks("", "recent", 3)
posts = Blog.list_posts(3)
listens = Listens.Listens.list_listens(3)
user = Tomie.Users.get_user!(1)
conn
|> render("index.html",
bookmarks: bookmarks,
posts: posts,
listens: listens,
page_title: "Home",
user: user

43
apps/tomie_web/lib/tomie_web/templates/home/index.html.eex

@ -22,22 +22,43 @@
</div>
<div>
<h3>Listens</h3>
<h3>Posts</h3>
<dl>
<%= for l <- @listens do %>
<dt><%= l.track.name %> <small class="brackets"></small></dt>
<dd>by <%= l.artist.name %> • <%= Timex.from_now(l.listened_at) %></dd>
<%= for p <- @posts do %>
<%= if Blog.Post.subtype(p) == :article do %>
<dt><%= p.title %></dt>
<% else %>
<dt><%= raw p.content_html %></dt>
<% end %>
<dd><%= Timex.from_now(p.inserted_at) %></dd>
<% end %>
</dl>
</div>
<h3>Projects</h3>
<div class="flex-container">
<div>
<h3>Listens</h3>
<dl>
<%= for l <- @listens do %>
<dt><%= l.track.name %> <small class="brackets"></small></dt>
<dd>by <%= l.artist.name %> • <%= Timex.from_now(l.listened_at) %></dd>
<% end %>
</dl>
</div>
<div>
<h3>Projects</h3>
<dl>
<dt><%= link "Tomie", to: Routes.home_path(@conn, :project, :tomie) %> <small class="brackets">2013 - 2020</small></dt>
<dd>Tomie is one of many attempts to build a selfhosted, universal platform for my content.</dd>
<dt><%= link "Eurorack", to: Routes.home_path(@conn, :project, :eurorack) %> <small class="brackets">2018 - 2020</small></dt>
<dd>My Eurorack system aims to be a lifelong experiment on music-making as a process, not a goal.</dd>
</dl>
</div>
</div>
<dl>
<dt><%= link "Tomie", to: Routes.home_path(@conn, :project, :tomie) %> <small class="brackets">2013 - 2020</small></dt>
<dd>Tomie is one of many attempts to build a selfhosted, universal platform for my content.</dd>
<dt><%= link "Eurorack", to: Routes.home_path(@conn, :project, :eurorack) %> <small class="brackets">2018 - 2020</small></dt>
<dd>My Eurorack system aims to be a lifelong experiment on music-making as a process, not a goal.</dd>
</dl>
Loading…
Cancel
Save