diff --git a/lib/outlook_web.ex b/lib/outlook_web.ex index 07db6ce..a545a18 100644 --- a/lib/outlook_web.ex +++ b/lib/outlook_web.ex @@ -89,6 +89,7 @@ defmodule OutlookWeb do import OutlookWeb.HtmlTreeComponent import OutlookWeb.HtmlDocComponent import OutlookWeb.TunitEditorComponent + import OutlookWeb.PublicComponents import OutlookWeb.Gettext # Shortcut for generating JS commands diff --git a/lib/outlook_web/components/public_components.ex b/lib/outlook_web/components/public_components.ex new file mode 100644 index 0000000..186b567 --- /dev/null +++ b/lib/outlook_web/components/public_components.ex @@ -0,0 +1,38 @@ +defmodule OutlookWeb.PublicComponents do + @moduledoc """ + Provides components for showing and listing artikel and autoren. + """ + use Phoenix.Component + import Phoenix.HTML + + alias Phoenix.LiveView.JS + + attr :autor, :any, required: true + + def autor(assigns) do + ~H""" + +
+
<%= @autor.name %>
+
<%= @autor.description %>
+
+
+ """ + end + + attr :artikel, :any, required: true + attr :show_author, :boolean, default: true + + def artikel(assigns) do + ~H""" + <.link navigate={"/artikel/#{@artikel.id}"}> +
+

<%= @artikel.title %>

+
<%= @artikel.article.author.name %>
+
<%= @artikel.date |> Calendar.strftime("%d.%m.%Y") %>
+
<%= @artikel.teaser |> raw %>
+
+ + """ + end +end diff --git a/lib/outlook_web/controllers/artikel_html/index.html.heex b/lib/outlook_web/controllers/artikel_html/index.html.heex index 611af4a..a7c3326 100644 --- a/lib/outlook_web/controllers/artikel_html/index.html.heex +++ b/lib/outlook_web/controllers/artikel_html/index.html.heex @@ -1,19 +1,2 @@ -<.header> - Listing Artikel - <:actions> - - -<.table id="artikel" rows={@artikel} row_click={&JS.navigate(~p"/artikel/#{&1}")}> - <:col :let={artikel} label="Title"><%= artikel.title %> - <:col :let={artikel} label="Teaser"><%= artikel.teaser %> - <%!-- <:col :let={artikel} label="Translator"><%= artikel.translator %> --%> - <:col :let={artikel} label="Unauthorized"><%= artikel.unauthorized %> - <:col :let={artikel} label="Public content"><%= artikel.public_content %> - <:col :let={artikel} label="Date"><%= Calendar.strftime(artikel.date, "%d.%m.%Y") %> - <:action :let={artikel}> -
- <.link navigate={~p"/artikel/#{artikel}"}>Show -
- - +<.artikel :for={artikel <- @artikel} artikel={artikel} /> diff --git a/lib/outlook_web/controllers/artikel_html/show.html.heex b/lib/outlook_web/controllers/artikel_html/show.html.heex index ff50bfc..ddcd02d 100644 --- a/lib/outlook_web/controllers/artikel_html/show.html.heex +++ b/lib/outlook_web/controllers/artikel_html/show.html.heex @@ -1,19 +1,17 @@ -<.header> - <%= @artikel.title %> - <:subtitle><%= @artikel.article.author.name %> - <:actions> +
+

<%= @artikel.title %>

+

<.link href={"/autoren/#{@artikel.article.author.id}"}><%= @artikel.article.author.name %> +     —    <%= Calendar.strftime(@artikel.article.date, "%d.%m.%Y") %>

+
Original <.link href={@artikel.article.url} > <%= @artikel.article.title %> - <%= Calendar.strftime(@artikel.article.date, "%d.%m.%Y") %> - - +
+
+
+ Übersetzung <%= Calendar.strftime(@artikel.date, "%d.%m.%Y") %> +
+
-<.list> - <:item title="Title"><%= @artikel.title %> - <%!-- <:item title="Translator"><%= @artikel.translator %> --%> - <:item title="Unauthorized"><%= @artikel.unauthorized %> - <:item title="Date"><%= Calendar.strftime(@artikel.date, "%d.%m.%Y") %> - -
<%= @artikel.public_content |> raw %>
+
<%= @artikel.public_content |> raw %>
<.back navigate={~p"/autoren/#{@artikel.article.author}"}>Back to Autor diff --git a/lib/outlook_web/controllers/autor_html/index.html.heex b/lib/outlook_web/controllers/autor_html/index.html.heex index 2cabc63..12049bb 100644 --- a/lib/outlook_web/controllers/autor_html/index.html.heex +++ b/lib/outlook_web/controllers/autor_html/index.html.heex @@ -1,20 +1,5 @@ <.header> - Listing Autoren - <:actions> - <.link href={~p"/autoren/new"}> - <.button>New Autor - - + Autoren -<.table id="autoren" rows={@autoren} row_click={&JS.navigate(~p"/autoren/#{&1}")}> - <:col :let={autor} label="Name"><%= autor.name %> - <:col :let={autor} label="Description"><%= autor.description %> - <:col :let={autor} label="Homepage name"><%= autor.homepage_name %> - <:col :let={autor} label="Homepage url"><%= autor.homepage_url %> - <:action :let={autor}> -
- <.link navigate={~p"/autoren/#{autor}"}>Show -
- - +<.autor :for={autor <- @autoren} autor={autor} /> diff --git a/lib/outlook_web/controllers/autor_html/show.html.heex b/lib/outlook_web/controllers/autor_html/show.html.heex index ee6f30d..81df610 100644 --- a/lib/outlook_web/controllers/autor_html/show.html.heex +++ b/lib/outlook_web/controllers/autor_html/show.html.heex @@ -7,10 +7,7 @@ <%= for article <- @autor.articles do %> -
- <.link navigate={~p"/artikel/#{translation}"}>

<%= translation.title %>

-
<%= translation.teaser %>
-
+ <.artikel :for={translation <- article.translations} artikel={translation} show_author={false} /> <% end %> <.back navigate={~p"/autoren"}>Back to autoren