Compare commits
No commits in common. "fdfca3f7a5e7cca59767d8a4fc8bf5ab3cc62a22" and "d0d958a638ef98b8fc41979f292c5fb64f0972a3" have entirely different histories.
fdfca3f7a5
...
d0d958a638
@ -1,6 +1,3 @@
|
|||||||
# v0.1.14
|
|
||||||
- Fix issue with item content not able to be displayed sometimes
|
|
||||||
|
|
||||||
# v0.1.13
|
# v0.1.13
|
||||||
- Update dependencies
|
- Update dependencies
|
||||||
- Fix debounces
|
- Fix debounces
|
||||||
|
@ -134,30 +134,25 @@ defmodule MemexWeb.CoreComponents do
|
|||||||
|
|
||||||
def pipeline_content(assigns)
|
def pipeline_content(assigns)
|
||||||
|
|
||||||
defp display_links(record) do
|
defp display_backlinks(record) do
|
||||||
record
|
record
|
||||||
|> get_content()
|
|> get_text()
|
||||||
|> replace_hyperlinks(record)
|
|> replace_links(record)
|
||||||
|> replace_triple_links(record)
|
|> replace_triple_backlinks(record)
|
||||||
|> replace_double_links(record)
|
|> replace_double_backlinks(record)
|
||||||
|> replace_single_links(record)
|
|> replace_single_backlinks(record)
|
||||||
|> HTML.raw()
|
|> HTML.raw()
|
||||||
end
|
end
|
||||||
|
|
||||||
defp get_content(%{content: content}), do: content |> get_text()
|
defp get_text(%{content: content}), do: content
|
||||||
defp get_content(%{description: description}), do: description |> get_text()
|
defp get_text(%{description: description}), do: description
|
||||||
defp get_content(_fallthrough), do: nil |> get_text()
|
|
||||||
|
|
||||||
defp get_text(string) when is_binary(string), do: string
|
|
||||||
defp get_text(_fallthrough), do: ""
|
defp get_text(_fallthrough), do: ""
|
||||||
|
|
||||||
# replaces hyperlinks like https://bubbletea.dev
|
|
||||||
#
|
|
||||||
# link regex from
|
# link regex from
|
||||||
# https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url
|
# https://stackoverflow.com/questions/3809401/what-is-a-good-regular-expression-to-match-a-url
|
||||||
# and modified with additional schemes from
|
# and modified with additional schemes from
|
||||||
# https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml
|
# https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml
|
||||||
defp replace_hyperlinks(content, _record) do
|
defp replace_links(content, _record) do
|
||||||
Regex.replace(
|
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()@:%_\+.~#?&//=]*))>,
|
~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,
|
content,
|
||||||
@ -178,8 +173,7 @@ defmodule MemexWeb.CoreComponents do
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
# replaces triple links like [[[slug-title]]]
|
defp replace_triple_backlinks(content, _record) do
|
||||||
defp replace_triple_links(content, _record) do
|
|
||||||
Regex.replace(
|
Regex.replace(
|
||||||
~r/(^|[^\[])\[\[\[([\p{L}\p{N}\-]+)\]\]\]($|[^\]])/,
|
~r/(^|[^\[])\[\[\[([\p{L}\p{N}\-]+)\]\]\]($|[^\]])/,
|
||||||
content,
|
content,
|
||||||
@ -198,8 +192,7 @@ defmodule MemexWeb.CoreComponents do
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
# replaces double links like [[slug-title]]
|
defp replace_double_backlinks(content, record) do
|
||||||
defp replace_double_links(content, record) do
|
|
||||||
Regex.replace(
|
Regex.replace(
|
||||||
~r/(^|[^\[])\[\[([\p{L}\p{N}\-]+)\]\]($|[^\]])/,
|
~r/(^|[^\[])\[\[([\p{L}\p{N}\-]+)\]\]($|[^\]])/,
|
||||||
content,
|
content,
|
||||||
@ -225,8 +218,7 @@ defmodule MemexWeb.CoreComponents do
|
|||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
# replaces single links like [slug-title]
|
defp replace_single_backlinks(content, record) do
|
||||||
defp replace_single_links(content, record) do
|
|
||||||
Regex.replace(
|
Regex.replace(
|
||||||
~r/(^|[^\[])\[([\p{L}\p{N}\-]+)\]($|[^\]])/,
|
~r/(^|[^\[])\[([\p{L}\p{N}\-]+)\]($|[^\]])/,
|
||||||
content,
|
content,
|
||||||
|
@ -4,4 +4,4 @@
|
|||||||
phx-update="ignore"
|
phx-update="ignore"
|
||||||
readonly
|
readonly
|
||||||
phx-no-format
|
phx-no-format
|
||||||
><p class="inline"><%= display_links(@context) %></p></div>
|
><p class="inline"><%= display_backlinks(@context) %></p></div>
|
||||||
|
@ -4,4 +4,4 @@
|
|||||||
phx-update="ignore"
|
phx-update="ignore"
|
||||||
readonly
|
readonly
|
||||||
phx-no-format
|
phx-no-format
|
||||||
><p class="inline"><%= display_links(@note) %></p></div>
|
><p class="inline"><%= display_backlinks(@note) %></p></div>
|
||||||
|
@ -4,4 +4,4 @@
|
|||||||
phx-update="ignore"
|
phx-update="ignore"
|
||||||
readonly
|
readonly
|
||||||
phx-no-format
|
phx-no-format
|
||||||
><p class="inline"><%= display_links(@pipeline) %></p></div>
|
><p class="inline"><%= display_backlinks(@pipeline) %></p></div>
|
||||||
|
@ -4,4 +4,4 @@
|
|||||||
phx-update="ignore"
|
phx-update="ignore"
|
||||||
readonly
|
readonly
|
||||||
phx-no-format
|
phx-no-format
|
||||||
><p class="inline"><%= display_links(@step) %></p></div>
|
><p class="inline"><%= display_backlinks(@step) %></p></div>
|
||||||
|
2
mix.exs
2
mix.exs
@ -4,7 +4,7 @@ defmodule Memex.MixProject do
|
|||||||
def project do
|
def project do
|
||||||
[
|
[
|
||||||
app: :memex,
|
app: :memex,
|
||||||
version: "0.1.14",
|
version: "0.1.13",
|
||||||
elixir: "1.15.6",
|
elixir: "1.15.6",
|
||||||
elixirc_paths: elixirc_paths(Mix.env()),
|
elixirc_paths: elixirc_paths(Mix.env()),
|
||||||
start_permanent: Mix.env() == :prod,
|
start_permanent: Mix.env() == :prod,
|
||||||
|
Loading…
Reference in New Issue
Block a user