From 76e9cbf3750c67b8d3fd98489cb1221648350e1c Mon Sep 17 00:00:00 2001 From: zafer Date: Tue, 8 Apr 2025 15:59:10 +0300 Subject: [PATCH 1/3] feat: remove org prefix in all org paths --- README.md | 4 +- config/config.exs | 3 +- lib/algora/accounts/schemas/user.ex | 4 +- lib/algora/activities/discord_views.ex | 4 +- lib/algora/activities/router.ex | 4 +- lib/algora/integrations/discord/discord.ex | 2 +- .../controllers/api/og_redirect_controller.ex | 4 +- lib/algora_web/controllers/org_auth.ex | 2 +- lib/algora_web/controllers/user_auth.ex | 2 +- lib/algora_web/controllers/user_controller.ex | 8 ++ lib/algora_web/live/bounty_live.ex | 2 +- lib/algora_web/live/contract/view_live.ex | 2 +- lib/algora_web/live/crowdfund.ex | 32 ++++---- lib/algora_web/live/home_live.ex | 48 ++++++----- lib/algora_web/live/onboarding/org.ex | 24 +++--- lib/algora_web/live/org/bounties_live.ex | 4 +- lib/algora_web/live/org/bounties_new_live.ex | 12 +-- lib/algora_web/live/org/dashboard_live.ex | 22 ++--- lib/algora_web/live/org/home_live.ex | 12 +-- lib/algora_web/live/org/nav.ex | 16 ++-- lib/algora_web/live/org/repo_nav.ex | 16 ++-- lib/algora_web/live/org/settings_live.ex | 6 +- lib/algora_web/live/orgs_live.ex | 2 +- lib/algora_web/live/payment/success_live.ex | 2 +- lib/algora_web/live/testimonials.ex | 32 ++++---- lib/algora_web/live/user/dashboard_live.ex | 2 +- lib/algora_web/plugs/redirect_plug.ex | 16 +++- lib/algora_web/router.ex | 81 +++++++++---------- priv/repo/seeds.exs | 4 +- test/algora_web/live/org_auth_test.exs | 6 +- 30 files changed, 199 insertions(+), 179 deletions(-) create mode 100644 lib/algora_web/controllers/user_controller.ex diff --git a/README.md b/README.md index c5bf0b0b7..608d5f59b 100644 --- a/README.md +++ b/README.md @@ -52,10 +52,10 @@ Algora combines: - Homepage + Homepage - Homepage + Homepage diff --git a/config/config.exs b/config/config.exs index 3ad132705..9a58c4c39 100644 --- a/config/config.exs +++ b/config/config.exs @@ -20,7 +20,8 @@ config :algora, {"/podcast", "https://www.youtube.com/@algora-io/podcasts"}, {"/create/org", "/onboarding/org"}, {"/solve", "/onboarding/dev"}, - {"/onboarding/solver", "/onboarding/dev"} + {"/onboarding/solver", "/onboarding/dev"}, + {"/org/*path", "/*path"} ] # Configures the endpoint diff --git a/lib/algora/accounts/schemas/user.ex b/lib/algora/accounts/schemas/user.ex index 5fb50c50e..77565233d 100644 --- a/lib/algora/accounts/schemas/user.ex +++ b/lib/algora/accounts/schemas/user.ex @@ -349,7 +349,7 @@ defmodule Algora.Accounts.User do def handle(%{provider_login: handle}), do: handle def url(%{handle: handle, type: :individual}) when is_binary(handle), do: "#{Endpoint.url()}/@/#{handle}" - def url(%{handle: handle, type: :organization}) when is_binary(handle), do: "#{Endpoint.url()}/org/#{handle}" - def url(%{handle: handle}) when is_binary(handle), do: "#{Endpoint.url()}/org/#{handle}" + def url(%{handle: handle, type: :organization}) when is_binary(handle), do: "#{Endpoint.url()}/#{handle}" + def url(%{handle: handle}) when is_binary(handle), do: "#{Endpoint.url()}/#{handle}" def url(%{provider_login: handle}), do: "https://github.com/#{handle}" end diff --git a/lib/algora/activities/discord_views.ex b/lib/algora/activities/discord_views.ex index f6529f1d9..d43dc2a65 100644 --- a/lib/algora/activities/discord_views.ex +++ b/lib/algora/activities/discord_views.ex @@ -56,7 +56,7 @@ defmodule Algora.Activities.DiscordViews do author: %{ name: tx.linked_transaction.user.name, icon_url: tx.linked_transaction.user.avatar_url, - url: "#{AlgoraWeb.Endpoint.url()}/org/#{tx.linked_transaction.user.handle}" + url: "#{AlgoraWeb.Endpoint.url()}/#{tx.linked_transaction.user.handle}" }, footer: %{ text: tx.user.name, @@ -75,7 +75,7 @@ defmodule Algora.Activities.DiscordViews do inline: false } ], - url: "#{AlgoraWeb.Endpoint.url()}/org/#{tx.linked_transaction.user.handle}", + url: "#{AlgoraWeb.Endpoint.url()}/#{tx.linked_transaction.user.handle}", timestamp: tx.succeeded_at } ] diff --git a/lib/algora/activities/router.ex b/lib/algora/activities/router.ex index 719d85772..7a3dfcc1a 100644 --- a/lib/algora/activities/router.ex +++ b/lib/algora/activities/router.ex @@ -2,11 +2,11 @@ defmodule Algora.Activities.Router do alias Algora.Accounts.Identity alias Algora.Bounties.Bounty - def route(%{assoc: %Bounty{owner: user}}), do: {:ok, "/org/#{user.handle}/bounties"} + def route(%{assoc: %Bounty{owner: user}}), do: {:ok, "/#{user.handle}/bounties"} def route(%{assoc: %Identity{user: %{type: :individual} = user}}), do: {:ok, "/@/#{user.handle}"} - def route(%{assoc: %Identity{user: %{type: :organization} = user}}), do: {:ok, "/org/#{user.handle}"} + def route(%{assoc: %Identity{user: %{type: :organization} = user}}), do: {:ok, "/#{user.handle}"} def route(_activity) do {:error, :not_found} diff --git a/lib/algora/integrations/discord/discord.ex b/lib/algora/integrations/discord/discord.ex index 054f034f0..2ae0cf85a 100644 --- a/lib/algora/integrations/discord/discord.ex +++ b/lib/algora/integrations/discord/discord.ex @@ -34,7 +34,7 @@ defmodule Algora.Discord do ...> icon_url: "https://example.com/avatar.png", ...> url: "https://example.com/org" ...> }, - ...> url: "https://github.com/org/repo/issues/1", + ...> url: "https://github.com/repo/issues/1", ...> timestamp: DateTime.utc_now() |> DateTime.to_iso8601() ...> } ...> ] diff --git a/lib/algora_web/controllers/api/og_redirect_controller.ex b/lib/algora_web/controllers/api/og_redirect_controller.ex index 808c58477..309463168 100644 --- a/lib/algora_web/controllers/api/og_redirect_controller.ex +++ b/lib/algora_web/controllers/api/og_redirect_controller.ex @@ -5,10 +5,10 @@ defmodule AlgoraWeb.API.OGRedirectController do target_path = case {asset, params["status"]} do {"leaderboard.png", _} -> - "/og/org/#{org_handle}/leaderboard" + "/og/#{org_handle}/leaderboard" {"bounties.png", _} -> - "/og/org/#{org_handle}" + "/og/#{org_handle}" _ -> nil diff --git a/lib/algora_web/controllers/org_auth.ex b/lib/algora_web/controllers/org_auth.ex index f72bcfdf5..592f1080d 100644 --- a/lib/algora_web/controllers/org_auth.ex +++ b/lib/algora_web/controllers/org_auth.ex @@ -31,7 +31,7 @@ defmodule AlgoraWeb.OrgAuth do if get_user_role(current_user, current_org) in allowed_roles do {:cont, socket} else - {:halt, redirect(socket, to: "/org/#{current_org.handle}")} + {:halt, redirect(socket, to: "/#{current_org.handle}")} end end end diff --git a/lib/algora_web/controllers/user_auth.ex b/lib/algora_web/controllers/user_auth.ex index fed087802..4cf2e49b2 100644 --- a/lib/algora_web/controllers/user_auth.ex +++ b/lib/algora_web/controllers/user_auth.ex @@ -236,7 +236,7 @@ defmodule AlgoraWeb.UserAuth do end end - def signed_in_path_from_context(org_handle), do: ~p"/org/#{org_handle}" + def signed_in_path_from_context(org_handle), do: ~p"/#{org_handle}" def signed_in_path(%User{} = user) do signed_in_path_from_context(Accounts.last_context(user)) diff --git a/lib/algora_web/controllers/user_controller.ex b/lib/algora_web/controllers/user_controller.ex new file mode 100644 index 000000000..5e5ce6f31 --- /dev/null +++ b/lib/algora_web/controllers/user_controller.ex @@ -0,0 +1,8 @@ +defmodule AlgoraWeb.UserController do + use AlgoraWeb, :controller + + def index(conn, params) do + dbg(params) + redirect(conn, to: "/#{params["handle"]}/dashboard") + end +end diff --git a/lib/algora_web/live/bounty_live.ex b/lib/algora_web/live/bounty_live.ex index 9023e86a9..74678fdd5 100644 --- a/lib/algora_web/live/bounty_live.ex +++ b/lib/algora_web/live/bounty_live.ex @@ -149,7 +149,7 @@ defmodule AlgoraWeb.BountyLive do ~p"/#{socket.assigns.ticket_ref.owner}/#{socket.assigns.ticket_ref.repo}/issues/#{socket.assigns.ticket_ref.number}" ) else - url(~p"/org/#{socket.assigns.bounty.owner.handle}/bounties/#{socket.assigns.bounty.id}") + url(~p"/#{socket.assigns.bounty.owner.handle}/bounties/#{socket.assigns.bounty.id}") end {:ok, diff --git a/lib/algora_web/live/contract/view_live.ex b/lib/algora_web/live/contract/view_live.ex index 6878d6ee9..d37681083 100644 --- a/lib/algora_web/live/contract/view_live.ex +++ b/lib/algora_web/live/contract/view_live.ex @@ -482,7 +482,7 @@ defmodule AlgoraWeb.Contract.ViewLive do case socket.assigns[:current_user] do nil -> - {:ok, redirect(socket, to: ~p"/auth/login?return_to=#{~p"/org/#{contract.client.handle}/contracts/#{id}"}")} + {:ok, redirect(socket, to: ~p"/auth/login?return_to=#{~p"/#{contract.client.handle}/contracts/#{id}"}")} current_user -> if current_user.id != contract.contractor_id and diff --git a/lib/algora_web/live/crowdfund.ex b/lib/algora_web/live/crowdfund.ex index 7e182c2e5..5e022797a 100644 --- a/lib/algora_web/live/crowdfund.ex +++ b/lib/algora_web/live/crowdfund.ex @@ -252,7 +252,7 @@ defmodule AlgoraWeb.CrowdfundLive do <.link - href={~p"/org/coollabsio"} + href={~p"/coollabsio"} rel="noopener" class="relative flex flex-col sm:flex-row items-start sm:items-center gap-4 sm:gap-x-4 rounded-xl bg-black p-4 sm:p-6 ring-1 ring-border transition-colors" > @@ -658,7 +658,7 @@ defmodule AlgoraWeb.CrowdfundLive do
<.link class="font-bold font-display text-base sm:text-4xl whitespace-nowrap flex items-center justify-center" - navigate={~p"/org/browser-use"} + navigate={~p"/browser-use"} > Browser Use - <.link class="relative flex items-center justify-center" navigate={~p"/org/outerbase"}> + <.link class="relative flex items-center justify-center" navigate={~p"/outerbase"}> - <.link class="relative flex items-center justify-center" navigate={~p"/org/triggerdotdev"}> + <.link class="relative flex items-center justify-center" navigate={~p"/triggerdotdev"}> Trigger.dev - <.link class="relative flex items-center justify-center" navigate={~p"/org/traceloop"}> + <.link class="relative flex items-center justify-center" navigate={~p"/traceloop"}> Traceloop <.link class="font-bold font-display text-base sm:text-5xl whitespace-nowrap flex items-center justify-center" - navigate={~p"/org/trieve"} + navigate={~p"/trieve"} > <.link class="font-bold font-display text-base sm:text-5xl whitespace-nowrap flex items-center justify-center" - navigate={~p"/org/twentyhq"} + navigate={~p"/twentyhq"} > Twenty - <.link class="relative flex items-center justify-center" navigate={~p"/org/aidenybai"}> + <.link class="relative flex items-center justify-center" navigate={~p"/aidenybai"}> Million - <.link class="relative flex items-center justify-center" navigate={~p"/org/moonrepo"}> + <.link class="relative flex items-center justify-center" navigate={~p"/moonrepo"}> moon - <.link class="relative flex items-center justify-center" navigate={~p"/org/dittofeed"}> + <.link class="relative flex items-center justify-center" navigate={~p"/dittofeed"}> Dittofeed 🔥 Firecrawl - <.link class="relative flex items-center justify-center" navigate={~p"/org/keephq"}> + <.link class="relative flex items-center justify-center" navigate={~p"/keephq"}> Keep Windmill - <.link class="relative flex items-center justify-center" navigate={~p"/org/panoratech"}> + <.link class="relative flex items-center justify-center" navigate={~p"/panoratech"}> Panora - <.link class="relative flex items-center justify-center" navigate={~p"/org/highlight"}> + <.link class="relative flex items-center justify-center" navigate={~p"/highlight"}> Highlight country_code} = params, _session, socket) do - Gettext.put_locale(AlgoraWeb.Gettext, Algora.Util.locale_from_country_code(country_code)) - + def mount(params, _session, socket) do total_contributors = get_contributors_count() total_countries = get_countries_count() @@ -54,27 +52,33 @@ defmodule AlgoraWeb.HomeLive do %{label: "Countries", value: format_number(total_countries)} ] - featured_devs = Accounts.list_featured_developers(country_code) + featured_devs = Accounts.list_featured_developers() featured_collabs = list_featured_collabs() - {:ok, - socket - |> assign(:page_title, "Algora - The open source Upwork for engineers") - |> assign(:page_image, "#{AlgoraWeb.Endpoint.url()}/images/og/home.png") - |> assign(:screenshot?, not is_nil(params["screenshot"])) - |> assign(:featured_devs, featured_devs) - |> assign(:featured_collabs, featured_collabs) - |> assign(:stats, stats) - |> assign(:bounty_form, to_form(BountyForm.changeset(%BountyForm{}, %{}))) - |> assign(:contract_form, to_form(ContractForm.changeset(%ContractForm{}, %{}))) - |> assign(:tip_form, to_form(TipForm.changeset(%TipForm{}, %{}))) - |> assign(:repo_form, to_form(RepoForm.changeset(%RepoForm{}, %{}))) - |> assign(:plans1, AlgoraWeb.PricingLive.get_plans1()) - |> assign(:total_contributors, total_contributors) - |> assign(:total_countries, total_countries) - |> assign(:selected_developer, nil) - |> assign(:share_drawer_type, nil) - |> assign(:show_share_drawer, false)} + case socket.assigns[:current_user] do + nil -> + {:ok, + socket + |> assign(:page_title, "Algora - The open source Upwork for engineers") + |> assign(:page_image, "#{AlgoraWeb.Endpoint.url()}/images/og/home.png") + |> assign(:screenshot?, not is_nil(params["screenshot"])) + |> assign(:featured_devs, featured_devs) + |> assign(:featured_collabs, featured_collabs) + |> assign(:stats, stats) + |> assign(:bounty_form, to_form(BountyForm.changeset(%BountyForm{}, %{}))) + |> assign(:contract_form, to_form(ContractForm.changeset(%ContractForm{}, %{}))) + |> assign(:tip_form, to_form(TipForm.changeset(%TipForm{}, %{}))) + |> assign(:repo_form, to_form(RepoForm.changeset(%RepoForm{}, %{}))) + |> assign(:plans1, AlgoraWeb.PricingLive.get_plans1()) + |> assign(:total_contributors, total_contributors) + |> assign(:total_countries, total_countries) + |> assign(:selected_developer, nil) + |> assign(:share_drawer_type, nil) + |> assign(:show_share_drawer, false)} + + user -> + {:ok, redirect(socket, to: AlgoraWeb.UserAuth.signed_in_path(user))} + end end defp org_features do diff --git a/lib/algora_web/live/onboarding/org.ex b/lib/algora_web/live/onboarding/org.ex index 205f00ae7..1ef107497 100644 --- a/lib/algora_web/live/onboarding/org.ex +++ b/lib/algora_web/live/onboarding/org.ex @@ -755,60 +755,60 @@ defmodule AlgoraWeb.Onboarding.OrgLive do You're in good company
- + - + - + Remotion - + ZIO - + Trigger.dev - + Tembo - + Maybe - + - + Million - + - + Highlight - + Dittofeed "completed"}, socket) do - {:noreply, push_patch(socket, to: ~p"/org/#{socket.assigns.current_org.handle}/bounties?status=completed")} + {:noreply, push_patch(socket, to: ~p"/#{socket.assigns.current_org.handle}/bounties?status=completed")} end def handle_event("change-tab", %{"tab" => "open"}, socket) do - {:noreply, push_patch(socket, to: ~p"/org/#{socket.assigns.current_org.handle}/bounties?status=open")} + {:noreply, push_patch(socket, to: ~p"/#{socket.assigns.current_org.handle}/bounties?status=open")} end def handle_event("load_more", _params, socket) do diff --git a/lib/algora_web/live/org/bounties_new_live.ex b/lib/algora_web/live/org/bounties_new_live.ex index 86d29f53c..fa3277b4d 100644 --- a/lib/algora_web/live/org/bounties_new_live.ex +++ b/lib/algora_web/live/org/bounties_new_live.ex @@ -86,28 +86,28 @@ defmodule AlgoraWeb.Org.BountiesNewLive do title="Open Bounties" value={Money.to_string!(@stats.open_bounties_amount)} subtext={"#{@stats.open_bounties_count} bounties"} - navigate={~p"/org/#{@org.handle}/bounties?status=open"} + navigate={~p"/#{@org.handle}/bounties?status=open"} icon="tabler-diamond" /> <.stat_card title="Total Awarded" value={Money.to_string!(@stats.total_awarded_amount)} subtext={"#{@stats.rewarded_bounties_count} #{ngettext("bounty", "bounties", @stats.rewarded_bounties_count)} / #{@stats.rewarded_tips_count} #{ngettext("tip", "tips", @stats.rewarded_tips_count)} / #{@stats.rewarded_contracts_count} #{ngettext("contract", "contracts", @stats.rewarded_contracts_count)}"} - navigate={~p"/org/#{@org.handle}/bounties?status=completed"} + navigate={~p"/#{@org.handle}/bounties?status=completed"} icon="tabler-gift" /> <.stat_card title="Solvers" value={@stats.solvers_count} subtext={"+#{@stats.solvers_diff} from last month"} - navigate={~p"/org/#{@org.handle}/leaderboard"} + navigate={~p"/#{@org.handle}/leaderboard"} icon="tabler-user-code" /> <.stat_card title="Members" value={@stats.members_count} subtext="" - navigate={~p"/org/#{@org.handle}/team"} + navigate={~p"/#{@org.handle}/team"} icon="tabler-users" />
@@ -122,7 +122,7 @@ defmodule AlgoraWeb.Org.BountiesNewLive do

