Replace PhoenixHTMLHelpers with Markdown rendering
This commit is contained in:
@@ -7,6 +7,7 @@ defmodule MusicLibraryWeb.ArtistLive.Show do
|
||||
alias MusicLibrary.{Artists, Chats, Records}
|
||||
alias MusicLibrary.Artists.ArtistInfo
|
||||
alias MusicLibraryWeb.ErrorMessages
|
||||
alias MusicLibraryWeb.Markdown
|
||||
|
||||
attr :country, :map, required: true
|
||||
|
||||
@@ -363,7 +364,9 @@ defmodule MusicLibraryWeb.ArtistLive.Show do
|
||||
:if={lastfm_artist_info.bio not in [nil, ""]}
|
||||
class="text-zinc-700 dark:text-zinc-300"
|
||||
>
|
||||
{remove_read_more_link(lastfm_artist_info.summary)}
|
||||
<div class="dark:prose-invert prose prose-sm">
|
||||
{remove_read_more_link(lastfm_artist_info.summary)}
|
||||
</div>
|
||||
<.link
|
||||
class="mt-2 block text-sm font-medium text-zinc-900 dark:text-zinc-400"
|
||||
phx-click={Fluxon.open_dialog("lastfm-bio")}
|
||||
@@ -383,7 +386,9 @@ defmodule MusicLibraryWeb.ArtistLive.Show do
|
||||
class="max-w-2xl text-zinc-700 dark:text-zinc-300"
|
||||
placement="left"
|
||||
>
|
||||
{render_bio(lastfm_artist_info.bio)}
|
||||
<div class="dark:prose-invert prose prose-sm">
|
||||
{render_bio(lastfm_artist_info.bio)}
|
||||
</div>
|
||||
</.sheet>
|
||||
</.async_result>
|
||||
<% end %>
|
||||
@@ -777,10 +782,7 @@ defmodule MusicLibraryWeb.ArtistLive.Show do
|
||||
""
|
||||
)
|
||||
|
||||
PhoenixHTMLHelpers.Format.text_to_html(reformatted_bio,
|
||||
escape: false,
|
||||
attributes: [class: "mt-2 text-sm/7"]
|
||||
)
|
||||
render_content(reformatted_bio)
|
||||
|
||||
[text, link, license] ->
|
||||
reformatted_bio =
|
||||
@@ -793,16 +795,10 @@ defmodule MusicLibraryWeb.ArtistLive.Show do
|
||||
""
|
||||
)
|
||||
|
||||
PhoenixHTMLHelpers.Format.text_to_html(reformatted_bio,
|
||||
escape: false,
|
||||
attributes: [class: "mt-2 text-sm/7"]
|
||||
)
|
||||
render_content(reformatted_bio)
|
||||
|
||||
other ->
|
||||
PhoenixHTMLHelpers.Format.text_to_html(other,
|
||||
escape: false,
|
||||
attributes: [class: "mt-2 text-sm/7"]
|
||||
)
|
||||
render_content(other)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -810,9 +806,14 @@ defmodule MusicLibraryWeb.ArtistLive.Show do
|
||||
last_fm_link_regex = ~r/<a.*Read more on Last\.fm<\/a>\.*\s*/
|
||||
reformatted_summary = String.replace(summary, last_fm_link_regex, "")
|
||||
|
||||
PhoenixHTMLHelpers.Format.text_to_html(reformatted_summary,
|
||||
escape: false,
|
||||
attributes: [class: "mt-2 text-sm/7"]
|
||||
)
|
||||
render_content(reformatted_summary)
|
||||
end
|
||||
|
||||
# sobelow_skip ["XSS.Raw"]
|
||||
# Markdown.to_html/1 sanitizes HTML via MDEx (ammonia)
|
||||
defp render_content(content) do
|
||||
content
|
||||
|> Markdown.to_html()
|
||||
|> raw()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -62,7 +62,6 @@ defmodule MusicLibrary.MixProject do
|
||||
# UI
|
||||
{:phoenix_html, "~> 4.2"},
|
||||
{:phoenix_live_view, "~> 1.1"},
|
||||
{:phoenix_html_helpers, "~> 1.0"},
|
||||
{:heroicons,
|
||||
github: "tailwindlabs/heroicons",
|
||||
tag: "v2.2.0",
|
||||
|
||||
@@ -52,7 +52,6 @@
|
||||
"phoenix": {:hex, :phoenix, "1.8.5", "919db335247e6d4891764dc3063415b0d2457641c5f9b3751b5df03d8e20bbcf", [:mix], [{:bandit, "~> 1.0", [hex: :bandit, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.7", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:websock_adapter, "~> 0.5.3", [hex: :websock_adapter, repo: "hexpm", optional: false]}], "hexpm", "83b2bb125127e02e9f475c8e3e92736325b5b01b0b9b05407bcb4083b7a32485"},
|
||||
"phoenix_ecto": {:hex, :phoenix_ecto, "4.7.0", "75c4b9dfb3efdc42aec2bd5f8bccd978aca0651dbcbc7a3f362ea5d9d43153c6", [:mix], [{:ecto, "~> 3.5", [hex: :ecto, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 2.14.2 or ~> 3.0 or ~> 4.1", [hex: :phoenix_html, repo: "hexpm", optional: true]}, {:plug, "~> 1.9", [hex: :plug, repo: "hexpm", optional: false]}, {:postgrex, "~> 0.16 or ~> 1.0", [hex: :postgrex, repo: "hexpm", optional: true]}], "hexpm", "1d75011e4254cb4ddf823e81823a9629559a1be93b4321a6a5f11a5306fbf4cc"},
|
||||
"phoenix_html": {:hex, :phoenix_html, "4.3.0", "d3577a5df4b6954cd7890c84d955c470b5310bb49647f0a114a6eeecc850f7ad", [:mix], [], "hexpm", "3eaa290a78bab0f075f791a46a981bbe769d94bc776869f4f3063a14f30497ad"},
|
||||
"phoenix_html_helpers": {:hex, :phoenix_html_helpers, "1.0.1", "7eed85c52eff80a179391036931791ee5d2f713d76a81d0d2c6ebafe1e11e5ec", [:mix], [{:phoenix_html, "~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:plug, "~> 1.5", [hex: :plug, repo: "hexpm", optional: true]}], "hexpm", "cffd2385d1fa4f78b04432df69ab8da63dc5cf63e07b713a4dcf36a3740e3090"},
|
||||
"phoenix_live_dashboard": {:hex, :phoenix_live_dashboard, "0.8.7", "405880012cb4b706f26dd1c6349125bfc903fb9e44d1ea668adaf4e04d4884b7", [:mix], [{:ecto, "~> 3.6.2 or ~> 3.7", [hex: :ecto, repo: "hexpm", optional: true]}, {:ecto_mysql_extras, "~> 0.5", [hex: :ecto_mysql_extras, repo: "hexpm", optional: true]}, {:ecto_psql_extras, "~> 0.7", [hex: :ecto_psql_extras, repo: "hexpm", optional: true]}, {:ecto_sqlite3_extras, "~> 1.1.7 or ~> 1.2.0", [hex: :ecto_sqlite3_extras, repo: "hexpm", optional: true]}, {:mime, "~> 1.6 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:phoenix_live_view, "~> 0.19 or ~> 1.0", [hex: :phoenix_live_view, repo: "hexpm", optional: false]}, {:telemetry_metrics, "~> 0.6 or ~> 1.0", [hex: :telemetry_metrics, repo: "hexpm", optional: false]}], "hexpm", "3a8625cab39ec261d48a13b7468dc619c0ede099601b084e343968309bd4d7d7"},
|
||||
"phoenix_live_reload": {:hex, :phoenix_live_reload, "1.6.2", "b18b0773a1ba77f28c52decbb0f10fd1ac4d3ae5b8632399bbf6986e3b665f62", [:mix], [{:file_system, "~> 0.2.10 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}, {:phoenix, "~> 1.4", [hex: :phoenix, repo: "hexpm", optional: false]}], "hexpm", "d1f89c18114c50d394721365ffb428cce24f1c13de0467ffa773e2ff4a30d5b9"},
|
||||
"phoenix_live_view": {:hex, :phoenix_live_view, "1.1.27", "9afcab28b0c82afdc51044e661bcd5b8de53d242593d34c964a37710b40a42af", [:mix], [{:igniter, ">= 0.6.16 and < 1.0.0-0", [hex: :igniter, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:lazy_html, "~> 0.1.0", [hex: :lazy_html, repo: "hexpm", optional: true]}, {:phoenix, "~> 1.6.15 or ~> 1.7.0 or ~> 1.8.0-rc", [hex: :phoenix, repo: "hexpm", optional: false]}, {:phoenix_html, "~> 3.3 or ~> 4.0", [hex: :phoenix_html, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.15", [hex: :plug, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4.2 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "415735d0b2c612c9104108b35654e977626a0cb346711e1e4f1ed16e3c827ede"},
|
||||
|
||||
Reference in New Issue
Block a user