Wt examples  3.3.0
Classes | Functions
WtHome.h File Reference
#include <Wt/WApplication>
#include "Home.h"

Go to the source code of this file.

Classes

class  WtHome
 

Functions

WApplicationcreateWtHomeApplication (const WEnvironment &env)
 

Function Documentation

WApplication* createWtHomeApplication ( const WEnvironment env)

Definition at line 170 of file WtHome.C.

171 {
172  // support for old (< Wt-2.2) homepage URLS: redirect from "states"
173  // to "internal paths"
174  // this contains the initial "history state" in old Wt versions
175  const std::string *historyKey = env.getParameter("historyKey");
176 
177  if (historyKey) {
178  const char *mainStr[]
179  = { "main:0", "/",
180  "main:1", "/news",
181  "main:2", "/features",
182  "main:4", "/examples",
183  "main:3", "/documentation",
184  "main:5", "/download",
185  "main:6", "/community" };
186 
187  const char *exampleStr[]
188  = { "example:0", "/examples",
189  "example:1", "/examples/charts",
190  "example:2", "/examples/wt-homepage",
191  "example:3", "/examples/treelist",
192  "example:4", "/examples/hangman",
193  "example:5", "/examples/chat",
194  "example:6", "/examples/mail-composer",
195  "example:7", "/examples/drag-and-drop",
196  "example:8", "/examples/file-explorer",
197  "example:9", "/examples/calendar" };
198 
199  if (historyKey->find("main:4") != std::string::npos) {
200  for (unsigned i = 0; i < 10; ++i)
201  if (historyKey->find(exampleStr[i*2]) != std::string::npos) {
202  WApplication *app = new WApplication(env);
203  app->log("notice") << "redirecting old style URL '"
204  << *historyKey << "' to internal path: '"
205  << exampleStr[i*2+1] << "'";
206  app->redirect(app->bookmarkUrl(exampleStr[i*2+1]));
207  app->quit();
208  return app;
209  }
210  } else
211  for (unsigned i = 0; i < 6; ++i)
212  if (historyKey->find(mainStr[i*2]) != std::string::npos) {
213  WApplication *app = new WApplication(env);
214 
215  app->log("notice") << "redirecting old style URL '"
216  << *historyKey << "' to internal path: '"
217  << mainStr[i*2+1] << "'";
218  app->redirect(app->bookmarkUrl(mainStr[i*2+1]));
219  app->quit();
220  return app;
221  }
222 
223  // unknown history key, just continue
224  }
225 
226  return new WtHome(env);
227 }

Generated on Fri May 31 2013 for the C++ Web Toolkit (Wt) by doxygen 1.8.3.1