Skip to content
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

social cards - part 1 #1

Draft
wants to merge 10 commits into
base: master
Choose a base branch
from
Draft

Conversation

mscoutermarsh
Copy link
Owner

SocialPreviewsController can now render .pngs via HTML/CSS to Image.

Screen Recording 2019-03-16 at 03 07 PM

This will be used by social_previews to convert the templates into images.

Setup a fallback image primarily for local dev, so that this won't cause
errors if authentication is missing.

Caching is setup to use contents of the html/css. So it with
autobust/generate a new image whenever the markup changes.
+ Being random breaks caching (since we generate cachekey by a SHA of html content)
+ Use Roboto for when generating via HTML/CSS to Image
+ Make rand deterministic so it doesn't break caching
When adding .png to the url, these routes will now generate an image and
redirect to it.

This leaves the existing pages as they were, so we're backwards
compatible with all the existing links out in the world.
before do
stub_request(:post, /hcti.io/).
to_return(status: 200,
body: '{ "url": "https://hcti.io/v1/image/6c52de9d-4d37-4008-80f8-67155589e1a1" }',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about extracting the return-url into a let that you can re-use here and the assertions

expect(response).to render_template(:shecoded)
end

it "requesting png generates an image and redirects to image url" do
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"requesting png ..." reads a bit funny in these descriptions of the tests, wonder if it's more clear if you just omit it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants