change to_string to to_owned
Some checks are pending
ci/woodpecker/push/publish Pipeline is pending

This commit is contained in:
Mylloon 2023-04-21 19:22:00 +02:00
parent 69149681f7
commit dce767d641
Signed by: Anri
GPG key ID: A82D63DFF8D1317F
10 changed files with 28 additions and 32 deletions

View file

@ -20,9 +20,9 @@ pub struct FileConfig {
impl FileConfig { impl FileConfig {
fn new() -> Self { fn new() -> Self {
Self { Self {
scheme: Some("http".to_string()), scheme: Some("http".to_owned()),
port: Some(8080), port: Some(8080),
app_name: Some("EWP".to_string()), app_name: Some("EWP".to_owned()),
..FileConfig::default() ..FileConfig::default()
} }
} }
@ -77,13 +77,9 @@ fn get_file_config(file_path: &str) -> FileConfig {
pub fn get_config(file_path: &str) -> Config { pub fn get_config(file_path: &str) -> Config {
let internal_config = get_file_config(file_path); let internal_config = get_file_config(file_path);
let static_dir = "static".to_string(); let static_dir = "static".to_owned();
let templates_dir = "templates".to_string(); let templates_dir = "templates".to_owned();
let files_root = init( let files_root = init("dist".to_owned(), static_dir.clone(), templates_dir.clone());
"dist".to_string(),
static_dir.clone(),
templates_dir.clone(),
);
Config { Config {
fc: internal_config.clone(), fc: internal_config.clone(),
@ -98,7 +94,7 @@ pub fn get_config(file_path: &str) -> Config {
fn init(dist_dir: String, static_dir: String, templates_dir: String) -> String { fn init(dist_dir: String, static_dir: String, templates_dir: String) -> String {
// The static folder is minimized only in release mode // The static folder is minimized only in release mode
if cfg!(debug_assertions) { if cfg!(debug_assertions) {
".".to_string() ".".to_owned()
} else { } else {
let cfg = Cfg { let cfg = Cfg {
keep_closing_tags: true, keep_closing_tags: true,

View file

@ -67,7 +67,7 @@ pub async fn fetch_pr() -> Result<Vec<Project>, Error> {
let mut list = vec![]; let mut list = vec![];
resp.items.iter().for_each(|p| { resp.items.iter().for_each(|p| {
list.push(Project { list.push(Project {
project: p.repository_url.split('/').last().unwrap().to_string(), project: p.repository_url.split('/').last().unwrap().to_owned(),
project_url: p.repository_url.clone(), project_url: p.repository_url.clone(),
status: if p.pull_request.merged_at.is_none() { status: if p.pull_request.merged_at.is_none() {
if p.state == "closed" { if p.state == "closed" {

View file

@ -42,7 +42,7 @@ pub fn get_options() -> ComrakOptions {
header_ids: Some(String::new()), header_ids: Some(String::new()),
footnotes: false, // true? footnotes: false, // true?
description_lists: true, description_lists: true,
front_matter_delimiter: Some("---".to_string()), front_matter_delimiter: Some("---".to_owned()),
}, },
parse: ComrakParseOptions { parse: ComrakParseOptions {
smart: false, // true one day? smart: false, // true one day?
@ -80,8 +80,8 @@ pub fn read(raw_text: &str) -> File {
File { File {
metadata: Metadata { metadata: Metadata {
info: metadata, info: metadata,
mermaid: check_mermaid(root, mermaid_name.to_string()), mermaid: check_mermaid(root, mermaid_name.to_owned()),
syntax_highlight: check_code(root, &[mermaid_name.to_string()]), syntax_highlight: check_code(root, &[mermaid_name.to_owned()]),
}, },
content: String::from_utf8(html).unwrap(), content: String::from_utf8(html).unwrap(),
} }

View file

@ -51,7 +51,7 @@ pub async fn robots() -> impl Responder {
#[once(time = 60)] #[once(time = 60)]
fn build_robotstxt() -> String { fn build_robotstxt() -> String {
// TODO, see https://www.robotstxt.org/orig.html // TODO, see https://www.robotstxt.org/orig.html
"User-agent: * Allow: /".to_string() "User-agent: * Allow: /".to_owned()
} }
#[get("/sitemap.xml")] #[get("/sitemap.xml")]

View file

@ -37,8 +37,8 @@ pub fn build_index(config: Config) -> String {
posts: if posts.is_empty() { None } else { Some(posts) }, posts: if posts.is_empty() { None } else { Some(posts) },
}, },
Infos { Infos {
page_title: Some("Blog".to_string()), page_title: Some("Blog".to_owned()),
page_desc: Some("Liste des posts d'Anri".to_string()), page_desc: Some("Liste des posts d'Anri".to_owned()),
page_kw: Some(["blog", "blogging"].join(", ")), page_kw: Some(["blog", "blogging"].join(", ")),
}, },
) )
@ -75,20 +75,20 @@ fn get_posts(location: &str) -> Vec<Post> {
metadata.title = match metadata.title { metadata.title = match metadata.title {
Some(title) => Some(title), Some(title) => Some(title),
None => Some(file_without_ext.to_string()), None => Some(file_without_ext.to_owned()),
}; };
metadata metadata
} }
Err(_) => FileMetadata { Err(_) => FileMetadata {
title: Some(file_without_ext.to_string()), title: Some(file_without_ext.to_owned()),
link: None, link: None,
date: None, date: None,
}, },
}; };
Post { Post {
url: file_without_ext.to_string(), url: file_without_ext.to_owned(),
title: file_metadata.title.unwrap(), title: file_metadata.title.unwrap(),
date: file_metadata.date.unwrap_or({ date: file_metadata.date.unwrap_or({
let m = f.metadata().unwrap(); let m = f.metadata().unwrap();
@ -143,7 +143,7 @@ fn get_post(post: &mut Option<File>, filename: String) -> Infos {
Infos { Infos {
page_title: Some(format!("Post: {}", title)), page_title: Some(format!("Post: {}", title)),
page_desc: Some("Blog d'Anri".to_string()), page_desc: Some("Blog d'Anri".to_owned()),
page_kw: Some(["blog", "blogging", "write", "writing"].join(", ")), page_kw: Some(["blog", "blogging", "write", "writing"].join(", ")),
} }
} }

View file

@ -60,7 +60,7 @@ pub async fn build_page(config: Config) -> String {
map.entry(project_name).and_modify(|v| v.push(project)); map.entry(project_name).and_modify(|v| v.push(project));
} else { } else {
data.push(Project { data.push(Project {
name: project_name.to_string(), name: project_name.to_owned(),
url: p.project_url.clone(), url: p.project_url.clone(),
pulls_merged: Vec::new(), pulls_merged: Vec::new(),
pulls_closed: Vec::new(), pulls_closed: Vec::new(),
@ -138,8 +138,8 @@ pub async fn build_page(config: Config) -> String {
"contrib.html", "contrib.html",
data, data,
Infos { Infos {
page_title: Some("Mes contributions".to_string()), page_title: Some("Mes contributions".to_owned()),
page_desc: Some("Contributions à l'opensource par Anri".to_string()), page_desc: Some("Contributions à l'opensource par Anri".to_owned()),
page_kw: None, page_kw: None,
}, },
) )

View file

@ -18,8 +18,8 @@ pub fn build_page(config: Config) -> String {
"index.html", "index.html",
IndexTemplate {}, IndexTemplate {},
Infos { Infos {
page_title: Some("Mylloon".to_string()), page_title: Some("Mylloon".to_owned()),
page_desc: Some("Page principale".to_string()), page_desc: Some("Page principale".to_owned()),
page_kw: None, page_kw: None,
}, },
) )

View file

@ -18,8 +18,8 @@ pub fn build_page(config: Config) -> String {
"networks.html", "networks.html",
NetworksTemplate {}, NetworksTemplate {},
Infos { Infos {
page_title: Some("Mes réseaux".to_string()), page_title: Some("Mes réseaux".to_owned()),
page_desc: Some("Réseaux d'Anri".to_string()), page_desc: Some("Réseaux d'Anri".to_owned()),
page_kw: None, page_kw: None,
}, },
) )

View file

@ -75,8 +75,8 @@ pub fn build_page(config: Config) -> String {
err_msg: "is empty", err_msg: "is empty",
}, },
Infos { Infos {
page_title: Some("Portfolio".to_string()), page_title: Some("Portfolio".to_owned()),
page_desc: Some("Portfolio d'Anri".to_string()), page_desc: Some("Portfolio d'Anri".to_owned()),
page_kw: None, page_kw: None,
}, },
) )

View file

@ -18,8 +18,8 @@ pub fn build_page(config: Config) -> String {
"web3.html", "web3.html",
Web3Template {}, Web3Template {},
Infos { Infos {
page_title: Some("Mylloon".to_string()), page_title: Some("Mylloon".to_owned()),
page_desc: Some("Coin reculé de l'internet".to_string()), page_desc: Some("Coin reculé de l'internet".to_owned()),
page_kw: None, page_kw: None,
}, },
) )