Merge pull request 'devel' (#239) from devel into main
Reviewed-on: #239
This commit is contained in:
commit
5b629a876c
8 changed files with 75 additions and 3 deletions
|
@ -17,6 +17,7 @@ defmodule Chiya.Site.Setting do
|
|||
belongs_to :default_channel, Chiya.Channels.Channel
|
||||
belongs_to :micropub_channel, Chiya.Channels.Channel
|
||||
belongs_to :wiki_channel, Chiya.Channels.Channel
|
||||
belongs_to :bookmark_channel, Chiya.Channels.Channel
|
||||
|
||||
field :show_images_on_home, :boolean, default: true
|
||||
|
||||
|
@ -37,6 +38,7 @@ defmodule Chiya.Site.Setting do
|
|||
:default_channel_id,
|
||||
:micropub_channel_id,
|
||||
:wiki_channel_id,
|
||||
:bookmark_channel_id,
|
||||
:show_images_on_home
|
||||
])
|
||||
|> validate_required([
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
<ul class="flex gap-3">
|
||||
<li>
|
||||
<a href="/" class="button">
|
||||
<.icon name="hero-home" /> Home
|
||||
<.icon name="hero-home" />
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
|
@ -56,14 +56,19 @@
|
|||
<.icon name="hero-paper-clip" /> Wiki
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/bookmarks" class="button">
|
||||
<.icon name="hero-bookmark" /> Bookmarks
|
||||
</a>
|
||||
</li>
|
||||
<li class="flex-1"></li>
|
||||
<%= if @current_user do %>
|
||||
<li>
|
||||
<a href="/admin" class="button">
|
||||
<.icon name="hero-beaker" /> Admin
|
||||
<.icon name="hero-beaker" />
|
||||
</a>
|
||||
</li>
|
||||
<% end %>
|
||||
<li class="flex-1"></li>
|
||||
<li>
|
||||
<.darkmode_toggle class="button" />
|
||||
</li>
|
||||
|
|
|
@ -86,4 +86,23 @@ defmodule ChiyaWeb.PageController do
|
|||
page_title: "Wiki"
|
||||
)
|
||||
end
|
||||
|
||||
def bookmarks(conn, _params) do
|
||||
[channel, notes] =
|
||||
case conn.assigns.settings.wiki_channel_id do
|
||||
nil ->
|
||||
[nil, nil]
|
||||
|
||||
id ->
|
||||
channel = Chiya.Channels.get_channel!(id)
|
||||
notes = Chiya.Notes.list_notes_by_channel_updated(channel, 5)
|
||||
[channel, notes]
|
||||
end
|
||||
|
||||
render(conn, :wiki,
|
||||
channel: channel,
|
||||
notes: notes,
|
||||
page_title: "Bookmarks"
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
27
lib/chiya_web/controllers/page_html/bookmarks.html.heex
Normal file
27
lib/chiya_web/controllers/page_html/bookmarks.html.heex
Normal file
|
@ -0,0 +1,27 @@
|
|||
<%= if @channel do %>
|
||||
<section class="mx-auto max-w-2xl">
|
||||
<.header>
|
||||
<%= @channel.name %>
|
||||
</.header>
|
||||
</section>
|
||||
|
||||
<section class="mt-6 flex flex-col gap-3 max-w-2xl mx-auto">
|
||||
<section class="prose prose-gruvbox md:prose-lg lg:prose-xl max-w-none">
|
||||
<%= Markdown.render(@channel.content) |> raw %>
|
||||
</section>
|
||||
|
||||
<section class="mt-6">
|
||||
<.note_list notes={@notes} layout={@channel.layout} show_content={false} />
|
||||
</section>
|
||||
</section>
|
||||
<% else %>
|
||||
<section class="mx-auto max-w-2xl">
|
||||
<.header>
|
||||
Wiki
|
||||
</.header>
|
||||
|
||||
<section class="prose prose-gruvbox mt-6">
|
||||
Wiki is not set up.
|
||||
</section>
|
||||
</section>
|
||||
<% end %>
|
|
@ -21,6 +21,12 @@
|
|||
label="Micropub Channel"
|
||||
options={@channels}
|
||||
/>
|
||||
<.input
|
||||
field={f[:bookmark_channel_id]}
|
||||
type="select"
|
||||
label="Bookmark Channel"
|
||||
options={@channels}
|
||||
/>
|
||||
<.input
|
||||
field={f[:default_channel_id]}
|
||||
type="select"
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
<:item title="Micropub Channel">
|
||||
<%= if @setting.micropub_channel, do: @setting.micropub_channel.name %>
|
||||
</:item>
|
||||
<:item title="Bookmark Channel">
|
||||
<%= if @setting.bookmark_channel, do: @setting.bookmark_channel.name %>
|
||||
</:item>
|
||||
<:item title="Wiki Channel">
|
||||
<%= if @setting.micropub_channel, do: @setting.wiki_channel.name %>
|
||||
</:item>
|
||||
|
|
|
@ -138,6 +138,7 @@ defmodule ChiyaWeb.Router do
|
|||
|
||||
get "/about", PageController, :about
|
||||
get "/wiki", PageController, :wiki
|
||||
get "/bookmarks", PageController, :bookmarks
|
||||
|
||||
get "/", PageController, :home
|
||||
end
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
defmodule Chiya.Repo.Migrations.AddBookmarkChannelSetting do
|
||||
use Ecto.Migration
|
||||
|
||||
def change do
|
||||
alter table(:settings) do
|
||||
add :bookmark_channel_id, references(:channels, on_delete: :nothing)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue