aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTill Hoeppner2014-11-30 00:32:47 +0100
committerTill Hoeppner2014-11-30 00:32:47 +0100
commit1c47df37c56da0ec30920ac98eb0d15c213ffd4c (patch)
tree12cc95d940f89eb93b85941be9baee2f536cc0f2 /src
parent0d159dabf4cd038d0dd690e44ed1d08e26247606 (diff)
downloadsersve-1c47df37c56da0ec30920ac98eb0d15c213ffd4c.tar.gz
sersve-1c47df37c56da0ec30920ac98eb0d15c213ffd4c.tar.xz
sersve-1c47df37c56da0ec30920ac98eb0d15c213ffd4c.zip
Optimised default template
Diffstat (limited to 'src')
-rw-r--r--src/constants.rs125
-rw-r--r--src/sersve.rs2
2 files changed, 65 insertions, 62 deletions
diff --git a/src/constants.rs b/src/constants.rs
index 3f54284..351ba5f 100644
--- a/src/constants.rs
+++ b/src/constants.rs
@@ -1,107 +1,110 @@
+pub const OPT_TEMPLATE: &'static str =
+"<!DOCTYPE html> <html> <title>{{title}}</title> <style type=\"text/css\"> * { padding:0; margin:0; } body { color: #333; font: 14px Sans-Serif; padding: 50px; background: #eee; } h1 { text-align: center; padding: 20px 0 12px 0; margin: 0; } h2 { font-size: 16px; text-align: center; padding: 0 0 12px 0; } #container { box-shadow: 0 5px 10px -5px rgba(0,0,0,0.5); position: relative; background: white; } table { background-color: #F3F3F3; border-collapse: collapse; width: 100%; margin: 15px 0; } th { background-color: #215fa4; color: #FFF; cursor: pointer; padding: 5px 10px; } th small { font-size: 9px; } td, th { text-align: left; } a { text-decoration: none; } td a { color: #001c3b; display: block; padding: 5px 10px; } th a { padding-left: 0 } tr:nth-of-type(odd) { background-color: #E6E6E6; } tr:hover td { background-color:#CACACA; } tr:hover td a { color: #000; } </style> <body> <div id=\"container\"> <h1>{{title}}</h1> <table> <thead> <tr> <th>Name</th> <th>Size</th> </tr> </thead> <tbody> {{#content}} <tr> <td> <a href=\"/{{url}}\">{{name}}</a> </td> <td> {{size}} </td> </tr> {{/content}} </tbody> </table> </div> </body> </html>";
+
pub const TEMPLATE: &'static str =
"<!DOCTYPE html>
<html>
- <title>{{title}}</title>
- <style type=\"text/css\">
+<title>{{title}}</title>
+<style type=\"text/css\">
* {
- padding:0;
- margin:0;
+padding:0;
+margin:0;
}
body {
- color: #333;
- font: 14px Sans-Serif;
- padding: 50px;
- background: #eee;
+color: #333;
+font: 14px Sans-Serif;
+padding: 50px;
+background: #eee;
}
h1 {
- text-align: center;
- padding: 20px 0 12px 0;
- margin: 0;
+text-align: center;
+padding: 20px 0 12px 0;
+margin: 0;
}
h2 {
- font-size: 16px;
- text-align: center;
- padding: 0 0 12px 0;
+font-size: 16px;
+text-align: center;
+padding: 0 0 12px 0;
}
#container {
- box-shadow: 0 5px 10px -5px rgba(0,0,0,0.5);
- position: relative;
- background: white;
+box-shadow: 0 5px 10px -5px rgba(0,0,0,0.5);
+position: relative;
+background: white;
}
table {
- background-color: #F3F3F3;
- border-collapse: collapse;
- width: 100%;
- margin: 15px 0;
+background-color: #F3F3F3;
+border-collapse: collapse;
+width: 100%;
+margin: 15px 0;
}
th {
- background-color: #215fa4;
- color: #FFF;
- cursor: pointer;
- padding: 5px 10px;
+background-color: #215fa4;
+color: #FFF;
+cursor: pointer;
+padding: 5px 10px;
}
th small {
- font-size: 9px;
+font-size: 9px;
}
td, th {
- text-align: left;
+text-align: left;
}
a {
- text-decoration: none;
+text-decoration: none;
}
td a {
- color: #001c3b;
- display: block;
- padding: 5px 10px;
+color: #001c3b;
+display: block;
+padding: 5px 10px;
}
th a {
- padding-left: 0
+padding-left: 0
}
tr:nth-of-type(odd) {
- background-color: #E6E6E6;
+background-color: #E6E6E6;
}
tr:hover td {
- background-color:#CACACA;
+background-color:#CACACA;
}
tr:hover td a {
- color: #000;
+color: #000;
}
- </style>
- <body>
- <div id=\"container\">
- <h1>{{title}}</h1>
- <table>
- <thead>
- <tr>
- <th>Name</th>
- <th>Size</th>
- </tr>
- </thead>
- <tbody>
- {{#content}}
- <tr>
- <td>
- <a href=\"/{{url}}\">{{name}}</a>
- </td>
- <td>
- {{size}}
- </td>
- </tr>
- {{/content}}
- </tbody>
- </table>
- </div>
- </body>
+</style>
+<body>
+ <div id=\"container\">
+ <h1>{{title}}</h1>
+ <table>
+ <thead>
+ <tr>
+ <th>Name</th>
+ <th>Size</th>
+ </tr>
+ </thead>
+ <tbody>
+ {{#content}}
+ <tr>
+ <td>
+ <a href=\"/{{url}}\">{{name}}</a>
+ </td>
+ <td>
+ {{size}}
+ </td>
+ </tr>
+ {{/content}}
+ </tbody>
+ </table>
+ </div>
+</body>
</html>";
diff --git a/src/sersve.rs b/src/sersve.rs
index 203bab4..da8ffe2 100644
--- a/src/sersve.rs
+++ b/src/sersve.rs
@@ -264,7 +264,7 @@ fn main() {
options.port.clone().unwrap_or(8080))
};
- let template = mustache::compile_str(options.template.clone().unwrap_or(constants::TEMPLATE.into_string())[]);
+ let template = mustache::compile_str(options.template.clone().unwrap_or(constants::OPT_TEMPLATE.into_string())[]);
let state = State {
template: template
};