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 protected:
00076 virtual WWidget *examples() = 0;
00077 virtual WWidget *download() = 0;
00078 virtual WWidget *sourceViewer(const std::string &deployPath) = 0;
00079 virtual std::string filePrefix() const = 0;
00080
00081 void init();
00082
00083 void addLanguage(const Lang& l) { languages.push_back(l); }
00084 WWidget *linkSourceBrowser(const std::string& examplePath);
00085
00086 WTabWidget *examplesMenu_;
00087
00088 WString tr(const char *key);
00089 std::string href(const std::string& url, const std::string& description);
00090
00091 WTable *releases_;
00092 void readReleases(WTable *releaseTable);
00093
00094 private:
00095 WWidget *homePage_;
00096 WWidget *sourceViewer_;
00097
00098 WStackedWidget *contents_;
00099
00100 WWidget *initHome();
00101
00102 WWidget *introduction();
00103 WWidget *news();
00104 WWidget *status();
00105 WWidget *features();
00106 WWidget *documentation();
00107 WWidget *community();
00108 WWidget *otherLanguage();
00109
00110 WTable *recentNews_;
00111 WTable *historicalNews_;
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
00127 WContainerWidget *sideBarContent_;
00128
00129 std::vector<Lang> languages;
00130 };
00131
00132 #endif // HOME_H_