diff --git a/lib/outlook_web.ex b/lib/outlook_web.ex index 7633fa5..6106db6 100644 --- a/lib/outlook_web.ex +++ b/lib/outlook_web.ex @@ -86,11 +86,15 @@ defmodule OutlookWeb do import Phoenix.HTML # Core UI components and translation import OutlookWeb.CoreComponents + + # custom components and module import OutlookWeb.HtmlTreeComponent import OutlookWeb.HtmlDocComponent import OutlookWeb.TunitEditorComponent import OutlookWeb.PublicComponents import OutlookWeb.DarkModeComponent + import OutlookWeb.ViewHelpers + 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 index fb1fcc3..9866381 100644 --- a/lib/outlook_web/components/public_components.ex +++ b/lib/outlook_web/components/public_components.ex @@ -20,7 +20,7 @@ defmodule OutlookWeb.PublicComponents do
<%= @autor.name %>
-
<%= @autor.description %>
+
<%= @autor.description |> tidy_raw %>
""" @@ -36,7 +36,7 @@ defmodule OutlookWeb.PublicComponents do

<%= @artikel.title %>

<%= @artikel.article.author.name %>
<%= @artikel.date |> Calendar.strftime("%d.%m.%Y") %>
-
<%= @artikel.teaser |> raw %>
+
<%= @artikel.teaser |> tidy_raw %>
""" diff --git a/lib/outlook_web/live/article_live/show.html.heex b/lib/outlook_web/live/article_live/show.html.heex index c8203c3..4c3e0a7 100644 --- a/lib/outlook_web/live/article_live/show.html.heex +++ b/lib/outlook_web/live/article_live/show.html.heex @@ -19,7 +19,7 @@ <.table id="translations" rows={@article.translations} row_click={&JS.navigate(~p"/translations/#{(&1).id}")}> <:col :let={translation} label="Language"><%= translation.language %> <:col :let={translation} label="Title"><%= translation.title %> - <:col :let={translation} label="Teaser"><%= translation.teaser %> + <:col :let={translation} label="Teaser"><%= translation.teaser |> tidy_raw %> <:col :let={translation} label="Date"><%= translation.date %> <:col :let={translation} label="Public"><%= translation.public %> <:action :let={translation}> diff --git a/lib/outlook_web/live/author_live/index.html.heex b/lib/outlook_web/live/author_live/index.html.heex index 2106239..469c5cc 100644 --- a/lib/outlook_web/live/author_live/index.html.heex +++ b/lib/outlook_web/live/author_live/index.html.heex @@ -9,7 +9,7 @@ <.table id="authors" rows={@authors} row_click={&JS.navigate(~p"/authors/#{&1}")}> <:col :let={author} label="Name"><%= author.name %> - <:col :let={author} label="Description"><%= author.description %> + <:col :let={author} label="Description"><%= author.description |> tidy_raw %> <:col :let={author} label="Homepage name"><%= author.homepage_name %> <:col :let={author} label="Homepage url"><%= author.homepage_url %> <:action :let={author}> diff --git a/lib/outlook_web/live/translation_live/index.html.heex b/lib/outlook_web/live/translation_live/index.html.heex index c615822..d890132 100644 --- a/lib/outlook_web/live/translation_live/index.html.heex +++ b/lib/outlook_web/live/translation_live/index.html.heex @@ -5,7 +5,7 @@ <.table id="translations" rows={@translations} row_click={&JS.navigate(~p(/translations/#{(&1).id}))}> <:col :let={translation} label="Language"><%= translation.language %> <:col :let={translation} label="Title"><%= translation.title %> - <:col :let={translation} label="Teaser"><%= translation.teaser %> + <:col :let={translation} label="Teaser"><%= translation.teaser |> tidy_raw %> <%!-- <:col :let={translation} label="Content"><%= translation.content %> --%> <:col :let={translation} label="Date"><%= translation.date %> <:col :let={translation} label="Public"><%= translation.public %> diff --git a/lib/outlook_web/view_helpers.ex b/lib/outlook_web/view_helpers.ex new file mode 100644 index 0000000..2b1343e --- /dev/null +++ b/lib/outlook_web/view_helpers.ex @@ -0,0 +1,12 @@ +defmodule OutlookWeb.ViewHelpers do + + import Phoenix.HTML, only: [raw: 1] + + @doc "Just sanitize tags" + def tidy_raw(html) do + html + |> Floki.parse_fragment!() + |> Floki.raw_html() + |> raw + end +end