Move diagnostics page to use Ritz, show server version

This commit is contained in:
Lucien Greathouse
2019-02-19 11:27:22 -08:00
parent 2890c677d4
commit aaa78c618c
6 changed files with 120 additions and 56 deletions

View File

@@ -29,6 +29,7 @@ rbx_dom_weak = "0.3.0"
rbx_xml = "0.3.0"
regex = "1.0"
reqwest = "0.9.5"
ritz = "0.1.0"
rouille = "2.1"
serde = "1.0"
serde_derive = "1.0"

43
server/assets/index.css Normal file
View File

@@ -0,0 +1,43 @@
* {
margin: 0;
padding: 0;
font: inherit;
}
html {
font-family: sans-serif;
height: 100%;
}
body {
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
}
.main {
padding: 1rem;
text-align: center;
margin: 0 auto;
width: 100%;
max-width: 60rem;
background-color: #efefef;
border: 1px solid #666;
border-radius: 4px;
}
.title {
font-size: 2rem;
font-weight: bold;
}
.subtitle {
font-size: 1.5rem;
font-weight: bold;
}
.docs {
font-size: 1.3rem;
font-weight: bold;
}

View File

@@ -1,54 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Rojo</title>
<style>
* {
margin: 0;
padding: 0;
font: inherit;
}
html {
font-family: sans-serif;
height: 100%;
}
body {
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
}
.main {
padding: 1rem;
text-align: center;
margin: 0 auto;
width: 100%;
max-width: 60rem;
background-color: #efefef;
border: 1px solid #666;
border-radius: 4px;
}
.title {
font-size: 2rem;
font-weight: bold;
}
.docs {
font-size: 1.5rem;
font-weight: bold;
}
</style>
</head>
<body>
<div class="main">
<h1 class="title">Rojo Live Sync is up and running!</h1>
<a class="docs" href="https://lpghatguy.github.io/rojo">Rojo Documentation</a>
</div>
</body>
</html>

View File

@@ -1,3 +1,5 @@
#![recursion_limit="128"]
// Macros
#[macro_use]
pub mod impl_from;

View File

@@ -16,6 +16,7 @@ use rouille::{
Response,
};
use rbx_dom_weak::{RbxId, RbxInstance};
use ritz::{html};
use crate::{
live_session::LiveSession,
@@ -25,7 +26,7 @@ use crate::{
rbx_session::{MetadataPerInstance},
};
static HOME_CONTENT: &str = include_str!("../assets/index.html");
static HOME_CSS: &str = include_str!("../assets/index.css");
/// Contains the instance metadata relevant to Rojo clients.
#[derive(Debug, Serialize, Deserialize)]
@@ -134,7 +135,32 @@ impl Server {
}
fn handle_home(&self) -> Response {
Response::html(HOME_CONTENT)
let page = html! {
<html>
<head>
<title>"Rojo"</title>
<style>
{ ritz::UnescapedText::new(HOME_CSS) }
</style>
</head>
<body>
<div class="main">
<h1 class="title">
"Rojo Live Sync is up and running!"
</h1>
<h2 class="subtitle">
"Version " { self.server_version }
</h2>
<a class="docs" href="https://lpghatguy.github.io/rojo">
"Rojo Documentation"
</a>
</div>
</body>
</html>
};
Response::html(format!("<!DOCTYPE html>{}", page))
}
/// Get a summary of information about the server