Previsualisation des liens ne fonctionne pas
Lors de la création d'une story (/new
), la prévisualisation des liens ne fonctionne pas (testé avec les lien https://www.franceculture.fr/sciences/stanislas-dehaene-en-cinq-idees
).
Un quick hack permettant de solutionner le problème qui pourrait être refait de façon plus propre :
diff --git a/lib/storia_web/views/opengraph_view.ex b/lib/storia_web/views/opengraph_view.ex
index f3e27cc..339d7d6 100644
--- a/lib/storia_web/views/opengraph_view.ex
+++ b/lib/storia_web/views/opengraph_view.ex
@@ -7,7 +7,7 @@ defmodule StoriaWeb.OpenGraphView do
end
def render("opengraph.json", opengraph) do
- opengraph = opengraph.opengraph
+ opengraph = keys_to_atoms(opengraph.opengraph)
%{
type: "opengraph",
title: opengraph.title,
@@ -19,6 +19,11 @@ defmodule StoriaWeb.OpenGraphView do
}
end
+ def keys_to_atoms(string_key_map) when is_map(string_key_map) do
+ for {key, val} <- string_key_map, into: %{}, do: {String.to_atom(key), keys_to_atoms(val)}
+ end
+ def keys_to_atoms(value), do: value
+
def toLinks(text) do
if text != nil do
urls = Regex.scan(~r/(http|ftp|https):\/\/([\w_-]+(?:(?:\.[\w_-]+)+))([\w.,@?^=%&:\/~+#-]*[\w@?^=%&\/~+#-])?/iu, text, [capture: :first])