Open Bounties

<.link - href={~p"/org/#{@org.handle}/bounties?status=open"} + href={~p"/#{@org.handle}/bounties?status=open"} class="text-sm text-muted-foreground hover:underline" > View all @@ -165,7 +165,7 @@ defmodule AlgoraWeb.Org.BountiesNewLive do

Completed Bounties

<.link - href={~p"/org/#{@org.handle}/bounties?status=completed"} + href={~p"/#{@org.handle}/bounties?status=completed"} class="text-sm text-muted-foreground hover:underline" > View all diff --git a/lib/algora_web/live/org/dashboard_live.ex b/lib/algora_web/live/org/dashboard_live.ex index aab4c03d5..854287306 100644 --- a/lib/algora_web/live/org/dashboard_live.ex +++ b/lib/algora_web/live/org/dashboard_live.ex @@ -101,7 +101,7 @@ defmodule AlgoraWeb.Org.DashboardLive do |> assign(:messages, []) |> assign(:show_chat, false)} else - {:ok, redirect(socket, to: ~p"/org/#{current_org.handle}/home")} + {:ok, redirect(socket, to: ~p"/#{current_org.handle}/home")} end end @@ -759,7 +759,7 @@ defmodule AlgoraWeb.Org.DashboardLive do {:noreply, socket |> assign(:show_share_drawer, false) - |> redirect(to: ~p"/org/#{socket.assigns.current_org.handle}/contracts/#{contract.id}")} + |> redirect(to: ~p"/#{socket.assigns.current_org.handle}/contracts/#{contract.id}")} {:error, changeset} -> {:noreply, put_flash(socket, :error, "Failed to create contract: #{inspect(changeset.errors)}")} @@ -821,12 +821,12 @@ defmodule AlgoraWeb.Org.DashboardLive do @impl true def handle_event("change-tab", %{"tab" => "completed"}, socket) do - {:noreply, push_patch(socket, to: ~p"/org/#{socket.assigns.current_org.handle}?status=completed")} + {:noreply, push_patch(socket, to: ~p"/#{socket.assigns.current_org.handle}?status=completed")} end @impl true def handle_event("change-tab", %{"tab" => "open"}, socket) do - {:noreply, push_patch(socket, to: ~p"/org/#{socket.assigns.current_org.handle}?status=open")} + {:noreply, push_patch(socket, to: ~p"/#{socket.assigns.current_org.handle}?status=open")} end @impl true @@ -1244,7 +1244,7 @@ defmodule AlgoraWeb.Org.DashboardLive do <.button :if={@contract_for_user && @contract_for_user.status in [:active, :paid]} - navigate={~p"/org/#{@current_org.handle}/contracts/#{@contract_for_user.id}"} + navigate={~p"/#{@current_org.handle}/contracts/#{@contract_for_user.id}"} variant="none" class="bg-emerald-800/10 text-emerald-300 drop-shadow-[0_1px_5px_#34d39980] focus:bg-emerald-800/10 focus:text-emerald-300 focus:outline-none focus:drop-shadow-[0_1px_5px_#34d39980] border border-emerald-400/50 focus:border-emerald-400/50" > @@ -1252,7 +1252,7 @@ defmodule AlgoraWeb.Org.DashboardLive do <.button :if={@contract_for_user && @contract_for_user.status in [:draft]} - navigate={~p"/org/#{@current_org.handle}/contracts/#{@contract_for_user.id}"} + navigate={~p"/#{@current_org.handle}/contracts/#{@contract_for_user.id}"} variant="none" class="bg-gray-800/10 text-gray-400 drop-shadow-[0_1px_5px_#94a3b880] focus:bg-gray-800/10 focus:text-gray-400 focus:outline-none focus:drop-shadow-[0_1px_5px_#94a3b880] border border-gray-400/50 focus:border-gray-400/50" > @@ -1371,7 +1371,7 @@ defmodule AlgoraWeb.Org.DashboardLive do <.button :if={@contract_for_user && @contract_for_user.status in [:active, :paid]} - navigate={~p"/org/#{@current_org.handle}/contracts/#{@contract_for_user.id}"} + navigate={~p"/#{@current_org.handle}/contracts/#{@contract_for_user.id}"} variant="none" class="bg-emerald-800/10 text-emerald-300 drop-shadow-[0_1px_5px_#34d39980] focus:bg-emerald-800/10 focus:text-emerald-300 focus:outline-none focus:drop-shadow-[0_1px_5px_#34d39980] border border-emerald-400/50 focus:border-emerald-400/50" > @@ -1379,7 +1379,7 @@ defmodule AlgoraWeb.Org.DashboardLive do <.button :if={@contract_for_user && @contract_for_user.status in [:draft]} - navigate={~p"/org/#{@current_org.handle}/contracts/#{@contract_for_user.id}"} + navigate={~p"/#{@current_org.handle}/contracts/#{@contract_for_user.id}"} variant="none" class="bg-gray-800/10 text-gray-400 drop-shadow-[0_1px_5px_#94a3b880] focus:bg-gray-800/10 focus:text-gray-400 focus:outline-none focus:drop-shadow-[0_1px_5px_#94a3b880] border border-gray-400/50 focus:border-gray-400/50" > @@ -1588,7 +1588,7 @@ defmodule AlgoraWeb.Org.DashboardLive do <.badge id="og-url" phx-hook="CopyToClipboard" - data-value={url(~p"/org/#{@current_org.handle}/home")} + data-value={url(~p"/#{@current_org.handle}/home")} phx-click={ %JS{} |> JS.hide( @@ -1614,11 +1614,11 @@ defmodule AlgoraWeb.Org.DashboardLive do class="absolute left-1 my-auto hidden size-4 mr-2" /> - {AlgoraWeb.Endpoint.host()}{~p"/org/#{@current_org.handle}/home"} + {AlgoraWeb.Endpoint.host()}{~p"/#{@current_org.handle}/home"} {@current_org.name} <.stat_card title="Total Awarded" value={Money.to_string!(@stats.total_awarded_amount)} subtext={"#{@stats.rewarded_bounties_count} #{ngettext("bounty", "bounties", @stats.rewarded_bounties_count)} / #{@stats.rewarded_tips_count} #{ngettext("tip", "tips", @stats.rewarded_tips_count)} / #{@stats.rewarded_contracts_count} #{ngettext("contract", "contracts", @stats.rewarded_contracts_count)}"} - navigate={~p"/org/#{@org.handle}/bounties?status=completed"} + navigate={~p"/#{@org.handle}/bounties?status=completed"} icon="tabler-gift" /> <.stat_card title="Solvers" value={@stats.solvers_count} subtext={"+#{@stats.solvers_diff} from last month"} - navigate={~p"/org/#{@org.handle}/leaderboard"} + navigate={~p"/#{@org.handle}/leaderboard"} icon="tabler-user-code" /> <.stat_card title="Members" value={@stats.members_count} subtext="" - navigate={~p"/org/#{@org.handle}/team"} + navigate={~p"/#{@org.handle}/team"} icon="tabler-users" />
@@ -105,7 +105,7 @@ defmodule AlgoraWeb.Org.HomeLive do

Open Bounties

<.link - href={~p"/org/#{@org.handle}/bounties?status=open"} + href={~p"/#{@org.handle}/bounties?status=open"} class="text-sm text-muted-foreground hover:underline" > View all @@ -148,7 +148,7 @@ defmodule AlgoraWeb.Org.HomeLive do

Completed Bounties

<.link - href={~p"/org/#{@org.handle}/bounties?status=completed"} + href={~p"/#{@org.handle}/bounties?status=completed"} class="text-sm text-muted-foreground hover:underline" > View all diff --git a/lib/algora_web/live/org/nav.ex b/lib/algora_web/live/org/nav.ex index a2ce8f11a..ab676c826 100644 --- a/lib/algora_web/live/org/nav.ex +++ b/lib/algora_web/live/org/nav.ex @@ -87,7 +87,7 @@ defmodule AlgoraWeb.Org.Nav do ~p"/#{data.ticket_ref.owner}/#{data.ticket_ref.repo}/issues/#{data.ticket_ref.number}" :custom -> - ~p"/org/#{socket.assigns.current_org.handle}/bounties/#{bounty.id}" + ~p"/#{socket.assigns.current_org.handle}/bounties/#{bounty.id}" end {:cont, redirect(socket, to: to)} @@ -146,49 +146,49 @@ defmodule AlgoraWeb.Org.Nav do Enum.filter( [ %{ - href: "/org/#{org_handle}", + href: "/#{org_handle}", tab: :dashboard, icon: "tabler-sparkles", label: "Dashboard", roles: [:admin, :mod] }, %{ - href: "/org/#{org_handle}/home", + href: "/#{org_handle}/home", tab: :home, icon: "tabler-home", label: "Home", roles: [:admin, :mod, :expert, :none] }, %{ - href: "/org/#{org_handle}/bounties", + href: "/#{org_handle}/bounties", tab: :bounties, icon: "tabler-diamond", label: "Bounties", roles: [:admin, :mod, :expert, :none] }, %{ - href: "/org/#{org_handle}/leaderboard", + href: "/#{org_handle}/leaderboard", tab: :leaderboard, icon: "tabler-trophy", label: "Leaderboard", roles: [:admin, :mod, :expert, :none] }, %{ - href: "/org/#{org_handle}/team", + href: "/#{org_handle}/team", tab: :team, icon: "tabler-users", label: "Team", roles: [:admin, :mod, :expert, :none] }, %{ - href: "/org/#{org_handle}/transactions", + href: "/#{org_handle}/transactions", tab: :transactions, icon: "tabler-credit-card", label: "Transactions", roles: [:admin] }, %{ - href: "/org/#{org_handle}/settings", + href: "/#{org_handle}/settings", tab: :settings, icon: "tabler-settings", label: "Settings", diff --git a/lib/algora_web/live/org/repo_nav.ex b/lib/algora_web/live/org/repo_nav.ex index 92dcaedaf..6ff3fe610 100644 --- a/lib/algora_web/live/org/repo_nav.ex +++ b/lib/algora_web/live/org/repo_nav.ex @@ -82,7 +82,7 @@ defmodule AlgoraWeb.Org.RepoNav do ~p"/#{data.ticket_ref.owner}/#{data.ticket_ref.repo}/issues/#{data.ticket_ref.number}" :custom -> - ~p"/org/#{socket.assigns.current_org.handle}/bounties/#{bounty.id}" + ~p"/#{socket.assigns.current_org.handle}/bounties/#{bounty.id}" end {:cont, redirect(socket, to: to)} @@ -141,49 +141,49 @@ defmodule AlgoraWeb.Org.RepoNav do Enum.filter( [ %{ - href: "/org/#{org_handle}", + href: "/#{org_handle}", tab: :dashboard, icon: "tabler-sparkles", label: "Dashboard", roles: [:admin, :mod] }, %{ - href: "/org/#{org_handle}/home", + href: "/#{org_handle}/home", tab: :home, icon: "tabler-home", label: "Home", roles: [:admin, :mod, :expert, :none] }, %{ - href: "/org/#{org_handle}/bounties", + href: "/#{org_handle}/bounties", tab: :bounties, icon: "tabler-diamond", label: "Bounties", roles: [:admin, :mod, :expert, :none] }, %{ - href: "/org/#{org_handle}/leaderboard", + href: "/#{org_handle}/leaderboard", tab: :leaderboard, icon: "tabler-trophy", label: "Leaderboard", roles: [:admin, :mod, :expert, :none] }, %{ - href: "/org/#{org_handle}/team", + href: "/#{org_handle}/team", tab: :team, icon: "tabler-users", label: "Team", roles: [:admin, :mod, :expert, :none] }, %{ - href: "/org/#{org_handle}/transactions", + href: "/#{org_handle}/transactions", tab: :transactions, icon: "tabler-credit-card", label: "Transactions", roles: [:admin] }, %{ - href: "/org/#{org_handle}/settings", + href: "/#{org_handle}/settings", tab: :settings, icon: "tabler-settings", label: "Settings", diff --git a/lib/algora_web/live/org/settings_live.ex b/lib/algora_web/live/org/settings_live.ex index 06e050bc5..6c47fc5c8 100644 --- a/lib/algora_web/live/org/settings_live.ex +++ b/lib/algora_web/live/org/settings_live.ex @@ -37,7 +37,7 @@ defmodule AlgoraWeb.Org.SettingsLive do
  • <.badge>/tip command is used by you or any other - <.link navigate={~p"/org/#{@current_org.handle}/team"} class="font-semibold"> + <.link navigate={~p"/#{@current_org.handle}/team"} class="font-semibold"> {@current_org.name} admins
  • @@ -287,8 +287,8 @@ defmodule AlgoraWeb.Org.SettingsLive do @impl true def handle_event("setup_payment", _params, socket) do %{current_org: org} = socket.assigns - success_url = url(~p"/org/#{org.handle}/settings") - cancel_url = url(~p"/org/#{org.handle}/settings") + success_url = url(~p"/#{org.handle}/settings") + cancel_url = url(~p"/#{org.handle}/settings") with {:ok, customer} <- Payments.fetch_or_create_customer(org), {:ok, session} <- Payments.create_stripe_setup_session(customer, success_url, cancel_url) do diff --git a/lib/algora_web/live/orgs_live.ex b/lib/algora_web/live/orgs_live.ex index 03be04071..7ea4c494a 100644 --- a/lib/algora_web/live/orgs_live.ex +++ b/lib/algora_web/live/orgs_live.ex @@ -45,7 +45,7 @@ defmodule AlgoraWeb.OrgsLive do
      <%= for org <- @orgs do %>
    • - <.link navigate={~p"/org/#{org.handle}"}> + <.link navigate={~p"/#{org.handle}"}>
      diff --git a/lib/algora_web/live/payment/success_live.ex b/lib/algora_web/live/payment/success_live.ex index 6a691cd2a..8c7fc2f5e 100644 --- a/lib/algora_web/live/payment/success_live.ex +++ b/lib/algora_web/live/payment/success_live.ex @@ -14,7 +14,7 @@ defmodule AlgoraWeb.Payment.SuccessLive do to = case Accounts.last_context(current_user) do "personal" -> ~p"/user/transactions" - org_handle -> ~p"/org/#{org_handle}/transactions" + org_handle -> ~p"/#{org_handle}/transactions" end socket diff --git a/lib/algora_web/live/testimonials.ex b/lib/algora_web/live/testimonials.ex index ba92c9a5b..c6421613d 100644 --- a/lib/algora_web/live/testimonials.ex +++ b/lib/algora_web/live/testimonials.ex @@ -395,7 +395,7 @@ defmodule AlgoraWeb.TestimonialsLive do <.link class="font-bold font-display text-2xl whitespace-nowrap flex items-center justify-center brightness-0 invert" aria-label="Logo" - navigate={~p"/org/mendableai"} + navigate={~p"/mendableai"} > 🔥 Firecrawl @@ -510,7 +510,7 @@ defmodule AlgoraWeb.TestimonialsLive do
      <.link class="font-bold font-display text-base sm:text-4xl whitespace-nowrap flex items-center justify-center" - navigate={~p"/org/browser-use"} + navigate={~p"/browser-use"} > Browser Use - <.link class="relative flex items-center justify-center" navigate={~p"/org/outerbase"}> + <.link class="relative flex items-center justify-center" navigate={~p"/outerbase"}> - <.link class="relative flex items-center justify-center" navigate={~p"/org/triggerdotdev"}> + <.link class="relative flex items-center justify-center" navigate={~p"/triggerdotdev"}> Trigger.dev - <.link class="relative flex items-center justify-center" navigate={~p"/org/traceloop"}> + <.link class="relative flex items-center justify-center" navigate={~p"/traceloop"}> Traceloop <.link class="font-bold font-display text-base sm:text-5xl whitespace-nowrap flex items-center justify-center" - navigate={~p"/org/trieve"} + navigate={~p"/trieve"} > <.link class="font-bold font-display text-base sm:text-5xl whitespace-nowrap flex items-center justify-center" - navigate={~p"/org/twentyhq"} + navigate={~p"/twentyhq"} > Twenty - <.link class="relative flex items-center justify-center" navigate={~p"/org/aidenybai"}> + <.link class="relative flex items-center justify-center" navigate={~p"/aidenybai"}> Million - <.link class="relative flex items-center justify-center" navigate={~p"/org/moonrepo"}> + <.link class="relative flex items-center justify-center" navigate={~p"/moonrepo"}> moon - <.link class="relative flex items-center justify-center" navigate={~p"/org/dittofeed"}> + <.link class="relative flex items-center justify-center" navigate={~p"/dittofeed"}> Dittofeed 🔥 Firecrawl - <.link class="relative flex items-center justify-center" navigate={~p"/org/keephq"}> + <.link class="relative flex items-center justify-center" navigate={~p"/keephq"}> Keep Windmill - <.link class="relative flex items-center justify-center" navigate={~p"/org/panoratech"}> + <.link class="relative flex items-center justify-center" navigate={~p"/panoratech"}> Panora - <.link class="relative flex items-center justify-center" navigate={~p"/org/highlight"}> + <.link class="relative flex items-center justify-center" navigate={~p"/highlight"}> Highlight
      <.button - navigate={~p"/org/#{@contract.client.handle}/contracts/#{@contract.id}"} + navigate={~p"/#{@contract.client.handle}/contracts/#{@contract.id}"} phx-click="view_contract" phx-value-org={@contract.client.handle} size="sm" diff --git a/lib/algora_web/plugs/redirect_plug.ex b/lib/algora_web/plugs/redirect_plug.ex index c2f93c104..3c37bad9b 100644 --- a/lib/algora_web/plugs/redirect_plug.ex +++ b/lib/algora_web/plugs/redirect_plug.ex @@ -26,7 +26,7 @@ defmodule AlgoraWeb.RedirectPlug do opts |> Keyword.put( :preserve_query_string, - Keyword.get(opts[:opts], :preserve_query_string, false) + Keyword.get(opts[:opts], :preserve_query_string, true) ) |> Keyword.delete(:opts) end @@ -43,13 +43,21 @@ defmodule AlgoraWeb.RedirectPlug do defp do_redirect(conn, opts) do query_string = - if opts[:preserve_query_string] && conn.params != %{} do - "?#{URI.encode_query(conn.params)}" + if opts[:preserve_query_string] && conn.query_string != "" do + "?#{conn.query_string}" else "" end - case opts[:to] do + to = + Enum.reduce(conn.path_params, opts[:to], fn {key, value}, acc -> + case value do + xs when is_list(xs) -> String.replace(acc, "*#{key}", Path.join(xs)) + _ -> String.replace(acc, ":#{key}", value) + end + end) + + case to do "http" <> _ = to -> Controller.redirect(conn, external: to <> query_string) to -> Controller.redirect(conn, to: to <> query_string) end diff --git a/lib/algora_web/router.ex b/lib/algora_web/router.ex index 839ef1209..7b7d24f0c 100644 --- a/lib/algora_web/router.ex +++ b/lib/algora_web/router.ex @@ -67,7 +67,6 @@ defmodule AlgoraWeb.Router do scope "/", AlgoraWeb do pipe_through [:browser] - get "/", RootController, :index get "/set_context/:context", ContextController, :set get "/a/:table_prefix/:activity_id", ActivityController, :get get "/auth/logout", OAuthCallbackController, :sign_out @@ -89,43 +88,6 @@ defmodule AlgoraWeb.Router do end end - scope "/:repo_owner/:repo_name" do - live_session :repo, - layout: {AlgoraWeb.Layouts, :user}, - on_mount: [{AlgoraWeb.UserAuth, :current_user}, AlgoraWeb.Org.RepoNav] do - live "/issues/:number", BountyLive - live "/pull/:number", BountyLive - end - end - - scope "/org/:org_handle" do - live_session :org, - layout: {AlgoraWeb.Layouts, :user}, - on_mount: [{AlgoraWeb.UserAuth, :current_user}, AlgoraWeb.Org.Nav] do - live "/", Org.DashboardLive, :index - live "/home", Org.HomeLive, :index - live "/bounties", Org.BountiesLive, :index - live "/bounties/new", Org.BountiesNewLive, :index - live "/bounties/community", Org.BountiesNewLive, :index - live "/bounties/:id", BountyLive, :index - live "/contracts/:id", Contract.ViewLive - live "/team", Org.TeamLive, :index - live "/leaderboard", Org.LeaderboardLive, :index - end - - live_session :org_admin, - layout: {AlgoraWeb.Layouts, :user}, - on_mount: [ - {AlgoraWeb.UserAuth, :ensure_authenticated}, - {AlgoraWeb.UserAuth, :current_user}, - AlgoraWeb.Org.Nav, - {AlgoraWeb.OrgAuth, :ensure_admin} - ] do - live "/settings", Org.SettingsLive, :edit - live "/transactions", Org.TransactionsLive, :index - end - end - live_session :authenticated, layout: {AlgoraWeb.Layouts, :user}, on_mount: [{AlgoraWeb.UserAuth, :ensure_authenticated}, AlgoraWeb.User.Nav] do @@ -138,6 +100,7 @@ defmodule AlgoraWeb.Router do live_session :public, layout: {AlgoraWeb.Layouts, :user}, on_mount: [{AlgoraWeb.UserAuth, :current_user}, AlgoraWeb.User.Nav] do + live "/", HomeLive live "/bounties", BountiesLive, :index live "/bounties/:tech", BountiesLive, :index live "/community", CommunityLive, :index @@ -177,12 +140,48 @@ defmodule AlgoraWeb.Router do live "/auth/signup", SignInLive, :signup end + scope "/:repo_owner/:repo_name" do + live_session :repo, + layout: {AlgoraWeb.Layouts, :user}, + on_mount: [{AlgoraWeb.UserAuth, :current_user}, AlgoraWeb.Org.RepoNav] do + live "/issues/:number", BountyLive + live "/pull/:number", BountyLive + end + end + + scope "/:org_handle" do + live_session :org, + layout: {AlgoraWeb.Layouts, :user}, + on_mount: [{AlgoraWeb.UserAuth, :current_user}, AlgoraWeb.Org.Nav] do + live "/dashboard", Org.DashboardLive, :index + live "/home", Org.HomeLive, :index + live "/bounties", Org.BountiesLive, :index + live "/bounties/new", Org.BountiesNewLive, :index + live "/bounties/community", Org.BountiesNewLive, :index + live "/bounties/:id", BountyLive, :index + live "/contracts/:id", Contract.ViewLive + live "/team", Org.TeamLive, :index + live "/leaderboard", Org.LeaderboardLive, :index + end + + live_session :org_admin, + layout: {AlgoraWeb.Layouts, :user}, + on_mount: [ + {AlgoraWeb.UserAuth, :ensure_authenticated}, + {AlgoraWeb.UserAuth, :current_user}, + AlgoraWeb.Org.Nav, + {AlgoraWeb.OrgAuth, :ensure_admin} + ] do + live "/settings", Org.SettingsLive, :edit + live "/transactions", Org.TransactionsLive, :index + end + end + live "/0/bounties/:id", OG.BountyLive, :show get "/og/*path", OGImageController, :generate - live_session :wildcard, - on_mount: [{AlgoraWeb.UserAuth, :current_user}] do - live "/:country_code", HomeLive, :index + scope "/:handle" do + get "/", UserController, :index end end diff --git a/priv/repo/seeds.exs b/priv/repo/seeds.exs index 89dbfadd4..f7143077c 100644 --- a/priv/repo/seeds.exs +++ b/priv/repo/seeds.exs @@ -296,7 +296,7 @@ for {sender, content, inserted_at} <- messages do ) end -Logger.info("Contract: #{AlgoraWeb.Endpoint.url()}/org/#{pied_piper.handle}/contracts/#{initial_contract.id}") +Logger.info("Contract: #{AlgoraWeb.Endpoint.url()}/#{pied_piper.handle}/contracts/#{initial_contract.id}") big_head = upsert!( @@ -632,4 +632,4 @@ for {reviewer, reviewee, rating_delta, content} <- reviews do ) end -IO.puts("Contract: #{AlgoraWeb.Endpoint.url()}/org/#{pied_piper.handle}/contracts/#{initial_contract.id}") +IO.puts("Contract: #{AlgoraWeb.Endpoint.url()}/#{pied_piper.handle}/contracts/#{initial_contract.id}") diff --git a/test/algora_web/live/org_auth_test.exs b/test/algora_web/live/org_auth_test.exs index 0ae0f34a2..860a552bb 100644 --- a/test/algora_web/live/org_auth_test.exs +++ b/test/algora_web/live/org_auth_test.exs @@ -19,7 +19,7 @@ defmodule AlgoraWeb.Org.SettingsLiveTest do # Helper function to test auth requirements for org routes defp assert_org_route_auth(conn, org, path, allowed_roles) do - test_path = "/org/#{org.handle}#{path}" + test_path = "/#{org.handle}#{path}" # Test unauthorized access assert {:error, {:redirect, %{to: to}}} = live(conn, test_path) @@ -29,7 +29,7 @@ defmodule AlgoraWeb.Org.SettingsLiveTest do user = insert!(:user) conn_with_user = AlgoraWeb.UserAuth.put_current_user(conn, user) assert {:error, {:redirect, %{to: to}}} = live(conn_with_user, test_path) - assert to == "/org/#{org.handle}" + assert to == "/#{org.handle}" # # Test access for each role member = insert!(:member, user: user, org: org) @@ -41,7 +41,7 @@ defmodule AlgoraWeb.Org.SettingsLiveTest do assert {:ok, _view, _html} = live(conn_with_user, test_path) else assert {:error, {:redirect, %{to: to}}} = live(conn_with_user, test_path) - assert to == "/org/#{org.handle}" + assert to == "/#{org.handle}" end end end From 3424defd6e7dff0b4feb88bf18eaa4f3f55e9d22 Mon Sep 17 00:00:00 2001 From: zafer Date: Tue, 8 Apr 2025 16:11:16 +0300 Subject: [PATCH 2/3] remove @ prefix in user profile path --- config/config.exs | 3 ++- lib/algora/accounts/schemas/user.ex | 2 -- lib/algora/activities/router.ex | 4 +--- lib/algora/bot_templates/bot_templates.ex | 2 +- lib/algora_web/controllers/user_controller.ex | 23 ++++++++++++++++--- lib/algora_web/live/user/dashboard_live.ex | 4 ++-- lib/algora_web/live/user/nav.ex | 9 ++++++-- lib/algora_web/live/user/profile_live.ex | 2 +- lib/algora_web/router.ex | 9 +++++++- test/algora/bounties_test.exs | 6 ++--- 10 files changed, 45 insertions(+), 19 deletions(-) diff --git a/config/config.exs b/config/config.exs index 9a58c4c39..a0ca8ddad 100644 --- a/config/config.exs +++ b/config/config.exs @@ -21,7 +21,8 @@ config :algora, {"/create/org", "/onboarding/org"}, {"/solve", "/onboarding/dev"}, {"/onboarding/solver", "/onboarding/dev"}, - {"/org/*path", "/*path"} + {"/org/*path", "/*path"}, + {"/@/:handle", "/:handle/profile"} ] # Configures the endpoint diff --git a/lib/algora/accounts/schemas/user.ex b/lib/algora/accounts/schemas/user.ex index 77565233d..f72ed36fd 100644 --- a/lib/algora/accounts/schemas/user.ex +++ b/lib/algora/accounts/schemas/user.ex @@ -348,8 +348,6 @@ defmodule Algora.Accounts.User do def handle(%{handle: handle}) when is_binary(handle), do: handle def handle(%{provider_login: handle}), do: handle - def url(%{handle: handle, type: :individual}) when is_binary(handle), do: "#{Endpoint.url()}/@/#{handle}" - def url(%{handle: handle, type: :organization}) when is_binary(handle), do: "#{Endpoint.url()}/#{handle}" def url(%{handle: handle}) when is_binary(handle), do: "#{Endpoint.url()}/#{handle}" def url(%{provider_login: handle}), do: "https://github.com/#{handle}" end diff --git a/lib/algora/activities/router.ex b/lib/algora/activities/router.ex index 7a3dfcc1a..351ad778c 100644 --- a/lib/algora/activities/router.ex +++ b/lib/algora/activities/router.ex @@ -4,9 +4,7 @@ defmodule Algora.Activities.Router do def route(%{assoc: %Bounty{owner: user}}), do: {:ok, "/#{user.handle}/bounties"} - def route(%{assoc: %Identity{user: %{type: :individual} = user}}), do: {:ok, "/@/#{user.handle}"} - - def route(%{assoc: %Identity{user: %{type: :organization} = user}}), do: {:ok, "/#{user.handle}"} + def route(%{assoc: %Identity{user: user}}), do: {:ok, "/#{user.handle}"} def route(_activity) do {:error, :not_found} diff --git a/lib/algora/bot_templates/bot_templates.ex b/lib/algora/bot_templates/bot_templates.ex index a6b459961..bbd891d6c 100644 --- a/lib/algora/bot_templates/bot_templates.ex +++ b/lib/algora/bot_templates/bot_templates.ex @@ -21,7 +21,7 @@ defmodule Algora.BotTemplates do def placeholders(:bounty_created, user) do %{ - "PRIZE_POOL" => "## 💎 $1,000 bounty [• #{user.name}](#{AlgoraWeb.Endpoint.url()}/@/#{user.handle})", + "PRIZE_POOL" => "## 💎 $1,000 bounty [• #{user.name}](#{AlgoraWeb.Endpoint.url()}/#{user.handle})", "ISSUE_NUMBER" => "100", "REPO_FULL_NAME" => "#{user.provider_login || user.handle}/repo", "ATTEMPTS" => """ diff --git a/lib/algora_web/controllers/user_controller.ex b/lib/algora_web/controllers/user_controller.ex index 5e5ce6f31..6506cbfd6 100644 --- a/lib/algora_web/controllers/user_controller.ex +++ b/lib/algora_web/controllers/user_controller.ex @@ -1,8 +1,25 @@ defmodule AlgoraWeb.UserController do use AlgoraWeb, :controller - def index(conn, params) do - dbg(params) - redirect(conn, to: "/#{params["handle"]}/dashboard") + alias Algora.Accounts.User + alias Algora.Repo + + def index(conn, %{"handle" => handle}) do + user = Repo.get_by(User, handle: handle) + + case user do + nil -> + # TODO: redirect to go page + raise AlgoraWeb.NotFoundError + + %{type: :individual} -> + redirect(conn, to: "/#{handle}/profile") + + %{type: :organization} -> + redirect(conn, to: "/#{handle}/dashboard") + + _ -> + raise AlgoraWeb.NotFoundError + end end end diff --git a/lib/algora_web/live/user/dashboard_live.ex b/lib/algora_web/live/user/dashboard_live.ex index 2ecda4b30..6f28e3fe9 100644 --- a/lib/algora_web/live/user/dashboard_live.ex +++ b/lib/algora_web/live/user/dashboard_live.ex @@ -269,7 +269,7 @@ defmodule AlgoraWeb.User.DashboardLive do <.badge id="og-url" phx-hook="CopyToClipboard" - data-value={url(~p"/@/#{@current_user.handle}")} + data-value={url(~p"/#{@current_user.handle}")} phx-click={ %JS{} |> JS.hide( @@ -294,7 +294,7 @@ defmodule AlgoraWeb.User.DashboardLive do name="tabler-check" class="absolute left-1 my-auto hidden size-4 mr-2" /> - {AlgoraWeb.Endpoint.host()}{~p"/@/#{@current_user.handle}"} + {AlgoraWeb.Endpoint.host()}{~p"/#{@current_user.handle}"} handle}, _session, socket) do + def mount(%{"user_handle" => handle}, _session, socket) do case Accounts.fetch_developer_by(handle: handle) do {:ok, user} -> transactions = Payments.list_received_transactions(user.id, limit: page_size()) diff --git a/lib/algora_web/router.ex b/lib/algora_web/router.ex index 7b7d24f0c..10ee71fab 100644 --- a/lib/algora_web/router.ex +++ b/lib/algora_web/router.ex @@ -106,7 +106,6 @@ defmodule AlgoraWeb.Router do live "/community", CommunityLive, :index live "/leaderboard", LeaderboardLive, :index live "/projects", OrgsLive, :index - live "/@/:handle", User.ProfileLive, :index live "/claims/:group_id", ClaimLive live "/payment/success", Payment.SuccessLive, :index live "/payment/canceled", Payment.CanceledLive, :index @@ -149,6 +148,14 @@ defmodule AlgoraWeb.Router do end end + scope "/:user_handle" do + live_session :user, + layout: {AlgoraWeb.Layouts, :user}, + on_mount: [{AlgoraWeb.UserAuth, :current_user}, AlgoraWeb.User.Nav] do + live "/profile", User.ProfileLive, :index + end + end + scope "/:org_handle" do live_session :org, layout: {AlgoraWeb.Layouts, :user}, diff --git a/test/algora/bounties_test.exs b/test/algora/bounties_test.exs index 9a44bc9af..08f2435a5 100644 --- a/test/algora/bounties_test.exs +++ b/test/algora/bounties_test.exs @@ -318,7 +318,7 @@ defmodule Algora.BountiesTest do response = Algora.Bounties.get_response_body(bounties, ticket_ref, [], []) expected_response = """ - ## 💎 $1,000 bounty [• Bounty Owner](http://localhost:4002/@/bounty_owner) + ## 💎 $1,000 bounty [• Bounty Owner](http://localhost:4002/bounty_owner) ### Steps to solve: 1. **Start working**: Comment `/attempt #100` with your implementation plan @@ -425,7 +425,7 @@ defmodule Algora.BountiesTest do response = Algora.Bounties.get_response_body(bounties, ticket_ref, attempts, claims) expected_response = """ - ## 💎 $1,000 bounty [• Bounty Owner](http://localhost:4002/@/bounty_owner) + ## 💎 $1,000 bounty [• Bounty Owner](http://localhost:4002/bounty_owner) ### Steps to solve: 1. **Start working**: Comment `/attempt #100` with your implementation plan 2. **Submit work**: Create a pull request including `/claim #100` in the PR body to claim the bounty @@ -479,7 +479,7 @@ defmodule Algora.BountiesTest do response = Algora.Bounties.get_response_body(bounties, ticket_ref, [], []) expected_response = """ - ## 💎 $1,000 bounty [• Bounty Owner](http://localhost:4002/@/bounty_owner) + ## 💎 $1,000 bounty [• Bounty Owner](http://localhost:4002/bounty_owner) ### Steps to solve: 1. **Start working**: Comment `/attempt #100` with your implementation plan 2. **Submit work**: Create a pull request including `/claim #100` in the PR body to claim the bounty From dc0ca4126a28cac89f82df45879dea5c3d10056a Mon Sep 17 00:00:00 2001 From: zafer Date: Tue, 8 Apr 2025 16:17:52 +0300 Subject: [PATCH 3/3] update path --- lib/algora_web/live/org/nav.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/algora_web/live/org/nav.ex b/lib/algora_web/live/org/nav.ex index ab676c826..a9f875a58 100644 --- a/lib/algora_web/live/org/nav.ex +++ b/lib/algora_web/live/org/nav.ex @@ -146,7 +146,7 @@ defmodule AlgoraWeb.Org.Nav do Enum.filter( [ %{ - href: "/#{org_handle}", + href: "/#{org_handle}/dashboard", tab: :dashboard, icon: "tabler-sparkles", label: "Dashboard",