More style
This commit is contained in:
parent
abfaf4c8db
commit
6a75946509
|
@ -647,9 +647,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.79"
|
||||
version = "0.2.80"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743"
|
||||
checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614"
|
||||
|
||||
[[package]]
|
||||
name = "lock_api"
|
||||
|
|
|
@ -8,7 +8,7 @@ edition = "2018"
|
|||
bincode = "1.3.1"
|
||||
dirs = "3.0.1"
|
||||
handlebars = "3.5.1"
|
||||
serde = { version = "1.0.116", features = ["derive"] }
|
||||
serde = { version = "1.0.117", features = ["derive"] }
|
||||
serde_json = "1.0.59"
|
||||
sha2 = "0.9.1"
|
||||
sled = "0.34.4"
|
||||
|
|
|
@ -21,15 +21,15 @@ pub async fn start_server(
|
|||
let templates = Arc::new(templates);
|
||||
|
||||
let ads = vec![];
|
||||
|
||||
|
||||
let mut data = Map::<String, Json>::new();
|
||||
data.insert("lang".into(), to_json("fr"));
|
||||
data.insert("ads".into(), to_json(ads.clone()));
|
||||
|
||||
|
||||
let ads = Arc::new(RwLock::new(ads));
|
||||
|
||||
let data = Arc::new(RwLock::new(data));
|
||||
|
||||
|
||||
let handle_index = {
|
||||
let data = data.clone();
|
||||
move || {
|
||||
|
@ -46,28 +46,26 @@ pub async fn start_server(
|
|||
.and(warp::get())
|
||||
.and(warp::fs::dir(opt.dir.0.join(static_files::STATIC_DIR)));
|
||||
|
||||
let route_index = warp::path::end()
|
||||
.and(
|
||||
warp::get()
|
||||
.map(handle_index.clone())
|
||||
.or(warp::post()
|
||||
.and(warp::body::form::<NewAdQuery>())
|
||||
.map(move |ad: NewAdQuery| {
|
||||
let mut hasher = Sha512Trunc256::new();
|
||||
hasher.update(ad.password);
|
||||
ads.write().unwrap().push(Ad {
|
||||
author: ad.author,
|
||||
password: hasher.finalize()[..].try_into().unwrap(),
|
||||
pubkey: (!ad.pubkey.is_empty()).then_some(ad.pubkey),
|
||||
time: 0,
|
||||
title: ad.title,
|
||||
});
|
||||
data.write().unwrap().insert("ads".into(), to_json(&*ads.read().unwrap()));
|
||||
handle_index()
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
let route_index = warp::path::end().and(
|
||||
warp::get().map(handle_index.clone()).or(warp::post()
|
||||
.and(warp::body::form::<NewAdQuery>())
|
||||
.map(move |ad: NewAdQuery| {
|
||||
let mut hasher = Sha512Trunc256::new();
|
||||
hasher.update(ad.password);
|
||||
ads.write().unwrap().push(Ad {
|
||||
author: ad.author,
|
||||
password: hasher.finalize()[..].try_into().unwrap(),
|
||||
pubkey: (!ad.pubkey.is_empty()).then_some(ad.pubkey),
|
||||
time: 0,
|
||||
title: ad.title,
|
||||
});
|
||||
data.write()
|
||||
.unwrap()
|
||||
.insert("ads".into(), to_json(&*ads.read().unwrap()));
|
||||
handle_index()
|
||||
})),
|
||||
);
|
||||
|
||||
warp::serve(route_static.or(route_index))
|
||||
.run(config.listen)
|
||||
.await;
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
use std::path::Path;
|
||||
|
||||
pub const STATIC_DIR: &'static str = "static";
|
||||
static STATIC_FILES: &'static [(&str, &[u8])] =
|
||||
&[("style1.css", include_bytes!("../static/style1.css")), ("standgm.png", include_bytes!("../static/standgm.png"))];
|
||||
static STATIC_FILES: &'static [(&str, &[u8])] = &[
|
||||
("style1.css", include_bytes!("../static/style1.css")),
|
||||
("standgm.png", include_bytes!("../static/standgm.png")),
|
||||
("banner.jpg", include_bytes!("../static/banner.jpg")),
|
||||
];
|
||||
|
||||
pub fn init_static_files(dir: &Path) {
|
||||
let dir = dir.join(STATIC_DIR);
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 73 KiB |
|
@ -1,8 +1,24 @@
|
|||
html, body {
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
#logo {
|
||||
#banner {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#stand {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.center {
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
@media screen and (min-width: 801px) {
|
||||
.center {
|
||||
width: 800px;
|
||||
margin: auto;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,39 +6,48 @@
|
|||
<link rel="stylesheet" href="/static/style1.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<h1>ĞMarché</h1>
|
||||
|
||||
<img id="logo" alt="Marché" src="/static/standgm.png"/>
|
||||
|
||||
<p>Ceci est une démo du nouveau site ĞMarché en développement. C'est très moche et il n'y a pas tellement de fonctionnalités mais ça avance. ;)</p>
|
||||
|
||||
<table border="1">
|
||||
<thead>
|
||||
<tr><td>Annonce</td><td>Vendeur</td></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each ads}}
|
||||
<tr>
|
||||
<td>{{this.title}}</td>
|
||||
<td>{{#if this.pubkey}}<details><summary>{{this.author}}</summary><br/>{{this.pubkey}}</details>{{else}}{{this.author}}{{/if}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<form method="post">
|
||||
<fieldset>
|
||||
<legend>Nouvelle annonce</legend>
|
||||
<label for="f_title">Titre :</label>
|
||||
<input type="text" id="f_title" name="title"/><br />
|
||||
<label for="f_author">Votre nom :</label>
|
||||
<input type="text" id="f_author" name="author"/><br />
|
||||
<label for="f_pubkey">Clé publique :</label>
|
||||
<input type="text" id="f_pubkey" name="pubkey"/><br />
|
||||
<label for="f_password">Mot de passe :</label>
|
||||
<input type="text" id="f_password" name="password"/><br />
|
||||
<input type="submit" value="Publier"/>
|
||||
</fieldset>
|
||||
</form>
|
||||
<div class="center">
|
||||
<img id="banner" alt="ĞMarché" src="/static/banner.jpg"/>
|
||||
|
||||
<h1>ĞMarché</h1>
|
||||
|
||||
<p>Ceci est une démo du nouveau site ĞMarché en développement. C'est très moche et il n'y a pas tellement de fonctionnalités mais ça avance. ;)</p>
|
||||
|
||||
<table border="1">
|
||||
<thead>
|
||||
<tr><td>Annonce</td><td>Vendeur</td></tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each ads}}
|
||||
<tr>
|
||||
<td>{{this.title}}</td>
|
||||
<td>{{#if this.pubkey}}<details><summary>{{this.author}}</summary><br/>{{this.pubkey}}</details>{{else}}{{this.author}}{{/if}}</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<img id="stand" alt="Marché" src="/static/standgm.png"/>
|
||||
|
||||
<form method="post">
|
||||
<fieldset>
|
||||
<legend>Nouvelle annonce</legend>
|
||||
<label for="f_title">Titre :</label>
|
||||
<input type="text" id="f_title" name="title"/><br />
|
||||
<label for="f_author">Votre nom :</label>
|
||||
<input type="text" id="f_author" name="author"/><br />
|
||||
<label for="f_pubkey">Clé publique :</label>
|
||||
<input type="text" id="f_pubkey" name="pubkey"/><br />
|
||||
<label for="f_password">Mot de passe :</label>
|
||||
<input type="text" id="f_password" name="password"/><br />
|
||||
<input type="submit" value="Publier"/>
|
||||
</fieldset>
|
||||
</form>
|
||||
|
||||
<hr />
|
||||
|
||||
<p><a href="https://git.p2p.legal/tuxmain/gmarche-rs">Code source</a> sous licence <a href="https://www.gnu.org/licenses/licenses.html#AGPL">GNU AGPL v3</a>. 🦀 Écrit en <a href="https://www.rust-lang.org">Rust</a>. Images de Attilax.<br/>
|
||||
CopyLeft 2020 Pascal Engélibert</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
|
Loading…
Reference in New Issue