aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp28
1 files changed, 9 insertions, 19 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 61407d8..8256717 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -19,7 +19,7 @@ int main(int argc, char ** argv)
if (argc <= 1 || argc > 5)
{
- std::cout << "usage: cpp-web [HOST] [PORT] [STATIC-WWWROOT] [DYNAMIC-WWWROOT]" << std::endl;
+ std::cout << "usage: cpp-web [HOST] [PORT] [WWWROOT]" << std::endl;
if (argc > 5)
{
return 1;
@@ -34,6 +34,10 @@ int main(int argc, char ** argv)
{
port = atoi(argv[2]);
}
+ if (argc > 3)
+ {
+ wwwroot = argv[3];
+ }
std::shared_ptr<TemplateManager> tmgr = std::make_shared<TemplateManager>();
std::shared_ptr<ContentManager> cmgr = std::make_shared<ContentManager>();
@@ -41,36 +45,22 @@ int main(int argc, char ** argv)
{
std::shared_ptr<Filesystem> static_fs = std::make_shared<Filesystem>();
- if (argc > 3)
- {
- if (static_fs->Scan(argv[3]) != true)
- {
- return 1;
- }
- }
- std::cout << "Static fs: " << wwwroot << std::endl;
- static_fs->Scan(wwwroot, {"html", "tmpl"}, true);
+ std::cout << "Static fs: " << wwwroot + "/static" << std::endl;
+ static_fs->Scan(wwwroot + "/static", {"html", "tmpl"}, true);
cmgr->RegisterModule(std::make_shared<Static>("/static", static_fs));
}
{
Filesystem dynamic_fs;
- if (argc > 4)
- {
- if (dynamic_fs.Scan(argv[4]) != true)
- {
- return 1;
- }
- }
std::cout << "Dynamic fs: " << wwwroot << std::endl;
dynamic_fs.Scan(wwwroot, {"html", "tmpl"}, false);
tmgr->ParseTemplates(dynamic_fs);
}
- cmgr->RegisterModule(std::make_shared<Markdown>("/", "./pages", "index.html"));
- cmgr->RegisterModule(std::make_shared<Blog>("/blog", "./blog", "blog/index.html"));
+ cmgr->RegisterModule(std::make_shared<Markdown>("/", wwwroot + "/pages", "index.html"));
+ cmgr->RegisterModule(std::make_shared<Blog>("/blog", wwwroot + "/blog", "blog/index.html"));
if (cmgr->InitAll() == false)
{