Compare commits
5 Commits
cfd9f7505a
...
8c96a94cd3
Author | SHA1 | Date |
---|---|---|
Shadowfacts | 8c96a94cd3 | |
Shadowfacts | 118de4ae53 | |
Shadowfacts | 957f271425 | |
Shadowfacts | c0f04791b6 | |
Shadowfacts | d7641b1c28 |
|
@ -0,0 +1,19 @@
|
|||
defmodule Frenzy.Pipeline.Extractor.BeckyHansmeyer do
|
||||
@moduledoc """
|
||||
Extractor for https://beckyhansmeyer.com
|
||||
"""
|
||||
|
||||
alias Frenzy.Pipeline.Extractor
|
||||
@behaviour Extractor
|
||||
|
||||
@impl Extractor
|
||||
def extract(html_tree) do
|
||||
case Floki.find(html_tree, "div.entry-content") do
|
||||
[content_elem | _] ->
|
||||
{:ok, content_elem}
|
||||
|
||||
_ ->
|
||||
{:error, "no matching elements"}
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,39 @@
|
|||
defmodule Frenzy.Pipeline.Extractor.FinerTech do
|
||||
@moduledoc """
|
||||
Extractor for https://finertech.com
|
||||
"""
|
||||
|
||||
alias Frenzy.Pipeline.Extractor
|
||||
@behaviour Extractor
|
||||
|
||||
@impl Extractor
|
||||
def extract(html_tree) do
|
||||
case Floki.find(html_tree, ".entry-content") do
|
||||
[content_elem | _] ->
|
||||
# remove patreon button
|
||||
content_elem = Floki.traverse_and_update(content_elem, &remove_patreon_banner/1)
|
||||
{:ok, content_elem}
|
||||
|
||||
_ ->
|
||||
{:error, "no matching element"}
|
||||
end
|
||||
end
|
||||
|
||||
@patreon_class_regex ~r/[a-z0-9_]patreon_button/i
|
||||
|
||||
defp remove_patreon_banner({"div", attrs, _children} = elem) do
|
||||
case Enum.find(attrs, fn {attr, _val} -> attr == "class" end) do
|
||||
nil ->
|
||||
elem
|
||||
|
||||
{"class", class} ->
|
||||
if Regex.match?(@patreon_class_regex, class) do
|
||||
nil
|
||||
else
|
||||
elem
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
defp remove_patreon_banner(elem), do: elem
|
||||
end
|
|
@ -0,0 +1,19 @@
|
|||
defmodule Frenzy.Pipeline.Extractor.FiveTwelvePixels do
|
||||
@moduledoc """
|
||||
Extractor for https://512pixels.net
|
||||
"""
|
||||
|
||||
alias Frenzy.Pipeline.Extractor
|
||||
@behaviour Extractor
|
||||
|
||||
@impl Extractor
|
||||
def extract(html_tree) do
|
||||
case Floki.find(html_tree, ".entry-content") do
|
||||
[content_elem | _] ->
|
||||
{:ok, content_elem}
|
||||
|
||||
_ ->
|
||||
{:error, "no matching elements"}
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,36 @@
|
|||
defmodule Frenzy.Pipeline.Extractor.MacStories do
|
||||
@moduledoc """
|
||||
Extractor for https://macstories.net
|
||||
"""
|
||||
|
||||
alias Frenzy.Pipeline.Extractor
|
||||
@behaviour Extractor
|
||||
|
||||
@impl Extractor
|
||||
def extract(html_tree) do
|
||||
case Floki.find(html_tree, ".post-content") do
|
||||
[content_elem | _] ->
|
||||
content_elem =
|
||||
content_elem
|
||||
# some images have full size links, strip those out
|
||||
|> Floki.filter_out("a.view-full-size")
|
||||
# rewrite non-standard images captions to <figure>/<figcaption>
|
||||
|> Floki.map(&rewrite_element/1)
|
||||
|
||||
{:ok, content_elem}
|
||||
|
||||
_ ->
|
||||
{:error, "no matching elements"}
|
||||
end
|
||||
end
|
||||
|
||||
defp rewrite_element({"div", [{"class", "media-wrapper"}]}) do
|
||||
{"figure", []}
|
||||
end
|
||||
|
||||
defp rewrite_element({"p", [{"class", "image-caption"}]}) do
|
||||
{"figcaption", []}
|
||||
end
|
||||
|
||||
defp rewrite_element(elem), do: elem
|
||||
end
|
|
@ -1,5 +1,5 @@
|
|||
<h1>
|
||||
<a href="<%= @item.url %>" target="_blank" rel="noopener noreferrer"><%= @item.title %></a>
|
||||
<a href="<%= @item.url %>" target="_blank" rel="noopener noreferrer"><%= @item.title || "(Untitled)" %></a>
|
||||
</h1>
|
||||
|
||||
<%= if @item.read do %>
|
||||
|
|
Loading…
Reference in New Issue