Compare commits

..

No commits in common. "f6f71d1ee5649712791f8dea9d1b482071877ba6" and "ec6be15032d4d63fd91db5d7c9cb955f6d7ed9d5" have entirely different histories.

3 changed files with 7 additions and 27 deletions

View File

@ -1,7 +0,0 @@
defmodule LogsrvApi.Crawler do
alias LogsrvApi.{Filesystem,Page,Journal}
def crawl do
Filesystem.
end
end

View File

@ -24,22 +24,10 @@ defmodule LogsrvApi.Filesystem do
def all(Page) do def all(Page) do
dir(:pages) dir(:pages)
|> File.ls! |> File.ls!
|> Enum.sort
|> Enum.map(fn(fd) -> |> Enum.map(fn(fd) ->
case fd |> File.ls do Page.init(fd)
{:error, _} ->
IO.puts("Error on #{fd}")
Page.init(fd)
pages ->
IO.puts(pages)
pages |> Enum.map(fn(page) ->
"pages/#{page}" |> Page.init
end)
end
end) end)
|> Enum.sort(&sort/2)
end
def sort(a, b) do
Timex.compare(a.date, b.date) > 0
end end
def all(Journal) do def all(Journal) do

View File

@ -49,14 +49,13 @@ defmodule LogsrvApi.Page do
{:nil, Earmark.as_html!(data)} {:nil, Earmark.as_html!(data)}
end end
end end
def parse_yaml(yaml) do defp parse_yaml(yaml) do
yaml [parsed] = :yamerl_constr.string(yaml)
|> :yamerl_constr.string parsed
|> List.flatten
end end
defp extract({props, content}, post) do defp extract({props, content}, post) do
%{post | %{post |
title: get_prop(props, "title") |> to_string || post.title, title: get_prop(props, "title") || post.title,
tags: get_prop(props, "tags"), tags: get_prop(props, "tags"),
content: content} content: content}
end end
@ -66,7 +65,7 @@ defmodule LogsrvApi.Page do
else else
case :proplists.get_value(String.to_char_list(key), props) do case :proplists.get_value(String.to_char_list(key), props) do
:undefined -> nil :undefined -> nil
x -> x x -> to_string(x)
end end
end end
end end