-
Notifications
You must be signed in to change notification settings - Fork 328
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
Added support for preview links #2184 #2187
base: main
Are you sure you want to change the base?
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.
Thanks for working on this @seagulley! I would like to see some demo to test these changes in action.
PreviewImage string | ||
PreviewTitle string | ||
PreviewDescription string |
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.
Make these part of the https://github.com/h2oai/wave/blob/94bf37f538719ad279a41b0df1b452623d61aaa4/conf.go#L71C7-L71C7 as well to expose new options to the users.
Also document here.
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.
I'll get started on this as well as a demo :)
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.
Hi Martin,
I started working on the demo. Using Meta's Open Graph debugger, it can read the custom title and description, but there are some issues with the image.
I did some more digging and there are some guidelines for adding images to preview links
https://developers.facebook.com/docs/sharing/best-practices/#precaching
How should I approach this?
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.
The warning says all it needs are og:image:height
and og:image:width
props. I would first try it out to see if they help. If they do, the next step would be to validate passed image dimensions and:
- If the image does not adhere to the recommended ratio or is too small, log warning and use the actual dimensions for the respective props.
- If the image ratio is good and >= required dimensions, use the copy of the image resized to the expected dimensions.
Hope that makes sense.
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 that makes sense I'll get started on it!
if auth != nil { | ||
fs = auth.wrap(fs) | ||
} | ||
return &WebServer{site, broker, fs, keychain, maxRequestSize, baseURL}, nil | ||
} | ||
|
||
func mungeIndexPage(baseURL, html string) string { | ||
func mungeIndexPage(baseURL, html string, previewImage string, previewTitle string, previewDescription string) string { |
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.
nit: Should be enough.
func mungeIndexPage(baseURL, html string, previewImage string, previewTitle string, previewDescription string) string { | |
func mungeIndexPage(baseURL, html, previewImage, previewTitle, previewDescription string) string { |
The PR fulfills these requirements: (check all the apply)
main
branch.feat: Add a button #xxx
, where "xxx" is the issue number).Closes #xxx
, where "xxx" is the issue number.ui
folder, unit tests (make test
) still pass.Added new variables to conf.go ServerConf: PreviewImage, PreviewTitle, PreviewDescription.
Modified web_server.go to use these new values as meta tags in the header of the root index.html.
Closes #2184