From 6c3073a637cc84e7b41a661c5efd4ca0629e5ebc Mon Sep 17 00:00:00 2001 From: Inhji Date: Sun, 11 Jun 2023 20:39:14 +0200 Subject: [PATCH] add micropub channel setting --- lib/chiya/site/setting.ex | 1 + .../controllers/setting_html/setting_form.html.heex | 12 +++++++++++- ...11183608_add_default_micropub_channel_setting.exs | 9 +++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 priv/repo/migrations/20230611183608_add_default_micropub_channel_setting.exs diff --git a/lib/chiya/site/setting.ex b/lib/chiya/site/setting.ex index f90a108..7ae485b 100644 --- a/lib/chiya/site/setting.ex +++ b/lib/chiya/site/setting.ex @@ -15,6 +15,7 @@ defmodule Chiya.Site.Setting do belongs_to :home_channel, Chiya.Channels.Channel belongs_to :default_channel, Chiya.Channels.Channel + belongs_to :micropub_channel, Chiya.Channels.Channel timestamps() end diff --git a/lib/chiya_web/controllers/setting_html/setting_form.html.heex b/lib/chiya_web/controllers/setting_html/setting_form.html.heex index 7256399..f442084 100644 --- a/lib/chiya_web/controllers/setting_html/setting_form.html.heex +++ b/lib/chiya_web/controllers/setting_html/setting_form.html.heex @@ -14,7 +14,17 @@ <.input field={f[:user_agent]} type="text" label="User agent" /> <.input field={f[:custom_css]} type="textarea" label="Custom css" class="font-mono" /> <.input field={f[:custom_html]} type="textarea" label="Custom html" class="font-mono" /> - <.input field={f[:home_channel_id]} type="select" label="Home Channel" options={@channels} /> + <.input + field={f[:home_channel_id]} + type="select" + label="Home Channel" + options={@channels} + /> + <.input + field={f[:micropub_channel_id]} + type="select" + label="Micropub Channel" options={@channels} + /> <.input field={f[:default_channel_id]} type="select" diff --git a/priv/repo/migrations/20230611183608_add_default_micropub_channel_setting.exs b/priv/repo/migrations/20230611183608_add_default_micropub_channel_setting.exs new file mode 100644 index 0000000..257948a --- /dev/null +++ b/priv/repo/migrations/20230611183608_add_default_micropub_channel_setting.exs @@ -0,0 +1,9 @@ +defmodule Chiya.Repo.Migrations.AddDefaultMicropubChannelSetting do + use Ecto.Migration + + def change do + alter table(:settings) do + add :micropub_channel_id, references(:channels, on_delete: :nothing) + end + end +end