More style
This commit is contained in:
parent
abfaf4c8db
commit
6a75946509
|
@ -647,9 +647,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.79"
|
version = "0.2.80"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2448f6066e80e3bfc792e9c98bf705b4b0fc6e8ef5b43e5889aff0eaa9c58743"
|
checksum = "4d58d1b70b004888f764dfbf6a26a3b0342a1632d33968e4a179d8011c760614"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lock_api"
|
name = "lock_api"
|
||||||
|
|
|
@ -8,7 +8,7 @@ edition = "2018"
|
||||||
bincode = "1.3.1"
|
bincode = "1.3.1"
|
||||||
dirs = "3.0.1"
|
dirs = "3.0.1"
|
||||||
handlebars = "3.5.1"
|
handlebars = "3.5.1"
|
||||||
serde = { version = "1.0.116", features = ["derive"] }
|
serde = { version = "1.0.117", features = ["derive"] }
|
||||||
serde_json = "1.0.59"
|
serde_json = "1.0.59"
|
||||||
sha2 = "0.9.1"
|
sha2 = "0.9.1"
|
||||||
sled = "0.34.4"
|
sled = "0.34.4"
|
||||||
|
|
|
@ -21,15 +21,15 @@ pub async fn start_server(
|
||||||
let templates = Arc::new(templates);
|
let templates = Arc::new(templates);
|
||||||
|
|
||||||
let ads = vec![];
|
let ads = vec![];
|
||||||
|
|
||||||
let mut data = Map::<String, Json>::new();
|
let mut data = Map::<String, Json>::new();
|
||||||
data.insert("lang".into(), to_json("fr"));
|
data.insert("lang".into(), to_json("fr"));
|
||||||
data.insert("ads".into(), to_json(ads.clone()));
|
data.insert("ads".into(), to_json(ads.clone()));
|
||||||
|
|
||||||
let ads = Arc::new(RwLock::new(ads));
|
let ads = Arc::new(RwLock::new(ads));
|
||||||
|
|
||||||
let data = Arc::new(RwLock::new(data));
|
let data = Arc::new(RwLock::new(data));
|
||||||
|
|
||||||
let handle_index = {
|
let handle_index = {
|
||||||
let data = data.clone();
|
let data = data.clone();
|
||||||
move || {
|
move || {
|
||||||
|
@ -46,28 +46,26 @@ pub async fn start_server(
|
||||||
.and(warp::get())
|
.and(warp::get())
|
||||||
.and(warp::fs::dir(opt.dir.0.join(static_files::STATIC_DIR)));
|
.and(warp::fs::dir(opt.dir.0.join(static_files::STATIC_DIR)));
|
||||||
|
|
||||||
let route_index = warp::path::end()
|
let route_index = warp::path::end().and(
|
||||||
.and(
|
warp::get().map(handle_index.clone()).or(warp::post()
|
||||||
warp::get()
|
.and(warp::body::form::<NewAdQuery>())
|
||||||
.map(handle_index.clone())
|
.map(move |ad: NewAdQuery| {
|
||||||
.or(warp::post()
|
let mut hasher = Sha512Trunc256::new();
|
||||||
.and(warp::body::form::<NewAdQuery>())
|
hasher.update(ad.password);
|
||||||
.map(move |ad: NewAdQuery| {
|
ads.write().unwrap().push(Ad {
|
||||||
let mut hasher = Sha512Trunc256::new();
|
author: ad.author,
|
||||||
hasher.update(ad.password);
|
password: hasher.finalize()[..].try_into().unwrap(),
|
||||||
ads.write().unwrap().push(Ad {
|
pubkey: (!ad.pubkey.is_empty()).then_some(ad.pubkey),
|
||||||
author: ad.author,
|
time: 0,
|
||||||
password: hasher.finalize()[..].try_into().unwrap(),
|
title: ad.title,
|
||||||
pubkey: (!ad.pubkey.is_empty()).then_some(ad.pubkey),
|
});
|
||||||
time: 0,
|
data.write()
|
||||||
title: ad.title,
|
.unwrap()
|
||||||
});
|
.insert("ads".into(), to_json(&*ads.read().unwrap()));
|
||||||
data.write().unwrap().insert("ads".into(), to_json(&*ads.read().unwrap()));
|
handle_index()
|
||||||
handle_index()
|
})),
|
||||||
})
|
);
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
warp::serve(route_static.or(route_index))
|
warp::serve(route_static.or(route_index))
|
||||||
.run(config.listen)
|
.run(config.listen)
|
||||||
.await;
|
.await;
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
pub const STATIC_DIR: &'static str = "static";
|
pub const STATIC_DIR: &'static str = "static";
|
||||||
static STATIC_FILES: &'static [(&str, &[u8])] =
|
static STATIC_FILES: &'static [(&str, &[u8])] = &[
|
||||||
&[("style1.css", include_bytes!("../static/style1.css")), ("standgm.png", include_bytes!("../static/standgm.png"))];
|
("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) {
|
pub fn init_static_files(dir: &Path) {
|
||||||
let dir = dir.join(STATIC_DIR);
|
let dir = dir.join(STATIC_DIR);
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 73 KiB |
|
@ -1,8 +1,24 @@
|
||||||
html, body {
|
html, body {
|
||||||
|
width: 100%;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#logo {
|
#banner {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
#stand {
|
||||||
width: 200px;
|
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"/>
|
<link rel="stylesheet" href="/static/style1.css"/>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>ĞMarché</h1>
|
<div class="center">
|
||||||
|
<img id="banner" alt="ĞMarché" src="/static/banner.jpg"/>
|
||||||
<img id="logo" alt="Marché" src="/static/standgm.png"/>
|
|
||||||
|
<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>
|
|
||||||
|
<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>
|
<table border="1">
|
||||||
<tr><td>Annonce</td><td>Vendeur</td></tr>
|
<thead>
|
||||||
</thead>
|
<tr><td>Annonce</td><td>Vendeur</td></tr>
|
||||||
<tbody>
|
</thead>
|
||||||
{{#each ads}}
|
<tbody>
|
||||||
<tr>
|
{{#each ads}}
|
||||||
<td>{{this.title}}</td>
|
<tr>
|
||||||
<td>{{#if this.pubkey}}<details><summary>{{this.author}}</summary><br/>{{this.pubkey}}</details>{{else}}{{this.author}}{{/if}}</td>
|
<td>{{this.title}}</td>
|
||||||
</tr>
|
<td>{{#if this.pubkey}}<details><summary>{{this.author}}</summary><br/>{{this.pubkey}}</details>{{else}}{{this.author}}{{/if}}</td>
|
||||||
{{/each}}
|
</tr>
|
||||||
</tbody>
|
{{/each}}
|
||||||
</table>
|
</tbody>
|
||||||
|
</table>
|
||||||
<form method="post">
|
|
||||||
<fieldset>
|
<img id="stand" alt="Marché" src="/static/standgm.png"/>
|
||||||
<legend>Nouvelle annonce</legend>
|
|
||||||
<label for="f_title">Titre :</label>
|
<form method="post">
|
||||||
<input type="text" id="f_title" name="title"/><br />
|
<fieldset>
|
||||||
<label for="f_author">Votre nom :</label>
|
<legend>Nouvelle annonce</legend>
|
||||||
<input type="text" id="f_author" name="author"/><br />
|
<label for="f_title">Titre :</label>
|
||||||
<label for="f_pubkey">Clé publique :</label>
|
<input type="text" id="f_title" name="title"/><br />
|
||||||
<input type="text" id="f_pubkey" name="pubkey"/><br />
|
<label for="f_author">Votre nom :</label>
|
||||||
<label for="f_password">Mot de passe :</label>
|
<input type="text" id="f_author" name="author"/><br />
|
||||||
<input type="text" id="f_password" name="password"/><br />
|
<label for="f_pubkey">Clé publique :</label>
|
||||||
<input type="submit" value="Publier"/>
|
<input type="text" id="f_pubkey" name="pubkey"/><br />
|
||||||
</fieldset>
|
<label for="f_password">Mot de passe :</label>
|
||||||
</form>
|
<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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue