Add embedded schema for Artikel
This commit is contained in:
@ -23,14 +23,14 @@ defmodule OutlookWeb.PublicComponents do
|
||||
end
|
||||
|
||||
attr :artikel, :any, required: true
|
||||
attr :show_author, :boolean, default: true
|
||||
attr :show_autor, :boolean, default: true
|
||||
|
||||
def artikel(assigns) do
|
||||
~H"""
|
||||
<.link navigate={~p"/artikel/#{@artikel}"}>
|
||||
<div class="my-2 px-2 rounded border-2 border-solid border-gray-300 dark:border-stone-800">
|
||||
<h4 class="font-bold text-stone-800 dark:text-stone-300 py-2"><%= @artikel.title %></h4>
|
||||
<div :if={@show_author}><small><%= @artikel.article.author.name %></small></div>
|
||||
<div :if={@show_autor}><small><%= @artikel.autor_name %></small></div>
|
||||
<div><small><%= @artikel.date |> Calendar.strftime("%d.%m.%Y") %></small></div>
|
||||
<div><%= @artikel.teaser |> tidy_raw %></div>
|
||||
</div>
|
||||
|
||||
@ -1,15 +1,15 @@
|
||||
defmodule OutlookWeb.ArtikelController do
|
||||
use OutlookWeb, :controller
|
||||
|
||||
alias Outlook.Artikel
|
||||
alias Outlook.Public
|
||||
|
||||
def index(conn, _params) do
|
||||
artikel = Artikel.list_artikel()
|
||||
artikel = Public.list_artikel()
|
||||
render(conn, :index, artikel: artikel, page_title: "Artikel")
|
||||
end
|
||||
|
||||
def show(conn, %{"tid" => tid} = params) do
|
||||
case Artikel.get_artikel_by_tid(tid) do
|
||||
case Public.get_artikel_by_tid(tid) do
|
||||
{:ok, artikel} -> render(conn, :show, artikel: artikel, page_title: artikel.title)
|
||||
{:error, message} -> conn
|
||||
|> put_status(404)
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<header class="mb-6">
|
||||
<h1 class="text-lg font-semibold leading-tight text-stone-800 dark:text-stone-200"><%= @artikel.title %></h1>
|
||||
<p class="my-2"><.link href={~p"/autoren/#{@artikel.author_id}"}><%= @artikel.author %></.link>
|
||||
<p class="my-2"><.link href={~p"/autoren/#{@artikel.author_id}"}><%= @artikel.autor_name %></.link>
|
||||
— <%= Calendar.strftime(@artikel.date_org, "%d.%m.%Y") %></p>
|
||||
<div>Original Artikel:
|
||||
<.link class="hover:text-sky-700" href={@artikel.url_org} >
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
|
||||
|
||||
<%= for article <- @autor.articles do %>
|
||||
<.artikel :for={translation <- article.translations} artikel={translation} show_author={false} />
|
||||
<.artikel :for={translation <- article.translations} artikel={translation} show_autor={false} />
|
||||
<% end %>
|
||||
|
||||
<.back navigate={~p"/autoren"}>Back to autoren</.back>
|
||||
|
||||
Reference in New Issue
Block a user