-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat(preview): added preview images #848
Conversation
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.
may I confrim that the API design here is such that
if site's favicon does not exist, we still return a 200 {imageUrl : undefined}
? I remember you mentioned that we timeout here, but the design of this pr seems to be what I would have requested changes for haha
@kishore03109 Thanks for reviewing my PRs 💯 |
@caando Bump on this > if site's favicon does not exist, we still return a 200 {imageUrl : undefined}? I remember you mentioned that we timeout here, but the design of this pr seems to be what I would have requested changes for haha TLDR; we shouldnt be
|
Problem
CMS dashboard page displays Isomer logo for all sites
Closes IS-266
Solution
This PR implements new POST backend endpoint that takes in a list of site names and try to get urls of preview images for those site. It tries to get the favicon from production site as preview image by parsing the HTML from index page, using a GET request to the url of the production site. If it is unsuccessful, undefined will be returned.
Breaking Changes
Features:
/sites/preview/
POST endpoint that returns the image urls for the favicons of the requested sites.Before & After Screenshots
BEFORE:
AFTER:
Tests
Visual test by visiting the dashboard of all sites.
New dependencies:
dependency
: jsdom, which is previously already a dependancy of the backend. This PR adds@types/jsdom
topackage.json
.Note
Requires isomerpages/isomercms-frontend#1360 to be merged in.
The
/sites/preview
is a POST endpoint as the frontend sends a list of sites to obtain previews for. This is to support GitHub login users who we don't have the list of sites for users in the db. However, using GET endpoint without sending a list of sites is ideal for caching of responses. Should all users be migrated to email based login in the future, a db query with session data can be used to obtain list of sites and endpoint can be changed to GET.We also deny this feature to admin users or request with more than limit (50) number of sites as they are most likely made by admin Github users. This is because fetching previews is expensive and incur high latency. As admin users have hundreds of sites, this results in high load for the system.
Todo
Add tests