Skip to content

Commit

Permalink
Merge pull request #11 from mi4uu/mi4uu-fix-make-it-work
Browse files Browse the repository at this point in the history
 ASAP hot-fix - current master does not work
  • Loading branch information
fankaiLiu authored Nov 17, 2023
2 parents 49fea44 + 3a71fee commit 0f426ff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
3 changes: 1 addition & 2 deletions src/template/src/routers/mod.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ pub fn router() -> Router {
.delete(delete_user),
),
];
let static_routers = static_routers::create_static_routers();
no_auth_routers.extend(static_routers);

let router = Router::new()
.hoop(Logger::new())
.hoop(CatchPanic::new())
Expand Down
19 changes: 19 additions & 0 deletions src/utils/create_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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
Expand Down Expand Up @@ -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)?;
Expand All @@ -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)?;
Expand Down Expand Up @@ -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))
}

Expand Down

0 comments on commit 0f426ff

Please sign in to comment.