Skip to content

Commit 631c32c

Browse files
committed
feat: bounty og image
- Introduced a new `BountyLive` module to display bounty details dynamically. - Updated the router to include a live route for bounties and restored the OG image generation route.
1 parent 6c8fdba commit 631c32c

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
defmodule AlgoraWeb.OG.BountyLive do
2+
@moduledoc false
3+
use AlgoraWeb, :live_view
4+
5+
alias Algora.Bounties
6+
7+
def mount(%{"id" => id}, _session, socket) do
8+
case Bounties.list_bounties(id: id) do
9+
[bounty | _] ->
10+
socket =
11+
socket
12+
|> assign(:bounty, bounty)
13+
|> assign(:ticket, bounty.ticket)
14+
15+
{:ok, socket}
16+
17+
[] ->
18+
{:ok, socket |> put_flash(:error, "Bounty not found") |> redirect(to: "/")}
19+
end
20+
end
21+
22+
def render(assigns) do
23+
~H"""
24+
<div class="relative flex h-[630px] w-[1200px] flex-col bg-[#0A0A0A] p-8 border-l-[1rem] border-emerald-400">
25+
<div class="absolute left-[3rem] top-8 text-2xl font-display font-medium text-muted-foreground">
26+
algora.io
27+
</div>
28+
<div class="absolute right-8 top-8 font-display text-2xl font-medium text-muted-foreground">
29+
{@bounty.repository.name}#{@ticket.number}
30+
</div>
31+
<div class="flex flex-col items-center text-center">
32+
<div class="relative">
33+
<img
34+
src={@bounty.owner.avatar_url}
35+
class="relative h-40 w-40 rounded-full bg-black"
36+
alt="Algora"
37+
/>
38+
</div>
39+
<div class="mt-4 flex flex-col items-center font-display">
40+
<p class="text-7xl font-semibold text-foreground">
41+
{@bounty.owner.name}
42+
</p>
43+
<h1 class="mt-4 text-8xl font-extrabold tracking-tight text-white">
44+
<span class="text-emerald-400">
45+
{Money.to_string!(@bounty.amount, no_fraction_if_integer: true)}
46+
</span>
47+
Bounty
48+
</h1>
49+
</div>
50+
</div>
51+
52+
<h2 class="mt-12 text-center text-4xl font-semibold text-foreground/90 line-clamp-3 leading-[3.5rem]">
53+
{@ticket.title}
54+
</h2>
55+
<%!-- <div class="mt-auto flex items-center justify-between">
56+
<div class="flex items-center gap-3">
57+
<div class="text-xl font-medium text-emerald-300">
58+
algora.io
59+
</div>
60+
<div class="h-2 w-2 rounded-full bg-muted-foreground"></div>
61+
<div class="text-xl font-medium text-muted-foreground">
62+
Earn bounties for open source contributions
63+
</div>
64+
</div>
65+
</div> --%>
66+
</div>
67+
"""
68+
end
69+
end

lib/algora_web/router.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ defmodule AlgoraWeb.Router do
6767
pipe_through [:browser]
6868

6969
get "/", RootController, :index
70-
get "/og/*path", OGImageController, :generate
7170
get "/set_context/:context", ContextController, :set
7271
get "/a/:table_prefix/:activity_id", ActivityController, :get
7372
get "/auth/logout", OAuthCallbackController, :sign_out
@@ -163,6 +162,9 @@ defmodule AlgoraWeb.Router do
163162
live "/auth/signup", SignInLive, :signup
164163
end
165164

165+
live "/0/bounties/:id", OG.BountyLive, :show
166+
get "/og/*path", OGImageController, :generate
167+
166168
live_session :wildcard,
167169
on_mount: [{AlgoraWeb.UserAuth, :current_user}] do
168170
live "/:country_code", HomeLive, :index

0 commit comments

Comments
 (0)