Skip to content

Commit

Permalink
📎 ♫
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksei Matiushkin committed Jun 7, 2024
1 parent 8ec18a6 commit 291339b
Showing 1 changed file with 33 additions and 27 deletions.
60 changes: 33 additions & 27 deletions lib/md/transforms.ex
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,12 @@ defmodule Md.Transforms.Soundcloud do

@impl Md.Transforms
def apply(_md, track) do
[id, author, author_link, track, title] = String.split(track, "|")
["♫" <> id | details] = String.split(track, "|")

src =
Enum.join(
[
"https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/#{String.replace(id, "♫", "")}",
"https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/#{id}",
"color=%23ff5500",
"auto_play=false",
"hide_related=false",
Expand All @@ -230,31 +230,37 @@ defmodule Md.Transforms.Soundcloud do
allowfullscreen: false
}, []}

div =
{:div,
%{
style:
"font-size: 10px; color: #cccccc; line-break: anywhere; word-break: normal; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-family: Ubuntu, Interstate,Lucida Grande,Lucida Sans Unicode,Lucida Sans,Garuda,Verdana,Tahoma,sans-serif; font-weight: 100;"
},
[
{:a,
%{
href: "https://soundcloud.com/nott-lovland",
title: "Nott Løvland",
target: "_blank",
style: "color: #cccccc;text-decoration: none;"
}, [String.replace(author, "~", " ")]},
" · ",
{:a,
%{
href: "https://soundcloud.com/#{author_link}/#{track}",
title: "#{title}",
target: "_blank",
style: "color: #cccccc; text-decoration: none;"
}, [title]}
]}

{:span, [], [iframe, div]}
case details do
[author, author_link, track, title] ->
div =
{:div,
%{
style:
"font-size: 10px; color: #cccccc; line-break: anywhere; word-break: normal; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-family: Ubuntu, Interstate,Lucida Grande,Lucida Sans Unicode,Lucida Sans,Garuda,Verdana,Tahoma,sans-serif; font-weight: 100;"
},
[
{:a,
%{
href: "https://soundcloud.com/nott-lovland",
title: "Nott Løvland",
target: "_blank",
style: "color: #cccccc;text-decoration: none;"
}, [String.replace(author, "~", " ")]},
" · ",
{:a,
%{
href: "https://soundcloud.com/#{author_link}/#{track}",
title: "#{title}",
target: "_blank",
style: "color: #cccccc; text-decoration: none;"
}, [title]}
]}

{:span, [], [iframe, div]}

_ ->
iframe
end
end
end

Expand Down

0 comments on commit 291339b

Please sign in to comment.