Merge branch 'feature/meeseeks-parser' into develop
This commit is contained in:
42
lib/something_erlang_web/live/bookmarks_live.ex
Normal file
42
lib/something_erlang_web/live/bookmarks_live.ex
Normal file
@ -0,0 +1,42 @@
|
||||
defmodule SomethingErlangWeb.BookmarksLive do
|
||||
use SomethingErlangWeb, :live_view
|
||||
|
||||
alias SomethingErlang.Grover
|
||||
|
||||
def render(assigns) do
|
||||
~H"""
|
||||
<div :if={@bookmarks}>
|
||||
<.bookmark
|
||||
:for={thread <- @bookmarks}
|
||||
id={thread.id}
|
||||
title={thread.title.thread_title}
|
||||
post_count={thread.replies}
|
||||
/>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
||||
defp bookmark(assigns) do
|
||||
assigns = assign(assigns, :pages, trunc(assigns.post_count / 40))
|
||||
|
||||
~H"""
|
||||
<div>
|
||||
<.link href={~p"/thread/#{@id}"}><%= @title %></.link>
|
||||
<.link href={~p"/thread/#{@id}?page=#{@pages}"}><%= @pages %></.link>
|
||||
</div>
|
||||
"""
|
||||
end
|
||||
|
||||
def mount(_params, session, socket) do
|
||||
user =
|
||||
socket.assigns.current_user
|
||||
|> Map.put(:bbpassword, session["bbpassword"])
|
||||
|
||||
Grover.mount(user)
|
||||
|
||||
{:ok,
|
||||
socket
|
||||
|> assign(:page_title, "Bookmarks")
|
||||
|> assign(:bookmarks, Grover.get_bookmarks!(1) |> dbg())}
|
||||
end
|
||||
end
|
@ -28,6 +28,8 @@ defmodule SomethingErlangWeb.Router do
|
||||
on_mount: [{SomethingErlangWeb.UserAuth, :ensure_authenticated}] do
|
||||
live("/thread", ThreadLive)
|
||||
live("/thread/:id", ThreadLive)
|
||||
live("/bookmarks", BookmarksLive)
|
||||
live("/bookmarks/:id", BookmarksLive)
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user