|
|
@ -8,19 +8,17 @@ post_feed_template = File.read!("./templates/posts.xml") |
|
|
|
# Converting handlebars in template to values |
|
|
|
# Converting handlebars in template to values |
|
|
|
fill_template = fn template, pairs -> |
|
|
|
fill_template = fn template, pairs -> |
|
|
|
Regex.compile!("{{(.*)}}") |> |
|
|
|
Regex.compile!("{{(.*)}}") |> |
|
|
|
Regex.replace(template, fn _, key -> if key != "content" do Map.get(pairs, String.to_atom(key)) else |
|
|
|
Regex.replace(template, fn _, key -> Map.get(pairs, String.to_atom(key)) end) |
|
|
|
Map.get(pairs, String.to_atom(key)) |
|
|
|
|
|
|
|
# Converting \n to paragraphs |
|
|
|
|
|
|
|
|> String.split("\\n") |
|
|
|
|
|
|
|
|> Enum.reject(fn(x) -> x == "" end) |
|
|
|
|
|
|
|
|> Enum.map(fn paragraph -> ("<p>" <> paragraph <> "</p>\n") end) |
|
|
|
|
|
|
|
|> Enum.join("") |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end) |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
fill_template_pretemplated = fn template -> &fill_template.(template, &1) end |
|
|
|
fill_template_pretemplated = fn template -> &fill_template.(template, &1) end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
wrapInParagraphs = fn content -> content |
|
|
|
|
|
|
|
|> String.split("\\n") |
|
|
|
|
|
|
|
|> Enum.reject(fn(x) -> x == "" end) |
|
|
|
|
|
|
|
|> Enum.map(fn paragraph -> "<p>" <> paragraph <> "</p>" end) |
|
|
|
|
|
|
|
|> Enum.join("") |
|
|
|
|
|
|
|
end |
|
|
|
post_contents_custom = File.ls!("./posts_custom") |
|
|
|
post_contents_custom = File.ls!("./posts_custom") |
|
|
|
|> Enum.reject(fn(x) -> String.starts_with?(x, ".") end) |
|
|
|
|> Enum.reject(fn(x) -> String.starts_with?(x, ".") end) |
|
|
|
|> Enum.map(fn f -> File.read!("./posts_custom/" <> f) end) |
|
|
|
|> Enum.map(fn f -> File.read!("./posts_custom/" <> f) end) |
|
|
@ -31,6 +29,7 @@ post_contents_custom = File.ls!("./posts_custom") |
|
|
|
Enum.map(c, fn [k, v] -> %{String.to_atom(k) => v} end) |
|
|
|
Enum.map(c, fn [k, v] -> %{String.to_atom(k) => v} end) |
|
|
|
|> Enum.reduce(%{}, fn(x, acc) -> Map.merge(x, acc) end) |
|
|
|
|> Enum.reduce(%{}, fn(x, acc) -> Map.merge(x, acc) end) |
|
|
|
end) |
|
|
|
end) |
|
|
|
|
|
|
|
|> Enum.map(fn m -> Map.update!(m, :content, wrapInParagraphs) end) |
|
|
|
|
|
|
|
|
|
|
|
filterCutFileExtension = fn files -> |
|
|
|
filterCutFileExtension = fn files -> |
|
|
|
fn ext -> |
|
|
|
fn ext -> |
|
|
|