diff --git a/Cargo.lock b/Cargo.lock index 0fe8edc..f1dc617 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -284,6 +284,10 @@ dependencies = [ "url", ] +[[package]] +name = "froxy-server" +version = "0.1.0" + [[package]] name = "froxy-templates" version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml index 7eb886b..4ff3e6e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,3 +1,3 @@ [workspace] -members = ["froxy-scraper", "froxy-templates"] +members = ["scraper", "server", "templates"] resolver = "3" diff --git a/froxy-scraper/Cargo.toml b/scraper/Cargo.toml similarity index 100% rename from froxy-scraper/Cargo.toml rename to scraper/Cargo.toml diff --git a/froxy-scraper/examples/get_friends.rs b/scraper/examples/get_friends.rs similarity index 100% rename from froxy-scraper/examples/get_friends.rs rename to scraper/examples/get_friends.rs diff --git a/froxy-scraper/examples/get_frontpage.rs b/scraper/examples/get_frontpage.rs similarity index 100% rename from froxy-scraper/examples/get_frontpage.rs rename to scraper/examples/get_frontpage.rs diff --git a/froxy-scraper/examples/get_user.rs b/scraper/examples/get_user.rs similarity index 100% rename from froxy-scraper/examples/get_user.rs rename to scraper/examples/get_user.rs diff --git a/froxy-scraper/src/lib.rs b/scraper/src/lib.rs similarity index 100% rename from froxy-scraper/src/lib.rs rename to scraper/src/lib.rs diff --git a/froxy-scraper/src/parsing.rs b/scraper/src/parsing.rs similarity index 100% rename from froxy-scraper/src/parsing.rs rename to scraper/src/parsing.rs diff --git a/froxy-scraper/src/state.rs b/scraper/src/state.rs similarity index 88% rename from froxy-scraper/src/state.rs rename to scraper/src/state.rs index d675007..db24e9d 100644 --- a/froxy-scraper/src/state.rs +++ b/scraper/src/state.rs @@ -126,17 +126,7 @@ impl State { self.request(Method::POST, url.as_ref(), qs, None).await } - pub async fn post_with_body( - &self, - url: impl AsRef, - qs: Option<&str>, - body: Vec, - ) -> Result { - self.request(Method::POST, url.as_ref(), qs, Some(body)) - .await - } - - pub async fn getuser(&self, name: &str) -> Result, GetUserError> { + pub async fn get_user(&self, name: &str) -> Result, GetUserError> { let req = self.get(format!("/getuser/{name}"), None).await?; let text = req.text().await?; let json = serde_json::from_str::(&text)?; @@ -163,6 +153,23 @@ impl State { github: json.github.filter(|s| !s.is_empty()), })) } + + pub async fn add_friend(&self, names: &[impl AsRef]) -> Result { + let mut names_comma = + names + .iter() + .map(AsRef::as_ref) + .fold(String::from("/friends/add/"), |mut s, name| { + s += name; + s += ","; + s + }); + names_comma.pop(); + + self.get(names_comma, None) + .await + .map(|r| r.status().is_success()) + } } #[derive(Debug, thiserror::Error)] diff --git a/froxy-scraper/src/types.rs b/scraper/src/types.rs similarity index 100% rename from froxy-scraper/src/types.rs rename to scraper/src/types.rs diff --git a/server/Cargo.toml b/server/Cargo.toml new file mode 100644 index 0000000..d5991df --- /dev/null +++ b/server/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "froxy-server" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/server/src/main.rs b/server/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/server/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/froxy-templates/.gitignore b/templates/.gitignore similarity index 100% rename from froxy-templates/.gitignore rename to templates/.gitignore diff --git a/froxy-templates/Cargo.toml b/templates/Cargo.toml similarity index 100% rename from froxy-templates/Cargo.toml rename to templates/Cargo.toml diff --git a/froxy-templates/examples/friend.rs b/templates/examples/friend.rs similarity index 100% rename from froxy-templates/examples/friend.rs rename to templates/examples/friend.rs diff --git a/froxy-templates/examples/index.rs b/templates/examples/index.rs similarity index 100% rename from froxy-templates/examples/index.rs rename to templates/examples/index.rs diff --git a/froxy-templates/examples/profile.rs b/templates/examples/profile.rs similarity index 100% rename from froxy-templates/examples/profile.rs rename to templates/examples/profile.rs diff --git a/froxy-templates/src/friends.rs b/templates/src/friends.rs similarity index 100% rename from froxy-templates/src/friends.rs rename to templates/src/friends.rs diff --git a/froxy-templates/src/index.rs b/templates/src/index.rs similarity index 100% rename from froxy-templates/src/index.rs rename to templates/src/index.rs diff --git a/froxy-templates/src/lib.rs b/templates/src/lib.rs similarity index 100% rename from froxy-templates/src/lib.rs rename to templates/src/lib.rs diff --git a/froxy-templates/src/meta_template.rs b/templates/src/meta_template.rs similarity index 100% rename from froxy-templates/src/meta_template.rs rename to templates/src/meta_template.rs diff --git a/froxy-templates/src/open_modal.rs b/templates/src/open_modal.rs similarity index 100% rename from froxy-templates/src/open_modal.rs rename to templates/src/open_modal.rs diff --git a/froxy-templates/src/profile.rs b/templates/src/profile.rs similarity index 100% rename from froxy-templates/src/profile.rs rename to templates/src/profile.rs diff --git a/froxy-templates/src/templates/friends.html b/templates/src/templates/friends.html similarity index 100% rename from froxy-templates/src/templates/friends.html rename to templates/src/templates/friends.html diff --git a/froxy-templates/src/templates/index.html b/templates/src/templates/index.html similarity index 100% rename from froxy-templates/src/templates/index.html rename to templates/src/templates/index.html diff --git a/froxy-templates/src/templates/mod.rs b/templates/src/templates/mod.rs similarity index 100% rename from froxy-templates/src/templates/mod.rs rename to templates/src/templates/mod.rs diff --git a/froxy-templates/src/templates/open_modal.html b/templates/src/templates/open_modal.html similarity index 100% rename from froxy-templates/src/templates/open_modal.html rename to templates/src/templates/open_modal.html diff --git a/froxy-templates/src/templates/profile.html b/templates/src/templates/profile.html similarity index 100% rename from froxy-templates/src/templates/profile.html rename to templates/src/templates/profile.html diff --git a/froxy-templates/src/templates/template.html b/templates/src/templates/template.html similarity index 100% rename from froxy-templates/src/templates/template.html rename to templates/src/templates/template.html