parent
96011932f6
commit
b969a12595
@ -1,3 +1,4 @@
|
||||
pub mod help;
|
||||
pub mod index;
|
||||
pub mod replay;
|
||||
pub mod submit;
|
||||
|
@ -0,0 +1,36 @@
|
||||
use std::fs::File;
|
||||
use std::io::{BufReader, Read};
|
||||
use std::path::PathBuf;
|
||||
|
||||
use actix_web::http::header;
|
||||
use actix_web::{get, HttpRequest, HttpResponse};
|
||||
use actix_web::web::{Data, Path};
|
||||
|
||||
use handlebars::Handlebars;
|
||||
use log::info;
|
||||
use serde_json::json;
|
||||
|
||||
use crate::Result;
|
||||
|
||||
#[get("/+{id}")]
|
||||
pub async fn get(req: HttpRequest, id: Path<String>, hb: Data<Handlebars<'_>>) -> Result<HttpResponse> {
|
||||
println!("HIHIHI");
|
||||
let mut path = PathBuf::from("replays");
|
||||
let id: String = id.into_inner();
|
||||
path.push(&id);
|
||||
let file: File = File::open(&path)?;
|
||||
info!("loaded file: {:?}", path);
|
||||
let mut buffer = BufReader::new(file);
|
||||
let mut file_contents = String::new();
|
||||
buffer.read_to_string(&mut file_contents)?;
|
||||
info!("read to buffer");
|
||||
|
||||
|
||||
|
||||
let data = json!({
|
||||
"replayid": id,
|
||||
});
|
||||
let body = hb.render("replay", &data).unwrap();
|
||||
|
||||
Ok(HttpResponse::Ok().body(body))
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,81 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>ReWoT</title>
|
||||
<link rel="stylesheet" href="/static/rewot.css" type="text/css">
|
||||
<link rel="stylesheet" href="/static/ansi2html.css" type="text/css">
|
||||
<link rel="stylesheet" href="/static/fontello/css/fontello.css" type="text/css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="top">
|
||||
<h1><a href="/">ReWoT</a></h1>
|
||||
<ul>
|
||||
<li><a href="/latest">latest</a></li>
|
||||
<li><a href="/submit">submit</a></li>
|
||||
<li><a href="/help">help</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="bottom">
|
||||
<table>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
<a href="#" onclick="return speed_up();">
|
||||
<i class="icon-plus" title="Speed up"></i>
|
||||
</a>
|
||||
</td>
|
||||
<td></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="#" onclick="return reverse();">
|
||||
<i class="icon-fast-backward" title="Rewind"></i>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="#" onclick="return play_pause();">
|
||||
<i id="play_pause" class="icon-play" title="Play"></i>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<a href="#" onclick="return forward();">
|
||||
<i class="icon-fast-forward" title="Fast forward"></i>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
<a href="#" onclick="return slow_down();">
|
||||
<i class="icon-minus" title="Slow down"></i>
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
<small>x</small><span id="speed" title="Speed">1</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span style="font-size: x-large;" title="Line number">#</span><span id="lineno" title="Line number"></span>
|
||||
</td>
|
||||
<td colspan=2>
|
||||
<progress id="progress" max="0" value="0"></progress>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<main id="main">
|
||||
|
||||
|
||||
</main>
|
||||
|
||||
<script src="/static/rewot.js"></script>
|
||||
<script>load_log("/replays/{{ replayid }}");</script>
|
||||
</body>
|
||||
|
||||
</html>
|
Loading…
Reference in new issue