Created
December 16, 2016 01:40
-
-
Save underhilllabs/30f60259bba1e3c104cd2335b2322c54 to your computer and use it in GitHub Desktop.
an Elixir module to archive pages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule Archiver do | |
def archive(url, user_id, bookmark_id) do | |
summary = Readability.summarize(url) | |
page = summary.article_html | |
path = "priv/static/archive/#{user_id}" | |
unless File.exists?(path) do | |
File.mkdir(path) | |
end | |
File.write("#{path}/#{bookmark_id}.html", page) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment