diff --git a/src/utils/create_project.rs b/src/utils/create_project.rs index 1866546..3cc2a12 100644 --- a/src/utils/create_project.rs +++ b/src/utils/create_project.rs @@ -184,6 +184,7 @@ fn write_project_file( let (src_path, router_path) = create_basic_file(project_path, &handlebars, &data)?; + if is_web_site { //templates let template_path = project_path.join("templates"); @@ -202,9 +203,13 @@ fn write_project_file( handle_404_file.write_all(handle_404_template_rendered.as_bytes())?; //assets let assets_path = project_path.join("assets"); + std::fs::create_dir_all(&assets_path)?; + + //assets/favicon.ico let favicon_bytes = include_bytes!("../template/assets/favicon.ico"); let mut favicon_file = File::create(assets_path.join("favicon.ico"))?; + favicon_file.write_all(favicon_bytes)?; if need_db_conn { //assets/js @@ -260,6 +265,13 @@ fn write_project_file( let router_user_rendered = handlebars.render_template(router_user_template, &data)?; let mut router_user_file = File::create(router_path.join("user.rs"))?; router_user_file.write_all(router_user_rendered.as_bytes())?; + + //src/router/static_routers.rs + let router_static_routers_template = include_str!("../template/src/routers/static_routers.hbs"); + let router_static_routers_rendered = handlebars.render_template(router_static_routers_template, &data)?; + let mut router_static_routers_file = File::create(router_path.join("static_routers.rs"))?; + router_static_routers_file.write_all(router_static_routers_rendered.as_bytes())?; + //src/services let services_path = src_path.join("services"); std::fs::create_dir_all(&services_path)?; @@ -273,6 +285,7 @@ fn write_project_file( let services_user_rendered = handlebars.render_template(services_user_template, &data)?; let mut services_user_file = File::create(services_path.join("user.rs"))?; services_user_file.write_all(services_user_rendered.as_bytes())?; + //src/utils let utils_path = src_path.join("utils"); std::fs::create_dir_all(&utils_path)?; @@ -649,6 +662,12 @@ fn create_basic_file( let mut router_demo_file = File::create(router_path.join("demo.rs"))?; router_demo_file.write_all(router_demo_rendered.as_bytes())?; + //src/router/static_routers.rs + // let router_static_routers_template = include_str!("../template/src/routers/static_routers.hbs"); + // let router_static_routers_rendered = handlebars.render_template(router_static_routers_template, &data)?; + // let mut router_static_routers_file = File::create(router_path.join("static_routers.rs"))?; + // router_static_routers_file.write_all(router_static_routers_rendered.as_bytes())?; + Ok((src_path, router_path)) }