Add ability to cache bookmark
This commit is contained in:
@@ -91,6 +91,7 @@ module Adamantium
|
||||
})
|
||||
end
|
||||
new_params[:url] = params[:"bookmark-of"]
|
||||
new_params[:cache] = params[:cache] || false
|
||||
|
||||
new_params
|
||||
end
|
||||
|
12
lib/adamantium/page_cacher.rb
Normal file
12
lib/adamantium/page_cacher.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
require "readability"
|
||||
require "down"
|
||||
|
||||
module Adamantium
|
||||
class PageCacher
|
||||
def call(url:, &block)
|
||||
tempfile = Down.download(bookmark.url)
|
||||
content = Readability::Document.new(tempfile.read, tags: %w[div section header p h1 h2 h3 h4 h5 h6 ol ul li table td tr thead tbody a code pre], attributes: %w[href]).content
|
||||
yield content
|
||||
end
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user