10 #include <boost/lexical_cast.hpp>
11 #include <boost/tokenizer.hpp>
12 #include <boost/algorithm/string.hpp>
14 #include <Wt/WAnchor.h>
15 #include <Wt/WApplication.h>
16 #include <Wt/WEnvironment.h>
17 #include <Wt/WLogger.h>
19 #include <Wt/WPushButton.h>
20 #include <Wt/WStackedWidget.h>
21 #include <Wt/WTabWidget.h>
22 #include <Wt/WTable.h>
23 #include <Wt/WTableCell.h>
24 #include <Wt/WTemplate.h>
26 #include <Wt/WViewWidget.h>
27 #include <Wt/WVBoxLayout.h>
30 #include "view/BlogView.h"
42 const std::string& title,
const std::string& resourceBundle,
43 const std::string& cssPath)
93 auto layout = cpp14::make_unique<WVBoxLayout>();
94 layout->setContentsMargins(0, 0, 0, 0);
97 layout->addWidget(std::move(source));
119 auto languagesDiv = cpp14::make_unique<WContainerWidget>();
120 languagesDiv->setId(
"top_languages");
122 for (
unsigned i = 0; i <
languages.size(); ++i) {
124 languagesDiv->addWidget(cpp14::make_unique<WText>(
"- "));
131 auto contents = cpp14::make_unique<WStackedWidget>();
132 WAnimation fade(AnimationEffect::Fade, TimingFunction::Linear, 250);
133 contents->setTransitionAnimation(fade);
134 contents->setId(
"main_page");
136 auto mainMenu = cpp14::make_unique<WMenu>(contents.get());
146 ContentLoading::Eager);
150 ContentLoading::Eager);
158 ContentLoading::Eager);
162 ContentLoading::Eager);
166 ContentLoading::Eager);
177 result->
bindWidget(
"languages", std::move(languagesDiv));
178 result->
bindWidget(
"menu", std::move(mainMenu));
179 result->
bindWidget(
"contents", std::move(contents));
190 std::string langPath = l.
path_;
195 blog->setInternalBasePath(langPath +
"blog/");
210 std::unique_ptr<WText> a(cpp14::make_unique<WText>(
tr(
"source-browser-link").arg(path)));
211 a->setInternalPathEncoding(
true);
219 if (langPath.empty())
222 langPath =
'/' + langPath +
'/';
226 for (
unsigned i = 0; i <
languages.size(); ++i) {
250 if (path.size() >= 4 && path.substr(0, 4) ==
"/src") {
257 return cpp14::make_unique<WText>(
tr(
"home.intro"));
263 std::string langPath = l.
path_;
264 std::unique_ptr<BlogView>
blog
265 = cpp14::make_unique<BlogView>(langPath +
"blog/",
267 blog->setObjectName(
"blog");
269 if (!
blog->user().empty())
274 return std::move(
blog);
279 WApplication::instance()->doJavaScript
280 (
"if (window.chat && window.chat.emit) {"
282 "" "window.chat.emit(window.chat, 'login', "
293 return cpp14::make_unique<WText>(
tr(
"home.status"));
298 return std::unique_ptr<WText>(cpp14::make_unique<WText>(
tr(
"home.features")));
303 std::unique_ptr<WText> result
304 = cpp14::make_unique<WText>(
tr(
"home.documentation"));
305 result->setInternalPathEncoding(
true);
306 return std::move(result);
311 return std::unique_ptr<WText>(cpp14::make_unique<WText>(
tr(
"home.other-language")));
319 std::string
Home::href(
const std::string& url,
const std::string& description)
321 return "<a href=\"" +
url +
"\" target=\"_blank\">" + description +
"</a>";
326 return cpp14::make_unique<WText>(
tr(
"home.community"));
331 std::ifstream f((
filePrefix() +
"releases.txt").c_str());
333 releaseTable->
clear();
336 ->
addWidget(cpp14::make_unique<WText>(
tr(
"home.download.version")));
338 ->
addWidget(cpp14::make_unique<WText>(
tr(
"home.download.date")));
340 ->
addWidget(cpp14::make_unique<WText>(
tr(
"home.download.description")));
354 typedef boost::tokenizer<boost::escaped_list_separator<char> >
356 CsvTokenizer tok(line);
358 CsvTokenizer::iterator i=tok.begin();
360 std::string fileName = *i;
361 std::string description = *(++i);
366 std::string
url =
"http://prdownloads.sourceforge.net/witty/"
367 + fileName +
"?download";
372 (cpp14::make_unique<WText>(
href(
url, description)));
379 #ifdef WT_EMWEB_BUILD
382 auto result = cpp14::make_unique<WContainerWidget>();
383 result->setStyleClass(
"quote");
386 result->addWidget(cpp14::make_unique<WTemplate>(
tr(
"quote.request")));
388 auto quoteButton = cpp14::make_unique<WPushButton>(
tr(
"quote.requestbutton"));
389 auto quoteButtonPtr = requestTemplate->
bindWidget(
"button", std::move(quoteButton));
393 quoteButtonPtr->clicked().connect(
quoteForm, &WWidget::show);
394 quoteButtonPtr->clicked().connect(requestTemplate, &WWidget::hide);
400 #endif // WT_EMWEB_BUILD
404 auto result = cpp14::make_unique<WContainerWidget>();
405 result->addWidget(cpp14::make_unique<WText>(
tr(
"home.download")));
407 result->addWidget(cpp14::make_unique<WText>(
tr(
"home.download.license")));
409 #ifdef WT_EMWEB_BUILD
410 result->addWidget(std::move(
quoteForm()));
411 #endif // WT_EMWEB_BUILD
413 result->addWidget(cpp14::make_unique<WText>(
tr(
"home.download.packages")));
415 auto releases = cpp14::make_unique<WTable>();
417 releases_ = result->addWidget(std::move(releases));
419 result->addWidget(cpp14::make_unique<WText>(
tr(
"home.download.other")));
421 return std::move(result);
427 return WString::tr(key);
433 + WWebWidget::jsStringLiteral(
environment().deploymentPath()