diff --git a/WebApplication/Hello.cpp b/WebApplication/Hello.cpp index c54ba73..e478ce8 100644 --- a/WebApplication/Hello.cpp +++ b/WebApplication/Hello.cpp @@ -14,8 +14,7 @@ #include #include -Hello::Hello(const Wt::WEnvironment &env, Wt::Dbo::SqlConnectionPool &connectionPool, bool embedded) - : Wt::WApplication(env) { +Hello::Hello(const Wt::WEnvironment &env, Wt::Dbo::SqlConnectionPool &connectionPool, bool embedded) : Wt::WApplication(env) { LOG(info) << "app root: " << appRoot(); m_session = std::make_unique(connectionPool); m_session->login().changed().connect(this, &Hello::authEvent); @@ -34,10 +33,20 @@ Hello::Hello(const Wt::WEnvironment &env, Wt::Dbo::SqlConnectionPool &connection } else { LOG(error) << "Missing: parameter: 'div'"; } + internalPathChanged().connect(this, &Hello::handlePathChange); + auto externalPath = env.getParameter("path"); + if (externalPath != nullptr) { + m_externalPath = *externalPath; + + } else { + auto parameters = env.getParameterMap(); + for (auto &p : parameters) { + LOG(info) << p.first; + } + } LOG(info) << "url: " << url(); LOG(info) << "relative resources url: " << relativeResourcesUrl(); LOG(info) << "resources url: " << resourcesUrl(); - url(); } if (!embedded) { @@ -60,8 +69,7 @@ Hello::Hello(const Wt::WEnvironment &env, Wt::Dbo::SqlConnectionPool &connection m_nameEdit->enterPressed().connect(this, &Hello::greet); auto app = Amass::Singleton::instance(); - auto authWidget = - std::make_unique(app->authService(), m_session->users(), m_session->login()); + auto authWidget = std::make_unique(app->authService(), m_session->users(), m_session->login()); authWidget->setInternalBasePath("/"); authWidget->model()->addPasswordAuth(&app->passwordService()); authWidget->setRegistrationEnabled(true); @@ -76,6 +84,7 @@ Hello::~Hello() { void Hello::greet() { m_greeting->setText("Hello there, " + m_nameEdit->text()); + setInternalPath(m_externalPath); } void Hello::authEvent() { @@ -87,3 +96,7 @@ void Hello::authEvent() { LOG(info) << "User logged out."; } } + +void Hello::handlePathChange(const std::string &path) { + LOG(info) << "handlePathChange: " << path; +} diff --git a/WebApplication/Hello.h b/WebApplication/Hello.h index 3ec76f7..40c5936 100644 --- a/WebApplication/Hello.h +++ b/WebApplication/Hello.h @@ -7,17 +7,19 @@ class Session; class Hello : public Wt::WApplication { public: - Hello(const Wt::WEnvironment &env,Wt::Dbo::SqlConnectionPool &connectionPool, bool embedded); + Hello(const Wt::WEnvironment &env, Wt::Dbo::SqlConnectionPool &connectionPool, bool embedded); ~Hello(); protected: void greet(); void authEvent(); + void handlePathChange(const std::string &path); private: Wt::WLineEdit *m_nameEdit = nullptr; Wt::WText *m_greeting = nullptr; std::unique_ptr m_session; + std::string m_externalPath; }; #endif // __HELLO_H__ \ No newline at end of file diff --git a/WebApplication/WebApplication.cpp b/WebApplication/WebApplication.cpp index bc43cb5..e0bf55c 100644 --- a/WebApplication/WebApplication.cpp +++ b/WebApplication/WebApplication.cpp @@ -30,7 +30,7 @@ WebApplication::WebApplication() { "/hello"); m_server->addEntryPoint(Wt::EntryPointType::WidgetSet, std::bind(&WebApplication::createApplication, this, std::placeholders::_1, true), - "/gui/hello.js"); + "/wt.js"); m_server->addResource(std::make_shared(*m_sqlConnectionPool), "/auth"); m_server->addResource(std::make_shared(), "/plaintext"); m_server->addResource(std::make_shared("database.sqlite"), "/db");