Hi there,
Very much new in onion and so on doing web-dev with C.
I want to build a web application in onion which will serve the index page as starting and every html page will have some ajax function call,for which I have to include some .js file in them.(also .css)
I have made two way to make this happen. I want better suggestions on which process,this is ought to be used and with which way, I will have less trouble in further to maintain more coding.
With process 1, I have as like following folder structure(more resources than that) in where, I write the following code in main.c
--index.html /* have js functions*/
--page1.html /* have js functions*/
onion_url *root = onion_root_url(o);
onion_url_add_handler(root, "^Assets", onion_handler_export_local_new("Assets"));
onion_url_add_handler(root, "^Images", onion_handler_export_local_new("Images"));
onion_url_add(root, "index", index_page);
onion_url_add(root, "page1", page1_handler);
onion_url_add_with_data(root, "", onion_shortcut_internal_redirect,
"index", NULL);
With process 2, I made a static folder as same as example given in
oterm, I made this with opack but my data file become so large(110mib), that every when I run a
Cmake, it takes more time to build than usual.
--assets.h
--opack_data.c
--index.html /* have js functions*/
--page1.html /* have js functions*/
onion_url *url = onion_url_new();
onion_url_add(url, "^Static/", opack_static);
onion_url_add_with_data(url, "", onion_shortcut_internal_redirect,
"static/index.html", NULL);
I have seen
this example but this one doesn't include any resources to the html which is not a help for me. Can you suggest me any example code or example project which will help me to decide with my project structure.