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