Skip to content

Commit

Permalink
refactor: rename structs and path from 'prime_down' to 'render'
Browse files Browse the repository at this point in the history
  • Loading branch information
Kremilly committed Jul 23, 2024
1 parent ab5bbcd commit 8ccae50
Show file tree
Hide file tree
Showing 10 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ mod scimon;
mod configs;
mod args_cli;
mod generator;
mod prime_down;
mod render;

use crate::scimon::Scimon;

Expand Down
6 changes: 3 additions & 3 deletions src/monset/blocks/readme_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use std::{
use crate::{
args_cli::Flags,
monset::vars::Vars,
render::render::Render,
system::markdown::Markdown,
prime_down::pd_core::PrimeDown,
ui::macros_alerts::MacrosAlerts,
regexp::regex_blocks::BlocksRegExp,

Expand Down Expand Up @@ -70,7 +70,7 @@ impl ReadMeBlock {
if let Some(markdown_html) = Self::render(run) {
let path = Markdown::get_filename_rendered(run);

if let Ok(contents) = PrimeDown::render_content(&run, markdown_html).await {
if let Ok(contents) = Render::render_content(&run, markdown_html).await {
FileUtils::write_file(&path, contents);
Markdown::open_file(&path, flags.no_open_link);

Expand All @@ -92,7 +92,7 @@ impl ReadMeBlock {
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 {
if let Ok(contents) = Render::render_content(&get_last_part, contents_extras).await {
FileUtils::write_file(&path, contents);
Markdown::open_file(&path, flags.no_open_link);

Expand Down
8 changes: 0 additions & 8 deletions src/prime_down/mod.rs

This file was deleted.

8 changes: 8 additions & 0 deletions src/render/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
pub mod render;
pub mod render_io;

// Helpers
pub mod render_inject;

// Extras
pub mod render_extras;
8 changes: 4 additions & 4 deletions src/prime_down/pd_core.rs → src/render/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,22 @@ use headless_chrome::{
use crate::{
consts::addons::Addons,
configs::settings::Settings,
prime_down::pd_inject::PrimeDownInject,
render::render_inject::RenderInject,

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

pub struct PrimeDown;
pub struct Render;

impl PrimeDown {
impl Render {

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 = Remote::content(Addons::README_TEMPLATE_LINK).await?;
let content = PrimeDownInject::content(&file, template_content, md_content);
let content = RenderInject::content(&file, template_content, md_content);

let output = if minify_prop == true {
minify(&content)
Expand Down
4 changes: 2 additions & 2 deletions src/prime_down/pd_extras.rs → src/render/render_extras.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use crate::{
regexp::regex_core::CoreRegExp,
};

pub struct PrimeDownExtras;
pub struct RenderExtras;

impl PrimeDownExtras {
impl RenderExtras {

pub fn gist(markdown: &str) -> String {
let re = Regex::new(CoreRegExp::RENDER_EXTRA_GIST).unwrap();
Expand Down
4 changes: 2 additions & 2 deletions src/prime_down/pd_inject.rs → src/render/render_inject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ use crate::{
},
};

pub struct PrimeDownInject;
pub struct RenderInject;

impl PrimeDownInject {
impl RenderInject {

pub fn content(file: &str, contents: String, markdown_html: String) -> String {
let title = format!(
Expand Down
4 changes: 2 additions & 2 deletions src/prime_down/pd_io.rs → src/render/render_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ use crate::{
configs::settings::Settings,
};

pub struct PrimeDownIO;
pub struct RenderIO;

impl PrimeDownIO {
impl RenderIO {

fn get_path() -> String {
let value = Settings::get("render_markdown.output_path", "STRING");
Expand Down
16 changes: 8 additions & 8 deletions src/system/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ use crate::{
generator::generate::Generate,
ui::success_alerts::SuccessAlerts,

prime_down::{
pd_io::PrimeDownIO,
pd_inject::PrimeDownInject,
pd_extras::PrimeDownExtras,
render::{
render_io::RenderIO,
render_inject::RenderInject,
render_extras::RenderExtras,
},

utils::{
Expand Down Expand Up @@ -60,14 +60,14 @@ impl Markdown {
)
};

PrimeDownIO::get_file_path(file).replace(
RenderIO::get_file_path(file).replace(
".html", &filename
)
}

pub fn append_extras_and_render(markdown: &str) -> String {
let markdown_block_extras_qrcode = PrimeDownExtras::qrcode(&markdown);
let markdown_block_extras_gist = PrimeDownExtras::gist(&markdown_block_extras_qrcode);
let markdown_block_extras_qrcode = RenderExtras::qrcode(&markdown);
let markdown_block_extras_gist = RenderExtras::gist(&markdown_block_extras_qrcode);

let parser = Parser::new_ext(&markdown_block_extras_gist, Options::all());
let mut html_output = String::new();
Expand All @@ -91,7 +91,7 @@ impl Markdown {
pub async fn create(contents: &str, url: &str, path: &str) -> Result<(), Box<dyn Error>> {
if Remote::check_content_type(&url, "text/markdown").await? || url.contains(".md") {
let html_content = Self::render(url).await?;
let content = PrimeDownInject::html_content(contents, html_content).await?;
let content = RenderInject::html_content(contents, html_content).await?;

let original_name = UrlMisc::get_last_part(url);
let new_filename = FileUtils::replace_extension(&original_name, "pdf");
Expand Down
4 changes: 2 additions & 2 deletions src/system/pdf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use std::{

use crate::{
cmd::tasks::Tasks,
render::render::Render,
system::providers::Providers,
prime_down::pd_core::PrimeDown,

ui::{
ui_base::UI,
Expand Down Expand Up @@ -63,7 +63,7 @@ impl Pdf {

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

let pb = ProgressBar::new(len);

Expand Down

0 comments on commit 8ccae50

Please sign in to comment.