diff options
| -rw-r--r-- | src/data/templates/quotes.hbs | 4 | ||||
| -rw-r--r-- | src/server.rs | 6 | 
2 files changed, 8 insertions, 2 deletions
| diff --git a/src/data/templates/quotes.hbs b/src/data/templates/quotes.hbs index 92cf114..ff66d8e 100644 --- a/src/data/templates/quotes.hbs +++ b/src/data/templates/quotes.hbs @@ -15,6 +15,8 @@ Dato: {{date}}, Score:  <br>  <hr>  {{/each}} +{{#if display_more}} +<a href="quotes.jsp?limit=999999">Alle quotes</a> +{{/if}}  {{/inline}} -  {{~> base~}} diff --git a/src/server.rs b/src/server.rs index 8a45e37..84bebb4 100644 --- a/src/server.rs +++ b/src/server.rs @@ -111,6 +111,9 @@ fn quotes(r: &mut Request) -> IronResult<Response> {          |id| id.parse::<i64>().ok(),      );      let ordering = get_param(r, "order").unwrap_or("".to_string()); +    let limit = get_param(r, "limit").ok().and_then( +        |limit| limit.parse::<usize>().ok(), +    ).unwrap_or(200);      let quotes = {          let mu = r.get::<Write<State>>().unwrap(); @@ -120,9 +123,10 @@ fn quotes(r: &mut Request) -> IronResult<Response> {              None => data::get_quotes(&state.connection, user_id.0, &ordering)?,          }      }; -    let quotes = quotes.into_iter().collect::<Vec<_>>(); +    let quotes = quotes.into_iter().take(limit).collect::<Vec<_>>();      result.insert("quotes".to_string(), to_json("es));      result.insert("scores".to_string(), to_json(&(1..6).collect::<Vec<_>>())); +    result.insert("display_more".to_string(), to_json(&(quotes.len() == limit)));      Ok(Response::with((          status::Ok,          Header(ContentType::html()), | 
