Add number of hits to search results.
This commit is contained in:
parent
e263e54649
commit
bb0751f37c
@ -22,6 +22,10 @@ body {
|
||||
|
||||
h1 {
|
||||
margin: .3em 0;
|
||||
small.n_hits {
|
||||
font-weight: normal;
|
||||
font-size: 1ex;
|
||||
}
|
||||
}
|
||||
|
||||
p {
|
||||
|
@ -71,11 +71,12 @@ pub fn search(context: Context, query: Vec<(String, String)>) -> Response {
|
||||
.load(&c)
|
||||
.unwrap();
|
||||
|
||||
let n = photos.len();
|
||||
let coords = get_positions(&photos, &c);
|
||||
let links = split_to_group_links(&photos, &query.to_base_url(), true);
|
||||
|
||||
Builder::new()
|
||||
.html(|o| templates::search(o, &context, &query, &links, &coords))
|
||||
.html(|o| templates::search(o, &context, &query, n, &links, &coords))
|
||||
.unwrap()
|
||||
}
|
||||
|
||||
|
@ -1,12 +1,12 @@
|
||||
@use super::{data_positions, page_base, photo_link};
|
||||
@use super::{base, data_positions, photo_link};
|
||||
@use crate::models::Coord;
|
||||
@use crate::server::{Context, PhotoLink};
|
||||
@use crate::server::search::SearchQuery;
|
||||
|
||||
@(context: &Context, query: &SearchQuery, photos: &[PhotoLink], coords: &[(Coord, i32)])
|
||||
|
||||
@:page_base(context, "Search", &[], {}, {
|
||||
|
||||
@(context: &Context, query: &SearchQuery, n: usize, photos: &[PhotoLink], coords: &[(Coord, i32)])
|
||||
@:base(context, "Search", &[], {}, {
|
||||
<main>
|
||||
<h1>Search@if n > 0 { <small class="n_hits">(@n hits)</small>}</h1>
|
||||
<form class="search" action="/search/" method="get">
|
||||
<label for="s_q" accesskey="s" title="Search">🔍</label>
|
||||
<div class="refs">
|
||||
@ -40,4 +40,5 @@
|
||||
<div class="group"@:data_positions(coords)>
|
||||
@for p in photos {@:photo_link(p)}
|
||||
</div>
|
||||
</main>
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user