Skip to content

Commit

Permalink
refactor: update module names and imports to use Scibun instead of Pa…
Browse files Browse the repository at this point in the history
…imon
  • Loading branch information
Kremilly committed Jun 5, 2024
1 parent bae6b8e commit 0c0a8ac
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 19 deletions.
2 changes: 1 addition & 1 deletion paimon.pbd
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ path = "downloads/"
open = "https://github.com/kremilly"

readme = "https://gist.githubusercontent.com/kremilly/5fd360d994bb0fe108b648d0e4c9e92f/raw/508b038adb977440cc3722b04f9a5fc1ebfcdcb0/readme-examples.md"
checksum = "https://gist.githubusercontent.com/kremilly/499d6d51d096c1813cea0eade8eb0bc4/raw/d7c5965aeaf005cf0b612e3468ab47c30480083b/paimon.sha256"
checksum = "https://gist.githubusercontent.com/kremilly/499d6d51d096c1813cea0eade8eb0bc4/raw/d7c5965aeaf005cf0b612e3468ab47c30480083b/scibun.sha256"
checksum.unmatch = "keep"

compress = "file.zip"
Expand Down
2 changes: 1 addition & 1 deletion paimon.yml → scibun.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ui:
render_markdown:
output_path: '{app_path}' # String (default: '{app_path}')
overwrite: true # Boolean (valid values: 'true' or 'false'; default: 'true')
mode: 'paimon' # String (valid values: 'paimon' and 'pure'; default: 'paimon')
mode: 'scibun' # String (valid values: 'scibun' and 'pure'; default: 'scibun')
minify_html: true # Boolean (valid values: 'true' or 'false'; default: 'true')
minify_extra_plugins: true # Boolean (valid values: 'true' or 'false'; default: 'true')

Expand Down
2 changes: 1 addition & 1 deletion src/configs/configs_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl DownloadConfigsFiles {

let response = reqwest::get(url).await?;
if response.status().is_success() {
let file_path = output_directory.join("paimon.yml");
let file_path = output_directory.join("scibun.yml");

if !force_mode {
if !Path::new(&file_path).is_file() {
Expand Down
2 changes: 1 addition & 1 deletion src/configs/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl Settings {

pub fn open_settings_file() -> Result<(), IoError> {
let app_folder = &*System::APP_FOLDER;
let env_path: PathBuf = app_folder.join("paimon.yml");
let env_path: PathBuf = app_folder.join("scibun.yml");

if let SerdeValue(editor) = &Settings::get(
"general.default_text_editor", "STRING"
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ mod consts;
mod addons;
mod system;
mod syntax;
mod paimon;
mod scibun;
mod configs;
mod args_cli;
mod prime_down;

use crate::paimon::Paimon;
use crate::scibun::Scibun;

#[tokio::main]
async fn main() {
Paimon::init().await;
Scibun::init().await;
}
6 changes: 3 additions & 3 deletions src/prime_down/inject/pd_inject.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ pub struct PrimeDownInject;
impl PrimeDownInject {

fn get_js(render_mode: Value, minify: Value) -> String {
let cdn = if render_mode == "paimon" {
let cdn = if render_mode == Global::APP_NAME {
PrimeDownInjectJS::load_from_cdn()
} else {
"".to_string()
};

let local = if render_mode == "paimon" {
let local = if render_mode == Global::APP_NAME {
PrimeDownInjectJS::load_from_files(minify)
} else {
"".to_string()
Expand All @@ -34,7 +34,7 @@ impl PrimeDownInject {
}

fn get_css(render_mode: Value, minify: Value) -> String {
let local = if render_mode == "paimon" {
let local = if render_mode == Global::APP_NAME {
PrimeDownInjectCSS::load_from_files(minify)
} else {
"".to_string()
Expand Down
5 changes: 3 additions & 2 deletions src/prime_down/pd_extras.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use regex::Regex;

use crate::{
consts::global::Global,
utils::generate::Generate,
configs::settings::Settings,
regexp::regex_core::CoreRegExp,
Expand All @@ -11,7 +12,7 @@ pub struct PrimeDownExtras;
impl PrimeDownExtras {

pub fn gist(markdown: &str) -> String {
if Settings::get("render_markdown.mode", "STRING") == "paimon" {
if Settings::get("render_markdown.mode", "STRING") == Global::APP_NAME {
let re = Regex::new(CoreRegExp::RENDER_EXTRA_GIST).unwrap();

let replaced_markdown = re.replace_all(markdown, |captures: &regex::Captures| {
Expand All @@ -26,7 +27,7 @@ impl PrimeDownExtras {
}

pub fn qrcode(markdown: &str) -> String {
if Settings::get("render_markdown.mode", "STRING") == "paimon" {
if Settings::get("render_markdown.mode", "STRING") == Global::APP_NAME {
let re = Regex::new(CoreRegExp::RENDER_EXTRA_QRCODE).unwrap();

let replaced_markdown = re.replace_all(markdown, |captures: &regex::Captures| {
Expand Down
4 changes: 2 additions & 2 deletions src/regexp/regex_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ impl CoreRegExp {
pub const EXTRACT_URL: &'static str = r"(?P<url>https?://[^\s]+)";
pub const VALIDATE_TAGS: &'static str = r".*\*{1,2}.*|.*_.*|.*<\s*[a-zA-Z]+[^>]*>.*";

pub const RENDER_EXTRA_GIST: &'static str = r#"\[!paimon gist data=['"](.*?)['"]\]"#;
pub const RENDER_EXTRA_QRCODE: &'static str = r#"\[!paimon qrcode data=['"](.*?)['"], size=(\d+)\]"#;
pub const RENDER_EXTRA_GIST: &'static str = r#"\[!scibun gist data=['"](.*?)['"]\]"#;
pub const RENDER_EXTRA_QRCODE: &'static str = r#"\[!scibun qrcode data=['"](.*?)['"], size=(\d+)\]"#;

pub const GET_CHECKSUM: &'static str = r"(?i)\b([a-f0-9]{64})\b\s+(.+)";

Expand Down
4 changes: 2 additions & 2 deletions src/paimon.rs → src/scibun.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ use crate::{
},
};

pub struct Paimon;
pub struct Scibun;

impl Paimon {
impl Scibun {

async fn options(options: &str) -> Result<(), Box<dyn Error>> {
if options == "open-env" {
Expand Down
5 changes: 4 additions & 1 deletion src/system/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ impl System {
pub const SETTINGS_FILE: Lazy<PathBuf> = Lazy::new(|| {
let mut path = config_dir().expect("No config directory");
path.push(Global::APP_NAME);
path.push("paimon.yml");
path.push(
format!("{}.yml", Global::APP_NAME)
);

path
});

Expand Down
6 changes: 4 additions & 2 deletions src/ui/ui_base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ impl UI {
let name = StrUtils::capitalize(Global::APP_NAME);
let standard_font = FIGfont::standard().unwrap();

if Settings::get("render_markdown.mode", "STRING") == "paimon" {
render_md_mode = format!("{} ({})", "Paimon".cyan(), PrimeDownEnv::README_PAIMON_MODE_DOC.blue());
println!("{}", Global::APP_NAME);

if Settings::get("render_markdown.mode", "STRING") == Global::APP_NAME {
render_md_mode = format!("{} ({})", name.cyan(), PrimeDownEnv::README_PAIMON_MODE_DOC.blue());
} else {
render_md_mode = format!("{}", "Vanilla".cyan());
}
Expand Down

0 comments on commit 0c0a8ac

Please sign in to comment.