Skip to content

Commit

Permalink
Merge pull request #446 from midarrlabs/feature/add-people
Browse files Browse the repository at this point in the history
feat: add people
  • Loading branch information
trueChazza committed Jan 31, 2024
2 parents e4f9a04 + 09da10e commit a41f927
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 2 deletions.
3 changes: 3 additions & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ config :web_push_elixir,
vapid_private_key: System.get_env("VAPID_PRIVATE_KEY"),
vapid_subject: System.get_env("VAPID_SUBJECT")

config :oapi_tmdb,
api_key: System.get_env("TMDB_API_KEY")

# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{config_env()}.exs"
2 changes: 1 addition & 1 deletion lib/media_server_web/live/movies_live/show.html.heex
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
subtitle=""
runtime=""
img_src={~p"/api/images?url=#{MediaServer.Helpers.get_headshot(item)}&type=proxy&token=#{@current_user.api_token.token}"}
link=""
link={~p"/people/#{item["personTmdbId"]}"}
width="80"
/>
<% end %>
Expand Down
40 changes: 40 additions & 0 deletions lib/media_server_web/live/people_live/show.ex
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
defmodule MediaServerWeb.PeopleLive.Show do
use MediaServerWeb, :live_view

@impl true
def mount(_params, session, socket) do
{
:ok,
socket
|> assign(
:current_user,
MediaServer.Accounts.get_user_by_session_token(session["user_token"])
)
}
end

@impl true
def handle_params(%{"id" => id}, _url, socket) do
pid = self()

Task.start(fn ->
send(pid, {:person, OapiTmdb.Operations.person_details(id)})
end)

{
:noreply,
socket
|> assign(:id, id)
}
end

@impl true
def handle_info({:person, person}, socket) do
{
:noreply,
socket
|> assign(:page_title, person["name"])
|> assign(:person, person)
}
end
end
40 changes: 40 additions & 0 deletions lib/media_server_web/live/people_live/show.html.heex
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<%= if assigns[:person] do %>

<div class="flex-auto prose dark:prose-invert">

<div class="relative overflow-visible bg-zinc-900 w-40 mb-6">
<img
src={"https://image.tmdb.org/t/p/original/#{ @person["profile_path"] }"}
alt=""
class="h-full w-full object-cover object-center"
loading="lazy"
/>
</div>

<header class="flex flex-col gap-y-2">
<div class="flex items-center gap-6">
<div class="flex flex-col">
<h1 class="text-4xl font-bold text-slate-900"><%= @person["name"] %></h1>
</div>
</div>
<div class="flex gap-x-4 items-center">
<.live_component
module={MediaServerWeb.Components.FollowComponent}
id="followComponent"
media_id={@person["id"]}
media_type="person"
user_id={@current_user.id}
return_to={~p"/people/#{@person["id"]}"}
/>
</div>
</header>

<h2>Overview</h2>

<p class="lead">
<%= @person["biography"] %>
</p>

</div>

<% end %>
2 changes: 2 additions & 0 deletions lib/media_server_web/router.ex
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ defmodule MediaServerWeb.Router do
live "/series", SeriesLive.Index, :index
live "/series/:id", SeriesLive.Show, :show

live "/people/:id", PeopleLive.Show, :show

live "/history", HistoryLive.Index, :index

live "/search", SearchLive.Index, :index
Expand Down
3 changes: 2 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ defmodule MediaServer.MixProject do
{:extitles, "~> 0.1.0"},
{:exstream, "~> 0.20.0"},
{:oauth2, "~> 2.0"},
{:web_push_elixir, "~> 0.4.0"}
{:web_push_elixir, "~> 0.4.0"},
{:oapi_tmdb, "~> 0.3.0"}
]
end

Expand Down
1 change: 1 addition & 0 deletions mix.lock
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], [], "hexpm", "69b09adddc4f74a40716ae54d140f93beb0fb8978d8636eaded0c31b6f099f16"},
"mime": {:hex, :mime, "2.0.5", "dc34c8efd439abe6ae0343edbb8556f4d63f178594894720607772a041b04b02", [:mix], [], "hexpm", "da0d64a365c45bc9935cc5c8a7fc5e49a0e0f9932a761c55d6c52b142780a05c"},
"mimerl": {:hex, :mimerl, "1.2.0", "67e2d3f571088d5cfd3e550c383094b47159f3eee8ffa08e64106cdf5e981be3", [:rebar3], [], "hexpm", "f278585650aa581986264638ebf698f8bb19df297f66ad91b18910dfc6e19323"},
"oapi_tmdb": {:hex, :oapi_tmdb, "0.3.0", "b803847378011dcce5865ec618f60a2889d5c73f56fbfd0b4ebdb5bbdce8168d", [:mix], [{:httpoison, "~> 2.0", [hex: :httpoison, repo: "hexpm", optional: false]}, {:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "88c71c45631c5071f53e6552db01c1c06da3b1a7ef646101e2ca6d1b7f0d5661"},
"oauth2": {:hex, :oauth2, "2.1.0", "beb657f393814a3a7a8a15bd5e5776ecae341fd344df425342a3b6f1904c2989", [:mix], [{:tesla, "~> 1.5", [hex: :tesla, repo: "hexpm", optional: false]}], "hexpm", "8ac07f85b3307dd1acfeb0ec852f64161b22f57d0ce0c15e616a1dfc8ebe2b41"},
"openid_connect": {:hex, :openid_connect, "0.2.2", "c05055363330deab39ffd89e609db6b37752f255a93802006d83b45596189c0b", [:mix], [{:httpoison, "~> 1.2", [hex: :httpoison, repo: "hexpm", optional: false]}, {:jason, ">= 1.0.0", [hex: :jason, repo: "hexpm", optional: false]}, {:jose, "~> 1.8", [hex: :jose, repo: "hexpm", optional: false]}], "hexpm", "735769b6d592124b58edd0582554ce638524c0214cd783d8903d33357d74cc13"},
"parse_trans": {:hex, :parse_trans, "3.4.1", "6e6aa8167cb44cc8f39441d05193be6e6f4e7c2946cb2759f015f8c56b76e5ff", [:rebar3], [], "hexpm", "620a406ce75dada827b82e453c19cf06776be266f5a67cff34e1ef2cbb60e49a"},
Expand Down
4 changes: 4 additions & 0 deletions priv/repo/seeds.exs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ MediaServer.MediaTypes.create(%{
type: "episode"
})

MediaServer.MediaTypes.create(%{
type: "person"
})

MediaServer.Actions.create(%{
action: "played"
})
Expand Down

0 comments on commit a41f927

Please sign in to comment.