add setting show_images_on_home, clean up setting page
This commit is contained in:
parent
8a893a6237
commit
6ef125baeb
5 changed files with 55 additions and 32 deletions
|
@ -18,6 +18,8 @@ defmodule Chiya.Site.Setting do
|
|||
belongs_to :micropub_channel, Chiya.Channels.Channel
|
||||
belongs_to :wiki_channel, Chiya.Channels.Channel
|
||||
|
||||
field :show_images_on_home, :boolean, default: true
|
||||
|
||||
timestamps()
|
||||
end
|
||||
|
||||
|
@ -34,8 +36,15 @@ defmodule Chiya.Site.Setting do
|
|||
:home_channel_id,
|
||||
:default_channel_id,
|
||||
:micropub_channel_id,
|
||||
:wiki_channel_id
|
||||
:wiki_channel_id,
|
||||
:show_images_on_home
|
||||
])
|
||||
|> validate_required([
|
||||
:title,
|
||||
:subtitle,
|
||||
:theme,
|
||||
:user_agent,
|
||||
:show_images_on_home
|
||||
])
|
||||
|> validate_required([:title, :subtitle, :theme, :user_agent])
|
||||
end
|
||||
end
|
||||
|
|
|
@ -149,7 +149,7 @@ defmodule ChiyaWeb.PublicComponents do
|
|||
"""
|
||||
end
|
||||
|
||||
attr :note, :map, required: true
|
||||
attr :notes, :list, required: true
|
||||
|
||||
def note_list_microblog(assigns) do
|
||||
~H"""
|
||||
|
@ -184,6 +184,8 @@ defmodule ChiyaWeb.PublicComponents do
|
|||
"""
|
||||
end
|
||||
|
||||
attr :notes, :list, required: true
|
||||
|
||||
def note_list_gallery(assigns) do
|
||||
~H"""
|
||||
<section class="note-list gallery | mt-6">
|
||||
|
@ -218,6 +220,8 @@ defmodule ChiyaWeb.PublicComponents do
|
|||
"""
|
||||
end
|
||||
|
||||
attr :note, :map, required: true
|
||||
|
||||
def featured_images(assigns) do
|
||||
images = main_images(assigns.note)
|
||||
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
options={@channels}
|
||||
/>
|
||||
<.input field={f[:wiki_channel_id]} type="select" label="Wiki Channel" options={@channels} />
|
||||
|
||||
<.input field={f[:show_images_on_home]} type="checkbox" label="Show Images on Home" />
|
||||
<:actions>
|
||||
<.button>Save Setting</.button>
|
||||
</:actions>
|
||||
|
|
|
@ -18,19 +18,11 @@
|
|||
<.list>
|
||||
<:item title="Title"><%= @setting.title %></:item>
|
||||
<:item title="Subtitle"><%= @setting.subtitle %></:item>
|
||||
<:item title="Theme">
|
||||
<%= @setting.theme %>
|
||||
<div class="flex flex-row gap-2 bg-theme-background p-1 rounded-lg border">
|
||||
<.icon name="hero-heart-solid" class="bg-theme-primary" />
|
||||
<.icon name="hero-heart-solid" class="bg-theme-heading" />
|
||||
<.icon name="hero-heart-solid" class="bg-theme-base" />
|
||||
<.icon name="hero-heart-solid" class="bg-theme-muted" />
|
||||
<.icon name="hero-heart-solid" class="bg-theme-dim" />
|
||||
</div>
|
||||
</:item>
|
||||
<:item title="User agent"><%= @setting.user_agent %></:item>
|
||||
<:item title="Custom css"><%= @setting.custom_css %></:item>
|
||||
<:item title="Custom html"><%= @setting.custom_html %></:item>
|
||||
</.list>
|
||||
|
||||
<.list>
|
||||
<:item title="Default Channel">
|
||||
<%= if @setting.default_channel, do: @setting.default_channel.name %>
|
||||
</:item>
|
||||
|
@ -44,4 +36,11 @@
|
|||
<%= if @setting.micropub_channel, do: @setting.wiki_channel.name %>
|
||||
</:item>
|
||||
</.list>
|
||||
|
||||
<.list>
|
||||
<:item title="Show Images on Home">
|
||||
<%= if @setting.show_images_on_home, do: "✅", else: "❌" %>
|
||||
</:item>
|
||||
</.list>
|
||||
|
||||
<% end %>
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
defmodule Chiya.Repo.Migrations.AddBooleanSettings do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
alter table(:settings) do
|
||||
add :show_images_on_home, :boolean, default: true
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue