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);