#include <Wt/WApplication>
#include "Home.h"
Go to the source code of this file.
Classes | |
class | WtHome |
Functions | |
WApplication * | createWtHomeApplication (const WEnvironment &env) |
WApplication* createWtHomeApplication | ( | const WEnvironment & | env | ) |
Definition at line 164 of file WtHome.C.
00165 { 00166 // support for old (< Wt-2.2) homepage URLS: redirect from "states" 00167 // to "internal paths" 00168 // this contains the initial "history state" in old Wt versions 00169 const std::string *historyKey = env.getParameter("historyKey"); 00170 00171 if (historyKey) { 00172 const char *mainStr[] 00173 = { "main:0", "/", 00174 "main:1", "/news", 00175 "main:2", "/features", 00176 "main:4", "/examples", 00177 "main:3", "/documentation", 00178 "main:5", "/download", 00179 "main:6", "/community" }; 00180 00181 const char *exampleStr[] 00182 = { "example:0", "/examples", 00183 "example:1", "/examples/charts", 00184 "example:2", "/examples/wt-homepage", 00185 "example:3", "/examples/treelist", 00186 "example:4", "/examples/hangman", 00187 "example:5", "/examples/chat", 00188 "example:6", "/examples/mail-composer", 00189 "example:7", "/examples/drag-and-drop", 00190 "example:8", "/examples/file-explorer", 00191 "example:9", "/examples/calendar" }; 00192 00193 if (historyKey->find("main:4") != std::string::npos) { 00194 for (unsigned i = 0; i < 10; ++i) 00195 if (historyKey->find(exampleStr[i*2]) != std::string::npos) { 00196 WApplication *app = new WApplication(env); 00197 app->log("notice") << "redirecting old style URL '" 00198 << *historyKey << "' to internal path: '" 00199 << exampleStr[i*2+1] << "'"; 00200 app->redirect(app->bookmarkUrl(exampleStr[i*2+1])); 00201 app->quit(); 00202 return app; 00203 } 00204 } else 00205 for (unsigned i = 0; i < 6; ++i) 00206 if (historyKey->find(mainStr[i*2]) != std::string::npos) { 00207 WApplication *app = new WApplication(env); 00208 00209 app->log("notice") << "redirecting old style URL '" 00210 << *historyKey << "' to internal path: '" 00211 << mainStr[i*2+1] << "'"; 00212 app->redirect(app->bookmarkUrl(mainStr[i*2+1])); 00213 app->quit(); 00214 return app; 00215 } 00216 00217 // unknown history key, just continue 00218 } 00219 00220 return new WtHome(env); 00221 }