From 5f8d6b8e0e81390118c4e7eef97546252bc5a7bf Mon Sep 17 00:00:00 2001 From: Ana Gelez Date: Tue, 21 Jan 2020 07:02:03 +0100 Subject: [PATCH] Rust 2018! (#726) --- Cargo.toml | 1 + build.rs | 4 +- plume-api/Cargo.toml | 1 + plume-api/src/lib.rs | 1 - plume-cli/Cargo.toml | 1 + plume-cli/src/main.rs | 6 +- plume-common/Cargo.toml | 1 + plume-common/src/activity_pub/mod.rs | 2 +- plume-common/src/activity_pub/request.rs | 4 +- plume-common/src/activity_pub/sign.rs | 2 +- plume-common/src/lib.rs | 17 +--- plume-common/src/utils.rs | 4 +- plume-front/Cargo.toml | 1 + plume-front/src/editor.rs | 2 +- plume-front/src/main.rs | 3 - plume-macro/src/lib.rs | 3 +- plume-models/Cargo.toml | 1 + plume-models/src/admin.rs | 3 +- plume-models/src/api_tokens.rs | 5 +- plume-models/src/apps.rs | 4 +- plume-models/src/blocklisted_emails.rs | 9 +-- plume-models/src/blog_authors.rs | 4 +- plume-models/src/blogs.rs | 43 +++++----- plume-models/src/comment_seers.rs | 6 +- plume-models/src/comments.rs | 40 +++++----- plume-models/src/db_conn.rs | 5 +- plume-models/src/follows.rs | 12 ++- plume-models/src/instance.rs | 20 ++--- plume-models/src/lib.rs | 31 +------- plume-models/src/likes.rs | 11 +-- plume-models/src/lists.rs | 18 ++--- plume-models/src/medias.rs | 19 ++--- plume-models/src/mentions.rs | 12 +-- plume-models/src/migrations.rs | 6 +- plume-models/src/notifications.rs | 21 ++--- plume-models/src/password_reset_requests.rs | 6 +- plume-models/src/plume_rocket.rs | 18 ++--- plume-models/src/post_authors.rs | 6 +- plume-models/src/posts.rs | 46 +++++------ plume-models/src/reshares.rs | 11 +-- plume-models/src/safe_string.rs | 8 +- plume-models/src/search/mod.rs | 14 ++-- plume-models/src/search/query.rs | 2 +- plume-models/src/search/searcher.rs | 18 ++--- plume-models/src/tags.rs | 5 +- plume-models/src/timeline/mod.rs | 38 ++++----- plume-models/src/timeline/query.rs | 34 ++++---- plume-models/src/users.rs | 79 +++++++++---------- plume-models/tests/lib.rs | 4 - src/api/mod.rs | 2 +- src/inbox.rs | 6 +- src/main.rs | 27 ------- src/routes/blogs.rs | 4 +- src/routes/comments.rs | 6 +- src/routes/errors.rs | 10 +-- src/routes/instance.rs | 10 +-- src/routes/likes.rs | 2 +- src/routes/medias.rs | 4 +- src/routes/mod.rs | 4 +- src/routes/notifications.rs | 4 +- src/routes/posts.rs | 8 +- src/routes/reshares.rs | 2 +- src/routes/search.rs | 4 +- src/routes/session.rs | 12 +-- src/routes/tags.rs | 4 +- src/routes/timelines.rs | 4 +- src/routes/user.rs | 10 +-- src/template_utils.rs | 8 +- templates/base.rs.html | 5 +- templates/blogs/details.rs.html | 6 +- templates/blogs/edit.rs.html | 12 +-- templates/blogs/new.rs.html | 8 +- templates/errors/base.rs.html | 4 +- templates/errors/csrf.rs.html | 4 +- templates/errors/not_authorized.rs.html | 4 +- templates/errors/not_found.rs.html | 5 +- templates/errors/server_error.rs.html | 4 +- templates/errors/unprocessable_entity.rs.html | 5 +- templates/instance/about.rs.html | 6 +- templates/instance/admin.rs.html | 8 +- templates/instance/admin_mod.rs.html | 6 +- templates/instance/emailblocklist.rs.html | 6 +- templates/instance/index.rs.html | 6 +- templates/instance/list.rs.html | 6 +- templates/instance/privacy.rs.html | 4 +- templates/instance/users.rs.html | 6 +- templates/medias/details.rs.html | 6 +- templates/medias/index.rs.html | 6 +- templates/medias/new.rs.html | 6 +- templates/notifications/index.rs.html | 4 +- templates/partials/comment.rs.html | 4 +- templates/partials/image_select.rs.html | 2 +- .../partials/instance_description.rs.html | 4 +- templates/partials/post_card.rs.html | 5 +- templates/posts/details.rs.html | 10 +-- templates/posts/new.rs.html | 14 ++-- templates/posts/remote_interact.rs.html | 10 +-- templates/remote_interact_base.rs.html | 8 +- templates/search/index.rs.html | 4 +- templates/search/result.rs.html | 4 +- templates/session/login.rs.html | 8 +- templates/session/password_reset.rs.html | 6 +- .../session/password_reset_request.rs.html | 6 +- .../password_reset_request_expired.rs.html | 4 +- .../session/password_reset_request_ok.rs.html | 4 +- templates/tags/index.rs.html | 4 +- templates/timelines/details.rs.html | 8 +- templates/users/dashboard.rs.html | 6 +- templates/users/details.rs.html | 6 +- templates/users/edit.rs.html | 8 +- templates/users/follow_remote.rs.html | 8 +- templates/users/followed.rs.html | 6 +- templates/users/followers.rs.html | 6 +- templates/users/header.rs.html | 4 +- templates/users/new.rs.html | 10 +-- 115 files changed, 447 insertions(+), 582 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7434062b..27994771 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,6 +3,7 @@ authors = ["Plume contributors"] name = "plume" version = "0.4.0" repository = "https://github.com/Plume-org/Plume" +edition = "2018" [dependencies] activitypub = "0.1.3" diff --git a/build.rs b/build.rs index 6723e797..151bd668 100644 --- a/build.rs +++ b/build.rs @@ -1,5 +1,5 @@ -extern crate rsass; -extern crate ructe; +use rsass; + use ructe::Ructe; use std::process::{Command, Stdio}; use std::{ffi::OsStr, fs::*, io::Write, path::*}; diff --git a/plume-api/Cargo.toml b/plume-api/Cargo.toml index 7f4f36d7..ce51cc54 100644 --- a/plume-api/Cargo.toml +++ b/plume-api/Cargo.toml @@ -2,6 +2,7 @@ name = "plume-api" version = "0.4.0" authors = ["Plume contributors"] +edition = "2018" [dependencies] serde = "1.0" diff --git a/plume-api/src/lib.rs b/plume-api/src/lib.rs index 158b4261..c22af6a9 100644 --- a/plume-api/src/lib.rs +++ b/plume-api/src/lib.rs @@ -1,4 +1,3 @@ -extern crate serde; #[macro_use] extern crate serde_derive; diff --git a/plume-cli/Cargo.toml b/plume-cli/Cargo.toml index 7b375484..4c6bc76f 100644 --- a/plume-cli/Cargo.toml +++ b/plume-cli/Cargo.toml @@ -2,6 +2,7 @@ name = "plume-cli" version = "0.4.0" authors = ["Plume contributors"] +edition = "2018" [[bin]] name = "plm" diff --git a/plume-cli/src/main.rs b/plume-cli/src/main.rs index a6d1b7db..8dc11692 100644 --- a/plume-cli/src/main.rs +++ b/plume-cli/src/main.rs @@ -1,8 +1,4 @@ -extern crate clap; -extern crate diesel; -extern crate dotenv; -extern crate plume_models; -extern crate rpassword; +use dotenv; use clap::App; use diesel::Connection; diff --git a/plume-common/Cargo.toml b/plume-common/Cargo.toml index 99a352f7..6c7e02ff 100644 --- a/plume-common/Cargo.toml +++ b/plume-common/Cargo.toml @@ -2,6 +2,7 @@ name = "plume-common" version = "0.4.0" authors = ["Plume contributors"] +edition = "2018" [dependencies] activitypub = "0.1.1" diff --git a/plume-common/src/activity_pub/mod.rs b/plume-common/src/activity_pub/mod.rs index 5e60fe72..58c270e2 100644 --- a/plume-common/src/activity_pub/mod.rs +++ b/plume-common/src/activity_pub/mod.rs @@ -64,7 +64,7 @@ impl ActivityStream { } impl<'r, O: Object> Responder<'r> for ActivityStream { - fn respond_to(self, request: &Request) -> Result, Status> { + fn respond_to(self, request: &Request<'_>) -> Result, Status> { let mut json = serde_json::to_value(&self.0).map_err(|_| Status::InternalServerError)?; json["@context"] = context(); serde_json::to_string(&json).respond_to(request).map(|r| { diff --git a/plume-common/src/activity_pub/request.rs b/plume-common/src/activity_pub/request.rs index 4a456193..795c7d11 100644 --- a/plume-common/src/activity_pub/request.rs +++ b/plume-common/src/activity_pub/request.rs @@ -5,8 +5,8 @@ use reqwest::header::{HeaderMap, HeaderValue, ACCEPT, CONTENT_TYPE, DATE, USER_A use std::ops::Deref; use std::time::SystemTime; -use activity_pub::sign::Signer; -use activity_pub::{ap_accept_header, AP_CONTENT_TYPE}; +use crate::activity_pub::sign::Signer; +use crate::activity_pub::{ap_accept_header, AP_CONTENT_TYPE}; const PLUME_USER_AGENT: &str = concat!("Plume/", env!("CARGO_PKG_VERSION")); diff --git a/plume-common/src/activity_pub/sign.rs b/plume-common/src/activity_pub/sign.rs index 83834b9a..745bb83f 100644 --- a/plume-common/src/activity_pub/sign.rs +++ b/plume-common/src/activity_pub/sign.rs @@ -131,7 +131,7 @@ impl SignatureValidity { pub fn verify_http_headers( sender: &S, - all_headers: &HeaderMap, + all_headers: &HeaderMap<'_>, data: &request::Digest, ) -> SignatureValidity { let sig_header = all_headers.get_one("Signature"); diff --git a/plume-common/src/lib.rs b/plume-common/src/lib.rs index dd94c0eb..085f1a42 100644 --- a/plume-common/src/lib.rs +++ b/plume-common/src/lib.rs @@ -1,27 +1,16 @@ #![feature(associated_type_defaults)] -extern crate activitypub; #[macro_use] extern crate activitystreams_derive; -extern crate activitystreams_traits; -extern crate array_tool; -extern crate base64; -extern crate chrono; -extern crate heck; -extern crate hex; -extern crate openssl; -extern crate pulldown_cmark; -extern crate reqwest; -extern crate rocket; -extern crate serde; +use activitystreams_traits; + +use serde; #[macro_use] extern crate shrinkwraprs; #[macro_use] extern crate serde_derive; #[macro_use] extern crate serde_json; -extern crate syntect; -extern crate tokio; pub mod activity_pub; pub mod utils; diff --git a/plume-common/src/utils.rs b/plume-common/src/utils.rs index 151c3dd8..eeb0302d 100644 --- a/plume-common/src/utils.rs +++ b/plume-common/src/utils.rs @@ -48,7 +48,7 @@ enum State { Ready, } -fn to_inline(tag: Tag) -> Tag { +fn to_inline(tag: Tag<'_>) -> Tag<'_> { match tag { Tag::Header(_) | Tag::Table(_) | Tag::TableHead | Tag::TableRow | Tag::TableCell => { Tag::Paragraph @@ -214,7 +214,7 @@ pub fn md_to_html<'a>( }; let parser = Parser::new_ext(md, Options::all()); - let (parser, mentions, hashtags): (Vec, Vec, Vec) = parser + let (parser, mentions, hashtags): (Vec>, Vec, Vec) = parser // Flatten text because pulldown_cmark break #hashtag in two individual text elements .scan(None, flatten_text) .flatten() diff --git a/plume-front/Cargo.toml b/plume-front/Cargo.toml index 26786779..90a89a5b 100644 --- a/plume-front/Cargo.toml +++ b/plume-front/Cargo.toml @@ -2,6 +2,7 @@ name = "plume-front" version = "0.4.0" authors = ["Plume contributors"] +edition = "2018" [dependencies] stdweb = "=0.4.18" diff --git a/plume-front/src/editor.rs b/plume-front/src/editor.rs index dabc1e7b..4dd8e71e 100644 --- a/plume-front/src/editor.rs +++ b/plume-front/src/editor.rs @@ -1,3 +1,4 @@ +use crate::CATALOG; use serde::{Deserialize, Serialize}; use serde_json; use std::sync::Mutex; @@ -5,7 +6,6 @@ use stdweb::{ unstable::{TryFrom, TryInto}, web::{event::*, html_element::*, *}, }; -use CATALOG; macro_rules! mv { ( $( $var:ident ),* => $exp:expr ) => { diff --git a/plume-front/src/main.rs b/plume-front/src/main.rs index ebb42c11..84c66a73 100644 --- a/plume-front/src/main.rs +++ b/plume-front/src/main.rs @@ -1,15 +1,12 @@ #![recursion_limit = "128"] #![feature(decl_macro, proc_macro_hygiene, try_trait)] -extern crate gettext; #[macro_use] extern crate gettext_macros; #[macro_use] extern crate lazy_static; #[macro_use] extern crate stdweb; -extern crate serde; -extern crate serde_json; use stdweb::web::{event::*, *}; init_i18n!( diff --git a/plume-macro/src/lib.rs b/plume-macro/src/lib.rs index 7f02c331..7b0f5d27 100644 --- a/plume-macro/src/lib.rs +++ b/plume-macro/src/lib.rs @@ -1,8 +1,7 @@ #![recursion_limit = "128"] -extern crate proc_macro; + #[macro_use] extern crate quote; -extern crate syn; use proc_macro::TokenStream; use proc_macro2::TokenStream as TokenStream2; diff --git a/plume-models/Cargo.toml b/plume-models/Cargo.toml index a2cbcc91..d122187c 100644 --- a/plume-models/Cargo.toml +++ b/plume-models/Cargo.toml @@ -2,6 +2,7 @@ name = "plume-models" version = "0.4.0" authors = ["Plume contributors"] +edition = "2018" [dependencies] activitypub = "0.1.1" diff --git a/plume-models/src/admin.rs b/plume-models/src/admin.rs index 94f16507..a4fa0455 100644 --- a/plume-models/src/admin.rs +++ b/plume-models/src/admin.rs @@ -1,11 +1,10 @@ +use crate::users::User; use rocket::{ http::Status, request::{self, FromRequest, Request}, Outcome, }; -use users::User; - /// Wrapper around User to use as a request guard on pages reserved to admins. pub struct Admin(pub User); diff --git a/plume-models/src/api_tokens.rs b/plume-models/src/api_tokens.rs index cc876fbc..5e2eca07 100644 --- a/plume-models/src/api_tokens.rs +++ b/plume-models/src/api_tokens.rs @@ -1,3 +1,4 @@ +use crate::{db_conn::DbConn, schema::api_tokens, Error, Result}; use chrono::NaiveDateTime; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; use rocket::{ @@ -6,10 +7,6 @@ use rocket::{ Outcome, }; -use db_conn::DbConn; -use schema::api_tokens; -use {Error, Result}; - #[derive(Clone, Queryable)] pub struct ApiToken { pub id: i32, diff --git a/plume-models/src/apps.rs b/plume-models/src/apps.rs index 4b24a88e..bf68777d 100644 --- a/plume-models/src/apps.rs +++ b/plume-models/src/apps.rs @@ -1,9 +1,7 @@ +use crate::{schema::apps, Error, Result}; use chrono::NaiveDateTime; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; -use schema::apps; -use {Error, Result}; - #[derive(Clone, Queryable, Serialize)] pub struct App { pub id: i32, diff --git a/plume-models/src/blocklisted_emails.rs b/plume-models/src/blocklisted_emails.rs index 71d1ec79..b6585523 100644 --- a/plume-models/src/blocklisted_emails.rs +++ b/plume-models/src/blocklisted_emails.rs @@ -1,9 +1,7 @@ +use crate::{schema::email_blocklist, Connection, Error, Result}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, TextExpressionMethods}; use glob::Pattern; -use schema::email_blocklist; -use {Connection, Error, Result}; - #[derive(Clone, Queryable, Identifiable)] #[table_name = "email_blocklist"] pub struct BlocklistedEmail { @@ -89,10 +87,9 @@ impl BlocklistedEmail { #[cfg(test)] pub(crate) mod tests { use super::*; + use crate::{instance::tests as instance_tests, tests::rockets, Connection as Conn}; use diesel::Connection; - use instance::tests as instance_tests; - use tests::rockets; - use Connection as Conn; + pub(crate) fn fill_database(conn: &Conn) -> Vec { instance_tests::fill_database(conn); let domainblock = diff --git a/plume-models/src/blog_authors.rs b/plume-models/src/blog_authors.rs index 20b99b13..561b410d 100644 --- a/plume-models/src/blog_authors.rs +++ b/plume-models/src/blog_authors.rs @@ -1,8 +1,6 @@ +use crate::{schema::blog_authors, Error, Result}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; -use schema::blog_authors; -use {Error, Result}; - #[derive(Clone, Queryable, Identifiable)] pub struct BlogAuthor { pub id: i32, diff --git a/plume-models/src/blogs.rs b/plume-models/src/blogs.rs index 571cdb25..cbef35c6 100644 --- a/plume-models/src/blogs.rs +++ b/plume-models/src/blogs.rs @@ -1,3 +1,7 @@ +use crate::{ + ap_url, instance::*, medias::Media, posts::Post, safe_string::SafeString, schema::blogs, + search::Searcher, users::User, Connection, Error, PlumeRocket, Result, ITEMS_PER_PAGE, +}; use activitypub::{ actor::Group, collection::{OrderedCollection, OrderedCollectionPage}, @@ -12,22 +16,13 @@ use openssl::{ rsa::Rsa, sign::{Signer, Verifier}, }; -use serde_json; -use url::Url; -use webfinger::*; - -use instance::*; -use medias::Media; use plume_common::activity_pub::{ inbox::{AsActor, FromId}, sign, ActivityStream, ApSignature, Id, IntoId, PublicKey, Source, }; -use posts::Post; -use safe_string::SafeString; -use schema::blogs; -use search::Searcher; -use users::User; -use {ap_url, Connection, Error, PlumeRocket, Result, ITEMS_PER_PAGE}; +use serde_json; +use url::Url; +use webfinger::*; pub type CustomGroup = CustomObject; @@ -106,8 +101,8 @@ impl Blog { } pub fn list_authors(&self, conn: &Connection) -> Result> { - use schema::blog_authors; - use schema::users; + use crate::schema::blog_authors; + use crate::schema::users; let authors_ids = blog_authors::table .filter(blog_authors::blog_id.eq(self.id)) .select(blog_authors::author_id); @@ -118,7 +113,7 @@ impl Blog { } pub fn count_authors(&self, conn: &Connection) -> Result { - use schema::blog_authors; + use crate::schema::blog_authors; blog_authors::table .filter(blog_authors::blog_id.eq(self.id)) .count() @@ -127,7 +122,7 @@ impl Blog { } pub fn find_for_author(conn: &Connection, author: &User) -> Result> { - use schema::blog_authors; + use crate::schema::blog_authors; let author_ids = blog_authors::table .filter(blog_authors::author_id.eq(author.id)) .select(blog_authors::blog_id); @@ -501,14 +496,16 @@ impl NewBlog { #[cfg(test)] pub(crate) mod tests { use super::*; - use blog_authors::*; + use crate::{ + blog_authors::*, + instance::tests as instance_tests, + medias::NewMedia, + search::tests::get_searcher, + tests::{db, rockets}, + users::tests as usersTests, + Connection as Conn, + }; use diesel::Connection; - use instance::tests as instance_tests; - use medias::NewMedia; - use search::tests::get_searcher; - use tests::{db, rockets}; - use users::tests as usersTests; - use Connection as Conn; pub(crate) fn fill_database(conn: &Conn) -> (Vec, Vec) { instance_tests::fill_database(conn); diff --git a/plume-models/src/comment_seers.rs b/plume-models/src/comment_seers.rs index d26d622d..a8d9fa2a 100644 --- a/plume-models/src/comment_seers.rs +++ b/plume-models/src/comment_seers.rs @@ -1,10 +1,6 @@ +use crate::{comments::Comment, schema::comment_seers, users::User, Connection, Error, Result}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; -use comments::Comment; -use schema::comment_seers; -use users::User; -use {Connection, Error, Result}; - #[derive(Queryable, Clone)] pub struct CommentSeers { pub id: i32, diff --git a/plume-models/src/comments.rs b/plume-models/src/comments.rs index 1afce957..702db19c 100644 --- a/plume-models/src/comments.rs +++ b/plume-models/src/comments.rs @@ -1,3 +1,15 @@ +use crate::{ + comment_seers::{CommentSeers, NewCommentSeers}, + instance::Instance, + medias::Media, + mentions::Mention, + notifications::*, + posts::Post, + safe_string::SafeString, + schema::comments, + users::User, + Connection, Error, PlumeRocket, Result, +}; use activitypub::{ activity::{Create, Delete}, link, @@ -5,25 +17,15 @@ use activitypub::{ }; use chrono::{self, NaiveDateTime}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl}; -use serde_json; - -use std::collections::HashSet; - -use comment_seers::{CommentSeers, NewCommentSeers}; -use instance::Instance; -use medias::Media; -use mentions::Mention; -use notifications::*; -use plume_common::activity_pub::{ - inbox::{AsActor, AsObject, FromId}, - Id, IntoId, PUBLIC_VISIBILITY, +use plume_common::{ + activity_pub::{ + inbox::{AsActor, AsObject, FromId}, + Id, IntoId, PUBLIC_VISIBILITY, + }, + utils, }; -use plume_common::utils; -use posts::Post; -use safe_string::SafeString; -use schema::comments; -use users::User; -use {Connection, Error, PlumeRocket, Result}; +use serde_json; +use std::collections::HashSet; #[derive(Queryable, Identifiable, Clone, AsChangeset)] pub struct Comment { @@ -77,7 +79,7 @@ impl Comment { } pub fn count_local(conn: &Connection) -> Result { - use schema::users; + use crate::schema::users; let local_authors = users::table .filter(users::instance_id.eq(Instance::get_local()?.id)) .select(users::id); diff --git a/plume-models/src/db_conn.rs b/plume-models/src/db_conn.rs index c043820d..5e461b18 100644 --- a/plume-models/src/db_conn.rs +++ b/plume-models/src/db_conn.rs @@ -1,3 +1,4 @@ +use crate::Connection; use diesel::r2d2::{ ConnectionManager, CustomizeConnection, Error as ConnError, Pool, PooledConnection, }; @@ -10,8 +11,6 @@ use rocket::{ }; use std::ops::Deref; -use Connection; - pub type DbPool = Pool>; // From rocket documentation @@ -26,7 +25,7 @@ impl<'a, 'r> FromRequest<'a, 'r> for DbConn { type Error = (); fn from_request(request: &'a Request<'r>) -> request::Outcome { - let pool = request.guard::>()?; + let pool = request.guard::>()?; match pool.get() { Ok(conn) => Outcome::Success(DbConn(conn)), Err(_) => Outcome::Failure((Status::ServiceUnavailable, ())), diff --git a/plume-models/src/follows.rs b/plume-models/src/follows.rs index cc5976ea..d371e04e 100644 --- a/plume-models/src/follows.rs +++ b/plume-models/src/follows.rs @@ -1,16 +1,15 @@ +use crate::{ + ap_url, notifications::*, schema::follows, users::User, Connection, Error, PlumeRocket, Result, + CONFIG, +}; use activitypub::activity::{Accept, Follow as FollowAct, Undo}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl}; - -use notifications::*; use plume_common::activity_pub::{ broadcast, inbox::{AsActor, AsObject, FromId}, sign::Signer, Id, IntoId, PUBLIC_VISIBILITY, }; -use schema::follows; -use users::User; -use {ap_url, Connection, Error, PlumeRocket, Result, CONFIG}; #[derive(Clone, Queryable, Identifiable, Associations, AsChangeset)] #[belongs_to(User, foreign_key = "following_id")] @@ -201,9 +200,8 @@ impl IntoId for Follow { #[cfg(test)] mod tests { use super::*; + use crate::{tests::db, users::tests as user_tests}; use diesel::Connection; - use tests::db; - use users::tests as user_tests; #[test] fn test_id() { diff --git a/plume-models/src/instance.rs b/plume-models/src/instance.rs index bf3d3929..fec3cd24 100644 --- a/plume-models/src/instance.rs +++ b/plume-models/src/instance.rs @@ -1,14 +1,15 @@ +use crate::{ + ap_url, + medias::Media, + safe_string::SafeString, + schema::{instances, users}, + users::{Role, User}, + Connection, Error, Result, +}; use chrono::NaiveDateTime; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; -use std::sync::RwLock; - -use ap_url; -use medias::Media; use plume_common::utils::md_to_html; -use safe_string::SafeString; -use schema::{instances, users}; -use users::{Role, User}; -use {Connection, Error, Result}; +use std::sync::RwLock; #[derive(Clone, Identifiable, Queryable)] pub struct Instance { @@ -242,9 +243,8 @@ impl Instance { #[cfg(test)] pub(crate) mod tests { use super::*; + use crate::{tests::db, Connection as Conn}; use diesel::Connection; - use tests::db; - use Connection as Conn; pub(crate) fn fill_database(conn: &Conn) -> Vec<(NewInstance, Instance)> { let res = vec![ diff --git a/plume-models/src/lib.rs b/plume-models/src/lib.rs index 51fddb79..2a56028e 100644 --- a/plume-models/src/lib.rs +++ b/plume-models/src/lib.rs @@ -2,41 +2,20 @@ #![feature(never_type)] #![feature(proc_macro_hygiene)] -extern crate activitypub; -extern crate ammonia; -extern crate askama_escape; -extern crate bcrypt; -extern crate chrono; #[macro_use] extern crate diesel; -extern crate guid_create; -extern crate heck; -extern crate itertools; #[macro_use] extern crate lazy_static; -extern crate migrations_internals; -extern crate openssl; -extern crate plume_api; -extern crate plume_common; #[macro_use] extern crate plume_macro; -extern crate reqwest; #[macro_use] extern crate rocket; -extern crate rocket_i18n; -extern crate scheduled_thread_pool; -extern crate serde; #[macro_use] extern crate serde_derive; #[macro_use] extern crate serde_json; #[macro_use] extern crate tantivy; -extern crate glob; -extern crate url; -extern crate walkdir; -extern crate webfinger; -extern crate whatlang; use plume_common::activity_pub::inbox::InboxError; @@ -249,10 +228,10 @@ macro_rules! get { /// Model::insert(connection, NewModelType::new()); /// ``` macro_rules! insert { - ($table:ident, $from:ident) => { + ($table:ident, $from:ty) => { insert!($table, $from, |x, _conn| Ok(x)); }; - ($table:ident, $from:ident, |$val:ident, $conn:ident | $( $after:tt )+) => { + ($table:ident, $from:ty, |$val:ident, $conn:ident | $( $after:tt )+) => { last!($table); #[allow(dead_code)] @@ -302,16 +281,12 @@ pub fn ap_url(url: &str) -> String { #[cfg(test)] #[macro_use] mod tests { - use db_conn; + use crate::{db_conn, migrations::IMPORTED_MIGRATIONS, search, Connection as Conn, CONFIG}; use diesel::r2d2::ConnectionManager; - use migrations::IMPORTED_MIGRATIONS; use plume_common::utils::random_hex; use scheduled_thread_pool::ScheduledThreadPool; - use search; use std::env::temp_dir; use std::sync::Arc; - use Connection as Conn; - use CONFIG; #[macro_export] macro_rules! part_eq { diff --git a/plume-models/src/likes.rs b/plume-models/src/likes.rs index 063d661c..bbb13596 100644 --- a/plume-models/src/likes.rs +++ b/plume-models/src/likes.rs @@ -1,17 +1,14 @@ +use crate::{ + notifications::*, posts::Post, schema::likes, timeline::*, users::User, Connection, Error, + PlumeRocket, Result, +}; use activitypub::activity; use chrono::NaiveDateTime; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; - -use notifications::*; use plume_common::activity_pub::{ inbox::{AsActor, AsObject, FromId}, Id, IntoId, PUBLIC_VISIBILITY, }; -use posts::Post; -use schema::likes; -use timeline::*; -use users::User; -use {Connection, Error, PlumeRocket, Result}; #[derive(Clone, Queryable, Identifiable)] pub struct Like { diff --git a/plume-models/src/lists.rs b/plume-models/src/lists.rs index ac988b84..9ca125ce 100644 --- a/plume-models/src/lists.rs +++ b/plume-models/src/lists.rs @@ -1,10 +1,11 @@ +use crate::{ + blogs::Blog, + schema::{blogs, list_elems, lists, users}, + users::User, + Connection, Error, Result, +}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; - -use blogs::Blog; -use schema::{blogs, list_elems, lists, users}; use std::convert::{TryFrom, TryInto}; -use users::User; -use {Connection, Error, Result}; /// Represent what a list is supposed to store. Represented in database as an integer #[derive(Copy, Clone, Debug, PartialEq, Eq)] @@ -164,7 +165,7 @@ impl List { last!(lists); get!(lists); - fn insert(conn: &Connection, val: NewList) -> Result { + fn insert(conn: &Connection, val: NewList<'_>) -> Result { diesel::insert_into(lists::table) .values(val) .execute(conn)?; @@ -309,7 +310,7 @@ mod private { }; impl ListElem { - insert!(list_elems, NewListElem); + insert!(list_elems, NewListElem<'_>); pub fn user_in_list(conn: &Connection, list: &List, user: i32) -> Result { dsl::select(dsl::exists( @@ -359,9 +360,8 @@ mod private { #[cfg(test)] mod tests { use super::*; - use blogs::tests as blog_tests; + use crate::{blogs::tests as blog_tests, tests::db}; use diesel::Connection; - use tests::db; #[test] fn list_type() { diff --git a/plume-models/src/medias.rs b/plume-models/src/medias.rs index e708dbe2..7cae530a 100644 --- a/plume-models/src/medias.rs +++ b/plume-models/src/medias.rs @@ -1,20 +1,17 @@ +use crate::{ + ap_url, instance::Instance, safe_string::SafeString, schema::medias, users::User, Connection, + Error, PlumeRocket, Result, +}; use activitypub::object::Image; use askama_escape::escape; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; use guid_create::GUID; -use reqwest; -use std::{fs, path::Path}; - use plume_common::{ activity_pub::{inbox::FromId, Id}, utils::MediaProcessor, }; - -use instance::Instance; -use safe_string::SafeString; -use schema::medias; -use users::User; -use {ap_url, Connection, Error, PlumeRocket, Result}; +use reqwest; +use std::{fs, path::Path}; #[derive(Clone, Identifiable, Queryable)] pub struct Media { @@ -263,13 +260,11 @@ impl Media { #[cfg(test)] pub(crate) mod tests { use super::*; + use crate::{tests::db, users::tests as usersTests, Connection as Conn}; use diesel::Connection; use std::env::{current_dir, set_current_dir}; use std::fs; use std::path::Path; - use tests::db; - use users::tests as usersTests; - use Connection as Conn; pub(crate) fn fill_database(conn: &Conn) -> (Vec, Vec) { let mut wd = current_dir().unwrap().to_path_buf(); diff --git a/plume-models/src/mentions.rs b/plume-models/src/mentions.rs index 0984b728..6eff48a0 100644 --- a/plume-models/src/mentions.rs +++ b/plume-models/src/mentions.rs @@ -1,14 +1,10 @@ +use crate::{ + comments::Comment, notifications::*, posts::Post, schema::mentions, users::User, Connection, + Error, PlumeRocket, Result, +}; use activitypub::link; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; - -use comments::Comment; -use notifications::*; use plume_common::activity_pub::inbox::AsActor; -use posts::Post; -use schema::mentions; -use users::User; -use PlumeRocket; -use {Connection, Error, Result}; #[derive(Clone, Queryable, Identifiable)] pub struct Mention { diff --git a/plume-models/src/migrations.rs b/plume-models/src/migrations.rs index 98a627d6..ab8788de 100644 --- a/plume-models/src/migrations.rs +++ b/plume-models/src/migrations.rs @@ -1,10 +1,6 @@ -use Connection; -use Error; -use Result; - +use crate::{Connection, Error, Result}; use diesel::connection::{Connection as Conn, SimpleConnection}; use migrations_internals::{setup_database, MigrationConnection}; - use std::path::Path; #[allow(dead_code)] //variants might not be constructed if not required by current migrations diff --git a/plume-models/src/notifications.rs b/plume-models/src/notifications.rs index 8aa5a7d2..0fff320a 100644 --- a/plume-models/src/notifications.rs +++ b/plume-models/src/notifications.rs @@ -1,16 +1,17 @@ +use crate::{ + comments::Comment, + follows::Follow, + likes::Like, + mentions::Mention, + posts::Post, + reshares::Reshare, + schema::{follows, notifications}, + users::User, + Connection, Error, Result, +}; use chrono::NaiveDateTime; use diesel::{self, ExpressionMethods, JoinOnDsl, QueryDsl, RunQueryDsl}; -use comments::Comment; -use follows::Follow; -use likes::Like; -use mentions::Mention; -use posts::Post; -use reshares::Reshare; -use schema::{follows, notifications}; -use users::User; -use {Connection, Error, Result}; - pub mod notification_kind { pub const COMMENT: &str = "COMMENT"; pub const FOLLOW: &str = "FOLLOW"; diff --git a/plume-models/src/password_reset_requests.rs b/plume-models/src/password_reset_requests.rs index ab1deefb..b86381b3 100644 --- a/plume-models/src/password_reset_requests.rs +++ b/plume-models/src/password_reset_requests.rs @@ -1,7 +1,6 @@ +use crate::{schema::password_reset_requests, Connection, Error, Result}; use chrono::{offset::Utc, Duration, NaiveDateTime}; use diesel::{ExpressionMethods, QueryDsl, RunQueryDsl}; -use schema::password_reset_requests; -use {Connection, Error, Result}; #[derive(Clone, Identifiable, Queryable)] pub struct PasswordResetRequest { @@ -75,9 +74,8 @@ impl PasswordResetRequest { #[cfg(test)] mod tests { use super::*; + use crate::{tests::db, users::tests as user_tests}; use diesel::Connection; - use tests::db; - use users::tests as user_tests; #[test] fn test_insert_and_find_password_reset_request() { diff --git a/plume-models/src/plume_rocket.rs b/plume-models/src/plume_rocket.rs index dbc10bcc..0a2b3cec 100644 --- a/plume-models/src/plume_rocket.rs +++ b/plume-models/src/plume_rocket.rs @@ -2,9 +2,7 @@ pub use self::module::PlumeRocket; #[cfg(not(test))] mod module { - use crate::db_conn::DbConn; - use crate::search; - use crate::users; + use crate::{db_conn::DbConn, search, users}; use rocket::{ request::{self, FlashMessage, FromRequest, Request}, Outcome, State, @@ -29,9 +27,9 @@ mod module { let conn = request.guard::()?; let intl = request.guard::()?; let user = request.guard::().succeeded(); - let worker = request.guard::>>()?; - let searcher = request.guard::>>()?; - let flash_msg = request.guard::().succeeded(); + let worker = request.guard::<'_, State<'_, Arc>>()?; + let searcher = request.guard::<'_, State<'_, Arc>>()?; + let flash_msg = request.guard::>().succeeded(); Outcome::Success(PlumeRocket { conn, intl, @@ -46,9 +44,7 @@ mod module { #[cfg(test)] mod module { - use crate::db_conn::DbConn; - use crate::search; - use crate::users; + use crate::{db_conn::DbConn, search, users}; use rocket::{ request::{self, FromRequest, Request}, Outcome, State, @@ -70,8 +66,8 @@ mod module { fn from_request(request: &'a Request<'r>) -> request::Outcome { let conn = request.guard::()?; let user = request.guard::().succeeded(); - let worker = request.guard::>>()?; - let searcher = request.guard::>>()?; + let worker = request.guard::<'_, State<'_, Arc>>()?; + let searcher = request.guard::<'_, State<'_, Arc>>()?; Outcome::Success(PlumeRocket { conn, user, diff --git a/plume-models/src/post_authors.rs b/plume-models/src/post_authors.rs index b8db5549..32b6f6da 100644 --- a/plume-models/src/post_authors.rs +++ b/plume-models/src/post_authors.rs @@ -1,10 +1,6 @@ +use crate::{posts::Post, schema::post_authors, users::User, Error, Result}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; -use posts::Post; -use schema::post_authors; -use users::User; -use {Error, Result}; - #[derive(Clone, Queryable, Identifiable, Associations)] #[belongs_to(Post)] #[belongs_to(User, foreign_key = "author_id")] diff --git a/plume-models/src/posts.rs b/plume-models/src/posts.rs index f9b4f7d1..73c0c915 100644 --- a/plume-models/src/posts.rs +++ b/plume-models/src/posts.rs @@ -1,3 +1,8 @@ +use crate::{ + ap_url, blogs::Blog, instance::Instance, medias::Media, mentions::Mention, post_authors::*, + safe_string::SafeString, schema::posts, search::Searcher, tags::*, timeline::*, users::User, + Connection, Error, PlumeRocket, Result, CONFIG, +}; use activitypub::{ activity::{Create, Delete, Update}, link, @@ -7,13 +12,6 @@ use activitypub::{ use chrono::{NaiveDateTime, TimeZone, Utc}; use diesel::{self, BelongingToDsl, ExpressionMethods, QueryDsl, RunQueryDsl, SaveChangesDsl}; use heck::{CamelCase, KebabCase}; -use serde_json; -use std::collections::HashSet; - -use blogs::Blog; -use instance::Instance; -use medias::Media; -use mentions::Mention; use plume_common::{ activity_pub::{ inbox::{AsObject, FromId}, @@ -21,14 +19,8 @@ use plume_common::{ }, utils::md_to_html, }; -use post_authors::*; -use safe_string::SafeString; -use schema::posts; -use search::Searcher; -use tags::*; -use timeline::*; -use users::User; -use {ap_url, Connection, Error, PlumeRocket, Result, CONFIG}; +use serde_json; +use std::collections::HashSet; pub type LicensedArticle = CustomObject; @@ -111,7 +103,7 @@ impl Post { tag: String, (min, max): (i32, i32), ) -> Result> { - use schema::tags; + use crate::schema::tags; let ids = tags::table.filter(tags::tag.eq(tag)).select(tags::post_id); posts::table @@ -125,7 +117,7 @@ impl Post { } pub fn count_for_tag(conn: &Connection, tag: String) -> Result { - use schema::tags; + use crate::schema::tags; let ids = tags::table.filter(tags::tag.eq(tag)).select(tags::post_id); posts::table .filter(posts::id.eq_any(ids)) @@ -139,8 +131,8 @@ impl Post { } pub fn count_local(conn: &Connection) -> Result { - use schema::post_authors; - use schema::users; + use crate::schema::post_authors; + use crate::schema::users; let local_authors = users::table .filter(users::instance_id.eq(Instance::get_local()?.id)) .select(users::id); @@ -188,7 +180,7 @@ impl Post { author: &User, limit: i64, ) -> Result> { - use schema::post_authors; + use crate::schema::post_authors; let posts = PostAuthor::belonging_to(author).select(post_authors::post_id); posts::table @@ -239,7 +231,7 @@ impl Post { } pub fn drafts_by_author(conn: &Connection, author: &User) -> Result> { - use schema::post_authors; + use crate::schema::post_authors; let posts = PostAuthor::belonging_to(author).select(post_authors::post_id); posts::table @@ -251,8 +243,8 @@ impl Post { } pub fn get_authors(&self, conn: &Connection) -> Result> { - use schema::post_authors; - use schema::users; + use crate::schema::post_authors; + use crate::schema::users; let author_list = PostAuthor::belonging_to(self).select(post_authors::author_id); users::table .filter(users::id.eq_any(author_list)) @@ -261,7 +253,7 @@ impl Post { } pub fn is_author(&self, conn: &Connection, author_id: i32) -> Result { - use schema::post_authors; + use crate::schema::post_authors; Ok(PostAuthor::belonging_to(self) .filter(post_authors::author_id.eq(author_id)) .count() @@ -270,7 +262,7 @@ impl Post { } pub fn get_blog(&self, conn: &Connection) -> Result { - use schema::blogs; + use crate::schema::blogs; blogs::table .filter(blogs::id.eq(self.blog_id)) .first(conn) @@ -278,7 +270,7 @@ impl Post { } pub fn count_likes(&self, conn: &Connection) -> Result { - use schema::likes; + use crate::schema::likes; likes::table .filter(likes::post_id.eq(self.id)) .count() @@ -287,7 +279,7 @@ impl Post { } pub fn count_reshares(&self, conn: &Connection) -> Result { - use schema::reshares; + use crate::schema::reshares; reshares::table .filter(reshares::post_id.eq(self.id)) .count() diff --git a/plume-models/src/reshares.rs b/plume-models/src/reshares.rs index 0467929a..3621cc17 100644 --- a/plume-models/src/reshares.rs +++ b/plume-models/src/reshares.rs @@ -1,17 +1,14 @@ +use crate::{ + notifications::*, posts::Post, schema::reshares, timeline::*, users::User, Connection, Error, + PlumeRocket, Result, +}; use activitypub::activity::{Announce, Undo}; use chrono::NaiveDateTime; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; - -use notifications::*; use plume_common::activity_pub::{ inbox::{AsActor, AsObject, FromId}, Id, IntoId, PUBLIC_VISIBILITY, }; -use posts::Post; -use schema::reshares; -use timeline::*; -use users::User; -use {Connection, Error, PlumeRocket, Result}; #[derive(Clone, Queryable, Identifiable)] pub struct Reshare { diff --git a/plume-models/src/safe_string.rs b/plume-models/src/safe_string.rs index a5753792..5f36ea3b 100644 --- a/plume-models/src/safe_string.rs +++ b/plume-models/src/safe_string.rs @@ -82,7 +82,7 @@ lazy_static! { }; } -fn url_add_prefix(url: &str) -> Option> { +fn url_add_prefix(url: &str) -> Option> { if url.starts_with('#') && !url.starts_with("#postcontent-") { //if start with an # let mut new_url = "#postcontent-".to_owned(); //change to valid id @@ -139,7 +139,7 @@ struct SafeStringVisitor; impl<'de> Visitor<'de> for SafeStringVisitor { type Value = SafeString; - fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result { + fn expecting(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result { formatter.write_str("a string") } @@ -181,7 +181,7 @@ where DB: diesel::backend::Backend, str: ToSql, { - fn to_sql(&self, out: &mut Output) -> serialize::Result { + fn to_sql(&self, out: &mut Output<'_, W, DB>) -> serialize::Result { str::to_sql(&self.value, out) } } @@ -193,7 +193,7 @@ impl Borrow for SafeString { } impl Display for SafeString { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}", self.value) } } diff --git a/plume-models/src/search/mod.rs b/plume-models/src/search/mod.rs index 28fbef89..423c1b9c 100644 --- a/plume-models/src/search/mod.rs +++ b/plume-models/src/search/mod.rs @@ -8,15 +8,17 @@ pub use self::searcher::*; pub(crate) mod tests { use super::{Query, Searcher}; use diesel::Connection; + use plume_common::utils::random_hex; use std::env::temp_dir; use std::str::FromStr; - use blogs::tests::fill_database; - use plume_common::utils::random_hex; - use post_authors::*; - use posts::{NewPost, Post}; - use safe_string::SafeString; - use tests::db; + use crate::{ + blogs::tests::fill_database, + post_authors::*, + posts::{NewPost, Post}, + safe_string::SafeString, + tests::db, + }; pub(crate) fn get_searcher() -> Searcher { let dir = temp_dir().join(&format!("plume-test-{}", random_hex())); diff --git a/plume-models/src/search/query.rs b/plume-models/src/search/query.rs index 38cf7752..1e053d4a 100644 --- a/plume-models/src/search/query.rs +++ b/plume-models/src/search/query.rs @@ -1,5 +1,5 @@ +use crate::search::searcher::Searcher; use chrono::{naive::NaiveDate, offset::Utc, Datelike}; -use search::searcher::Searcher; use std::{cmp, ops::Bound}; use tantivy::{query::*, schema::*, Term}; diff --git a/plume-models/src/search/searcher.rs b/plume-models/src/search/searcher.rs index 86a2ca6a..90aad8d9 100644 --- a/plume-models/src/search/searcher.rs +++ b/plume-models/src/search/searcher.rs @@ -1,9 +1,11 @@ -use instance::Instance; -use posts::Post; -use schema::posts; -use tags::Tag; -use Connection; - +use crate::{ + instance::Instance, + posts::Post, + schema::posts, + search::{query::PlumeQuery, tokenizer}, + tags::Tag, + Connection, Result, +}; use chrono::Datelike; use diesel::{ExpressionMethods, QueryDsl, RunQueryDsl}; use itertools::Itertools; @@ -14,10 +16,6 @@ use tantivy::{ }; use whatlang::{detect as detect_lang, Lang}; -use super::tokenizer; -use search::query::PlumeQuery; -use Result; - #[derive(Debug)] pub enum SearcherError { IndexCreationError, diff --git a/plume-models/src/tags.rs b/plume-models/src/tags.rs index eba26813..9ed7687b 100644 --- a/plume-models/src/tags.rs +++ b/plume-models/src/tags.rs @@ -1,9 +1,6 @@ +use crate::{ap_url, instance::Instance, schema::tags, Connection, Error, Result}; use diesel::{self, ExpressionMethods, QueryDsl, RunQueryDsl}; - -use instance::Instance; use plume_common::activity_pub::Hashtag; -use schema::tags; -use {ap_url, Connection, Error, Result}; #[derive(Clone, Identifiable, Queryable)] pub struct Tag { diff --git a/plume-models/src/timeline/mod.rs b/plume-models/src/timeline/mod.rs index d53528fb..426c228b 100644 --- a/plume-models/src/timeline/mod.rs +++ b/plume-models/src/timeline/mod.rs @@ -1,16 +1,16 @@ +use crate::{ + lists::List, + posts::Post, + schema::{posts, timeline, timeline_definition}, + Connection, Error, PlumeRocket, Result, +}; use diesel::{self, BoolExpressionMethods, ExpressionMethods, QueryDsl, RunQueryDsl}; - -use lists::List; -use posts::Post; -use schema::{posts, timeline, timeline_definition}; use std::ops::Deref; -use {Connection, Error, PlumeRocket, Result}; pub(crate) mod query; -use self::query::{QueryError, TimelineQuery}; - pub use self::query::Kind; +use self::query::{QueryError, TimelineQuery}; #[derive(Clone, Debug, PartialEq, Queryable, Identifiable, AsChangeset)] #[table_name = "timeline_definition"] @@ -208,7 +208,7 @@ impl Timeline { .map_err(Error::from) } - pub fn add_to_all_timelines(rocket: &PlumeRocket, post: &Post, kind: Kind) -> Result<()> { + pub fn add_to_all_timelines(rocket: &PlumeRocket, post: &Post, kind: Kind<'_>) -> Result<()> { let timelines = timeline_definition::table .load::(rocket.conn.deref()) .map_err(Error::from)?; @@ -231,7 +231,7 @@ impl Timeline { Ok(()) } - pub fn matches(&self, rocket: &PlumeRocket, post: &Post, kind: Kind) -> Result { + pub fn matches(&self, rocket: &PlumeRocket, post: &Post, kind: Kind<'_>) -> Result { let query = TimelineQuery::parse(&self.query)?; query.matches(rocket, self, post, kind) } @@ -240,16 +240,18 @@ impl Timeline { #[cfg(test)] mod tests { use super::*; - use blogs::tests as blogTests; + use crate::{ + blogs::tests as blogTests, + follows::*, + lists::ListType, + post_authors::{NewPostAuthor, PostAuthor}, + posts::NewPost, + safe_string::SafeString, + tags::Tag, + tests::{db, rockets}, + users::tests as userTests, + }; use diesel::Connection; - use follows::*; - use lists::ListType; - use post_authors::{NewPostAuthor, PostAuthor}; - use posts::NewPost; - use safe_string::SafeString; - use tags::Tag; - use tests::{db, rockets}; - use users::tests as userTests; #[test] fn test_timeline() { diff --git a/plume-models/src/timeline/query.rs b/plume-models/src/timeline/query.rs index ea9aeea9..68cd42d5 100644 --- a/plume-models/src/timeline/query.rs +++ b/plume-models/src/timeline/query.rs @@ -1,15 +1,15 @@ -use blogs::Blog; -use lists::{self, ListType}; +use crate::{ + blogs::Blog, + lists::{self, ListType}, + posts::Post, + tags::Tag, + timeline::Timeline, + users::User, + PlumeRocket, Result, +}; use plume_common::activity_pub::inbox::AsActor; -use posts::Post; -use tags::Tag; -use users::User; use whatlang::{self, Lang}; -use {PlumeRocket, Result}; - -use super::Timeline; - #[derive(Debug, Clone, PartialEq)] pub enum QueryError { SyntaxError(usize, usize, String), @@ -65,7 +65,7 @@ impl<'a> Token<'a> { } } - fn get_error(&self, token: Token) -> QueryResult { + fn get_error(&self, token: Token<'_>) -> QueryResult { let (b, e) = self.get_pos(); let message = format!( "Syntax Error: Expected {}, got {}", @@ -127,7 +127,7 @@ macro_rules! gen_tokenizer { } } -fn lex(stream: &str) -> Vec { +fn lex(stream: &str) -> Vec> { stream .chars() .chain(" ".chars()) // force a last whitespace to empty scan's state @@ -163,7 +163,7 @@ impl<'a> TQ<'a> { rocket: &PlumeRocket, timeline: &Timeline, post: &Post, - kind: Kind, + kind: Kind<'_>, ) -> Result { match self { TQ::Or(inner) => inner.iter().try_fold(false, |s, e| { @@ -208,7 +208,7 @@ impl<'a> Arg<'a> { rocket: &PlumeRocket, timeline: &Timeline, post: &Post, - kind: Kind, + kind: Kind<'_>, ) -> Result { match self { Arg::In(t, l) => t.matches(rocket, timeline, post, l, kind), @@ -233,8 +233,8 @@ impl WithList { rocket: &PlumeRocket, timeline: &Timeline, post: &Post, - list: &List, - kind: Kind, + list: &List<'_>, + kind: Kind<'_>, ) -> Result { match list { List::List(name) => { @@ -374,7 +374,7 @@ impl Bool { rocket: &PlumeRocket, timeline: &Timeline, post: &Post, - kind: Kind, + kind: Kind<'_>, ) -> Result { match self { Bool::Followed { boosts, likes } => { @@ -645,7 +645,7 @@ impl<'a> TimelineQuery<'a> { rocket: &PlumeRocket, timeline: &Timeline, post: &Post, - kind: Kind, + kind: Kind<'_>, ) -> Result { self.0.matches(rocket, timeline, post, kind) } diff --git a/plume-models/src/users.rs b/plume-models/src/users.rs index 966ddbc7..d6c31f65 100644 --- a/plume-models/src/users.rs +++ b/plume-models/src/users.rs @@ -1,3 +1,9 @@ +use crate::{ + ap_url, blocklisted_emails::BlocklistedEmail, blogs::Blog, db_conn::DbConn, follows::Follow, + instance::*, medias::Media, notifications::Notification, post_authors::PostAuthor, posts::Post, + safe_string::SafeString, schema::users, search::Searcher, timeline::Timeline, Connection, + Error, PlumeRocket, Result, ITEMS_PER_PAGE, +}; use activitypub::{ activity::Delete, actor::Person, @@ -14,13 +20,15 @@ use openssl::{ rsa::Rsa, sign, }; -use plume_common::activity_pub::{ - ap_accept_header, - inbox::{AsActor, AsObject, FromId}, - sign::{gen_keypair, Signer}, - ActivityStream, ApSignature, Id, IntoId, PublicKey, PUBLIC_VISIBILITY, +use plume_common::{ + activity_pub::{ + ap_accept_header, + inbox::{AsActor, AsObject, FromId}, + sign::{gen_keypair, Signer}, + ActivityStream, ApSignature, Id, IntoId, PublicKey, PUBLIC_VISIBILITY, + }, + utils, }; -use plume_common::utils; use reqwest::{ header::{HeaderValue, ACCEPT}, ClientBuilder, @@ -37,23 +45,6 @@ use std::{ use url::Url; use webfinger::*; -use blogs::Blog; -use db_conn::DbConn; -use follows::Follow; -use instance::*; -use medias::Media; -use notifications::Notification; -use post_authors::PostAuthor; -use posts::Post; -use safe_string::SafeString; -use schema::users; -use search::Searcher; -use timeline::Timeline; -use { - ap_url, blocklisted_emails::BlocklistedEmail, Connection, Error, PlumeRocket, Result, - ITEMS_PER_PAGE, -}; - pub type CustomPerson = CustomObject; pub enum Role { @@ -139,7 +130,7 @@ impl User { } pub fn delete(&self, conn: &Connection, searcher: &Searcher) -> Result<()> { - use schema::post_authors; + use crate::schema::post_authors; for blog in Blog::find_for_author(conn, self)? .iter() @@ -464,8 +455,8 @@ impl User { .collect::>()) } fn get_activities_count(&self, conn: &Connection) -> i64 { - use schema::post_authors; - use schema::posts; + use crate::schema::post_authors; + use crate::schema::posts; let posts_by_self = PostAuthor::belonging_to(self).select(post_authors::post_id); posts::table .filter(posts::published.eq(true)) @@ -479,8 +470,8 @@ impl User { conn: &Connection, (min, max): (i32, i32), ) -> Result> { - use schema::post_authors; - use schema::posts; + use crate::schema::post_authors; + use crate::schema::posts; let posts_by_self = PostAuthor::belonging_to(self).select(post_authors::post_id); let posts = posts::table .filter(posts::published.eq(true)) @@ -500,7 +491,7 @@ impl User { } pub fn get_followers(&self, conn: &Connection) -> Result> { - use schema::follows; + use crate::schema::follows; let follows = Follow::belonging_to(self).select(follows::follower_id); users::table .filter(users::id.eq_any(follows)) @@ -509,7 +500,7 @@ impl User { } pub fn count_followers(&self, conn: &Connection) -> Result { - use schema::follows; + use crate::schema::follows; let follows = Follow::belonging_to(self).select(follows::follower_id); users::table .filter(users::id.eq_any(follows)) @@ -523,7 +514,7 @@ impl User { conn: &Connection, (min, max): (i32, i32), ) -> Result> { - use schema::follows; + use crate::schema::follows; let follows = Follow::belonging_to(self).select(follows::follower_id); users::table .filter(users::id.eq_any(follows)) @@ -534,7 +525,7 @@ impl User { } pub fn get_followed(&self, conn: &Connection) -> Result> { - use schema::follows::dsl::*; + use crate::schema::follows::dsl::*; let f = follows.filter(follower_id.eq(self.id)).select(following_id); users::table .filter(users::id.eq_any(f)) @@ -543,7 +534,7 @@ impl User { } pub fn count_followed(&self, conn: &Connection) -> Result { - use schema::follows; + use crate::schema::follows; follows::table .filter(follows::follower_id.eq(self.id)) .count() @@ -556,7 +547,7 @@ impl User { conn: &Connection, (min, max): (i32, i32), ) -> Result> { - use schema::follows; + use crate::schema::follows; let follows = follows::table .filter(follows::follower_id.eq(self.id)) .select(follows::following_id) @@ -569,7 +560,7 @@ impl User { } pub fn is_followed_by(&self, conn: &Connection, other_id: i32) -> Result { - use schema::follows; + use crate::schema::follows; follows::table .filter(follows::follower_id.eq(other_id)) .filter(follows::following_id.eq(self.id)) @@ -580,7 +571,7 @@ impl User { } pub fn is_following(&self, conn: &Connection, other_id: i32) -> Result { - use schema::follows; + use crate::schema::follows; follows::table .filter(follows::follower_id.eq(self.id)) .filter(follows::following_id.eq(other_id)) @@ -591,7 +582,7 @@ impl User { } pub fn has_liked(&self, conn: &Connection, post: &Post) -> Result { - use schema::likes; + use crate::schema::likes; likes::table .filter(likes::post_id.eq(post.id)) .filter(likes::user_id.eq(self.id)) @@ -602,7 +593,7 @@ impl User { } pub fn has_reshared(&self, conn: &Connection, post: &Post) -> Result { - use schema::reshares; + use crate::schema::reshares; reshares::table .filter(reshares::post_id.eq(post.id)) .filter(reshares::user_id.eq(self.id)) @@ -613,7 +604,7 @@ impl User { } pub fn is_author_in(&self, conn: &Connection, blog: &Blog) -> Result { - use schema::blog_authors; + use crate::schema::blog_authors; blog_authors::table .filter(blog_authors::author_id.eq(self.id)) .filter(blog_authors::blog_id.eq(blog.id)) @@ -1033,11 +1024,13 @@ impl NewUser { #[cfg(test)] pub(crate) mod tests { use super::*; + use crate::{ + instance::{tests as instance_tests, Instance}, + search::tests::get_searcher, + tests::{db, rockets}, + Connection as Conn, + }; use diesel::Connection; - use instance::{tests as instance_tests, Instance}; - use search::tests::get_searcher; - use tests::{db, rockets}; - use Connection as Conn; pub(crate) fn fill_database(conn: &Conn) -> Vec { instance_tests::fill_database(conn); diff --git a/plume-models/tests/lib.rs b/plume-models/tests/lib.rs index 467be39a..3b563b03 100644 --- a/plume-models/tests/lib.rs +++ b/plume-models/tests/lib.rs @@ -1,7 +1,3 @@ -extern crate diesel; -extern crate plume_common; -extern crate plume_models; - use diesel::Connection; use plume_common::utils::random_hex; use plume_models::migrations::IMPORTED_MIGRATIONS; diff --git a/src/api/mod.rs b/src/api/mod.rs index c320e081..1ea9f6d3 100644 --- a/src/api/mod.rs +++ b/src/api/mod.rs @@ -27,7 +27,7 @@ impl From for ApiError { } impl<'r> Responder<'r> for ApiError { - fn respond_to(self, req: &Request) -> response::Result<'r> { + fn respond_to(self, req: &Request<'_>) -> response::Result<'r> { match self.0 { Error::NotFound => Json(json!({ "error": "Not found" diff --git a/src/inbox.rs b/src/inbox.rs index 451b1db4..71270f53 100644 --- a/src/inbox.rs +++ b/src/inbox.rs @@ -14,7 +14,7 @@ use std::io::Read; pub fn handle_incoming( rockets: PlumeRocket, data: SignedJson, - headers: Headers, + headers: Headers<'_>, ) -> Result> { let conn = &*rockets.conn; let act = data.1.into_inner(); @@ -74,7 +74,7 @@ impl<'a, T: Deserialize<'a>> FromData<'a> for SignedJson { type Borrowed = str; fn transform( - r: &Request, + r: &Request<'_>, d: Data, ) -> Transform> { let size_limit = r.limits().get("json").unwrap_or(JSON_LIMIT); @@ -86,7 +86,7 @@ impl<'a, T: Deserialize<'a>> FromData<'a> for SignedJson { } fn from_data( - _: &Request, + _: &Request<'_>, o: Transformed<'a, Self>, ) -> rocket::data::Outcome { let string = o.borrowed()?; diff --git a/src/main.rs b/src/main.rs index bc321419..5016e982 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,43 +1,16 @@ #![allow(clippy::too_many_arguments)] #![feature(decl_macro, proc_macro_hygiene, try_trait)] -extern crate activitypub; -extern crate askama_escape; -extern crate atom_syndication; -extern crate chrono; -extern crate clap; -extern crate colored; -extern crate ctrlc; -extern crate diesel; -extern crate dotenv; #[macro_use] extern crate gettext_macros; -extern crate gettext_utils; -extern crate guid_create; -extern crate heck; -extern crate lettre; -extern crate lettre_email; -extern crate multipart; -extern crate num_cpus; -extern crate plume_api; -extern crate plume_common; -extern crate plume_models; #[macro_use] extern crate rocket; -extern crate rocket_contrib; -extern crate rocket_csrf; -extern crate rocket_i18n; #[macro_use] extern crate runtime_fmt; -extern crate scheduled_thread_pool; -extern crate serde; #[macro_use] extern crate serde_json; -extern crate serde_qs; -extern crate validator; #[macro_use] extern crate validator_derive; -extern crate webfinger; use clap::App; use diesel::r2d2::ConnectionManager; diff --git a/src/routes/blogs.rs b/src/routes/blogs.rs index 0802025a..bba2b402 100644 --- a/src/routes/blogs.rs +++ b/src/routes/blogs.rs @@ -10,14 +10,14 @@ use rocket_i18n::I18n; use std::{borrow::Cow, collections::HashMap}; use validator::{Validate, ValidationError, ValidationErrors}; +use crate::routes::{errors::ErrorPage, Page, RespondOrRedirect}; +use crate::template_utils::{IntoContext, Ructe}; use plume_common::activity_pub::{ActivityStream, ApRequest}; use plume_common::utils; use plume_models::{ blog_authors::*, blogs::*, instance::Instance, medias::*, posts::Post, safe_string::SafeString, users::User, Connection, PlumeRocket, }; -use routes::{errors::ErrorPage, Page, RespondOrRedirect}; -use template_utils::{IntoContext, Ructe}; #[get("/~/?", rank = 2)] pub fn details(name: String, page: Option, rockets: PlumeRocket) -> Result { diff --git a/src/routes/comments.rs b/src/routes/comments.rs index fb6c4d05..eaf27751 100644 --- a/src/routes/comments.rs +++ b/src/routes/comments.rs @@ -1,13 +1,15 @@ +use crate::template_utils::Ructe; use activitypub::object::Note; use rocket::{ request::LenientForm, response::{Flash, Redirect}, }; -use template_utils::Ructe; use validator::Validate; use std::time::Duration; +use crate::routes::errors::ErrorPage; +use crate::template_utils::IntoContext; use plume_common::{ activity_pub::{broadcast, ActivityStream, ApRequest}, utils, @@ -16,8 +18,6 @@ use plume_models::{ blogs::Blog, comments::*, inbox::inbox, instance::Instance, medias::Media, mentions::Mention, posts::Post, safe_string::SafeString, tags::Tag, users::User, Error, PlumeRocket, }; -use routes::errors::ErrorPage; -use template_utils::IntoContext; #[derive(Default, FromForm, Debug, Validate)] pub struct NewCommentForm { diff --git a/src/routes/errors.rs b/src/routes/errors.rs index 1320a068..53baeef0 100644 --- a/src/routes/errors.rs +++ b/src/routes/errors.rs @@ -1,9 +1,9 @@ +use crate::template_utils::{IntoContext, Ructe}; use plume_models::{Error, PlumeRocket}; use rocket::{ response::{self, Responder}, Request, }; -use template_utils::{IntoContext, Ructe}; #[derive(Debug)] pub struct ErrorPage(Error); @@ -15,7 +15,7 @@ impl From for ErrorPage { } impl<'r> Responder<'r> for ErrorPage { - fn respond_to(self, req: &Request) -> response::Result<'r> { + fn respond_to(self, req: &Request<'_>) -> response::Result<'r> { let rockets = req.guard::().unwrap(); match self.0 { @@ -29,19 +29,19 @@ impl<'r> Responder<'r> for ErrorPage { } #[catch(404)] -pub fn not_found(req: &Request) -> Ructe { +pub fn not_found(req: &Request<'_>) -> Ructe { let rockets = req.guard::().unwrap(); render!(errors::not_found(&rockets.to_context())) } #[catch(422)] -pub fn unprocessable_entity(req: &Request) -> Ructe { +pub fn unprocessable_entity(req: &Request<'_>) -> Ructe { let rockets = req.guard::().unwrap(); render!(errors::unprocessable_entity(&rockets.to_context())) } #[catch(500)] -pub fn server_error(req: &Request) -> Ructe { +pub fn server_error(req: &Request<'_>) -> Ructe { let rockets = req.guard::().unwrap(); render!(errors::server_error(&rockets.to_context())) } diff --git a/src/routes/instance.rs b/src/routes/instance.rs index f09e3117..72d41c3f 100644 --- a/src/routes/instance.rs +++ b/src/routes/instance.rs @@ -9,7 +9,9 @@ use serde_json; use std::str::FromStr; use validator::{Validate, ValidationErrors}; -use inbox; +use crate::inbox; +use crate::routes::{errors::ErrorPage, rocket_uri_macro_static_files, Page, RespondOrRedirect}; +use crate::template_utils::{IntoContext, Ructe}; use plume_common::activity_pub::{broadcast, inbox::FromId}; use plume_models::{ admin::*, @@ -25,8 +27,6 @@ use plume_models::{ users::{Role, User}, Connection, Error, PlumeRocket, CONFIG, }; -use routes::{errors::ErrorPage, rocket_uri_macro_static_files, Page, RespondOrRedirect}; -use template_utils::{IntoContext, Ructe}; #[get("/")] pub fn index(rockets: PlumeRocket) -> Result { @@ -248,7 +248,7 @@ where { type Error = (); - fn from_form(items: &mut FormItems, _strict: bool) -> Result { + fn from_form(items: &mut FormItems<'_>, _strict: bool) -> Result { let (ids, act) = items.fold((vec![], None), |(mut ids, act), item| { let (name, val) = item.key_value_decoded(); @@ -389,7 +389,7 @@ fn ban( pub fn shared_inbox( rockets: PlumeRocket, data: inbox::SignedJson, - headers: Headers, + headers: Headers<'_>, ) -> Result> { inbox::handle_incoming(rockets, data, headers) } diff --git a/src/routes/likes.rs b/src/routes/likes.rs index e7d895fb..3d8687fe 100644 --- a/src/routes/likes.rs +++ b/src/routes/likes.rs @@ -1,12 +1,12 @@ use rocket::response::{Flash, Redirect}; use rocket_i18n::I18n; +use crate::routes::errors::ErrorPage; use plume_common::activity_pub::broadcast; use plume_common::utils; use plume_models::{ blogs::Blog, inbox::inbox, likes, posts::Post, timeline::*, users::User, Error, PlumeRocket, }; -use routes::errors::ErrorPage; #[post("/~///like")] pub fn create( diff --git a/src/routes/medias.rs b/src/routes/medias.rs index c5b464cf..91c64db8 100644 --- a/src/routes/medias.rs +++ b/src/routes/medias.rs @@ -1,3 +1,5 @@ +use crate::routes::{errors::ErrorPage, Page}; +use crate::template_utils::{IntoContext, Ructe}; use guid_create::GUID; use multipart::server::{ save::{SaveResult, SavedData}, @@ -10,9 +12,7 @@ use rocket::{ Data, }; use rocket_i18n::I18n; -use routes::{errors::ErrorPage, Page}; use std::fs; -use template_utils::{IntoContext, Ructe}; #[get("/medias?")] pub fn list(user: User, page: Option, rockets: PlumeRocket) -> Result { diff --git a/src/routes/mod.rs b/src/routes/mod.rs index e2a37266..88da993d 100644 --- a/src/routes/mod.rs +++ b/src/routes/mod.rs @@ -1,4 +1,5 @@ #![warn(clippy::too_many_arguments)] +use crate::template_utils::Ructe; use atom_syndication::{ContentBuilder, Entry, EntryBuilder, LinkBuilder, Person, PersonBuilder}; use plume_models::{posts::Post, Connection, CONFIG, ITEMS_PER_PAGE}; use rocket::{ @@ -16,7 +17,6 @@ use std::{ hash::Hasher, path::{Path, PathBuf}, }; -use template_utils::Ructe; /// Special return type used for routes that "cannot fail", and instead /// `Redirect`, or `Flash`, when we cannot deliver a `Ructe` Response @@ -178,7 +178,7 @@ pub struct CachedFile { pub struct ThemeFile(NamedFile); impl<'r> Responder<'r> for ThemeFile { - fn respond_to(self, r: &Request) -> response::Result<'r> { + fn respond_to(self, r: &Request<'_>) -> response::Result<'r> { let contents = std::fs::read(self.0.path()).map_err(|_| Status::InternalServerError)?; let mut hasher = DefaultHasher::new(); diff --git a/src/routes/notifications.rs b/src/routes/notifications.rs index 41ba5918..cec540d7 100644 --- a/src/routes/notifications.rs +++ b/src/routes/notifications.rs @@ -1,10 +1,10 @@ use rocket::response::{Flash, Redirect}; use rocket_i18n::I18n; +use crate::routes::{errors::ErrorPage, Page}; +use crate::template_utils::{IntoContext, Ructe}; use plume_common::utils; use plume_models::{notifications::Notification, users::User, PlumeRocket}; -use routes::{errors::ErrorPage, Page}; -use template_utils::{IntoContext, Ructe}; #[get("/notifications?")] pub fn notifications( diff --git a/src/routes/posts.rs b/src/routes/posts.rs index dcd0417b..d070bb5f 100644 --- a/src/routes/posts.rs +++ b/src/routes/posts.rs @@ -10,6 +10,10 @@ use std::{ }; use validator::{Validate, ValidationError, ValidationErrors}; +use crate::routes::{ + comments::NewCommentForm, errors::ErrorPage, ContentLen, RemoteForm, RespondOrRedirect, +}; +use crate::template_utils::{IntoContext, Ructe}; use plume_common::activity_pub::{broadcast, ActivityStream, ApRequest}; use plume_common::utils; use plume_models::{ @@ -27,10 +31,6 @@ use plume_models::{ users::User, Error, PlumeRocket, }; -use routes::{ - comments::NewCommentForm, errors::ErrorPage, ContentLen, RemoteForm, RespondOrRedirect, -}; -use template_utils::{IntoContext, Ructe}; #[get("/~//?", rank = 4)] pub fn details( diff --git a/src/routes/reshares.rs b/src/routes/reshares.rs index a66c24f8..9fe63650 100644 --- a/src/routes/reshares.rs +++ b/src/routes/reshares.rs @@ -1,13 +1,13 @@ use rocket::response::{Flash, Redirect}; use rocket_i18n::I18n; +use crate::routes::errors::ErrorPage; use plume_common::activity_pub::broadcast; use plume_common::utils; use plume_models::{ blogs::Blog, inbox::inbox, posts::Post, reshares::*, timeline::*, users::User, Error, PlumeRocket, }; -use routes::errors::ErrorPage; #[post("/~///reshare")] pub fn create( diff --git a/src/routes/search.rs b/src/routes/search.rs index b605d103..0341bf8f 100644 --- a/src/routes/search.rs +++ b/src/routes/search.rs @@ -1,10 +1,10 @@ use chrono::offset::Utc; use rocket::request::Form; +use crate::routes::Page; +use crate::template_utils::{IntoContext, Ructe}; use plume_models::{search::Query, PlumeRocket}; -use routes::Page; use std::str::FromStr; -use template_utils::{IntoContext, Ructe}; #[derive(Default, FromForm)] pub struct SearchQuery { diff --git a/src/routes/session.rs b/src/routes/session.rs index 86a5b631..6c968720 100644 --- a/src/routes/session.rs +++ b/src/routes/session.rs @@ -1,3 +1,4 @@ +use crate::routes::RespondOrRedirect; use lettre::Transport; use rocket::http::ext::IntoOwned; use rocket::{ @@ -7,7 +8,6 @@ use rocket::{ State, }; use rocket_i18n::I18n; -use routes::RespondOrRedirect; use std::{ borrow::Cow, sync::{Arc, Mutex}, @@ -15,13 +15,13 @@ use std::{ }; use validator::{Validate, ValidationError, ValidationErrors}; -use mail::{build_mail, Mailer}; +use crate::mail::{build_mail, Mailer}; +use crate::template_utils::{IntoContext, Ructe}; use plume_models::{ password_reset_requests::*, users::{User, AUTH_COOKIE}, Error, PlumeRocket, CONFIG, }; -use template_utils::{IntoContext, Ructe}; #[get("/login?")] pub fn new(m: Option, rockets: PlumeRocket) -> Ructe { @@ -44,7 +44,7 @@ pub struct LoginForm { #[post("/login", data = "
")] pub fn create( form: LenientForm, - mut cookies: Cookies, + mut cookies: Cookies<'_>, rockets: PlumeRocket, ) -> RespondOrRedirect { let conn = &*rockets.conn; @@ -118,7 +118,7 @@ pub fn create( } #[get("/logout")] -pub fn delete(mut cookies: Cookies, intl: I18n) -> Flash { +pub fn delete(mut cookies: Cookies<'_>, intl: I18n) -> Flash { if let Some(cookie) = cookies.get_private(AUTH_COOKIE) { cookies.remove_private(cookie); } @@ -158,7 +158,7 @@ pub struct ResetForm { #[post("/password-reset", data = "")] pub fn password_reset_request( - mail: State>>, + mail: State<'_, Arc>>, form: Form, rockets: PlumeRocket, ) -> Ructe { diff --git a/src/routes/tags.rs b/src/routes/tags.rs index 95d637a2..56dabd1d 100644 --- a/src/routes/tags.rs +++ b/src/routes/tags.rs @@ -1,6 +1,6 @@ +use crate::routes::{errors::ErrorPage, Page}; +use crate::template_utils::{IntoContext, Ructe}; use plume_models::{posts::Post, PlumeRocket}; -use routes::{errors::ErrorPage, Page}; -use template_utils::{IntoContext, Ructe}; #[get("/tag/?")] pub fn tag(name: String, page: Option, rockets: PlumeRocket) -> Result { diff --git a/src/routes/timelines.rs b/src/routes/timelines.rs index 66d7587c..b435e449 100644 --- a/src/routes/timelines.rs +++ b/src/routes/timelines.rs @@ -1,10 +1,10 @@ #![allow(dead_code)] +use crate::routes::Page; +use crate::template_utils::IntoContext; use crate::{routes::errors::ErrorPage, template_utils::Ructe}; use plume_models::{timeline::*, PlumeRocket}; use rocket::response::Redirect; -use routes::Page; -use template_utils::IntoContext; #[get("/timeline/?")] pub fn details(id: i32, rockets: PlumeRocket, page: Option) -> Result { diff --git a/src/routes/user.rs b/src/routes/user.rs index eac1b2f5..2cc48302 100644 --- a/src/routes/user.rs +++ b/src/routes/user.rs @@ -14,7 +14,9 @@ use serde_json; use std::{borrow::Cow, collections::HashMap}; use validator::{Validate, ValidationError, ValidationErrors}; -use inbox; +use crate::inbox; +use crate::routes::{errors::ErrorPage, Page, RemoteForm, RespondOrRedirect}; +use crate::template_utils::{IntoContext, Ructe}; use plume_common::activity_pub::{broadcast, inbox::FromId, ActivityStream, ApRequest, Id}; use plume_common::utils; use plume_models::{ @@ -31,8 +33,6 @@ use plume_models::{ users::*, Error, PlumeRocket, }; -use routes::{errors::ErrorPage, Page, RemoteForm, RespondOrRedirect}; -use template_utils::{IntoContext, Ructe}; #[get("/me")] pub fn me(user: Option) -> RespondOrRedirect { @@ -413,7 +413,7 @@ pub fn update( pub fn delete( name: String, user: User, - mut cookies: Cookies, + mut cookies: Cookies<'_>, rockets: PlumeRocket, ) -> Result, ErrorPage> { let account = User::find_by_fqn(&rockets, &name)?; @@ -580,7 +580,7 @@ pub fn outbox_page( pub fn inbox( name: String, data: inbox::SignedJson, - headers: Headers, + headers: Headers<'_>, rockets: PlumeRocket, ) -> Result> { User::find_by_fqn(&rockets, &name).map_err(|_| status::BadRequest(Some("User not found")))?; diff --git a/src/template_utils.rs b/src/template_utils.rs index a5c7cceb..26bf58b4 100644 --- a/src/template_utils.rs +++ b/src/template_utils.rs @@ -1,5 +1,6 @@ use plume_models::{notifications::*, users::User, Connection, PlumeRocket}; +use crate::templates::Html; use rocket::http::hyper::header::{ETag, EntityTag}; use rocket::http::{Method, Status}; use rocket::request::Request; @@ -7,7 +8,6 @@ use rocket::response::{self, content::Html as HtmlCt, Responder, Response}; use rocket_i18n::Catalog; use std::collections::{btree_map::BTreeMap, hash_map::DefaultHasher}; use std::hash::Hasher; -use templates::Html; pub use askama_escape::escape; @@ -53,7 +53,7 @@ impl IntoContext for PlumeRocket { pub struct Ructe(pub Vec); impl<'r> Responder<'r> for Ructe { - fn respond_to(self, r: &Request) -> response::Result<'r> { + fn respond_to(self, r: &Request<'_>) -> response::Result<'r> { //if method is not Get or page contain a form, no caching if r.method() != Method::Get || self.0.windows(6).any(|w| w == b" Responder<'r> for Ructe { macro_rules! render { ($group:tt :: $page:tt ( $( $param:expr ),* ) ) => { { - use templates; + use crate::templates; let mut res = vec![]; templates::$group::$page( @@ -96,7 +96,7 @@ macro_rules! render { } } -pub fn translate_notification(ctx: BaseContext, notif: Notification) -> String { +pub fn translate_notification(ctx: BaseContext<'_>, notif: Notification) -> String { let name = notif.get_actor(ctx.0).unwrap().name(); match notif.kind.as_ref() { notification_kind::COMMENT => i18n!(ctx.1, "{0} commented on your article."; &name), diff --git a/templates/base.rs.html b/templates/base.rs.html index 7e261860..110c764d 100644 --- a/templates/base.rs.html +++ b/templates/base.rs.html @@ -1,8 +1,9 @@ @use plume_models::CONFIG; @use plume_models::instance::Instance; -@use template_utils::*; -@use routes::*; @use std::path::Path; +@use crate::template_utils::*; +@use crate::routes::*; + @(ctx: BaseContext, title: String, head: Content, header: Content, content: Content) diff --git a/templates/blogs/details.rs.html b/templates/blogs/details.rs.html index 938a6645..5dacdd98 100644 --- a/templates/blogs/details.rs.html +++ b/templates/blogs/details.rs.html @@ -2,10 +2,10 @@ @use plume_models::instance::Instance; @use plume_models::posts::Post; @use plume_models::users::User; -@use templates::{base, partials::post_card}; -@use template_utils::*; -@use routes::*; @use std::path::Path; +@use crate::templates::{base, partials::post_card}; +@use crate::template_utils::*; +@use crate::routes::*; @(ctx: BaseContext, blog: Blog, authors: &[User], page: i32, n_pages: i32, posts: Vec) diff --git a/templates/blogs/edit.rs.html b/templates/blogs/edit.rs.html index fa14a106..b7806830 100644 --- a/templates/blogs/edit.rs.html +++ b/templates/blogs/edit.rs.html @@ -2,12 +2,12 @@ @use plume_models::blogs::Blog; @use plume_models::instance::Instance; @use plume_models::medias::Media; -@use routes::blogs; -@use routes::blogs::EditForm; -@use routes::medias; -@use template_utils::*; -@use templates::base; -@use templates::partials::image_select; +@use crate::template_utils::*; +@use crate::templates::base; +@use crate::templates::partials::image_select; +@use crate::routes::blogs; +@use crate::routes::blogs::EditForm; +@use crate::routes::medias; @(ctx: BaseContext, blog: &Blog, medias: Vec, form: &EditForm, errors: ValidationErrors) diff --git a/templates/blogs/new.rs.html b/templates/blogs/new.rs.html index 8480814b..5b98a7e8 100644 --- a/templates/blogs/new.rs.html +++ b/templates/blogs/new.rs.html @@ -1,8 +1,8 @@ @use validator::ValidationErrors; -@use templates::base; -@use template_utils::*; -@use routes::blogs::NewBlogForm; -@use routes::*; +@use crate::templates::base; +@use crate::template_utils::*; +@use crate::routes::blogs::NewBlogForm; +@use crate::routes::*; @(ctx: BaseContext, form: &NewBlogForm, errors: ValidationErrors) diff --git a/templates/errors/base.rs.html b/templates/errors/base.rs.html index 33abe8c3..247a6000 100644 --- a/templates/errors/base.rs.html +++ b/templates/errors/base.rs.html @@ -1,5 +1,5 @@ -@use templates::base as base_template; -@use template_utils::*; +@use crate::templates::base as base_template; +@use crate::template_utils::*; @(ctx: BaseContext, error_message: String, error: Content) diff --git a/templates/errors/csrf.rs.html b/templates/errors/csrf.rs.html index 144cf14a..a66a1e95 100644 --- a/templates/errors/csrf.rs.html +++ b/templates/errors/csrf.rs.html @@ -1,5 +1,5 @@ -@use templates::errors::base; -@use template_utils::*; +@use crate::templates::errors::base; +@use crate::template_utils::*; @(ctx: BaseContext) diff --git a/templates/errors/not_authorized.rs.html b/templates/errors/not_authorized.rs.html index 84967340..2efd2993 100644 --- a/templates/errors/not_authorized.rs.html +++ b/templates/errors/not_authorized.rs.html @@ -1,5 +1,5 @@ -@use templates::errors::base; -@use template_utils::*; +@use crate::templates::errors::base; +@use crate::template_utils::*; @(ctx: BaseContext, error_message: String) diff --git a/templates/errors/not_found.rs.html b/templates/errors/not_found.rs.html index bdeba65b..758d976e 100644 --- a/templates/errors/not_found.rs.html +++ b/templates/errors/not_found.rs.html @@ -1,5 +1,5 @@ -@use templates::errors::base; -@use template_utils::*; +@use crate::templates::errors::base; +@use crate::template_utils::*; @(ctx: BaseContext) @@ -7,4 +7,3 @@

@i18n!(ctx.1, "We couldn't find this page.")

@i18n!(ctx.1, "The link that led you here may be broken.")

}) - diff --git a/templates/errors/server_error.rs.html b/templates/errors/server_error.rs.html index cace0ae8..5e5ce46d 100644 --- a/templates/errors/server_error.rs.html +++ b/templates/errors/server_error.rs.html @@ -1,5 +1,5 @@ -@use templates::errors::base; -@use template_utils::*; +@use crate::templates::errors::base; +@use crate::template_utils::*; @(ctx: BaseContext) diff --git a/templates/errors/unprocessable_entity.rs.html b/templates/errors/unprocessable_entity.rs.html index 647c0505..8e0347ac 100644 --- a/templates/errors/unprocessable_entity.rs.html +++ b/templates/errors/unprocessable_entity.rs.html @@ -1,5 +1,5 @@ -@use templates::errors::base; -@use template_utils::*; +@use crate::templates::errors::base; +@use crate::template_utils::*; @(ctx: BaseContext) @@ -7,4 +7,3 @@

