Add UserController
This commit is contained in:
parent
f61444cffa
commit
178c2bf72e
5 changed files with 81 additions and 2 deletions
64
lib/nulla_web/controllers/user_controller.ex
Normal file
64
lib/nulla_web/controllers/user_controller.ex
Normal file
|
@ -0,0 +1,64 @@
|
|||
defmodule NullaWeb.UserController do
|
||||
use NullaWeb, :controller
|
||||
|
||||
def show(conn, %{"username" => username}) do
|
||||
accept = get_req_header(conn, "accept") |> List.first() || ""
|
||||
|
||||
if String.contains?(accept, "application/activity+json") or String.contains?(accept, "application/ld+json") do
|
||||
conn
|
||||
|> put_resp_content_type("application/activity+json")
|
||||
|> json(%{
|
||||
id: "https://localhost/@#{username}",
|
||||
type: "Person",
|
||||
following: "https://localhost/@#{username}/following",
|
||||
followers: "https://localhost/@#{username}/followers",
|
||||
inbox: "https://localhost/@#{username}/inbox",
|
||||
outbox: "https://localhost/@#{username}/outbox",
|
||||
featured: "https://localhost/@#{username}/collections/featured",
|
||||
preferredUsername: "miraikumiko",
|
||||
name: "Mirai Kumiko",
|
||||
summary: "Lol Kek Cheburek",
|
||||
url: "https://localhost/@#{username}",
|
||||
manuallyApprovesFollowers: false,
|
||||
discoverable: true,
|
||||
indexable: true,
|
||||
published: "2025-05-05T00:00:00Z",
|
||||
memorial: false,
|
||||
publicKey: %{
|
||||
id: "https://localhost/@#{username}#main-key",
|
||||
owner: "https://localhost/@#{username}",
|
||||
publicKeyPem: "public key"
|
||||
},
|
||||
tag: [
|
||||
%{
|
||||
type: "Hashtag",
|
||||
href: "https://localhost/tags/linux",
|
||||
name: "#linux"
|
||||
}
|
||||
],
|
||||
attachment: [
|
||||
%{
|
||||
type: "PropertyValue",
|
||||
name: "Website",
|
||||
value: "<a href=\"https://miraikumiko.com/\" rel=\"me nofollow noopener\" target=\"_blank\">https://miraikumiko.com</a>"
|
||||
}
|
||||
],
|
||||
endpoints: %{
|
||||
sharedInbox: "https://localhost/inbox"
|
||||
},
|
||||
icon: %{
|
||||
type: "Image",
|
||||
mediaType: "image/jpeg",
|
||||
url: "url"
|
||||
},
|
||||
image: %{
|
||||
type: "Image",
|
||||
mediaType: "image/jpeg",
|
||||
url: "url"
|
||||
}
|
||||
})
|
||||
else
|
||||
render(conn, :show, username: username, layout: false)
|
||||
end
|
||||
end
|
||||
end
|
10
lib/nulla_web/controllers/user_html.ex
Normal file
10
lib/nulla_web/controllers/user_html.ex
Normal file
|
@ -0,0 +1,10 @@
|
|||
defmodule NullaWeb.UserHTML do
|
||||
@moduledoc """
|
||||
This module contains pages rendered by UserController.
|
||||
|
||||
See the `user_html` directory for all templates available.
|
||||
"""
|
||||
use NullaWeb, :html
|
||||
|
||||
embed_templates "user_html/*"
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue