devel #84
15 changed files with 172 additions and 102 deletions
|
@ -61,8 +61,7 @@ config :waffle,
|
|||
storage_dir_prefix: "priv/waffle/public"
|
||||
|
||||
# Configure Timezones with :tz
|
||||
config :elixir,
|
||||
:time_zone_database, Tz.TimeZoneDatabase
|
||||
config :elixir, :time_zone_database, Tz.TimeZoneDatabase
|
||||
|
||||
# Import environment specific config. This must remain at the bottom
|
||||
# of this file so it overrides the configuration defined above.
|
||||
|
|
|
@ -8,12 +8,16 @@ defmodule Chiya.Channels.Channel do
|
|||
field :content, :string
|
||||
field :name, :string
|
||||
field :slug, ChannelSlug.Type
|
||||
field :visibility, Ecto.Enum, values: [
|
||||
|
||||
field :visibility, Ecto.Enum,
|
||||
values: [
|
||||
:public,
|
||||
:private,
|
||||
:unlisted
|
||||
]
|
||||
field :layout, Ecto.Enum, values: [
|
||||
|
||||
field :layout, Ecto.Enum,
|
||||
values: [
|
||||
:default,
|
||||
:microblog,
|
||||
:gallery
|
||||
|
|
|
@ -333,7 +333,8 @@ defmodule ChiyaWeb.CoreComponents do
|
|||
attr :multiple, :boolean, default: false, doc: "the multiple flag for select inputs"
|
||||
|
||||
attr :rest, :global,
|
||||
include: ~w(autocomplete accept cols disabled form max maxlength min minlength pattern placeholder readonly required rows size step)
|
||||
include:
|
||||
~w(autocomplete accept cols disabled form max maxlength min minlength pattern placeholder readonly required rows size step)
|
||||
|
||||
slot :inner_block
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
|
||||
<.favicon />
|
||||
|
||||
<link rel="preconnect" href="https://rsms.me/">
|
||||
<link rel="stylesheet" href="https://rsms.me/inter/inter.css">
|
||||
<link rel="preconnect" href="https://rsms.me/" />
|
||||
<link rel="stylesheet" href="https://rsms.me/inter/inter.css" />
|
||||
<link phx-track-static rel="stylesheet" href={~p"/assets/app.css"} />
|
||||
<script defer phx-track-static type="text/javascript" src={~p"/assets/app.js"}>
|
||||
</script>
|
||||
|
|
|
@ -10,8 +10,12 @@
|
|||
|
||||
<.favicon />
|
||||
|
||||
<link rel="preconnect" href="https://rsms.me/">
|
||||
<link rel="stylesheet" href="https://rsms.me/inter/inter.css">
|
||||
<%= for identity <- @identities do %>
|
||||
<link rel="me" href={identity.url} />
|
||||
<% end %>
|
||||
|
||||
<link rel="preconnect" href="https://rsms.me/" />
|
||||
<link rel="stylesheet" href="https://rsms.me/inter/inter.css" />
|
||||
<link phx-track-static rel="stylesheet" href={~p"/assets/app.css"} />
|
||||
<script defer phx-track-static type="text/javascript" src={~p"/assets/public.js"}>
|
||||
</script>
|
||||
|
@ -31,7 +35,12 @@
|
|||
<nav>
|
||||
<ul class="flex gap-3">
|
||||
<li>
|
||||
<a href="/" class="text-theme-base px-3 py-2.5 border border-theme-background1 hover:bg-theme-background1 rounded transition font-semibold"><.icon name="hero-home" /> Home</a>
|
||||
<a
|
||||
href="/"
|
||||
class="text-theme-base px-3 py-2.5 border border-theme-background1 hover:bg-theme-background1 rounded transition font-semibold"
|
||||
>
|
||||
<.icon name="hero-home" /> Home
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
@ -51,7 +60,7 @@
|
|||
</p>
|
||||
|
||||
<p>
|
||||
<%= for identity <- @identities do %>
|
||||
<%= for identity <- @public_identities do %>
|
||||
<span><a href={identity.url}><%= identity.name %></a></span>
|
||||
<.dot />
|
||||
<% end %>
|
||||
|
|
|
@ -14,20 +14,19 @@ defmodule ChiyaWeb.PublicComponents do
|
|||
@doc """
|
||||
Renders a middot as divider
|
||||
"""
|
||||
def dot(assigns), do:
|
||||
~H"""
|
||||
def dot(assigns),
|
||||
do: ~H"""
|
||||
<span class="text-theme-primary font-bold">·</span>
|
||||
"""
|
||||
|
||||
@doc """
|
||||
Renders a horizontal line
|
||||
"""
|
||||
def line(assigns), do:
|
||||
~H"""
|
||||
def line(assigns),
|
||||
do: ~H"""
|
||||
<hr class="my-6 border-theme-base/20" />
|
||||
"""
|
||||
|
||||
|
||||
@doc """
|
||||
Renders a note-header with title.
|
||||
"""
|
||||
|
@ -107,7 +106,7 @@ defmodule ChiyaWeb.PublicComponents do
|
|||
<%= for note <- assigns.notes do %>
|
||||
<article class="mt-8 first:mt-0">
|
||||
<div class="prose prose-gruvbox">
|
||||
<%= raw render(note.content) %>
|
||||
<%= raw(render(note.content)) %>
|
||||
</div>
|
||||
<footer class="mt-1">
|
||||
<time class="text-theme-base/75">
|
||||
|
@ -125,7 +124,8 @@ defmodule ChiyaWeb.PublicComponents do
|
|||
</section>
|
||||
"""
|
||||
|
||||
_ -> # default, show headings only
|
||||
# default, show headings only
|
||||
_ ->
|
||||
~H"""
|
||||
<section class="note-list default | mt-6 sm:w-auto flex flex-col gap-1.5">
|
||||
<%= for note <- assigns.notes do %>
|
||||
|
|
|
@ -10,13 +10,19 @@
|
|||
<section class="mx-auto max-w-xl mt-8 text-sm">
|
||||
<ul class="flex flex-wrap gap-3">
|
||||
<li>
|
||||
<a href="#" class="inline-block text-theme-base px-3 py-2.5 hover:bg-theme-background1 rounded transition font-semibold">
|
||||
<a
|
||||
href="#"
|
||||
class="inline-block text-theme-base px-3 py-2.5 hover:bg-theme-background1 rounded transition font-semibold"
|
||||
>
|
||||
<.icon name="hero-megaphone" />
|
||||
</a>
|
||||
</li>
|
||||
<%= for channel <- @channels do %>
|
||||
<li>
|
||||
<a href={~p"/c/#{channel.slug}"} class="inline-block text-theme-base px-3 py-2.5 border border-theme-background1 hover:bg-theme-background1 rounded transition font-semibold">
|
||||
<a
|
||||
href={~p"/c/#{channel.slug}"}
|
||||
class="inline-block text-theme-base px-3 py-2.5 border border-theme-background1 hover:bg-theme-background1 rounded transition font-semibold"
|
||||
>
|
||||
<%= channel.name %>
|
||||
</a>
|
||||
</li>
|
||||
|
@ -25,9 +31,7 @@
|
|||
</section>
|
||||
|
||||
<%= if @channel do %>
|
||||
<section class="mx-auto max-w-xl mt-8 border-t border-theme-background1">
|
||||
<section class="mx-auto max-w-xl mt-8 border-t border-theme-background1">
|
||||
<.note_list notes={@channel.notes} layout={@channel.layout} />
|
||||
</section>
|
||||
</section>
|
||||
<% end %>
|
||||
|
||||
|
||||
|
|
|
@ -80,12 +80,28 @@
|
|||
|
||||
<.line />
|
||||
|
||||
<.simple_form :let={f} for={@changeset} action={~p"/#{@note.slug}/comment"} class="bg-theme-background -m-3">
|
||||
<.simple_form
|
||||
:let={f}
|
||||
for={@changeset}
|
||||
action={~p"/#{@note.slug}/comment"}
|
||||
class="bg-theme-background -m-3"
|
||||
>
|
||||
<.error :if={@changeset.action}>
|
||||
Oops, something went wrong! Please check the errors below.
|
||||
</.error>
|
||||
<.input field={f[:author_name]} type="text" placeholder="Name" class="bg-theme-background dark:bg-theme-background border-theme-base/20 dark:border-theme-base/20 text-theme-base dark:text-theme-base placeholder-theme-base/40 dark:placeholder-theme-base/60 dark:focus:border-theme-base/60 dark:focus:border-theme-base/60" />
|
||||
<.input field={f[:content]} type="textarea" placeholder="Content" rows="3" class="bg-theme-background dark:bg-theme-background border-theme-base/20 dark:border-theme-base/20 text-theme-base dark:text-theme-base placeholder-theme-base/60 dark:placeholder-theme-base/60 focus:border-theme-base/60 dark:focus:border-theme-base/60" />
|
||||
<.input
|
||||
field={f[:author_name]}
|
||||
type="text"
|
||||
placeholder="Name"
|
||||
class="bg-theme-background dark:bg-theme-background border-theme-base/20 dark:border-theme-base/20 text-theme-base dark:text-theme-base placeholder-theme-base/40 dark:placeholder-theme-base/60 dark:focus:border-theme-base/60 dark:focus:border-theme-base/60"
|
||||
/>
|
||||
<.input
|
||||
field={f[:content]}
|
||||
type="textarea"
|
||||
placeholder="Content"
|
||||
rows="3"
|
||||
class="bg-theme-background dark:bg-theme-background border-theme-base/20 dark:border-theme-base/20 text-theme-base dark:text-theme-base placeholder-theme-base/60 dark:placeholder-theme-base/60 focus:border-theme-base/60 dark:focus:border-theme-base/60"
|
||||
/>
|
||||
<.input field={f[:note_id]} type="hidden" />
|
||||
<:actions>
|
||||
<.button>Submit Comment</.button>
|
||||
|
|
|
@ -10,8 +10,14 @@ defmodule ChiyaWeb.GlobalAssigns do
|
|||
identities = Chiya.Identities.list_identities()
|
||||
|
||||
conn
|
||||
|> assign(:identities, identities)
|
||||
|> assign(:public_identities, Enum.filter(identities, fn i -> i.public && i.active end))
|
||||
|> assign(
|
||||
:identities,
|
||||
Enum.filter(identities, fn i -> i.active end)
|
||||
)
|
||||
|> assign(
|
||||
:public_identities,
|
||||
Enum.filter(identities, fn i -> i.public && i.active end)
|
||||
)
|
||||
end
|
||||
|
||||
def fetch_public_channels(conn, _opts) do
|
||||
|
|
15
lib/chiya_web/indie/micropub_handler.ex
Normal file
15
lib/chiya_web/indie/micropub_handler.ex
Normal file
|
@ -0,0 +1,15 @@
|
|||
defmodule ChiyaWeb.Indie.MicropubHandler do
|
||||
@impl true
|
||||
def handle_create(type, properties, access_token) do
|
||||
properties = handle_uploads(properties)
|
||||
params = %{type: type, properties: properties}
|
||||
# Chiya.Notes.create_note
|
||||
id = 0
|
||||
{:ok, :created, ""}
|
||||
end
|
||||
|
||||
def handle_create(_, _, _), do: {:error, :insufficient_scope}
|
||||
|
||||
defp handle_uploads(props) do
|
||||
end
|
||||
end
|
|
@ -27,7 +27,7 @@ defmodule ChiyaWeb.NoteShowLive do
|
|||
<.button>Publish</.button>
|
||||
</.link>
|
||||
<% else %>
|
||||
<.link href={~p"/admin/notes/#{@note}/unpublish"}>
|
||||
<.link href={~p"/amdin/notes/#{@note}/unpublish"}>
|
||||
<.button>Un-Publish</.button>
|
||||
</.link>
|
||||
<% end %>
|
||||
|
@ -44,7 +44,9 @@ defmodule ChiyaWeb.NoteShowLive do
|
|||
<:item title="Tags"><%= note_tags(@note.tags) %></:item>
|
||||
<:item title="Links outgoing"><%= note_links(@note.links_from) %></:item>
|
||||
<:item title="Links incoming"><%= note_links(@note.links_to) %></:item>
|
||||
<:item title="Embed"><pre class="p-1 bg-gray-100 text-black rounded select-all">[[<%= @note.slug %>]]</pre></:item>
|
||||
<:item title="Embed">
|
||||
<pre class="p-1 bg-gray-100 text-black rounded select-all">[[<%= @note.slug %>]]</pre>
|
||||
</:item>
|
||||
</.list>
|
||||
|
||||
<.line />
|
||||
|
|
|
@ -25,6 +25,10 @@ defmodule ChiyaWeb.Router do
|
|||
plug :accepts, ["json"]
|
||||
end
|
||||
|
||||
pipeline :indie do
|
||||
plug :accepts, ["json", "html"]
|
||||
end
|
||||
|
||||
# Other scopes may use custom stacks.
|
||||
scope "/api", ChiyaWeb do
|
||||
pipe_through :api
|
||||
|
@ -113,6 +117,14 @@ defmodule ChiyaWeb.Router do
|
|||
end
|
||||
end
|
||||
|
||||
## Indie routes
|
||||
scope "/indie", ChiyaWeb.Indie do
|
||||
forward "/micropub",
|
||||
PlugMicropub,
|
||||
handler: MicropubHandler,
|
||||
json_encoder: Jason
|
||||
end
|
||||
|
||||
## Public routes
|
||||
|
||||
scope "/", ChiyaWeb do
|
||||
|
|
3
mix.exs
3
mix.exs
|
@ -56,7 +56,8 @@ defmodule Chiya.MixProject do
|
|||
{:waffle_ecto, "~> 0.0.12"},
|
||||
{:earmark, "~> 1.4"},
|
||||
{:yaml_front_matter, "~> 1.0.0"},
|
||||
{:tz, "~> 0.26.1"}
|
||||
{:tz, "~> 0.26.1"},
|
||||
{:plug_micropub, git: "https://git.inhji.de/inhji/plug_micropub"}
|
||||
]
|
||||
end
|
||||
|
||||
|
|
1
mix.lock
1
mix.lock
|
@ -44,6 +44,7 @@
|
|||
"plug": {:hex, :plug, "1.14.0", "ba4f558468f69cbd9f6b356d25443d0b796fbdc887e03fa89001384a9cac638f", [:mix], [{:mime, "~> 1.0 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:plug_crypto, "~> 1.1.1 or ~> 1.2", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "bf020432c7d4feb7b3af16a0c2701455cbbbb95e5b6866132cb09eb0c29adc14"},
|
||||
"plug_cowboy": {:hex, :plug_cowboy, "2.6.0", "d1cf12ff96a1ca4f52207c5271a6c351a4733f413803488d75b70ccf44aebec2", [:mix], [{:cowboy, "~> 2.7", [hex: :cowboy, repo: "hexpm", optional: false]}, {:cowboy_telemetry, "~> 0.3", [hex: :cowboy_telemetry, repo: "hexpm", optional: false]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}], "hexpm", "073cf20b753ce6682ed72905cd62a2d4bd9bad1bf9f7feb02a1b8e525bd94fa6"},
|
||||
"plug_crypto": {:hex, :plug_crypto, "1.2.3", "8f77d13aeb32bfd9e654cb68f0af517b371fb34c56c9f2b58fe3df1235c1251a", [:mix], [], "hexpm", "b5672099c6ad5c202c45f5a403f21a3411247f164e4a8fab056e5cd8a290f4a2"},
|
||||
"plug_micropub": {:git, "https://git.inhji.de/inhji/plug_micropub", "c6976ac9510035a78a6b1d1fa2e469cb94aa3248", []},
|
||||
"postgrex": {:hex, :postgrex, "0.16.5", "fcc4035cc90e23933c5d69a9cd686e329469446ef7abba2cf70f08e2c4b69810", [:mix], [{:connection, "~> 1.1", [hex: :connection, repo: "hexpm", optional: false]}, {:db_connection, "~> 2.1", [hex: :db_connection, repo: "hexpm", optional: false]}, {:decimal, "~> 1.5 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: false]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:table, "~> 0.1.0", [hex: :table, repo: "hexpm", optional: true]}], "hexpm", "edead639dc6e882618c01d8fc891214c481ab9a3788dfe38dd5e37fd1d5fb2e8"},
|
||||
"ranch": {:hex, :ranch, "1.8.0", "8c7a100a139fd57f17327b6413e4167ac559fbc04ca7448e9be9057311597a1d", [:make, :rebar3], [], "hexpm", "49fbcfd3682fab1f5d109351b61257676da1a2fdbe295904176d5e521a2ddfe5"},
|
||||
"slugger": {:hex, :slugger, "0.3.0", "efc667ab99eee19a48913ccf3d038b1fb9f165fa4fbf093be898b8099e61b6ed", [:mix], [], "hexpm", "20d0ded0e712605d1eae6c5b4889581c3460d92623a930ddda91e0e609b5afba"},
|
||||
|
|
Loading…
Reference in a new issue