Skip to content

Instantly share code, notes, and snippets.

@underhilllabs
Created December 16, 2016 01:40
Show Gist options
  • Save underhilllabs/30f60259bba1e3c104cd2335b2322c54 to your computer and use it in GitHub Desktop.
Save underhilllabs/30f60259bba1e3c104cd2335b2322c54 to your computer and use it in GitHub Desktop.
an Elixir module to archive pages
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