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 addWidget(f_());
00055 }
00056
00057 Function f_;
00058 };
00059
00060 template <typename Function>
00061 DeferredWidget<Function> *deferCreate(Function f)
00062 {
00063 return new DeferredWidget<Function>(f);
00064 }
00065
00066 class Home : public WApplication
00067 {
00068 public:
00069 Home(const WEnvironment& env,
00070 const std::string& title,
00071 const std::string& resourceBundle, const std::string& cssPath);
00072
00073 virtual ~Home();
00074
00075 void googleAnalyticsLogger();
00076
00077 protected:
00078 virtual WWidget *examples() = 0;
00079 virtual WWidget *download() = 0;
00080 virtual WWidget *sourceViewer(const std::string &deployPath) = 0;
00081 virtual std::string filePrefix() const = 0;
00082
00083 void init();
00084
00085 void addLanguage(const Lang& l) { languages.push_back(l); }
00086 WWidget *linkSourceBrowser(const std::string& examplePath);
00087
00088 WTabWidget *examplesMenu_;
00089
00090 WString tr(const char *key);
00091 std::string href(const std::string& url, const std::string& description);
00092
00093 WTable *releases_;
00094 void readReleases(WTable *releaseTable);
00095
00096 private:
00097 WWidget *homePage_;
00098 WWidget *sourceViewer_;
00099
00100 WStackedWidget *contents_;
00101
00102 WWidget *initHome();
00103
00104 WWidget *introduction();
00105 WWidget *news();
00106 WWidget *status();
00107 WWidget *features();
00108 WWidget *documentation();
00109 WWidget *community();
00110 WWidget *otherLanguage();
00111
00112 WTable *recentNews_;
00113 WTable *historicalNews_;
00114
00115 WMenu *mainMenu_;
00116
00117 int language_;
00118
00119 void readNews(WTable *newsTable, const std::string& newsfile);
00120
00121 WWidget *wrapView(WWidget *(Home::*createFunction)());
00122
00123 void updateTitle();
00124 void setLanguage(int language);
00125 void setLanguageFromPath();
00126 void setup();
00127 void logInternalPath(const std::string& path);
00128
00129 WContainerWidget *sideBarContent_;
00130
00131 std::vector<Lang> languages;
00132 };
00133
00134 #endif // HOME_H_