Add asynchronous page content request
This commit is contained in:
parent
ed4e749901
commit
244edf90ac
@ -144,6 +144,19 @@
|
|||||||
<h1><span><%= hostname %></span> status - MALP</h1>
|
<h1><span><%= hostname %></span> status - MALP</h1>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
<% if authenticated %>
|
||||||
|
<div id="content"></div>
|
||||||
|
<script>
|
||||||
|
fetch("?content", { credentials: "same-origin" })
|
||||||
|
.then(function(response) {
|
||||||
|
if (response.ok) return response.text();
|
||||||
|
})
|
||||||
|
.then(function(html) {
|
||||||
|
if (html) document.getElementById("content").innerHTML = html;
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<% unless authenticated %>
|
<% unless authenticated %>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-title">Sign In</div>
|
<div class="card-title">Sign In</div>
|
||||||
|
|||||||
@ -79,6 +79,19 @@ if cgi.request_method == "POST" && !authenticated
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if cgi.params.key?("content")
|
||||||
|
if authenticated
|
||||||
|
cgi.out("type" => "text/html", "charset" => "UTF-8") do
|
||||||
|
"<p>Content placeholder</p>"
|
||||||
|
end
|
||||||
|
else
|
||||||
|
cgi.out("Status" => "403 Forbidden", "type" => "text/plain", "charset" => "UTF-8") do
|
||||||
|
"Forbidden"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
exit
|
||||||
|
end
|
||||||
|
|
||||||
template = ERB.new(File.read(File.join(ASSETS_DIR, "page.erb")))
|
template = ERB.new(File.read(File.join(ASSETS_DIR, "page.erb")))
|
||||||
|
|
||||||
out_params = { "type" => "text/html", "charset" => "UTF-8" }
|
out_params = { "type" => "text/html", "charset" => "UTF-8" }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user