2021-10-30 22:48:02 +02:00
|
|
|
#ifndef RDN_APPLICATION_H
|
|
|
|
#define RDN_APPLICATION_H
|
|
|
|
|
|
|
|
//#include "core/http/web_application.h"
|
|
|
|
#include "core/object.h"
|
|
|
|
#include "modules/drogon/web_application.h"
|
|
|
|
|
|
|
|
#include "modules/list_page/list_page.h"
|
|
|
|
#include "modules/message_page/message_page.h"
|
|
|
|
#include "modules/paged_article/paged_article.h"
|
|
|
|
#include "modules/paged_list/paged_list.h"
|
|
|
|
|
2021-11-14 21:37:04 +01:00
|
|
|
class AdminPanel;
|
|
|
|
|
2021-10-31 02:11:47 +01:00
|
|
|
#define ENSURE_LOGIN(request) \
|
|
|
|
if (!is_logged_in(request)) { \
|
|
|
|
request->send_redirect("/user/login"); \
|
|
|
|
return; \
|
2021-10-31 02:07:50 +01:00
|
|
|
}
|
|
|
|
|
2021-10-30 22:48:02 +02:00
|
|
|
class MourneApplication : public DWebApplication {
|
|
|
|
public:
|
|
|
|
enum MenuEntries {
|
|
|
|
MENUENTRY_NEWS = 0,
|
|
|
|
MENUENTRY_MAIL,
|
|
|
|
MENUENTRY_HERO,
|
|
|
|
MENUENTRY_VILLAGE,
|
|
|
|
MENUENTRY_SELECT_VILLAGE,
|
|
|
|
MENUENTRY_ALLIANCE,
|
|
|
|
MENUENTRY_ALLIANCE_MENU,
|
|
|
|
MENUENTRY_FORUM,
|
|
|
|
MENUENTRY_CHANGELOG,
|
|
|
|
MENUENTRY_SETTINGS,
|
|
|
|
MENUENTRY_LOGOUT,
|
|
|
|
|
|
|
|
MENUENTRY_MAX,
|
|
|
|
};
|
|
|
|
|
|
|
|
public:
|
2021-10-31 02:11:47 +01:00
|
|
|
static bool is_logged_in(Request *request);
|
2021-10-31 02:07:50 +01:00
|
|
|
|
2021-10-30 22:48:02 +02:00
|
|
|
static void index(Object *instance, Request *request);
|
|
|
|
|
|
|
|
static void session_middleware_func(Object *instance, Request *request);
|
|
|
|
|
|
|
|
static void add_menu(Request *request, const MenuEntries index);
|
|
|
|
|
|
|
|
static void village_page_func(Object *instance, Request *request);
|
|
|
|
static void user_page_func(Object *instance, Request *request);
|
|
|
|
|
2021-11-14 21:37:04 +01:00
|
|
|
static void admin_page_func(Object *instance, Request *request);
|
|
|
|
|
2021-10-30 22:48:02 +02:00
|
|
|
virtual void setup_routes();
|
|
|
|
virtual void setup_middleware();
|
|
|
|
|
|
|
|
virtual void migrate();
|
2021-11-14 13:59:02 +01:00
|
|
|
virtual void add_default_data();
|
2021-10-30 22:48:02 +02:00
|
|
|
|
|
|
|
void compile_menu();
|
|
|
|
|
|
|
|
MourneApplication();
|
|
|
|
~MourneApplication();
|
|
|
|
|
2021-11-14 21:37:04 +01:00
|
|
|
AdminPanel *_admin_panel;
|
|
|
|
|
2021-10-30 22:48:02 +02:00
|
|
|
static std::string menu_head;
|
|
|
|
static std::string footer;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|