Run 'cargo fmt' to format code (#489)

This commit is contained in:
Atul Bhosale
2019-03-20 17:56:17 +01:00
committed by Baptiste Gelez
parent 732f514da7
commit b945d1f602
58 changed files with 3159 additions and 2194 deletions
+41 -33
View File
@@ -2,25 +2,21 @@
use atom_syndication::{ContentBuilder, Entry, EntryBuilder, LinkBuilder, Person, PersonBuilder};
use rocket::{
http::{
RawStr, Status, uri::{FromUriParam, Query},
hyper::header::{CacheControl, CacheDirective}
hyper::header::{CacheControl, CacheDirective},
uri::{FromUriParam, Query},
RawStr, Status,
},
Outcome,
request::{self, FromFormValue, FromRequest, Request},
response::NamedFile,
Outcome,
};
use rocket_i18n::I18n;
use std::path::{Path, PathBuf};
use plume_models::{
Connection,
users::User,
posts::Post,
db_conn::DbConn,
};
use plume_models::{db_conn::DbConn, posts::Post, users::User, Connection};
use Worker;
use Searcher;
use Worker;
pub struct PlumeRocket<'a> {
conn: DbConn,
@@ -100,7 +96,6 @@ impl<'a, 'r> FromRequest<'a, 'r> for ContentLen {
}
}
impl Default for Page {
fn default() -> Self {
Page(1)
@@ -110,20 +105,33 @@ impl Default for Page {
pub fn post_to_atom(post: Post, conn: &Connection) -> Entry {
EntryBuilder::default()
.title(format!("<![CDATA[{}]]>", post.title))
.content(ContentBuilder::default()
.value(format!("<![CDATA[{}]]>", *post.content.get()))
.src(post.ap_url.clone())
.content_type("html".to_string())
.build().expect("Atom feed: content error"))
.authors(post.get_authors(&*conn).expect("Atom feed: author error")
.into_iter()
.map(|a| PersonBuilder::default()
.name(a.display_name)
.uri(a.ap_url)
.build().expect("Atom feed: author error"))
.collect::<Vec<Person>>())
.links(vec![LinkBuilder::default().href(post.ap_url).build().expect("Atom feed: link error")])
.build().expect("Atom feed: entry error")
.content(
ContentBuilder::default()
.value(format!("<![CDATA[{}]]>", *post.content.get()))
.src(post.ap_url.clone())
.content_type("html".to_string())
.build()
.expect("Atom feed: content error"),
)
.authors(
post.get_authors(&*conn)
.expect("Atom feed: author error")
.into_iter()
.map(|a| {
PersonBuilder::default()
.name(a.display_name)
.uri(a.ap_url)
.build()
.expect("Atom feed: author error")
})
.collect::<Vec<Person>>(),
)
.links(vec![LinkBuilder::default()
.href(post.ap_url)
.build()
.expect("Atom feed: link error")])
.build()
.expect("Atom feed: entry error")
}
pub mod blogs;
@@ -135,17 +143,17 @@ pub mod medias;
pub mod notifications;
pub mod posts;
pub mod reshares;
pub mod search;
pub mod session;
pub mod tags;
pub mod user;
pub mod search;
pub mod well_known;
#[derive(Responder)]
#[response()]
pub struct CachedFile {
inner: NamedFile,
cache_control: CacheControl
cache_control: CacheControl,
}
#[get("/static/cached/<_build_id>/<file..>", rank = 2)]
@@ -155,10 +163,10 @@ pub fn plume_static_files(file: PathBuf, _build_id: &RawStr) -> Option<CachedFil
#[get("/static/<file..>", rank = 3)]
pub fn static_files(file: PathBuf) -> Option<CachedFile> {
NamedFile::open(Path::new("static/").join(file)).ok()
.map(|f|
CachedFile {
inner: f,
cache_control: CacheControl(vec![CacheDirective::MaxAge(60*60*24*30)])
})
NamedFile::open(Path::new("static/").join(file))
.ok()
.map(|f| CachedFile {
inner: f,
cache_control: CacheControl(vec![CacheDirective::MaxAge(60 * 60 * 24 * 30)]),
})
}