diff --git a/.gitignore b/.gitignore index 4e7d288..5900ea9 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,8 @@ game/.prop_tool_temp/** .sconsign.dblite .DS_Store +settings.ini + www/** data/** export/** diff --git a/HEADS b/HEADS index 5482663..111678b 100644 --- a/HEADS +++ b/HEADS @@ -1 +1 @@ -{"engine": {"master": "000174f3c89174bf2d34a9f890c470daa7a1b998"}} \ No newline at end of file +{"engine": {"master": "5f17d9067651b5bf04bbfa7e7bfdc7e8a761e25d"}} \ No newline at end of file diff --git a/main.cpp b/main.cpp index 203d4e6..10dde54 100644 --- a/main.cpp +++ b/main.cpp @@ -2,7 +2,6 @@ #include #include -#include "core/bry_http/http_server.h" #include "core/file_cache.h" #include "core/http/web_application.h" @@ -12,19 +11,11 @@ #include "core/settings.h" -#include "core/http/session_manager.h" - -#define MAIN_CLASS CCMSApplication - #include "modules/drogon/web_application.h" //Backends #include "backends/hash_hashlib/setup.h" -#include "app/ccms_user_controller.h" -#include "modules/users/user.h" -#include "modules/rbac_users/rbac_user_model.h" - #include "core/database/database_manager.h" #include "platform/platform_initializer.h" @@ -34,96 +25,56 @@ #include "core/html/html_parser.h" +#include "core/settings.h" + +#include "modules/drogon/trantor/net/EventLoop.h" +#include "modules/drogon/trantor/net/TcpClient.h" + void initialize_backends() { initialize_database_backends(); backend_hash_hashlib_install_providers(); } -void create_databases() { - DatabaseManager *dbm = DatabaseManager::get_singleton(); - - uint32_t index = dbm->create_database("sqlite"); - Database *db = dbm->databases[index]; - db->connect("database.sqlite"); -} - int main(int argc, char **argv, char **envp) { PlatformInitializer::allocate_all(); PlatformInitializer::arg_setup(argc, argv, envp); initialize_backends(); - bool migrate = false; - - for (int i = 1; i < argc; ++i) { - const char *a = argv[i]; - - if (a[0] == 'm') { - migrate = true; - } - } - - String thtml = "Title

Hello

Hello world!

"; - - String thtml2 = "
Building Editor

Name:
Description:
Icon:
TODO
Rank:
Next Rank:
Time to Build:
Score:
Defense:
Ability:
TODO
Cost Food:
Cost Wood:
Cost Stone:
Cost Iron:
Cost Mana:
Creates:
TODO
Mod Max Food:
Mod Max Wood:
Mod Max Stone:
Mod Max Iron:
Mod Max Mana:
Mod Rate Food:
Mod Rate Wood:
Mod Rate Stone:
Mod Rate Iron:
Mod Rate Mana:
Mod Percent Food:
Mod Percent Wood:
Mod Percent Stone:
Mod Percent Iron:
Mod Percent Mana:
Assignment 1:
Assignment 2:
Assignment 3:
Assignment 4:
Assignment 5:
Required Technology:
Technology Group:
Secondary Technology Group:
"; - - HTMLParser p; - p.parse(thtml2); - - ::SessionManager *session_manager = new ::SessionManager(); - - //todo init these in the module automatically - UserController *user_controller = new CCMSUserController(); - RBACUserModel *user_model = new RBACUserModel(); - //user_manager->set_path("./users/"); - Settings *settings = new Settings(true); - //settings->parse_file("settings.json"); + settings->parse_ini_file("settings.ini"); - FileCache *file_cache = new FileCache(true); - file_cache->wwwroot = "./www"; - file_cache->wwwroot_refresh_cache(); + bool download = Platform::get_singleton()->arg_parser.has_arg("-d"); - DatabaseManager *dbm = new DatabaseManager(); + if (download) { + DatabaseManager *dbm = new DatabaseManager(); - create_databases(); + uint32_t index = dbm->create_database("sqlite"); + Database *db = dbm->databases[index]; + db->connect("database.sqlite"); - DWebApplication *app = new MAIN_CLASS(); - - //Ref r = RBACRank::db_get(1); - - //if (r.is_valid()) { - // RLOG_ERR("asdasdasd\n"); - //} - - app->load_settings(); - app->setup_routes(); - app->setup_middleware(); - - app->add_listener("127.0.0.1", 8080); - LOG_INFO << "Server running on 127.0.0.1:8080"; - - if (!migrate) { - session_manager->load_sessions(); + delete dbm; + } else { + /* + FileCache *file_cache = new FileCache(true); + file_cache->wwwroot = "./www"; + file_cache->wwwroot_refresh_cache(); + DWebApplication *app = new DWebApplication(); + app->load_settings(); + app->setup_routes(); + app->setup_middleware(); + app->add_listener("127.0.0.1", 8080); + LOG_INFO << "Server running on 127.0.0.1:8080"; printf("Initialized!\n"); app->run(); - } else { - printf("Running migrations.\n"); + delete app; - session_manager->migrate(); - user_model->migrate(); - - app->migrate(); + delete file_cache; + */ } - delete app; - delete dbm; - delete file_cache; delete settings; - delete user_controller; - delete user_model; - delete session_manager; PlatformInitializer::free_all(); diff --git a/settings.ini.example b/settings.ini.example new file mode 100644 index 0000000..a3c99f3 --- /dev/null +++ b/settings.ini.example @@ -0,0 +1,12 @@ + +sites=test1,test2 +save_original_data=true +original_data_backend=database + +voxday.url=https://test1.net/ +voxday.directory=test1 +voxday.original_data_table=test1 + +voxday.url=https://test2.net/ +voxday.directory=test2 +voxday.original_data_table=test2