Current section
Files
Jump to
Current section
Files
src/inlay@provider.erl
-module(inlay@provider).
-compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]).
-define(FILEPATH, "src/inlay/provider.gleam").
-export([render/2, detect/2]).
-file("src/inlay/provider.gleam", 43).
-spec render(inlay@embed:embed(), inlay@embed:config()) -> lustre@vdom@vnode:element(any()).
render(Embed, Config) ->
case Embed of
{youtube_video, _, _, _} ->
inlay@provider@youtube:render(Embed, Config);
{youtube_playlist, _} ->
inlay@provider@youtube:render(Embed, Config);
{vimeo_video, _, _} ->
inlay@provider@vimeo:render(Embed, Config);
{spotify_media, _, _} ->
inlay@provider@spotify:render(Embed, Config);
{tweet, _, _} ->
inlay@provider@twitter:render(Embed, Config);
{tik_tok_video, _, _} ->
inlay@provider@tiktok:render(Embed, Config);
{bluesky_post, _, _} ->
inlay@provider@bluesky:render(Embed, Config);
{instagram_post, _, _} ->
inlay@provider@instagram:render(Embed, Config);
{twitch_channel, _} ->
inlay@provider@twitch:render(Embed, Config);
{twitch_video, _} ->
inlay@provider@twitch:render(Embed, Config);
{map_location, _, _, _} ->
inlay@provider@openstreetmap:render(Embed, Config);
{ted_talk, _} ->
inlay@provider@ted:render(Embed, Config);
{sound_cloud_track, _} ->
inlay@provider@soundcloud:render(Embed, Config);
{mastodon_post, _, _, _} ->
inlay@provider@mastodon:render(Embed, Config);
{pixelfed_post, _, _, _} ->
inlay@provider@pixelfed:render(Embed, Config);
{apple_music_media, _, _, _, _} ->
inlay@provider@apple_music:render(Embed, Config)
end.
-file("src/inlay/provider.gleam", 62).
-spec try_one(
gleam@option:option(any()),
gleam@uri:uri(),
fun((gleam@uri:uri()) -> gleam@option:option(inlay@embed:embed())),
fun(() -> gleam@option:option(inlay@embed:embed()))
) -> gleam@option:option(inlay@embed:embed()).
try_one(Enabled, Url, Detector, Next) ->
case Enabled of
{some, _} ->
case Detector(Url) of
{some, Found} ->
{some, Found};
none ->
Next()
end;
none ->
Next()
end.
-file("src/inlay/provider.gleam", 25).
-spec detect(gleam@uri:uri(), inlay@embed:config()) -> gleam@option:option(inlay@embed:embed()).
detect(Url, Config) ->
try_one(
erlang:element(13, Config),
Url,
fun(U) -> inlay@provider@mastodon:detect(U, Config) end,
fun() ->
try_one(
erlang:element(14, Config),
Url,
fun(U@1) -> inlay@provider@pixelfed:detect(U@1, Config) end,
fun() ->
try_one(
erlang:element(2, Config),
Url,
fun inlay@provider@youtube:detect/1,
fun() ->
try_one(
erlang:element(11, Config),
Url,
fun inlay@provider@ted:detect/1,
fun() ->
try_one(
erlang:element(3, Config),
Url,
fun inlay@provider@vimeo:detect/1,
fun() ->
try_one(
erlang:element(4, Config),
Url,
fun inlay@provider@spotify:detect/1,
fun() ->
try_one(
erlang:element(
7,
Config
),
Url,
fun inlay@provider@bluesky:detect/1,
fun() ->
try_one(
erlang:element(
9,
Config
),
Url,
fun inlay@provider@twitch:detect/1,
fun() ->
try_one(
erlang:element(
12,
Config
),
Url,
fun inlay@provider@soundcloud:detect/1,
fun() ->
try_one(
erlang:element(
5,
Config
),
Url,
fun inlay@provider@twitter:detect/1,
fun(
) ->
try_one(
erlang:element(
6,
Config
),
Url,
fun inlay@provider@tiktok:detect/1,
fun(
) ->
try_one(
erlang:element(
8,
Config
),
Url,
fun inlay@provider@instagram:detect/1,
fun(
) ->
try_one(
erlang:element(
10,
Config
),
Url,
fun inlay@provider@openstreetmap:detect/1,
fun(
) ->
try_one(
erlang:element(
15,
Config
),
Url,
fun inlay@provider@apple_music:detect/1,
fun(
) ->
none
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
)
end
).