More style, ad detail, remove price column

This commit is contained in:
Pascal Engélibert 2020-12-10 12:19:03 +01:00
parent 533c96649a
commit 9baa8c1a0f
7 changed files with 71 additions and 23 deletions

12
Cargo.lock generated
View File

@ -160,9 +160,9 @@ dependencies = [
[[package]]
name = "const_fn"
version = "0.4.3"
version = "0.4.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c478836e029dcef17fb47c89023448c64f781a046e0300e257ad8225ae59afab"
checksum = "cd51eab21ab4fd6a3bf889e2d0958c0a6e3a61ad04260325e919e652a2a62826"
[[package]]
name = "constant_time_eq"
@ -730,9 +730,9 @@ dependencies = [
[[package]]
name = "net2"
version = "0.2.36"
version = "0.2.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7cf75f38f16cb05ea017784dc6dbfd354f76c223dba37701734c4f5a9337d02"
checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae"
dependencies = [
"cfg-if 0.1.10",
"libc",
@ -1221,9 +1221,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c"
[[package]]
name = "tokio"
version = "0.2.23"
version = "0.2.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a6d7ad61edd59bfcc7e80dababf0f4aed2e6d5e0ba1659356ae889752dfc12ff"
checksum = "099837d3464c16a808060bb3f02263b412f6fafcb5d01c533d309985fbeebe48"
dependencies = [
"bytes",
"fnv",

View File

@ -10,13 +10,13 @@ bs58 = "0.4.0"
dirs = "3.0.1"
handlebars = "3.5.1"
hex = "0.4.2"
http = "0.2"
http = "0.2.1"
rand = "0.7.3"
serde = { version = "1.0.118", features = ["derive"] }
serde_json = "1.0.60"
sha2 = "0.9.2"
sled = "0.34.6"
structopt = "0.3.21"
tokio = { version = "0.2.22", features = ["macros", "rt-threaded"] }
tokio = { version = "0.2.24", features = ["macros", "rt-threaded"] }
urlencoding = "1.1.1"
warp = { version = "0.2.5", default-features = false }

View File

@ -12,6 +12,7 @@ static STATIC_FILES: &[(&str, &[u8])] = &[
include_bytes!("../static/LinBiolinum_R.otf"),
),
("background.jpg", include_bytes!("../static/background.jpg")),
("script1.js", include_bytes!("../static/script1.js")),
];
pub fn init_static_files(dir: &Path) {

8
static/script1.js Normal file
View File

@ -0,0 +1,8 @@
function ad_detail(e, id) {
var el = document.getElementById("ad-detail-"+id);
if(el.className == "ad-detail")
el.className = "ad-detail ad-detail-no"
else
el.className = "ad-detail"
e.preventDefault();
}

View File

@ -48,8 +48,26 @@ h1, h2, h3, h4 {
width: 100%;
}
#ads tr:hover, #ads tr:focus {
background-color: rgba(255,128,0,0.2);
}
#ads input[type=radio] {
width: 100%;
margin: 0;
}
.ad-detail-no {
display: none;
}
#ads a, #ads a:visited {
text-decoration: none;
color: black;
}
fieldset {
border: 1px dashed grey;
border: 1px dashed #ff8000;
}
.center {

View File

@ -5,6 +5,7 @@
<title>Administration | ĞMarché</title>
<link rel="stylesheet" href="/static/style1.css"/>
<link rel="shortcut icon" href="/static/icon.png"/>
<script type="text/javascript" src="/static/script1.js"></script>
</head>
<body>
<div class="center page">
@ -26,32 +27,41 @@
</div>
{{/if}}
{{#if ads}}
<span>Cliquez sur une annonce pour afficher le détail.</span>
<form method="post">
<table id="ads">
<thead>
<tr><td></td><th>Annonce</th><th>Quantité</th><th>Prix</th><th>Vendeur</th></tr>
<tr><td></td><th>Annonce</th><th>Quantité</th><th>Vendeur</th></tr>
</thead>
<tbody>
{{#each ads}}
<tr>
<td><input type="radio" name="ad" value="{{this.id}}" aria-label="Sélectionner l'annonce" required/></td>
<td>{{this.ad.title}}</td>
<td onclick="ad_detail(event,'{{this.id}}')" title="Afficher le détail"><a href="ad/{{this.id}}">{{this.ad.title}}</a></td>
<td>{{this.ad.quantity}}</td>
<td>{{this.ad.price}}</td>
<td>{{#if this.ad.pubkey}}<details><summary>{{this.ad.author}}</summary><br/>{{this.ad.pubkey}}</details>{{else}}{{this.ad.author}}{{/if}}</td>
<td>{{this.ad.author}}</td>
</tr>
<tr id="ad-detail-{{this.id}}" class="ad-detail ad-detail-no">
<td colspan="4"><p>
{{#if this.ad.pubkey}}Clé publique&nbsp;: {{this.ad.pubkey}}<br/>{{/if}}
Prix&nbsp;: {{this.ad.price}}
</p></td>
</tr>
{{/each}}
</tbody>
</table>
<br/>
<input type="hidden" name="a" value="rm_ad" autocomplete="off"/>
<fieldset>
<legend>Supprimer l'annonce sélectionnée</legend>
<input type="submit" value="Supprimer"/>
<button type="submit" name="a" value="rm_ad">Supprimer</button>
</fieldset>
</form>
<br/>
{{else}}
<p>Il n'y a pas encore d'annonce ici.</p>
{{/if}}
</main>
<footer>

View File

@ -5,6 +5,7 @@
<title>ĞMarché</title>
<link rel="stylesheet" href="/static/style1.css"/>
<link rel="shortcut icon" href="/static/icon.png"/>
<script type="text/javascript" src="/static/script1.js"></script>
</head>
<body>
<div class="center page">
@ -26,23 +27,30 @@
</div>
{{/if}}
<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 <del>très</del> moche et il n'y a pas tellement de fonctionnalités mais ça avance. ;)</p>
<p>&#9888; <strong>Merci de ne pas encore utiliser ce site pour de vrais événements&#8239;!</strong></p>
{{#if ads}}
<span>Cliquez sur une annonce pour afficher le détail.</span>
<form method="post">
<table id="ads">
<thead>
<tr><td></td><th>Annonce</th><th>Quantité</th><th>Prix</th><th>Vendeur</th></tr>
<tr><td></td><th>Annonce</th><th>Quantité</th><th>Vendeur</th></tr>
</thead>
<tbody>
{{#each ads}}
<tr>
<td><input type="radio" name="ad" value="{{this.id}}" aria-label="Sélectionner l'annonce" required/></td>
<td>{{this.ad.title}}</td>
<td onclick="ad_detail(event,'{{this.id}}')" title="Afficher le détail"><a href="ad/{{this.id}}">{{this.ad.title}}</a></td>
<td>{{this.ad.quantity}}</td>
<td>{{this.ad.price}}</td>
<td>{{#if this.ad.pubkey}}<details><summary>{{this.ad.author}}</summary><br/>{{this.ad.pubkey}}</details>{{else}}{{this.ad.author}}{{/if}}</td>
<td>{{this.ad.author}}</td>
</tr>
<tr id="ad-detail-{{this.id}}" class="ad-detail ad-detail-no">
<td colspan="4"><p>
{{#if this.ad.pubkey}}Clé publique&nbsp;: {{this.ad.pubkey}}<br/>{{/if}}
Prix&nbsp;: {{this.ad.price}}
</p></td>
</tr>
{{/each}}
</tbody>
@ -57,6 +65,9 @@
</fieldset>
</form>
<br/>
{{else}}
<p>Il n'y a pas encore d'annonce ici.</p>
{{/if}}
<img id="stand" alt="Marché" src="/static/standgm.png"/>
@ -67,9 +78,9 @@
<label for="f_new_title">Titre&nbsp;:</label>
<input type="text" id="f_new_title" name="title" placeholder="Carottes"{{#if new_ad_form_refill}} value="{{new_ad_form_refill.title}}"{{/if}} required/><br/>
<label for="f_new_quantity">Quantité&nbsp;:</label>
<input type="text" id="f_new_quantity" name="quantity" placeholder="10 kg"{{#if new_ad_form_refill}} value="{{new_ad_form_refill.quantity}}"{{/if}} required/><br/>
<input type="text" id="f_new_quantity" name="quantity" placeholder="10 kg"{{#if new_ad_form_refill}} value="{{new_ad_form_refill.quantity}}"{{/if}}/><br/>
<label for="f_new_price">Prix&nbsp;:</label>
<input type="text" id="f_new_price" name="price" placeholder="42 DU/kg"{{#if new_ad_form_refill}} value="{{new_ad_form_refill.price}}"{{/if}} required/><br/>
<input type="text" id="f_new_price" name="price" placeholder="42 DU/kg"{{#if new_ad_form_refill}} value="{{new_ad_form_refill.price}}"{{/if}}/><br/>
<label for="f_new_author">Votre nom&nbsp;:</label>
<input type="text" id="f_new_author" name="author" placeholder="Toto"{{#if new_ad_form_refill}} value="{{new_ad_form_refill.author}}"{{/if}} required/><br/>
<label for="f_new_pubkey">Clé publique&nbsp;:</label>