Closed ericfranz closed 7 years ago
Files:
More tools/tips on inlining CSS:
And the HTML template can be an erb as well, rendered using the <%= app_init_url %>
, so this will make it easier to work with.
This erb should work:
<html>
<body style="font-family: 'Helvetica Neue', Helvetica,Arial,sans-serif;font-size: 16px;
line-height: 1.4;color: #333;font-weight: 300;padding: 15px;">
<h2 style="font-weight: 500;font-size: 30px;">App has not yet been initialized or does not exist</h2>
<p style="color: #a94442;">Restarting your per-user web server will initialize
this app's config and make it available to you. This will reset any web socket
connections. If you have the Shell app open, please save your work prior to
clicking "Initialize App" below.</p>
<p>If the app has already been initialized, clicking "Initialize App" will
simply restart your web server, making the app available to you.</p>
<a href="<%= app_init_url %>" style="text-decoration: none;font-weight: 400;
padding: 10px 16px;border-radius: 6px;color: #fff;background-color: #d9534f;">Initialize App</a>
</body>
</html>
Produces this:
Which may just be good enough. Render it to a string, using erb, then escape the result before using it in the pun config rendering:
rendered_html_string.gsub '"', '\"'
This is a rewriting of the original issue https://github.com/OSC/mod_ood_proxy/issues/7
The solution is instead of restarting immediately, show a warning to the user, explaining the cost of restarting. This warning page can be presented to the user either in the pun config or in the /nginx/init handler. Clicking init would result in the new config being created if the app exists.
Ideally, we would we present 404 if the app does not exist. However, it would appear that Apache would be responsible for displaying this 404, but the PUN would be responsible for determining the problem, and we wouldn't want to use a redirect for the PUN to let Apache know this - rather, probably, custom headers and more complex proxying code than what we currently use. So we table that for now.
The simplest solution currently is to present the warning with the option to init the app in the PUN config.
We can modify https://github.com/OSC/nginx_stage/blob/dbdda7ad202350135a970bebfba379f638284f7c/templates/pun.conf.erb#L61-L65:
Then if I go to a new app I see this:
If I click the app link, and the app doesn't exist, I see this:
But now this means that both responses are static HTML strings returned by NGINX or Apache lua module. So we can easily change these, especially since both NGINX and Lua allow you to add newlines to the strings.
The end result after determining the simplified HTML will look something like this:
This HTML can be embedded in the nginx_stage repo and provided as a variable used when rendering the PUN.
So the result will be something more like: