From 0f4f4940d051659faf9dc77777aa4c21f9d0cbc9 Mon Sep 17 00:00:00 2001 From: Inhji Date: Thu, 6 Jul 2023 21:28:49 +0200 Subject: [PATCH] add proper hcard to homepage --- lib/chiya/accounts.ex | 2 ++ lib/chiya_web/components/layouts/root_public.html.heex | 8 ++++++-- lib/chiya_web/global_assigns.ex | 10 ++++++++++ lib/chiya_web/router.ex | 1 + 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/chiya/accounts.ex b/lib/chiya/accounts.ex index 40c0dd9..8bc9ab4 100644 --- a/lib/chiya/accounts.ex +++ b/lib/chiya/accounts.ex @@ -68,6 +68,8 @@ defmodule Chiya.Accounts do """ def get_user!(id), do: Repo.get!(User, id) + def get_user(id), do: Repo.get(User, id) + ## User registration @doc """ diff --git a/lib/chiya_web/components/layouts/root_public.html.heex b/lib/chiya_web/components/layouts/root_public.html.heex index 4226b62..952ffe9 100644 --- a/lib/chiya_web/components/layouts/root_public.html.heex +++ b/lib/chiya_web/components/layouts/root_public.html.heex @@ -110,10 +110,14 @@

Struggling to make a decent website since 2011

- - + +
diff --git a/lib/chiya_web/global_assigns.ex b/lib/chiya_web/global_assigns.ex index c2cbc17..a17330d 100644 --- a/lib/chiya_web/global_assigns.ex +++ b/lib/chiya_web/global_assigns.ex @@ -4,6 +4,16 @@ defmodule ChiyaWeb.GlobalAssigns do @token_endpoint Application.compile_env!(:chiya, [:indie, :token_endpoint]) @auth_endpoint Application.compile_env!(:chiya, [:indie, :auth_endpoint]) + def fetch_profile(conn, _opts) do + user = Chiya.Accounts.get_user(1) + + if user do + assign(conn, :profile, user) + else + conn + end + end + def fetch_settings(conn, _opts) do settings = Chiya.Site.get_settings() diff --git a/lib/chiya_web/router.ex b/lib/chiya_web/router.ex index 0d98e6f..c9aa5d8 100644 --- a/lib/chiya_web/router.ex +++ b/lib/chiya_web/router.ex @@ -19,6 +19,7 @@ defmodule ChiyaWeb.Router do plug :put_root_layout, {ChiyaWeb.Layouts, :root_public} plug :fetch_identities plug :fetch_public_channels + plug :fetch_profile end pipeline :api do