add setting show_images_on_home, clean up setting page

This commit is contained in:
Inhji 2023-07-25 07:05:08 +02:00
parent 8a893a6237
commit 6ef125baeb
5 changed files with 55 additions and 32 deletions

View file

@ -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

View file

@ -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)
@ -275,13 +279,13 @@ defmodule ChiyaWeb.PublicComponents do
~H"""
<figure class="flex gap-1 flex-col">
<section class="flex gap-1">
<.featured_image image={assigns.first} size={:thumb} class="flex-1 w-full rounded-tl-lg" />
<.featured_image image={assigns.second} size={:thumb} class="flex-1 w-full rounded-tr-lg" />
</section>
<section class="flex gap-1">
<.featured_image image={assigns.third} size={:thumb} class="flex-1 w-full rounded-bl-lg" />
<.featured_image image={assigns.fourth} size={:thumb} class="flex-1 w-full rounded-br-lg" />
</section>
<.featured_image image={assigns.first} size={:thumb} class="flex-1 w-full rounded-tl-lg" />
<.featured_image image={assigns.second} size={:thumb} class="flex-1 w-full rounded-tr-lg" />
</section>
<section class="flex gap-1">
<.featured_image image={assigns.third} size={:thumb} class="flex-1 w-full rounded-bl-lg" />
<.featured_image image={assigns.fourth} size={:thumb} class="flex-1 w-full rounded-br-lg" />
</section>
</figure>
"""
end

View file

@ -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>

View file

@ -18,30 +18,29 @@
<.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>
<:item title="Default Channel">
<%= if @setting.default_channel, do: @setting.default_channel.name %>
</:item>
<:item title="Home Channel">
<%= if @setting.home_channel, do: @setting.home_channel.name %>
</:item>
<:item title="Micropub Channel">
<%= if @setting.micropub_channel, do: @setting.micropub_channel.name %>
</:item>
<:item title="Wiki Channel">
<%= if @setting.micropub_channel, do: @setting.wiki_channel.name %>
</.list>
<.list>
<:item title="Default Channel">
<%= if @setting.default_channel, do: @setting.default_channel.name %>
</:item>
<:item title="Home Channel">
<%= if @setting.home_channel, do: @setting.home_channel.name %>
</:item>
<:item title="Micropub Channel">
<%= if @setting.micropub_channel, do: @setting.micropub_channel.name %>
</:item>
<:item title="Wiki Channel">
<%= 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 %>

View file

@ -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