gourami

[UNMAINTAINED] Activitypub server in Rust
Log | Files | Refs | README | LICENSE

commit d6e8fc4d0626826a65403a1c249447cc8b6a1769
parent fde55079ce7d0da2d44e49cb23427e44b5635f66
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Mon,  1 Jun 2020 23:20:34 -0500

Bugfixes for page redirection

Diffstat:
MCargo.lock | 1+
MCargo.toml | 1+
Msrc/lib.rs | 14+++++++++++---
Mtemplates/createnote.html | 2+-
4 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -675,6 +675,7 @@ dependencies = [ "ring", "serde", "serde_json", + "serde_urlencoded", "tokio", "url", "uuid", diff --git a/Cargo.toml b/Cargo.toml @@ -29,6 +29,7 @@ ring = "0.16.13" reqwest = {version="0.10.4",features=["json", "blocking"]} serde = { version = "1.0.106", features = ["derive"] } serde_json = "1.0.52" +serde_urlencoded = "0.6.1" tokio = { version = "0.2.18", features = ["macros", "time", "sync"] } url = "2.1.1" uuid = { version = "0.8", features = ["v4"]} diff --git a/src/lib.rs b/src/lib.rs @@ -29,9 +29,11 @@ use db::user::{NewUser, RegistrationKey, User, Username}; use diesel::insert_into; use diesel::prelude::*; use hyper; -use serde::Deserialize; +use serde::{Serialize, Deserialize}; use session::Session; +use serde_urlencoded; + pub mod ap; mod db; pub mod error; @@ -364,7 +366,7 @@ fn do_logout(cook: String) -> impl Reply { redirect(warp::http::Uri::from_static("/")) } -#[derive(Deserialize)] +#[derive(Serialize, Deserialize)] struct GetPostsParams { #[serde(default = "default_page")] page: i64, @@ -476,7 +478,13 @@ fn render_timeline( ) -> impl Reply { // no session -- anonymous // pulls a bunch of data i dont really need - let mut header = Global::create(auth_user, url_path.as_str()); + let url_with_params = &format!("{}?{}", url_path.as_str(), serde_urlencoded::to_string(params).unwrap()); + let mut header = Global::create(auth_user, url_with_params); + header.page_title=""; + // wonky + if params.neighborhood == Some(true) { + header.page_title="neighborhood"; +} header.page_num = params.page; // TODO -- ignore neighborhood replies match notes { diff --git a/templates/createnote.html b/templates/createnote.html @@ -4,7 +4,7 @@ <br> <button id="post" class="submit-button-style">create note</button> <input type="checkbox" id="neighborhood" name="neighborhood" -{% if global.page == "/neighborhood" %} +{% if global.page_title == "neighborhood" %} checked> {% else %} unchecked>