Wt examples 3.1.10
Classes | Functions
/build/buildd/witty-3.1.10/examples/wt-homepage/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 162 of file WtHome.C.

{
  // support for old (< Wt-2.2) homepage URLS: redirect from "states"
  // to "internal paths"
  // this contains the initial "history state" in old Wt versions
  const std::string *historyKey = env.getParameter("historyKey");

  if (historyKey) {
    const char *mainStr[]
      = { "main:0", "/",
          "main:1", "/news",
          "main:2", "/features",
          "main:4", "/examples",
          "main:3", "/documentation",
          "main:5", "/download",
          "main:6", "/community" };

    const char *exampleStr[]
      = { "example:0", "/examples",
          "example:1", "/examples/charts",
          "example:2", "/examples/wt-homepage",
          "example:3", "/examples/treelist",
          "example:4", "/examples/hangman",
          "example:5", "/examples/chat",
          "example:6", "/examples/mail-composer",
          "example:7", "/examples/drag-and-drop",
          "example:8", "/examples/file-explorer",
          "example:9", "/examples/calendar" };

    if (historyKey->find("main:4") != std::string::npos) {
      for (unsigned i = 0; i < 10; ++i)
        if (historyKey->find(exampleStr[i*2]) != std::string::npos) {
          WApplication *app = new WApplication(env);
          app->log("notice") << "redirecting old style URL '"
                             << *historyKey << "' to internal path: '"
                             << exampleStr[i*2+1] << "'";
          app->redirect(app->bookmarkUrl(exampleStr[i*2+1]));
          app->quit();
          return app;
        }
    } else
      for (unsigned i = 0; i < 6; ++i)
        if (historyKey->find(mainStr[i*2]) != std::string::npos) {
          WApplication *app = new WApplication(env);

          app->log("notice") << "redirecting old style URL '"
                             << *historyKey << "' to internal path: '"
                             << mainStr[i*2+1] << "'";
          app->redirect(app->bookmarkUrl(mainStr[i*2+1]));
          app->quit();
          return app;
        }

    // unknown history key, just continue
  }

  return new WtHome(env);
}

Generated on Mon Nov 14 2011 for the C++ Web Toolkit (Wt) by doxygen 1.7.4