-
Notifications
You must be signed in to change notification settings - Fork 964
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
Simple console error message dialog in zola serve
webpages
#2312
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.
I like that a lot!
let html_error = format!( | ||
r#"<div style="all:revert;position:fixed;display:flex;align-items:center;justify-content:center;background-color:rgb(0,0,0,0.5);top:0;right:0;bottom:0;left:0;"><div style="background-color:white;padding:0.5rem;border-radius:0.375rem;filter:drop-shadow(0,25px,25px,rgb(0,0,0/0.15));overflow-x:auto;"><p style="font-weight:700;color:black;font-size:1.25rem;margin:0;margin-bottom:0.5rem;">Zola Build Error:</p><pre style="padding:0.5rem;margin:0;border-radius:0.375rem;background-color:#363636;color:#CE4A2F;font-weight:700;">{error_str}</pre></div></div>"# | ||
); | ||
bytes.extend(html_error.as_bytes()); |
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.
Can we get some invalid HTML generated by inserting after </html>
?
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, this way is technically invalid HTML, but it worked on all the browsers I tested it on. If that's too much of a problem I can try to remove </html>
before appending the message box 🤔
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.
If it works on all browsers it's fine, not the weirdest HTML they will see
Thanks! |
…#2312) * first attempt at injecting HTML into outgoing webpages * finish error handling * fix test_site debug line
…#2312) * first attempt at injecting HTML into outgoing webpages * finish error handling * fix test_site debug line
…#2312) * first attempt at injecting HTML into outgoing webpages * finish error handling * fix test_site debug line
…#2312) * first attempt at injecting HTML into outgoing webpages * finish error handling * fix test_site debug line
…#2312) * first attempt at injecting HTML into outgoing webpages * finish error handling * fix test_site debug line
Resolves #2303.
This PR creates a mutable static error variable in
crate::cmd::serve
, and inserts a console-like error message dialog onto all outgoing HTML responses. The actual implementation is a little sub-optimal, but it's the best I could do considering two different threads have to share state between 4+ nestedFnMut()
s.I tried to make the message dialog as neutral as possible, if there are any zola-specific styles it should have, let me know :)