From 49ef59e00074da88157b892b8bcaac0e8e0a73d6 Mon Sep 17 00:00:00 2001 From: Matthew Esposito Date: Mon, 21 Oct 2024 20:46:03 -0400 Subject: [PATCH] chore: make library --- src/lib.rs | 13 +++++++++++++ src/main.rs | 25 +++++-------------------- src/search.rs | 2 +- src/subreddit.rs | 2 +- 4 files changed, 20 insertions(+), 22 deletions(-) create mode 100644 src/lib.rs diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..b8eb17e --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,13 @@ +pub mod client; +pub mod config; +pub mod duplicates; +pub mod instance_info; +pub mod oauth; +pub mod oauth_resources; +pub mod post; +pub mod search; +pub mod server; +pub mod settings; +pub mod subreddit; +pub mod user; +pub mod utils; diff --git a/src/main.rs b/src/main.rs index 61f810e..556cf57 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,35 +2,20 @@ #![forbid(unsafe_code)] #![allow(clippy::cmp_owned)] -// Reference local files -mod config; -mod duplicates; -mod instance_info; -mod oauth; -mod oauth_resources; -mod post; -mod search; -mod settings; -mod subreddit; -mod user; -mod utils; - // Import Crates use clap::{Arg, ArgAction, Command}; use futures_lite::FutureExt; use hyper::{header::HeaderValue, Body, Request, Response}; -mod client; -use client::{canonical_path, proxy}; use log::info; use once_cell::sync::Lazy; -use server::RequestExt; -use utils::{error, redirect, ThemeAssets}; +use redlib::client::{canonical_path, proxy}; +use redlib::server::{self, RequestExt}; +use redlib::utils::{error, redirect, ThemeAssets}; +use redlib::{config, duplicates, headers, instance_info, post, search, settings, subreddit, user}; -use crate::client::OAUTH_CLIENT; - -mod server; +use redlib::client::OAUTH_CLIENT; // Create Services diff --git a/src/search.rs b/src/search.rs index f48b699..5780c5b 100644 --- a/src/search.rs +++ b/src/search.rs @@ -2,8 +2,8 @@ use crate::utils::{self, catch_random, error, filter_posts, format_num, format_url, get_filters, param, redirect, setting, template, val, Post, Preferences}; use crate::{ client::json, + server::RequestExt, subreddit::{can_access_quarantine, quarantine}, - RequestExt, }; use hyper::{Body, Request, Response}; use once_cell::sync::Lazy; diff --git a/src/subreddit.rs b/src/subreddit.rs index a98455d..5af3fb8 100644 --- a/src/subreddit.rs +++ b/src/subreddit.rs @@ -3,7 +3,7 @@ use crate::{config, utils}; use crate::utils::{ catch_random, error, filter_posts, format_num, format_url, get_filters, nsfw_landing, param, redirect, rewrite_urls, setting, template, val, Post, Preferences, Subreddit, }; -use crate::{client::json, server::ResponseExt, RequestExt}; +use crate::{client::json, server::RequestExt, server::ResponseExt}; use cookie::Cookie; use hyper::{Body, Request, Response}; use rinja::Template;