Add tidy_raw() helper
This commit is contained in:
@ -86,11 +86,15 @@ defmodule OutlookWeb do
|
|||||||
import Phoenix.HTML
|
import Phoenix.HTML
|
||||||
# Core UI components and translation
|
# Core UI components and translation
|
||||||
import OutlookWeb.CoreComponents
|
import OutlookWeb.CoreComponents
|
||||||
|
|
||||||
|
# custom components and module
|
||||||
import OutlookWeb.HtmlTreeComponent
|
import OutlookWeb.HtmlTreeComponent
|
||||||
import OutlookWeb.HtmlDocComponent
|
import OutlookWeb.HtmlDocComponent
|
||||||
import OutlookWeb.TunitEditorComponent
|
import OutlookWeb.TunitEditorComponent
|
||||||
import OutlookWeb.PublicComponents
|
import OutlookWeb.PublicComponents
|
||||||
import OutlookWeb.DarkModeComponent
|
import OutlookWeb.DarkModeComponent
|
||||||
|
import OutlookWeb.ViewHelpers
|
||||||
|
|
||||||
import OutlookWeb.Gettext
|
import OutlookWeb.Gettext
|
||||||
|
|
||||||
# Shortcut for generating JS commands
|
# Shortcut for generating JS commands
|
||||||
|
|||||||
@ -20,7 +20,7 @@ defmodule OutlookWeb.PublicComponents do
|
|||||||
<a href={"/autoren/#{@autor.id}"}>
|
<a href={"/autoren/#{@autor.id}"}>
|
||||||
<div class="p-4 my-2 border rounded-lg border-stone-400 text-stone-800 dark:text-stone-300 ">
|
<div class="p-4 my-2 border rounded-lg border-stone-400 text-stone-800 dark:text-stone-300 ">
|
||||||
<div class="font-bold"><%= @autor.name %></div>
|
<div class="font-bold"><%= @autor.name %></div>
|
||||||
<div class=""><%= @autor.description %></div>
|
<div class=""><%= @autor.description |> tidy_raw %></div>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
"""
|
"""
|
||||||
@ -36,7 +36,7 @@ defmodule OutlookWeb.PublicComponents do
|
|||||||
<h4 class="font-bold text-stone-800 dark:text-stone-300 py-2"><%= @artikel.title %></h4>
|
<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_author}><small><%= @artikel.article.author.name %></small></div>
|
||||||
<div><small><%= @artikel.date |> Calendar.strftime("%d.%m.%Y") %></small></div>
|
<div><small><%= @artikel.date |> Calendar.strftime("%d.%m.%Y") %></small></div>
|
||||||
<div><%= @artikel.teaser |> raw %></div>
|
<div><%= @artikel.teaser |> tidy_raw %></div>
|
||||||
</div>
|
</div>
|
||||||
</.link>
|
</.link>
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
<.table id="translations" rows={@article.translations} row_click={&JS.navigate(~p"/translations/#{(&1).id}")}>
|
<.table id="translations" rows={@article.translations} row_click={&JS.navigate(~p"/translations/#{(&1).id}")}>
|
||||||
<:col :let={translation} label="Language"><%= translation.language %></:col>
|
<:col :let={translation} label="Language"><%= translation.language %></:col>
|
||||||
<:col :let={translation} label="Title"><%= translation.title %></:col>
|
<:col :let={translation} label="Title"><%= translation.title %></:col>
|
||||||
<:col :let={translation} label="Teaser"><%= translation.teaser %></:col>
|
<:col :let={translation} label="Teaser"><%= translation.teaser |> tidy_raw %></:col>
|
||||||
<:col :let={translation} label="Date"><%= translation.date %></:col>
|
<:col :let={translation} label="Date"><%= translation.date %></:col>
|
||||||
<:col :let={translation} label="Public"><%= translation.public %></:col>
|
<:col :let={translation} label="Public"><%= translation.public %></:col>
|
||||||
<:action :let={translation}>
|
<:action :let={translation}>
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
<.table id="authors" rows={@authors} row_click={&JS.navigate(~p"/authors/#{&1}")}>
|
<.table id="authors" rows={@authors} row_click={&JS.navigate(~p"/authors/#{&1}")}>
|
||||||
<:col :let={author} label="Name"><%= author.name %></:col>
|
<:col :let={author} label="Name"><%= author.name %></:col>
|
||||||
<:col :let={author} label="Description"><%= author.description %></:col>
|
<:col :let={author} label="Description"><%= author.description |> tidy_raw %></:col>
|
||||||
<:col :let={author} label="Homepage name"><%= author.homepage_name %></:col>
|
<:col :let={author} label="Homepage name"><%= author.homepage_name %></:col>
|
||||||
<:col :let={author} label="Homepage url"><%= author.homepage_url %></:col>
|
<:col :let={author} label="Homepage url"><%= author.homepage_url %></:col>
|
||||||
<:action :let={author}>
|
<:action :let={author}>
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
<.table id="translations" rows={@translations} row_click={&JS.navigate(~p(/translations/#{(&1).id}))}>
|
<.table id="translations" rows={@translations} row_click={&JS.navigate(~p(/translations/#{(&1).id}))}>
|
||||||
<:col :let={translation} label="Language"><%= translation.language %></:col>
|
<:col :let={translation} label="Language"><%= translation.language %></:col>
|
||||||
<:col :let={translation} label="Title"><%= translation.title %></:col>
|
<:col :let={translation} label="Title"><%= translation.title %></:col>
|
||||||
<:col :let={translation} label="Teaser"><%= translation.teaser %></:col>
|
<:col :let={translation} label="Teaser"><%= translation.teaser |> tidy_raw %></:col>
|
||||||
<%!-- <:col :let={translation} label="Content"><%= translation.content %></:col> --%>
|
<%!-- <:col :let={translation} label="Content"><%= translation.content %></:col> --%>
|
||||||
<:col :let={translation} label="Date"><%= translation.date %></:col>
|
<:col :let={translation} label="Date"><%= translation.date %></:col>
|
||||||
<:col :let={translation} label="Public"><%= translation.public %></:col>
|
<:col :let={translation} label="Public"><%= translation.public %></:col>
|
||||||
|
|||||||
12
lib/outlook_web/view_helpers.ex
Normal file
12
lib/outlook_web/view_helpers.ex
Normal file
@ -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
|
||||||
Reference in New Issue
Block a user