summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKjetil Orbekk <kjetil.orbekk@gmail.com>2017-07-09 11:22:58 -0400
committerKjetil Orbekk <kjetil.orbekk@gmail.com>2017-07-09 11:22:58 -0400
commit444faa5936d9729a5ef270ce676bfdaf5210bb47 (patch)
tree0a33a44f9a5de27ba12cfb96b54b93e70e4a89a9
parenta307c4b856fa5cff7d3499a432eb50fe1fb57a23 (diff)
add: Form to add new quote
-rw-r--r--src/data/templates/add.hbs74
-rw-r--r--src/server.rs14
2 files changed, 88 insertions, 0 deletions
diff --git a/src/data/templates/add.hbs b/src/data/templates/add.hbs
new file mode 100644
index 0000000..1f5d782
--- /dev/null
+++ b/src/data/templates/add.hbs
@@ -0,0 +1,74 @@
+<!doctype html>
+<html lang="no">
+ <head>
+ <meta name="robots" content="noindex, nofollow" />
+ <link rel="shortcut icon" href="/favicon.ico" />
+ <title>Quotes fra #linux.no på freenode</title>
+ <style type="text/css">
+ body {
+ font-family: monospace;
+ background: #ffffff;
+ color: #000000;
+ }
+ a, a:visited {
+ color: #000000;
+ }
+ hr {
+ border-style: solid;
+ border-color: black;
+ border-width: 1px;
+ }
+ .ragebutton {
+ font-family: monospace;
+ text-align: left;
+ text-decoration: underline;
+ color: black;
+ background: none;
+ margin: 0;
+ padding: 0;
+ border: none;
+ cursor: pointer;
+ -moz-user-select: text;
+ }
+ </style>
+ </head>
+ <body>
+
+<pre>
+ _ _
+ | (_)_ __ _ ___ __ _ __ ___
+ _|_|_ | | | '_ \| | | \ \/ / | '_ \ / _ \
+ _|_|_ | | | | | | |_| |) ( _| | | | (_) |
+ | | |_|_|_| |_|\__,_/_/\_(_)_| |_|\___/
+ -=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=- GAMMA -=-
+
+ Legg til new quote
+
+ -=-=-=-=-=-=-=-=-=-=-
+</pre>
+<hr>
+
+<form action="add.jsp" method="post">
+ditt nick:<br>
+<input type=text name="nick" size=20><br>
+dato, YYYY-MM-DD (blank for dagens dato):<br>
+<input type=text name="date" size=20><br>
+quote:<br>
+<textarea name="quote" rows="20" cols="80"></textarea><br>
+Prøv å bruke sånn ca. samme timestamp-format (HH:MM) o.l. som eksisterende quotes :-)<br><br>
+<input type="submit" value="Legg til">
+</form>
+<a href="quotes.jsp">&lt;- Tilbake til quotes</a>
+
+<center>
+<br>
+<p>linoquotes v.3 © 2004-2017 Kjetil Ørbekk, Erlend Hamberg, Vidar Holen, John H. Anthony.
+<p>Source code at <a href="https://git.orbekk.com/linoquotes-gamma.git">https://git.orbekk.com/linoquotes-gamma.git</a>.
+<p>The quotes on this page are copyright their respective owners and submitters.</p>
+</center>
+
+ </body>
+</html>
+
+
+
diff --git a/src/server.rs b/src/server.rs
index 5d30cf7..2b0cff8 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -27,6 +27,10 @@ fn make_renderer() -> HandlebarsEngine {
"quotes".to_string(),
include_str!("data/templates/quotes.hbs").to_string(),
);
+ templates.insert(
+ "add".to_string(),
+ include_str!("data/templates/add.hbs").to_string(),
+ );
e.add(Box::new(MemorySource(templates)));
if let Err(r) = e.reload() {
@@ -62,10 +66,20 @@ fn quotes(r: &mut Request) -> IronResult<Response> {
)))
}
+fn add_get(r: &mut Request) -> IronResult<Response> {
+ Ok(Response::with((
+ status::Ok,
+ Header(ContentType::html()),
+ Template::new("add", Map::new()),
+ )))
+}
+
pub fn serve(state: State, port: u16) {
let router =
router!(
index: get "/" => quotes,
+ add_get: get "/add.jsp" => add_get,
+ quotes_jsp: get "/quotes.jsp" => quotes,
view_quote: get "/view_quote" => quotes,
);
let mut chain = Chain::new(router);