use to_owned instead of clone
Some checks are pending
ci/woodpecker/push/publish Pipeline is pending

This commit is contained in:
Mylloon 2023-04-24 12:18:21 +02:00
parent 1afa14dfed
commit b0112c06d6
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
12 changed files with 27 additions and 23 deletions

View file

@ -93,10 +93,14 @@ pub fn get_config(file_path: &str) -> Config {
let static_dir = "static".to_owned();
let templates_dir = "templates".to_owned();
let files_root = init("dist".to_owned(), static_dir.clone(), templates_dir.clone());
let files_root = init(
"dist".to_owned(),
static_dir.to_owned(),
templates_dir.to_owned(),
);
Config {
fc: internal_config.clone(),
fc: internal_config.to_owned(),
static_location: format!("{}/{}", files_root, static_dir),
tmpl: Template {
directory: format!("{}/{}", files_root, templates_dir),

View file

@ -20,14 +20,14 @@ async fn main() -> Result<()> {
println!(
"Listening to {}://{}:{}",
config.clone().fc.scheme.unwrap(),
config.to_owned().fc.scheme.unwrap(),
addr.0,
addr.1
);
HttpServer::new(move || {
App::new()
.app_data(web::Data::new(config.clone()))
.app_data(web::Data::new(config.to_owned()))
.wrap(DefaultHeaders::new().add((
"Onion-Location",
config.fc.onion.as_deref().unwrap_or_default(),
@ -46,7 +46,7 @@ async fn main() -> Result<()> {
.service(gaming::page)
.service(cours::page)
.service(cv::page)
.service(Files::new("/", config.static_location.clone()))
.service(Files::new("/", config.static_location.to_owned()))
.default_service(web::to(not_found::page))
})
.bind(addr)?

View file

@ -68,7 +68,7 @@ pub async fn fetch_pr() -> Result<Vec<Project>, Error> {
resp.items.iter().for_each(|p| {
list.push(Project {
project: p.repository_url.split('/').last().unwrap().to_owned(),
project_url: p.repository_url.clone(),
project_url: p.repository_url.to_owned(),
status: if p.pull_request.merged_at.is_none() {
if p.state == "closed" {
ProjectState::Closed
@ -78,9 +78,9 @@ pub async fn fetch_pr() -> Result<Vec<Project>, Error> {
} else {
ProjectState::Merged
},
title: p.title.clone(),
title: p.title.to_owned(),
id: p.number,
contrib_url: p.pull_request.html_url.clone(),
contrib_url: p.pull_request.html_url.to_owned(),
});
});

View file

@ -8,7 +8,7 @@ use ramhorns::Content;
#[get("/security.txt")]
pub async fn security(req: HttpRequest, config: web::Data<Config>) -> impl Responder {
HttpResponse::Ok().body(build_securitytxt(
config.get_ref().clone(),
config.get_ref().to_owned(),
req.connection_info().to_owned(),
))
}

View file

@ -15,7 +15,7 @@ use crate::{
#[get("/blog")]
pub async fn index(config: web::Data<Config>) -> impl Responder {
HttpResponse::Ok().body(build_index(config.get_ref().clone()))
HttpResponse::Ok().body(build_index(config.get_ref().to_owned()))
}
#[derive(Content)]
@ -115,7 +115,7 @@ struct BlogPostTemplate {
#[get("/blog/{id}")]
pub async fn page(path: web::Path<(String,)>, config: web::Data<Config>) -> impl Responder {
HttpResponse::Ok().body(build_post(path.into_inner().0, config.get_ref().clone()))
HttpResponse::Ok().body(build_post(path.into_inner().0, config.get_ref().to_owned()))
}
pub fn build_post(file: String, config: Config) -> String {

View file

@ -11,7 +11,7 @@ use ramhorns::Content;
#[get("/contrib")]
pub async fn page(config: web::Data<Config>) -> impl Responder {
HttpResponse::Ok().body(build_page(config.get_ref().clone()).await)
HttpResponse::Ok().body(build_page(config.get_ref().to_owned()).await)
}
#[derive(Content)]
@ -51,7 +51,7 @@ pub async fn build_page(config: Config) -> String {
let mut map: HashMap<&str, Vec<Pull>> = HashMap::new();
projects.iter().for_each(|p| {
let project = Pull {
url: p.contrib_url.clone(),
url: p.contrib_url.to_owned(),
id: p.id,
name_repo: p.project.to_owned(),
title: p.title.to_owned(),
@ -63,7 +63,7 @@ pub async fn build_page(config: Config) -> String {
} else {
data.push(Project {
name: project_name.to_owned(),
url: p.project_url.clone(),
url: p.project_url.to_owned(),
pulls_merged: Vec::new(),
pulls_closed: Vec::new(),
pulls_open: Vec::new(),
@ -77,9 +77,9 @@ pub async fn build_page(config: Config) -> String {
map.get(d.name.as_str()).unwrap().iter().for_each(|p| {
let state = p.state.into();
match state {
ProjectState::Closed => d.pulls_closed.push(p.clone()),
ProjectState::Merged => d.pulls_merged.push(p.clone()),
ProjectState::Open => d.pulls_open.push(p.clone()),
ProjectState::Closed => d.pulls_closed.push(p.to_owned()),
ProjectState::Merged => d.pulls_merged.push(p.to_owned()),
ProjectState::Open => d.pulls_open.push(p.to_owned()),
}
});
let mut name: Vec<char> = d.name.replace('-', " ").chars().collect();

View file

@ -5,7 +5,7 @@ use crate::{config::Config, template::Infos};
#[get("/")]
pub async fn page(config: web::Data<Config>) -> impl Responder {
HttpResponse::Ok().body(build_page(config.get_ref().clone()))
HttpResponse::Ok().body(build_page(config.get_ref().to_owned()))
}
#[once(time = 60)]

View file

@ -5,7 +5,7 @@ use crate::{config::Config, template::Infos};
#[get("/networks")]
pub async fn page(config: web::Data<Config>) -> impl Responder {
HttpResponse::Ok().body(build_page(config.get_ref().clone()))
HttpResponse::Ok().body(build_page(config.get_ref().to_owned()))
}
#[once(time = 60)]

View file

@ -4,7 +4,7 @@ use cached::proc_macro::once;
use crate::{config::Config, template::Infos};
pub async fn page(config: web::Data<Config>) -> impl Responder {
HttpResponse::NotFound().body(build_page(config.get_ref().clone()))
HttpResponse::NotFound().body(build_page(config.get_ref().to_owned()))
}
#[once(time = 60)]

View file

@ -11,7 +11,7 @@ use crate::{
#[get("/portfolio")]
pub async fn page(config: web::Data<Config>) -> impl Responder {
HttpResponse::Ok().body(build_page(config.get_ref().clone()))
HttpResponse::Ok().body(build_page(config.get_ref().to_owned()))
}
#[derive(Content)]

View file

@ -5,7 +5,7 @@ use crate::{config::Config, template::Infos};
#[get("/web3")]
pub async fn page(config: web::Data<Config>) -> impl Responder {
HttpResponse::Ok().body(build_page(config.get_ref().clone()))
HttpResponse::Ok().body(build_page(config.get_ref().to_owned()))
}
#[once(time = 60)]

View file

@ -41,7 +41,7 @@ impl Template {
let tplt = templates.from_file(template).unwrap();
tplt.render(&Data {
app_name: self.app_name.clone(),
app_name: self.app_name.to_owned(),
page_title: info.page_title,
page_desc: info.page_desc,
page_kw: info.page_kw,