Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007 #ifndef HOME_H_
00008 #define HOME_H_
00009
00010 #include <Wt/WApplication>
00011 #include <Wt/WContainerWidget>
00012
00013 namespace Wt {
00014 class WMenu;
00015 class WStackedWidget;
00016 class WTabWidget;
00017 class WTreeNode;
00018 class WTable;
00019 }
00020
00021 using namespace Wt;
00022
00023 struct Lang {
00024 Lang(const std::string& code, const std::string& path,
00025 const std::string& shortDescription,
00026 const std::string& longDescription) :
00027 code_(code),
00028 path_(path),
00029 shortDescription_(shortDescription),
00030 longDescription_(longDescription) {
00031 }
00032
00033 std::string code_, path_, shortDescription_, longDescription_;
00034 };
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044 template <typename Function>
00045 class DeferredWidget : public WContainerWidget
00046 {
00047 public:
00048 DeferredWidget(Function f)
00049 : f_(f) { }
00050
00051 private:
00052 void load() {
00053 WContainerWidget::load();
00054 if (count() == 0)
00055 addWidget(f_());
00056 }
00057
00058 Function f_;
00059 };
00060
00061 template <typename Function>
00062 DeferredWidget<Function> *deferCreate(Function f)
00063 {
00064 return new DeferredWidget<Function>(f);
00065 }
00066
00067 class Home : public WApplication
00068 {
00069 public:
00070 Home(const WEnvironment& env,
00071 const std::string& title,
00072 const std::string& resourceBundle, const std::string& cssPath);
00073
00074 virtual ~Home();
00075
00076 void googleAnalyticsLogger();
00077
00078 protected:
00079 virtual WWidget *examples() = 0;
00080 virtual WWidget *download() = 0;
00081 virtual WWidget *sourceViewer(const std::string &deployPath) = 0;
00082 virtual std::string filePrefix() const = 0;
00083
00084 void init();
00085
00086 void addLanguage(const Lang& l) { languages.push_back(l); }
00087 WWidget *linkSourceBrowser(const std::string& examplePath);
00088
00089 WTabWidget *examplesMenu_;
00090
00091 WString tr(const char *key);
00092 std::string href(const std::string& url, const std::string& description);
00093
00094 WTable *releases_;
00095 void readReleases(WTable *releaseTable);
00096
00097 private:
00098 WWidget *homePage_;
00099 WWidget *sourceViewer_;
00100
00101 WStackedWidget *contents_;
00102
00103 WWidget *initHome();
00104
00105 WWidget *introduction();
00106 WWidget *blog();
00107 WWidget *status();
00108 WWidget *features();
00109 WWidget *documentation();
00110 WWidget *community();
00111 WWidget *otherLanguage();
00112
00113 WMenu *mainMenu_;
00114
00115 int language_;
00116
00117 void readNews(WTable *newsTable, const std::string& newsfile);
00118
00119 WWidget *wrapView(WWidget *(Home::*createFunction)());
00120
00121 void updateTitle();
00122 void setLanguage(int language);
00123 void setLanguageFromPath();
00124 void setup();
00125 void logInternalPath(const std::string& path);
00126 void chatSetUser(const WString& name);
00127
00128 WContainerWidget *sideBarContent_;
00129
00130 std::vector<Lang> languages;
00131 };
00132
00133 #endif // HOME_H_