mix format
This commit is contained in:
@ -6,6 +6,7 @@ defmodule SomethingErlang.AwfulApi.Bookmarks do
|
||||
def compile(page, user) do
|
||||
doc = Client.bookmarks_doc(page, user)
|
||||
html = Floki.parse_document!(doc)
|
||||
|
||||
for thread <- Floki.find(html, "tr.thread") do
|
||||
parse(thread)
|
||||
end
|
||||
@ -17,26 +18,33 @@ defmodule SomethingErlang.AwfulApi.Bookmarks do
|
||||
icon: Floki.find(thread, "td.icon") |> inner_html() |> Floki.raw_html(),
|
||||
author: Floki.find(thread, "td.author") |> inner_html() |> Floki.text(),
|
||||
replies: Floki.find(thread, "td.replies") |> inner_html() |> Floki.text(),
|
||||
views: Floki.find(thread, "td.views") |> inner_html() |> Floki.text(),
|
||||
views: Floki.find(thread, "td.views") |> inner_html() |> Floki.text(),
|
||||
rating: Floki.find(thread, "td.rating") |> inner_html() |> Floki.raw_html(),
|
||||
lastpost: Floki.find(thread, "td.lastpost") |> inner_html() |> Floki.raw_html()
|
||||
}
|
||||
|
||||
for {"td", [{"class", class} | _attrs], children} <- Floki.find(thread, "td"),
|
||||
String.starts_with?(class, "star") == false,
|
||||
into: %{} do
|
||||
String.starts_with?(class, "star") == false,
|
||||
into: %{} do
|
||||
case class do
|
||||
<<"title", _rest::binary>> ->
|
||||
{:title, children |> Floki.raw_html()}
|
||||
|
||||
<<"icon", _rest::binary>> ->
|
||||
{:icon, children |> Floki.raw_html()}
|
||||
|
||||
<<"author", _rest::binary>> ->
|
||||
{:author, children |> Floki.text()}
|
||||
|
||||
<<"replies", _rest::binary>> ->
|
||||
{:replies, children |> Floki.text() |> String.to_integer()}
|
||||
|
||||
<<"views", _rest::binary>> ->
|
||||
{:views, children |> Floki.text() |> String.to_integer()}
|
||||
|
||||
<<"rating", _rest::binary>> ->
|
||||
{:rating, children |> Floki.raw_html()}
|
||||
|
||||
<<"lastpost", _rest::binary>> ->
|
||||
{:lastpost, children |> Floki.raw_html()}
|
||||
end
|
||||
|
Reference in New Issue
Block a user