diff --git a/src/constants.rs b/src/constants.rs index d79f4fc..960cc27 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -9,9 +9,12 @@ pub static IMAGE_FILE: &str = "logo.png"; // IPFS pub static IPFS_GATEWAY: &str = "https://ipfs.anspar.io/gateway"; -pub static CID_HTML: &str = "QmTPBUwTPgR23NfxzkQt88T5RqLB8VbSeaYT5DkaQPrQ85"; -pub static CID_JS: &str = "QmXDpwgw14uJjkkq4yUMNaspSkwPufDvbw6rp4rd7Xq4Qv"; -pub static CID_CSS: &str = "QmQKrx745sM1nY7GKMupMPdECu5eNwaxZajZzc5FW4Pmxh"; -pub static CID_LOGO: &str = "QmbFhtCDafQg29u9dQgdAdDtGNoHPftN2HibpoDdxMtaX6"; +// pub static CID_HTML: &str = "QmYsv4SdxduRwn2KdR3dG2BoqnNhhkYk7BwgASxSZ3pv1Y"; +// pub static CID_JS: &str = "QmXDpwgw14uJjkkq4yUMNaspSkwPufDvbw6rp4rd7Xq4Qv"; +// pub static CID_CSS: &str = "QmQKrx745sM1nY7GKMupMPdECu5eNwaxZajZzc5FW4Pmxh"; +// pub static CID_LOGO: &str = "QmbFhtCDafQg29u9dQgdAdDtGNoHPftN2HibpoDdxMtaX6"; // pub static CID_WASM_BIN: &str = ""; // pub static CID_WASM_JS: &str = ""; + +// GITHUB +pub static PROJECT_URL: &str = "https://raw.githubusercontent.com/anspar/arag/main"; diff --git a/src/main.rs b/src/main.rs index c7aa72c..48d0220 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,7 +4,6 @@ use notify::{watcher, RecursiveMode, Watcher}; use opener; use std::env; use std::error::Error; -use std::fmt::format; use std::fs::File; use std::sync::mpsc::channel; use std::time::Duration; diff --git a/src/project_creator.rs b/src/project_creator.rs index 956af87..5ed1112 100644 --- a/src/project_creator.rs +++ b/src/project_creator.rs @@ -45,13 +45,13 @@ fn create_folders(r_path: &str, name: &str) -> Result<(), std::io::Error> { pub fn create_new_project(r_path: &str, name: &str) -> Result<(), Box> { create_folders(r_path, name)?; create_file_from_web( - &format!("{}/{}", constants::IPFS_GATEWAY, constants::CID_HTML), + &format!("{}/{}/{}", constants::PROJECT_URL, constants::TEMPLATE_DIR, constants::ENTRY_TEMPLATE), &format!("{}/{}/{}", r_path, &name, constants::TEMPLATE_DIR), constants::ENTRY_TEMPLATE, )?; create_file_from_web( - &format!("{}/{}", constants::IPFS_GATEWAY, constants::CID_JS), + &format!("{}/{}/{}/{}", constants::PROJECT_URL, constants::STATIC_DIR, constants::JAVASCRIPT_DIR, constants::JAVASCRIPT_FILE), &format!( "{}/{}/{}/{}", r_path, @@ -63,7 +63,7 @@ pub fn create_new_project(r_path: &str, name: &str) -> Result<(), Box )?; create_file_from_web( - &format!("{}/{}", constants::IPFS_GATEWAY, constants::CID_CSS), + &format!("{}/{}/{}/{}", constants::PROJECT_URL, constants::STATIC_DIR, constants::CSS_DIR, constants::CSS_FILE), &format!( "{}/{}/{}/{}", r_path, @@ -75,7 +75,7 @@ pub fn create_new_project(r_path: &str, name: &str) -> Result<(), Box )?; create_file_from_web( - &format!("{}/{}", constants::IPFS_GATEWAY, constants::CID_LOGO), + &format!("{}/{}/{}", constants::PROJECT_URL, constants::STATIC_DIR, constants::IMAGE_FILE), &format!("{}/{}/{}", r_path, &name, constants::STATIC_DIR), constants::IMAGE_FILE, )?; diff --git a/src/utils/helpers.rs b/src/utils/helpers.rs index e4657a6..88deb9d 100644 --- a/src/utils/helpers.rs +++ b/src/utils/helpers.rs @@ -181,18 +181,20 @@ context_import_helper!(import_bytes_ipfs => |param: String, c: &Context|{ context_import_helper!( inject_gateway = |c: &Context| { minifier::js::minify(&format!( - "let IPFS_GATEWAY = {}; - document.addEventListener('DOMContentLoaded', function() {{ - setInterval(()=>{{ - try{{ - if(IPFS_GATEWAY_INJECTED){{ IPFS_GATEWAY=IPFS_GATEWAY_INJECTED }} - }}catch(e){{}} - document.querySelectorAll('[ipfs]').forEach((e, i)=>{{ - e.setAttribute('src', `${{IPFS_GATEWAY}}/${{e.getAttribute('ipfs')}}`); - e.removeAttribute('ipfs'); - }}) - }}, 1000) - }});", + "", c.data().to_string() )) } diff --git a/templates/index.html b/templates/index.html index 781eaf6..5a1c807 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,4 +1,3 @@ - @@ -21,9 +20,7 @@

Arag Dapp Builder

Handlebars Docs - + {{inject_gateway}} {{import_js "static/js/index.js"}}