Commit graph

6 commits

Author SHA1 Message Date
Ben Halpern
d822d8d7d9
Fall back to configured social image instead of hardcoded (#9747)
* Fall back to configured social image instead of hardcoded

* Move from constant to method for config inclusion

* Fix spec

* Fix test
2020-10-27 08:54:45 -04:00
Mike Coutermarsh
9f983e271c Increase cache TTL for social preview images (#5471) [deploy]
* Increase cache TTL for social preview images

These are expensive to generate + don't change often. We can have a long cache.

Ideally, they would never expire, and get auto evicted by redis when space fills up. But I don't think a `nil` ttl is possible when a default
is set in the Rails config (see production.rb).

So I set it to a real long value. + test to guard against it accidently being changed.

* Try a cache expiration of 6.weeks as suggested by @mstruve in PR
2020-01-17 17:06:06 -05:00
Molly Struve
7c650dcb1c
Remove RedisRailsCache and replace with Rails.cache (#5059) [deploy] 2019-12-10 13:11:08 -06:00
jeffin sam
f023a00d9f add html_css_to_image to RedisRailsCache (#4753) [deploy] 2019-11-28 09:44:31 -05:00
jeffin sam
7cc5ef5e40 Write to RedisCache to avoid cache miss in add html_css_to_image (#4821) [deploy] 2019-11-15 13:09:18 -05:00
Mike Coutermarsh
dd84051ce4 Social Card upgrade - Part 1 (#2090)
* Add HtmlCssToImage for generating images

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.

* Update Article social preview template to not be random

+ Being random breaks caching (since we generate cachekey by a SHA of html content)
+ Use Roboto for when generating via HTML/CSS to Image

* Update Tag social preview template to not be random

+ Make rand deterministic so it doesn't break caching

* Update user social preview template for html/csstoimage

* Update shecoded template to work with both url2png and htmlcsstoimage

* Add ability to respond to .png for social previews controller

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.

* Fix merge conflicts

* Remove some duplication

* Improve spec descriptions/read better

* clean up setting template with a ternary
2019-03-22 16:28:02 -04:00