Compare commits

..

No commits in common. "fdfca3f7a5e7cca59767d8a4fc8bf5ab3cc62a22" and "d0d958a638ef98b8fc41979f292c5fb64f0972a3" have entirely different histories.

7 changed files with 17 additions and 28 deletions

View File

@ -1,6 +1,3 @@
# v0.1.14
- Fix issue with item content not able to be displayed sometimes
# v0.1.13
- Update dependencies
- Fix debounces

View File

@ -134,30 +134,25 @@ defmodule MemexWeb.CoreComponents do
def pipeline_content(assigns)
defp display_links(record) do
defp display_backlinks(record) do
record
|> get_content()
|> replace_hyperlinks(record)
|> replace_triple_links(record)
|> replace_double_links(record)
|> replace_single_links(record)
|> get_text()
|> replace_links(record)
|> replace_triple_backlinks(record)
|> replace_double_backlinks(record)
|> replace_single_backlinks(record)
|> HTML.raw()
end
defp get_content(%{content: content}), do: content |> get_text()
defp get_content(%{description: description}), do: description |> get_text()
defp get_content(_fallthrough), do: nil |> get_text()
defp get_text(string) when is_binary(string), do: string
defp get_text(%{content: content}), do: content
defp get_text(%{description: description}), do: description
defp get_text(_fallthrough), do: ""
# replaces hyperlinks like https://bubbletea.dev
#
# link regex from
# https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url
# and modified with additional schemes from
# https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml
defp replace_hyperlinks(content, _record) do
defp replace_links(content, _record) do
Regex.replace(
~r<((file|git|https?|ipfs|ipns|irc|jabber|magnet|mailto|mumble|tel|udp|xmpp):\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*))>,
content,
@ -178,8 +173,7 @@ defmodule MemexWeb.CoreComponents do
)
end
# replaces triple links like [[[slug-title]]]
defp replace_triple_links(content, _record) do
defp replace_triple_backlinks(content, _record) do
Regex.replace(
~r/(^|[^\[])\[\[\[([\p{L}\p{N}\-]+)\]\]\]($|[^\]])/,
content,
@ -198,8 +192,7 @@ defmodule MemexWeb.CoreComponents do
)
end
# replaces double links like [[slug-title]]
defp replace_double_links(content, record) do
defp replace_double_backlinks(content, record) do
Regex.replace(
~r/(^|[^\[])\[\[([\p{L}\p{N}\-]+)\]\]($|[^\]])/,
content,
@ -225,8 +218,7 @@ defmodule MemexWeb.CoreComponents do
)
end
# replaces single links like [slug-title]
defp replace_single_links(content, record) do
defp replace_single_backlinks(content, record) do
Regex.replace(
~r/(^|[^\[])\[([\p{L}\p{N}\-]+)\]($|[^\]])/,
content,

View File

@ -4,4 +4,4 @@
phx-update="ignore"
readonly
phx-no-format
><p class="inline"><%= display_links(@context) %></p></div>
><p class="inline"><%= display_backlinks(@context) %></p></div>

View File

@ -4,4 +4,4 @@
phx-update="ignore"
readonly
phx-no-format
><p class="inline"><%= display_links(@note) %></p></div>
><p class="inline"><%= display_backlinks(@note) %></p></div>

View File

@ -4,4 +4,4 @@
phx-update="ignore"
readonly
phx-no-format
><p class="inline"><%= display_links(@pipeline) %></p></div>
><p class="inline"><%= display_backlinks(@pipeline) %></p></div>

View File

@ -4,4 +4,4 @@
phx-update="ignore"
readonly
phx-no-format
><p class="inline"><%= display_links(@step) %></p></div>
><p class="inline"><%= display_backlinks(@step) %></p></div>

View File

@ -4,7 +4,7 @@ defmodule Memex.MixProject do
def project do
[
app: :memex,
version: "0.1.14",
version: "0.1.13",
elixir: "1.15.6",
elixirc_paths: elixirc_paths(Mix.env()),
start_permanent: Mix.env() == :prod,