Skip to content

Commit

Permalink
refactor: update file remote module imports and module name
Browse files Browse the repository at this point in the history
  • Loading branch information
Kremilly committed Jun 13, 2024
1 parent 4c8e82a commit c589f0f
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/monset/blocks/readme_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::{
utils::{
url::UrlMisc,
file::FileUtils,
remote::FileRemote,
remote::Remote,
}
};

Expand Down Expand Up @@ -89,7 +89,7 @@ impl ReadMeBlock {
&get_last_part.replace(".md", ".html")
);

let markdown_content = FileRemote::content(&url).await?;
let markdown_content = Remote::content(&url).await?;
let contents_extras = Markdown::append_extras_and_render(&markdown_content);

if let Ok(contents) = PrimeDown::render_content(&get_last_part, contents_extras).await {
Expand Down
4 changes: 2 additions & 2 deletions src/prime_down/pd_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use crate::{

utils::{
base64::Base64,
remote::FileRemote,
remote::Remote,
},
};

Expand All @@ -25,7 +25,7 @@ impl PrimeDown {

pub async fn render_content(file: &str, md_content: String) -> Result<String, Box<dyn Error>> {
let minify_prop = Settings::get("render_markdown.minify_html", "BOOLEAN");
let template_content = FileRemote::content(Uris::README_TEMPLATE_LINK).await?;
let template_content = Remote::content(Uris::README_TEMPLATE_LINK).await?;
let content = PrimeDownInject::content(&file, template_content, md_content);

let output = if minify_prop == true {
Expand Down
4 changes: 2 additions & 2 deletions src/system/hashes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use sha2::{
};

use crate::{
utils::remote::FileRemote,
utils::remote::Remote,
regexp::regex_core::CoreRegExp,
};

Expand Down Expand Up @@ -62,7 +62,7 @@ impl Hashes {
}

pub async fn read_remote_file(url: &str) -> Result<(Vec<String>, usize), Box<dyn Error>> {
let body = FileRemote::content(url).await?;
let body = Remote::content(url).await?;

let lines: Vec<String> = body
.lines()
Expand Down
6 changes: 3 additions & 3 deletions src/system/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::{
url::UrlMisc,
file::FileUtils,
generate::Generate,
remote::FileRemote,
remote::Remote,
},

system::{
Expand Down Expand Up @@ -79,7 +79,7 @@ impl Markdown {
}

pub async fn render(url: &str) -> Result<String, Box<dyn Error>> {
let markdown_content = FileRemote::content(url).await?;
let markdown_content = Remote::content(url).await?;

let options = Options::empty();
let parser = Parser::new_ext(&markdown_content, options);
Expand All @@ -91,7 +91,7 @@ impl Markdown {
}

pub async fn create(url: &str, path: &str) -> Result<(), Box<dyn Error>> {
if FileRemote::check_content_type(&url, "text/markdown").await? || url.contains(".md") {
if Remote::check_content_type(&url, "text/markdown").await? || url.contains(".md") {
let html_content = Self::render(url).await?;

let original_name = UrlMisc::get_last_part(url);
Expand Down
6 changes: 3 additions & 3 deletions src/system/pdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ use crate::{
utils::{
url::UrlMisc,
file::FileUtils,
remote::FileRemote,
remote::Remote,
validation::Validate,
},
};
Expand Down Expand Up @@ -56,7 +56,7 @@ impl Pdf {
}

pub async fn create_pdf(content: &str, path: PathBuf, url: &str) -> Result<(), Box<dyn Error>> {
let len = FileRemote::get_file_size(url).await?;
let len = Remote::get_file_size(url).await?;
let pdf_contents = PrimeDown::connect_to_browser(content).await?;

let pb = ProgressBar::new(len);
Expand All @@ -75,7 +75,7 @@ impl Pdf {

let (request_uri, filename) = Providers::get_from_provider(url).await?;
let response = reqwest::get(&request_uri).await?;
let total_size = FileRemote::get_file_size(&request_uri).await?;
let total_size = Remote::get_file_size(&request_uri).await?;

let pb = ProgressBar::new(total_size);
pb.set_style(UI::pb_template());
Expand Down
6 changes: 3 additions & 3 deletions src/system/providers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::{
utils::{
url::UrlMisc,
domains::Domains,
remote::FileRemote,
remote::Remote,
},
};

Expand Down Expand Up @@ -69,14 +69,14 @@ impl Providers {
pub async fn scihub(url: &str) -> Result<(String, String), Box<dyn Error>> {
let paper = Self::extract_doi(url);
let paper_url = format!("{}{}", Uris::SCIHUB_ADDONS_ENDPOINT, paper);
let filename = FileRemote::get_filename(&paper_url, true).await?;
let filename = Remote::get_filename(&paper_url, true).await?;

Ok((paper_url, filename))
}

pub async fn generic(url: &str) -> Result<(String, String), Box<dyn Error>> {
let request_uri = url.to_string();
let filename = FileRemote::get_filename(url, true).await?;
let filename = Remote::get_filename(url, true).await?;

Ok((request_uri, filename))
}
Expand Down
4 changes: 2 additions & 2 deletions src/system/reporting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::error::Error;

use crate::{
monset::macros::Macros,
utils::remote::FileRemote,
utils::remote::Remote,
regexp::regex_core::CoreRegExp,
ui::errors_alerts::ErrorsAlerts,
};
Expand All @@ -29,7 +29,7 @@ impl Reporting {
url_valid = true;
}

if FileRemote::get_status_code(final_url).await != 200 && url_valid == true {
if Remote::get_status_code(final_url).await != 200 && url_valid == true {
let status_code = Box::from("Failed to retrieve the URL with status code other than 200");
ErrorsAlerts::download(status_code, final_url);
}
Expand Down
4 changes: 2 additions & 2 deletions src/system/scripts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::{

utils::{
file::FileUtils,
remote::FileRemote,
remote::Remote,
},
};

Expand All @@ -33,7 +33,7 @@ impl Scripts {
let response = reqwest::get(url).await?;

if response.status().is_success() {
let filename = FileRemote::get_filename(url, false).await?;
let filename = Remote::get_filename(url, false).await?;

let file_path = format!(
"{}/{}", path, url.split("/").last().unwrap_or(&filename)
Expand Down
4 changes: 2 additions & 2 deletions src/utils/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use std::error::Error;

use crate::utils::file::FileUtils;

pub struct FileRemote;
pub struct Remote;

impl FileRemote {
impl Remote {

pub async fn get_status_code(url: &str) -> u16 {
reqwest::get(url)
Expand Down

0 comments on commit c589f0f

Please sign in to comment.