10 #include <boost/lexical_cast.hpp>
11 #include <boost/tokenizer.hpp>
12 #include <boost/algorithm/string.hpp>
15 #include <Wt/WApplication>
16 #include <Wt/WEnvironment>
19 #include <Wt/WPushButton>
20 #include <Wt/WStackedWidget>
21 #include <Wt/WTabWidget>
23 #include <Wt/WTableCell>
24 #include <Wt/WTemplate>
26 #include <Wt/WViewWidget>
27 #include <Wt/WVBoxLayout>
30 #include "view/BlogView.h"
40 const std::string& title,
const std::string& resourceBundle,
41 const std::string& cssPath)
94 layout->setContentsMargins(0, 0, 0, 0);
96 root()->setLayout(layout);
119 languagesDiv->
setId(
"top_languages");
121 for (
unsigned i = 0; i <
languages.size(); ++i) {
123 new WText(
"- ", languagesDiv);
132 WAnimation fade(WAnimation::Fade, WAnimation::Linear, 250);
134 contents->
setId(
"main_page");
149 WMenuItem::PreLoading);
157 WMenuItem::PreLoading);
164 WMenuItem::PreLoading);
175 result->bindWidget(
"languages", languagesDiv);
177 result->bindWidget(
"contents", contents);
188 std::string langPath = l.
path_;
193 blog->setInternalBasePath(langPath +
"blog/");
208 WText *a =
new WText(
tr(
"source-browser-link").arg(path));
209 a->setInternalPathEncoding(
true);
217 if (langPath.empty())
220 langPath =
'/' + langPath +
'/';
224 for (
unsigned i = 0; i <
languages.size(); ++i) {
248 if (path.size() >= 4 && path.substr(0, 4) ==
"/src") {
255 return new WText(
tr(
"home.intro"));
261 std::string langPath = l.
path_;
262 BlogView *
blog =
new BlogView(langPath +
"blog/",
264 blog->setObjectName(
"blog");
266 if (!blog->user().empty())
276 WApplication::instance()->doJavaScript
277 (
"if (window.chat && window.chat.emit) {"
279 "" "window.chat.emit(window.chat, 'login', "
290 return new WText(
tr(
"home.status"));
295 return new WText(
tr(
"home.features"));
301 result->setInternalPathEncoding(
true);
307 return new WText(
tr(
"home.other-language"));
312 return makeStaticModel(boost::bind(createWidget,
this));
315 std::string
Home::href(
const std::string& url,
const std::string& description)
317 return "<a href=\"" + url +
"\" target=\"_blank\">" + description +
"</a>";
322 return new WText(
tr(
"home.community"));
327 std::ifstream f((
filePrefix() +
"releases.txt").c_str());
329 releaseTable->
clear();
332 ->addWidget(
new WText(
tr(
"home.download.version")));
334 ->addWidget(
new WText(
tr(
"home.download.date")));
336 ->addWidget(
new WText(
tr(
"home.download.description")));
350 typedef boost::tokenizer<boost::escaped_list_separator<char> >
352 CsvTokenizer tok(line);
354 CsvTokenizer::iterator i=tok.begin();
356 std::string fileName = *i;
357 std::string description = *(++i);
358 releaseTable->
elementAt(row, 0)->addWidget
359 (
new WText(
href(
"http://prdownloads.sourceforge.net/witty/"
360 + fileName +
"?download", description)));
369 #ifdef WT_EMWEB_BUILD
378 requestTemplate->bindWidget(
"button", quoteButton);
381 result->addWidget(quoteForm);
383 quoteButton->clicked().connect(quoteForm, &WWidget::show);
384 quoteButton->clicked().connect(requestTemplate, &WWidget::hide);
390 #endif // WT_EMWEB_BUILD
395 result->addWidget(
new WText(
tr(
"home.download")));
397 result->addWidget(
new WText(
tr(
"home.download.license")));
399 #ifdef WT_EMWEB_BUILD
401 #endif // WT_EMWEB_BUILD
403 result->addWidget(
new WText(
tr(
"home.download.packages")));
409 result->addWidget(
new WText(
tr(
"home.download.other")));
417 return WString::tr(key);
422 std::string googleCmd =
423 "if (window.pageTracker) {"
425 "" "setTimeout(function() {"
426 "" "window.pageTracker._trackPageview(\""
WLogEntry log(const std::string &type) const
void logInternalPath(const std::string &path)
WWidget * wrapView(WWidget *(Home::*createFunction)())
WWidget * linkSourceBrowser(const std::string &examplePath)
std::string jsStringLiteral(char delimiter= '\'') const
std::vector< Lang > languages
void setLanguage(int language)
WMessageResourceBundle & messageResourceBundle()
void setTitle(const WString &title)
virtual WWidget * examples()=0
std::string longDescription_
WString tr(const char *key)
virtual WWidget * sourceViewer(const std::string &deployPath)=0
virtual std::string filePrefix() const =0
Home(const WEnvironment &env, Wt::Dbo::SqlConnectionPool &blogDb, const std::string &title, const std::string &resourceBundle, const std::string &cssPath)
WTableCell * elementAt(int row, int column)
static const std::string SRC_INTERNAL_PATH
std::string internalPathNextPart(const std::string &path) const
std::string internalPath() const
DeferredWidget< Function > * deferCreate(Function f)
WWidget * documentation()
void use(const std::string &path, bool loadInMemory=true)
Wt::Dbo::SqlConnectionPool & blogDb_
std::string href(const std::string &url, const std::string &description)
WWidget * findWidget(const std::string &name)
WTabWidget * examplesMenu_
WWidget * otherLanguage()
void setLanguageFromPath()
const WEnvironment & environment() const
WContainerWidget * sideBarContent_
WApplication * createWidget(const WEnvironment &env, SimpleChatServer &server)
const std::string & deploymentPath() const
static std::string appRoot()
void useStyleSheet(const WLink &link, const std::string &media="all")
void addWidget(WWidget *widget, int stretch=0, WFlags< AlignmentFlag > alignment=0)
void chatSetUser(const WString &name)
void readReleases(WTable *releaseTable)
WContainerWidget * root() const
void doJavaScript(const std::string &javascript, bool afterLoaded=true)
void setLocale(const WLocale &locale)
virtual WWidget * createQuoteForm()=0
Signal< std::string > & internalPathChanged()
void googleAnalyticsLogger()