-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Caching support for preview #97
Conversation
Exploring https://github.com/minad/moneta for setting cache expire times. |
@@ -11,7 +12,7 @@ | |||
require_relative "onebox/engine" | |||
|
|||
module Onebox | |||
def self.preview(url, args={}) | |||
Preview.new(url, args) | |||
def self.preview(url, options = { cache: Hash.new }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should move this default somewhere, like a singleton method. Something like:
def self.defaults
{
cache: Hash.new
}
end
end | ||
|
||
def raw | ||
@raw ||= Nokogiri::HTML(open(@url)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets move this into it's the HTML module, just like the Onebox module. That means we'll need to change this to
def raw
raise NoMethodError, "your engine needs to implement this method"
end
and then write a test that makes sure this method doesn't raise an error, just like data
.
You'll also need to include HTML
into all the oneboxes that just use nokogiri.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also write some documentation on what this method needs to do on individual types of engines.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we test HTML
in engine_spec.rb
then? Or have a HTML spec? We don't have one currently for OpenGraph...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, excellent idea.
And we should.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok
Yeah! |
No description provided.