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>
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"
41 Dbo::SqlConnectionPool&
blogDb,
93 auto layout = std::make_unique<WVBoxLayout>();
94 layout->setContentsMargins(0, 0, 0, 0);
119 auto languagesDiv = std::make_unique<WContainerWidget>();
128 languagesDiv->addWidget(std::make_unique<WAnchor>(
WLink(LinkType::InternalPath,
l.path_),
l.longDescription_));
131 auto contents = std::make_unique<WStackedWidget>();
132 WAnimation fade(AnimationEffect::Fade, TimingFunction::Linear, 250);
146 ContentLoading::Eager);
150 ContentLoading::Eager);
154 ContentLoading::Eager)->setPathComponent(
"examples/");
158 ContentLoading::Eager);
162 ContentLoading::Eager);
166 ContentLoading::Eager);
210 std::unique_ptr<WText>
a(std::make_unique<WText>(
tr(
"source-browser-link").
arg(
path)));
211 a->setInternalPathEncoding(
true);
250 if (
path.size() >= 4 &&
path.substr(0, 4) ==
"/src") {
257 return std::make_unique<WText>(
tr(
"home.intro"));
264 std::unique_ptr<BlogView>
blog
265 = std::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', "
283 "" "" + userName.jsStringLiteral() +
"); "
285 "" "window.chatUser=" + userName.jsStringLiteral() +
";"
288 """window.chatUser=" + userName.jsStringLiteral() +
";");
293 return std::make_unique<WText>(
tr(
"home.status"));
298 return std::unique_ptr<WText>(std::make_unique<WText>(
tr(
"home.features")));
303 std::unique_ptr<WText>
result
304 = std::make_unique<WText>(
tr(
"home.documentation"));
305 result->setInternalPathEncoding(
true);
311 return std::unique_ptr<WText>(std::make_unique<WText>(
tr(
"home.other-language")));
321 return "<a href=\"" +
url +
"\" target=\"_blank\">" +
description +
"</a>";
326 return std::make_unique<WText>(
tr(
"home.community"));
336 ->addWidget(std::make_unique<WText>(
tr(
"home.download.version")));
338 ->addWidget(std::make_unique<WText>(
tr(
"home.download.date")));
340 ->addWidget(std::make_unique<WText>(
tr(
"home.download.description")));
354 typedef boost::tokenizer<boost::escaped_list_separator<char> >
358 CsvTokenizer::iterator
i=
tok.begin();
360 std::string fileName = *
i;
362 releaseTable->elementAt(
row, 1)->addWidget(std::make_unique<WText>(*(++
i)));
363 releaseTable->elementAt(
row, 2)->addWidget(std::make_unique<WText>(*(++
i)));
366 std::string
url =
"http://prdownloads.sourceforge.net/witty/"
367 + fileName +
"?download";
382 auto result = std::make_unique<WContainerWidget>();
383 result->setStyleClass(
"quote");
386 result->addWidget(std::make_unique<WTemplate>(
tr(
"quote.request")));
388 auto quoteButton = std::make_unique<WPushButton>(
tr(
"quote.requestbutton"));
404 auto result = std::make_unique<WContainerWidget>();
405 result->addWidget(std::make_unique<WText>(
tr(
"home.download")));
407 result->addWidget(std::make_unique<WText>(
tr(
"home.download.license")));
413 result->addWidget(std::make_unique<WText>(
tr(
"home.download.packages")));
415 auto releases = std::make_unique<WTable>();
419 result->addWidget(std::make_unique<WText>(
tr(
"home.download.other")));
427 return WString::tr(
key);
static const std::string SRC_INTERNAL_PATH
std::unique_ptr< DeferredWidget< Function > > deferCreate(Function f)
Wt::Auth::Dbo::UserDatabase< AuthInfo > UserDatabase
std::unique_ptr< WWidget > blog()
std::unique_ptr< WWidget > community()
std::unique_ptr< WWidget > linkSourceBrowser(const std::string &examplePath)
std::unique_ptr< WWidget > download()
Home(const WEnvironment &env, Dbo::SqlConnectionPool &blogDb, const std::string &title, const std::string &resourceBundle, const std::string &cssPath)
WTabWidget * examplesMenu_
void googleAnalyticsLogger()
virtual std::unique_ptr< WWidget > createQuoteForm()=0
std::string href(const std::string &url, const std::string &description)
std::unique_ptr< WWidget > wrapView(std::unique_ptr< WWidget >(Home::*createFunction)())
std::unique_ptr< WWidget > otherLanguage()
void setLanguage(int language)
std::unique_ptr< WWidget > documentation()
virtual std::unique_ptr< WWidget > examples()=0
Dbo::SqlConnectionPool & blogDb_
WString tr(const char *key)
virtual std::string filePrefix() const =0
std::unique_ptr< WWidget > quoteForm()
std::unique_ptr< WWidget > features()
void readReleases(WTable *releaseTable)
std::unique_ptr< WContainerWidget > sideBarContent_
std::unique_ptr< WWidget > status()
void logInternalPath(const std::string &path)
std::vector< Lang > languages
virtual std::unique_ptr< WWidget > sourceViewer(const std::string &deployPath)=0
void setLanguageFromPath()
std::unique_ptr< WWidget > introduction()
void chatSetUser(const WString &name)
std::unique_ptr< Wt::WApplication > createWidget(const Wt::WEnvironment &env, SimpleChatServer &server)