@i18n!(ctx.1, "The content you sent can't be processed.")

@i18n!(ctx.1, "Maybe it was too long.")

}) - diff --git a/templates/instance/about.rs.html b/templates/instance/about.rs.html index 16dade2a..180521d7 100644 --- a/templates/instance/about.rs.html +++ b/templates/instance/about.rs.html @@ -1,7 +1,7 @@ @use plume_models::{instance::Instance, users::User}; -@use templates::base; -@use template_utils::*; -@use routes::*; +@use crate::templates::base; +@use crate::template_utils::*; +@use crate::routes::*; @(ctx: BaseContext, instance: Instance, admin: User, n_users: i64, n_articles: i64, n_instances: i64) diff --git a/templates/instance/admin.rs.html b/templates/instance/admin.rs.html index 77c49c08..7ff3750d 100644 --- a/templates/instance/admin.rs.html +++ b/templates/instance/admin.rs.html @@ -1,9 +1,9 @@ @use plume_models::instance::Instance; @use validator::ValidationErrors; -@use templates::base; -@use template_utils::*; -@use routes::instance::InstanceSettingsForm; -@use routes::*; +@use crate::templates::base; +@use crate::template_utils::*; +@use crate::routes::instance::InstanceSettingsForm; +@use crate::routes::*; @(ctx: BaseContext, instance: Instance, form: InstanceSettingsForm, errors: ValidationErrors) diff --git a/templates/instance/admin_mod.rs.html b/templates/instance/admin_mod.rs.html index d1c2468f..e215d7e1 100644 --- a/templates/instance/admin_mod.rs.html +++ b/templates/instance/admin_mod.rs.html @@ -1,6 +1,6 @@ -@use templates::base; -@use template_utils::*; -@use routes::*; +@use crate::templates::base; +@use crate::template_utils::*; +@use crate::routes::*; @(ctx: BaseContext) diff --git a/templates/instance/emailblocklist.rs.html b/templates/instance/emailblocklist.rs.html index bd67bf56..f295fe16 100644 --- a/templates/instance/emailblocklist.rs.html +++ b/templates/instance/emailblocklist.rs.html @@ -1,7 +1,7 @@ -@use templates::base; @use plume_models::blocklisted_emails::BlocklistedEmail; -@use template_utils::*; -@use routes::*; +@use crate::templates::base; +@use crate::template_utils::*; +@use crate::routes::*; @(ctx:BaseContext, emails: Vec, page:i32, n_pages:i32) @:base(ctx, i18n!(ctx.1, "Blocklisted Emails"), {}, {}, { diff --git a/templates/instance/index.rs.html b/templates/instance/index.rs.html index bf865b1e..0361318e 100644 --- a/templates/instance/index.rs.html +++ b/templates/instance/index.rs.html @@ -1,9 +1,9 @@ -@use templates::{base, partials::*}; -@use template_utils::*; @use plume_models::instance::Instance; @use plume_models::posts::Post; @use plume_models::timeline::Timeline; -@use routes::*; +@use crate::templates::{base, partials::*}; +@use crate::template_utils::*; +@use crate::routes::*; @(ctx: BaseContext, instance: Instance, n_users: i64, n_articles: i64, all_tl: Vec<(Timeline, Vec)>) diff --git a/templates/instance/list.rs.html b/templates/instance/list.rs.html index cbb94045..619689f7 100644 --- a/templates/instance/list.rs.html +++ b/templates/instance/list.rs.html @@ -1,7 +1,7 @@ @use plume_models::instance::Instance; -@use templates::base; -@use template_utils::*; -@use routes::*; +@use crate::templates::base; +@use crate::template_utils::*; +@use crate::routes::*; @(ctx: BaseContext, instance: Instance, instances: Vec, page: i32, n_pages: i32) diff --git a/templates/instance/privacy.rs.html b/templates/instance/privacy.rs.html index 3d261751..0dd8a4b2 100644 --- a/templates/instance/privacy.rs.html +++ b/templates/instance/privacy.rs.html @@ -1,5 +1,5 @@ -@use templates::base; -@use template_utils::*; +@use crate::templates::base; +@use crate::template_utils::*; @(ctx: BaseContext) diff --git a/templates/instance/users.rs.html b/templates/instance/users.rs.html index 848a8aef..8bcf48e7 100644 --- a/templates/instance/users.rs.html +++ b/templates/instance/users.rs.html @@ -1,7 +1,7 @@ @use plume_models::users::User; -@use templates::base; -@use template_utils::*; -@use routes::*; +@use crate::templates::base; +@use crate::template_utils::*; +@use crate::routes::*; @(ctx: BaseContext, users: Vec, page: i32, n_pages: i32) diff --git a/templates/medias/details.rs.html b/templates/medias/details.rs.html index 08f14d82..0f5e894a 100644 --- a/templates/medias/details.rs.html +++ b/templates/medias/details.rs.html @@ -1,8 +1,8 @@ @use plume_models::medias::{Media, MediaCategory}; @use plume_models::safe_string::SafeString; -@use templates::base; -@use template_utils::*; -@use routes::*; +@use crate::templates::base; +@use crate::template_utils::*; +@use crate::routes::*; @(ctx: BaseContext, media: Media) diff --git a/templates/medias/index.rs.html b/templates/medias/index.rs.html index 6f5ba17a..faa59771 100644 --- a/templates/medias/index.rs.html +++ b/templates/medias/index.rs.html @@ -1,7 +1,7 @@ @use plume_models::medias::*; -@use templates::base; -@use template_utils::*; -@use routes::*; +@use crate::templates::base; +@use crate::template_utils::*; +@use crate::routes::*; @(ctx: BaseContext, medias: Vec, page: i32, n_pages: i32) diff --git a/templates/medias/new.rs.html b/templates/medias/new.rs.html index 5b3b4e5c..40bb6f87 100644 --- a/templates/medias/new.rs.html +++ b/templates/medias/new.rs.html @@ -1,6 +1,6 @@ -@use templates::base; -@use template_utils::*; -@use routes::*; +@use crate::templates::base; +@use crate::template_utils::*; +@use crate::routes::*; @(ctx: BaseContext) diff --git a/templates/notifications/index.rs.html b/templates/notifications/index.rs.html index da2b8bb9..92d5e538 100644 --- a/templates/notifications/index.rs.html +++ b/templates/notifications/index.rs.html @@ -1,6 +1,6 @@ -@use templates::base; -@use template_utils::*; @use plume_models::notifications::Notification; +@use crate::templates::base; +@use crate::template_utils::*; @(ctx: BaseContext, notifications: Vec, page: i32, n_pages: i32) diff --git a/templates/partials/comment.rs.html b/templates/partials/comment.rs.html index 3483f381..d6f07e91 100644 --- a/templates/partials/comment.rs.html +++ b/templates/partials/comment.rs.html @@ -1,6 +1,6 @@ -@use template_utils::*; @use plume_models::comments::CommentTree; -@use routes::*; +@use crate::template_utils::*; +@use crate::routes::*; @(ctx: BaseContext, comment_tree: &CommentTree, in_reply_to: Option<&str>, blog: &str, slug: &str) diff --git a/templates/partials/image_select.rs.html b/templates/partials/image_select.rs.html index cf1512da..8a200bbd 100644 --- a/templates/partials/image_select.rs.html +++ b/templates/partials/image_select.rs.html @@ -1,5 +1,5 @@ -@use template_utils::*; @use plume_models::medias::*; +@use crate::template_utils::*; @(ctx: BaseContext, id: &str, title: String, optional: bool, medias: Vec, selected: Option) diff --git a/templates/partials/instance_description.rs.html b/templates/partials/instance_description.rs.html index 6cfba348..3553e0f4 100644 --- a/templates/partials/instance_description.rs.html +++ b/templates/partials/instance_description.rs.html @@ -1,6 +1,6 @@ -@use template_utils::*; @use plume_models::instance::Instance; -@use routes::*; +@use crate::template_utils::*; +@use crate::routes::*; @(ctx: BaseContext, instance: Instance, n_users: i64, n_articles: i64) diff --git a/templates/partials/post_card.rs.html b/templates/partials/post_card.rs.html index e9e9f19a..d0475e95 100644 --- a/templates/partials/post_card.rs.html +++ b/templates/partials/post_card.rs.html @@ -1,6 +1,6 @@ @use plume_models::posts::Post; -@use template_utils::*; -@use routes::*; +@use crate::template_utils::*; +@use crate::routes::*; @(ctx: BaseContext, article: Post) @@ -31,4 +31,3 @@ } - diff --git a/templates/posts/details.rs.html b/templates/posts/details.rs.html index a11ddf55..7d689d98 100644 --- a/templates/posts/details.rs.html +++ b/templates/posts/details.rs.html @@ -1,14 +1,14 @@ -@use templates::{base, partials::comment}; -@use template_utils::*; @use plume_models::blogs::Blog; @use plume_models::comments::{Comment, CommentTree}; @use plume_models::posts::Post; @use plume_models::tags::Tag; @use plume_models::users::User; -@use validator::ValidationErrors; -@use routes::comments::NewCommentForm; -@use routes::*; @use std::path::Path; +@use validator::ValidationErrors; +@use crate::templates::{base, partials::comment}; +@use crate::template_utils::*; +@use crate::routes::comments::NewCommentForm; +@use crate::routes::*; @(ctx: BaseContext, article: Post, blog: Blog, comment_form: &NewCommentForm, comment_errors: ValidationErrors, tags: Vec, comments: Vec, previous_comment: Option, n_likes: i64, n_reshares: i64, has_liked: bool, has_reshared: bool, is_following: bool, author: User) diff --git a/templates/posts/new.rs.html b/templates/posts/new.rs.html index 156d352e..5debc7af 100644 --- a/templates/posts/new.rs.html +++ b/templates/posts/new.rs.html @@ -1,13 +1,13 @@ -@use templates::base; -@use templates::partials::image_select; -@use template_utils::*; -@use validator::{ValidationErrors, ValidationErrorsKind}; -@use std::borrow::Cow; @use plume_models::medias::*; @use plume_models::blogs::Blog; @use plume_models::posts::Post; -@use routes::posts::NewPostForm; -@use routes::*; +@use std::borrow::Cow; +@use validator::{ValidationErrors, ValidationErrorsKind}; +@use crate::templates::base; +@use crate::templates::partials::image_select; +@use crate::template_utils::*; +@use crate::routes::posts::NewPostForm; +@use crate::routes::*; @(ctx: BaseContext, title: String, blog: Blog, editing: bool, form: &NewPostForm, is_draft: bool, article: Option, errors: ValidationErrors, medias: Vec, content_len: u64) diff --git a/templates/posts/remote_interact.rs.html b/templates/posts/remote_interact.rs.html index d998f1f1..77d1605e 100644 --- a/templates/posts/remote_interact.rs.html +++ b/templates/posts/remote_interact.rs.html @@ -1,10 +1,10 @@ -@use templates::remote_interact_base; -@use templates::partials::post_card; @use plume_models::posts::Post; -@use routes::RemoteForm; -@use routes::session::LoginForm; -@use template_utils::*; @use validator::ValidationErrors; +@use crate::templates::remote_interact_base; +@use crate::templates::partials::post_card; +@use crate::template_utils::*; +@use crate::routes::RemoteForm; +@use crate::routes::session::LoginForm; @(ctx: BaseContext, post: Post, login_form: LoginForm, login_errs: ValidationErrors, remote_form: RemoteForm, remote_errs: ValidationErrors) diff --git a/templates/remote_interact_base.rs.html b/templates/remote_interact_base.rs.html index c5fc03f9..ee628cd5 100644 --- a/templates/remote_interact_base.rs.html +++ b/templates/remote_interact_base.rs.html @@ -1,8 +1,8 @@ -@use templates::base; -@use routes::session::LoginForm; -@use routes::RemoteForm; -@use template_utils::*; @use validator::ValidationErrors; +@use crate::templates::base; +@use crate::template_utils::*; +@use crate::routes::session::LoginForm; +@use crate::routes::RemoteForm; @(ctx: BaseContext, title: String, login_msg: String, remote_msg: String, header: Content, login_form: LoginForm, login_errs: ValidationErrors, remote_form: RemoteForm, remote_errs: ValidationErrors) diff --git a/templates/search/index.rs.html b/templates/search/index.rs.html index 84cfbb2a..c4fe7f73 100644 --- a/templates/search/index.rs.html +++ b/templates/search/index.rs.html @@ -1,5 +1,5 @@ -@use templates::base; -@use template_utils::*; +@use crate::templates::base; +@use crate::template_utils::*; @(ctx: BaseContext, now: &str) diff --git a/templates/search/result.rs.html b/templates/search/result.rs.html index 7490bd6a..cd0998e9 100644 --- a/templates/search/result.rs.html +++ b/templates/search/result.rs.html @@ -1,6 +1,6 @@ -@use templates::{base, partials::post_card}; -@use template_utils::*; @use plume_models::posts::Post; +@use crate::templates::{base, partials::post_card}; +@use crate::template_utils::*; @(ctx: BaseContext, query_str: &str, articles: Vec, page: i32, n_pages: i32) diff --git a/templates/session/login.rs.html b/templates/session/login.rs.html index c38bc059..a154d06e 100644 --- a/templates/session/login.rs.html +++ b/templates/session/login.rs.html @@ -1,8 +1,8 @@ -@use template_utils::*; -@use templates::base; @use validator::ValidationErrors; -@use routes::session::LoginForm; -@use routes::*; +@use crate::template_utils::*; +@use crate::templates::base; +@use crate::routes::session::LoginForm; +@use crate::routes::*; @(ctx: BaseContext, message: Option, form: &LoginForm, errors: ValidationErrors) diff --git a/templates/session/password_reset.rs.html b/templates/session/password_reset.rs.html index 918b9057..5d33f7c7 100644 --- a/templates/session/password_reset.rs.html +++ b/templates/session/password_reset.rs.html @@ -1,7 +1,7 @@ -@use template_utils::*; -@use templates::base; -@use routes::session::NewPasswordForm; @use validator::ValidationErrors; +@use crate::template_utils::*; +@use crate::templates::base; +@use crate::routes::session::NewPasswordForm; @(ctx: BaseContext, form: &NewPasswordForm, errors: ValidationErrors) diff --git a/templates/session/password_reset_request.rs.html b/templates/session/password_reset_request.rs.html index 55d2176c..6ac9f88c 100644 --- a/templates/session/password_reset_request.rs.html +++ b/templates/session/password_reset_request.rs.html @@ -1,7 +1,7 @@ -@use template_utils::*; -@use templates::base; -@use routes::session::ResetForm; @use validator::ValidationErrors; +@use crate::template_utils::*; +@use crate::templates::base; +@use crate::routes::session::ResetForm; @(ctx: BaseContext, form: &ResetForm, errors: ValidationErrors) diff --git a/templates/session/password_reset_request_expired.rs.html b/templates/session/password_reset_request_expired.rs.html index 3f3210cd..aad1fd76 100644 --- a/templates/session/password_reset_request_expired.rs.html +++ b/templates/session/password_reset_request_expired.rs.html @@ -1,5 +1,5 @@ -@use template_utils::*; -@use templates::base; +@use crate::template_utils::*; +@use crate::templates::base; @(ctx: BaseContext) diff --git a/templates/session/password_reset_request_ok.rs.html b/templates/session/password_reset_request_ok.rs.html index 9b141c89..c9d194ea 100644 --- a/templates/session/password_reset_request_ok.rs.html +++ b/templates/session/password_reset_request_ok.rs.html @@ -1,5 +1,5 @@ -@use template_utils::*; -@use templates::base; +@use crate::template_utils::*; +@use crate::templates::base; @(ctx: BaseContext) diff --git a/templates/tags/index.rs.html b/templates/tags/index.rs.html index 0b8bdbf0..46159b09 100644 --- a/templates/tags/index.rs.html +++ b/templates/tags/index.rs.html @@ -1,6 +1,6 @@ -@use templates::{base, partials::post_card}; -@use template_utils::*; @use plume_models::posts::Post; +@use crate::templates::{base, partials::post_card}; +@use crate::template_utils::*; @(ctx: BaseContext, tag: String, articles: Vec, page: i32, n_pages: i32) diff --git a/templates/timelines/details.rs.html b/templates/timelines/details.rs.html index afd3bec5..c66de56c 100644 --- a/templates/timelines/details.rs.html +++ b/templates/timelines/details.rs.html @@ -1,9 +1,9 @@ @use plume_models::posts::Post; @use plume_models::timeline::Timeline; -@use template_utils::*; -@use templates::base; -@use templates::partials::post_card; -@use routes::*; +@use crate::template_utils::*; +@use crate::templates::base; +@use crate::templates::partials::post_card; +@use crate::routes::*; @(ctx: BaseContext, tl: Timeline, articles: Vec, all_tl: Vec, page: i32, n_pages: i32) diff --git a/templates/users/dashboard.rs.html b/templates/users/dashboard.rs.html index ab3aacc3..239ec6b7 100644 --- a/templates/users/dashboard.rs.html +++ b/templates/users/dashboard.rs.html @@ -1,8 +1,8 @@ -@use templates::{base, partials::post_card}; -@use template_utils::*; @use plume_models::blogs::Blog; @use plume_models::posts::Post; -@use routes::*; +@use crate::templates::{base, partials::post_card}; +@use crate::template_utils::*; +@use crate::routes::*; @(ctx: BaseContext, blogs: Vec, drafts: Vec) diff --git a/templates/users/details.rs.html b/templates/users/details.rs.html index 617ce1ae..609e26f9 100644 --- a/templates/users/details.rs.html +++ b/templates/users/details.rs.html @@ -1,9 +1,9 @@ -@use templates::{base, partials::post_card, users::header}; -@use template_utils::*; @use plume_models::instance::Instance; @use plume_models::users::User; @use plume_models::posts::Post; -@use routes::*; +@use crate::templates::{base, partials::post_card, users::header}; +@use crate::template_utils::*; +@use crate::routes::*; @(ctx: BaseContext, user: User, follows: bool, is_remote: bool, remote_url: String, recents: Vec, reshares: Vec) diff --git a/templates/users/edit.rs.html b/templates/users/edit.rs.html index 43a0ebad..3c0086d9 100644 --- a/templates/users/edit.rs.html +++ b/templates/users/edit.rs.html @@ -1,9 +1,9 @@ -@use templates::base; -@use template_utils::*; @use plume_models::instance::Instance; -@use routes::user::UpdateUserForm; @use validator::ValidationErrors; -@use routes::*; +@use crate::templates::base; +@use crate::template_utils::*; +@use crate::routes::user::UpdateUserForm; +@use crate::routes::*; @(ctx: BaseContext, form: UpdateUserForm, errors: ValidationErrors) diff --git a/templates/users/follow_remote.rs.html b/templates/users/follow_remote.rs.html index 93270be4..7b291187 100644 --- a/templates/users/follow_remote.rs.html +++ b/templates/users/follow_remote.rs.html @@ -1,9 +1,9 @@ -@use templates::remote_interact_base; @use plume_models::users::User; -@use routes::RemoteForm; -@use routes::session::LoginForm; -@use template_utils::*; @use validator::ValidationErrors; +@use crate::templates::remote_interact_base; +@use crate::template_utils::*; +@use crate::routes::RemoteForm; +@use crate::routes::session::LoginForm; @(ctx: BaseContext, user: User, login_form: LoginForm, login_errs: ValidationErrors, remote_form: RemoteForm, remote_errs: ValidationErrors) diff --git a/templates/users/followed.rs.html b/templates/users/followed.rs.html index ce4e1146..106d6003 100644 --- a/templates/users/followed.rs.html +++ b/templates/users/followed.rs.html @@ -1,7 +1,7 @@ -@use templates::{base, users::header}; -@use template_utils::*; @use plume_models::users::User; -@use routes::*; +@use crate::templates::{base, users::header}; +@use crate::template_utils::*; +@use crate::routes::*; @(ctx: BaseContext, user: User, follows: bool, is_remote: bool, remote_url: String, followed: Vec, page: i32, n_pages: i32) diff --git a/templates/users/followers.rs.html b/templates/users/followers.rs.html index 762c85bc..65202ad0 100644 --- a/templates/users/followers.rs.html +++ b/templates/users/followers.rs.html @@ -1,7 +1,7 @@ -@use templates::{base, users::header}; -@use template_utils::*; @use plume_models::users::User; -@use routes::*; +@use crate::templates::{base, users::header}; +@use crate::template_utils::*; +@use crate::routes::*; @(ctx: BaseContext, user: User, follows: bool, is_remote: bool, remote_url: String, followers: Vec, page: i32, n_pages: i32) diff --git a/templates/users/header.rs.html b/templates/users/header.rs.html index ca68eda7..567d8a12 100644 --- a/templates/users/header.rs.html +++ b/templates/users/header.rs.html @@ -1,6 +1,6 @@ -@use template_utils::*; @use plume_models::users::User; -@use routes::*; +@use crate::template_utils::*; +@use crate::routes::*; @(ctx: BaseContext, user: &User, follows: bool, is_remote: bool, instance_url: String) diff --git a/templates/users/new.rs.html b/templates/users/new.rs.html index bd38d622..1bf91acd 100644 --- a/templates/users/new.rs.html +++ b/templates/users/new.rs.html @@ -1,9 +1,9 @@ -@use templates::base; -@use template_utils::*; -@use routes::user::NewUserForm; -@use validator::{ValidationErrors, ValidationErrorsKind}; -@use routes::*; @use std::borrow::Cow; +@use validator::{ValidationErrors, ValidationErrorsKind}; +@use crate::templates::base; +@use crate::template_utils::*; +@use crate::routes::user::NewUserForm; +@use crate::routes::*; @(ctx: BaseContext, enabled: bool, form: &NewUserForm, errors: ValidationErrors)