Wt examples 3.3.12
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
Home Class Referenceabstract

#include <Home.h>

Inheritance diagram for Home:
Inheritance graph
[legend]

Public Member Functions

 Home (const WEnvironment &env, Wt::Dbo::SqlConnectionPool &blogDb, const std::string &title, const std::string &resourceBundle, const std::string &cssPath)
 
virtual ~Home ()
 
void googleAnalyticsLogger ()
 
- Public Member Functions inherited from Wt::WApplication
 WApplication (const WEnvironment &environment)
 
 ~WApplication ()
 
const WEnvironmentenvironment () const
 
WContainerWidgetroot () const
 
WWidgetfindWidget (const std::string &name)
 
WCssStyleSheetstyleSheet ()
 
void useStyleSheet (const WLink &link, const std::string &media="all")
 
void useStyleSheet (const WLink &link, const std::string &condition, const std::string &media)
 
void useStyleSheet (const WCssStyleSheet &styleSheet, const std::string &condition="")
 
void removeStyleSheet (const WLink &link)
 
void setTheme (const WTheme *theme)
 
const WThemetheme () const
 
void setCssTheme (const std::string &name)
 
void setLayoutDirection (LayoutDirection direction)
 
LayoutDirection layoutDirection () const
 
void setBodyClass (const std::string &styleClass)
 
std::string bodyClass () const
 
void setHtmlClass (const std::string &styleClass)
 
std::string htmlClass () const
 
void setTitle (const WString &title)
 
const WStringtitle () const
 
const WStringcloseMessage () const
 
WLocalizedStringslocalizedStrings ()
 
WMessageResourceBundlebuiltinLocalizedStrings ()
 
void setLocalizedStrings (WLocalizedStrings *stringResolver)
 
WMessageResourceBundlemessageResourceBundle ()
 
void setLocale (const WLocale &locale)
 
const WLocalelocale () const
 
virtual void refresh ()
 
void bindWidget (WWidget *widget, const std::string &domId)
 
void enableUpdates (bool enabled=true)
 
bool updatesEnabled () const
 
void triggerUpdate ()
 
UpdateLock getUpdateLock ()
 
void attachThread (bool attach=true)
 
EventSignal< WKeyEvent > & globalKeyWentDown ()
 
EventSignal< WKeyEvent > & globalKeyPressed ()
 
EventSignal< WKeyEvent > & globalKeyWentUp ()
 
EventSignalglobalEnterPressed ()
 
EventSignalglobalEscapePressed ()
 
bool debug () const
 
void setFocus (const std::string &id, int selectionStart, int selectionEnd)
 
void loadJavaScript (const char *jsFile, const WJavaScriptPreamble &preamble)
 
bool javaScriptLoaded (const char *jsFile) const
 
void setConfirmCloseMessage (const WString &message)
 
void enableInternalPaths ()
 
void deferRendering ()
 
void resumeRendering ()
 
boost::function< void()> bind (const F &f)
 
std::string encodeUntrustedUrl (const std::string &url) const
 
void pushExposedConstraint (WWidget *w)
 
void popExposedConstraint (WWidget *w)
 
void addGlobalWidget (WWidget *w)
 
void removeGlobalWidget (WWidget *w)
 
WCssStyleSheetstyleSheet ()
 
void useStyleSheet (const WLink &link, const std::string &media="all")
 
void useStyleSheet (const WLink &link, const std::string &condition, const std::string &media)
 
void useStyleSheet (const WCssStyleSheet &styleSheet, const std::string &condition="")
 
void removeStyleSheet (const WLink &link)
 
void setTheme (const WTheme *theme)
 
const WThemetheme () const
 
void setCssTheme (const std::string &name)
 
void setLayoutDirection (LayoutDirection direction)
 
LayoutDirection layoutDirection () const
 
void setBodyClass (const std::string &styleClass)
 
std::string bodyClass () const
 
void setHtmlClass (const std::string &styleClass)
 
std::string htmlClass () const
 
void setTitle (const WString &title)
 
const WStringtitle () const
 
const WStringcloseMessage () const
 
WLocalizedStringslocalizedStrings ()
 
WMessageResourceBundlebuiltinLocalizedStrings ()
 
void setLocalizedStrings (WLocalizedStrings *stringResolver)
 
WMessageResourceBundlemessageResourceBundle ()
 
void setLocale (const WLocale &locale)
 
const WLocalelocale () const
 
virtual void refresh ()
 
void bindWidget (WWidget *widget, const std::string &domId)
 
std::string url (const std::string &internalPath=std::string()) const
 
virtual std::string makeAbsoluteUrl (const std::string &url) const
 
std::string resolveRelativeUrl (const std::string &url) const
 
std::string bookmarkUrl () const
 
std::string bookmarkUrl (const std::string &internalPath) const
 
void setInternalPath (const std::string &path, bool emitChange=false)
 
void setInternalPathDefaultValid (bool valid)
 
bool internalPathDefaultValid () const
 
void setInternalPathValid (bool valid)
 
bool internalPathValid () const
 
std::string internalPath () const
 
std::string internalPathNextPart (const std::string &path) const
 
std::string internalSubPath (const std::string &path) const
 
bool internalPathMatches (const std::string &path) const
 
Signal< std::string > & internalPathChanged ()
 
Signal< std::string > & internalPathInvalid ()
 
void redirect (const std::string &url)
 
std::string docRoot () const
 
void setConnectionMonitor (const std::string &jsObject)
 
std::string sessionId () const
 
void changeSessionId ()
 
WebSession * session () const
 
void enableUpdates (bool enabled=true)
 
bool updatesEnabled () const
 
void triggerUpdate ()
 
UpdateLock getUpdateLock ()
 
void attachThread (bool attach=true)
 
void doJavaScript (const std::string &javascript, bool afterLoaded=true)
 
void addAutoJavaScript (const std::string &javascript)
 
void declareJavaScriptFunction (const std::string &name, const std::string &function)
 
bool require (const std::string &url, const std::string &symbol=std::string())
 
bool requireJQuery (const std::string &url)
 
bool customJQuery () const
 
void setJavaScriptClass (const std::string &className)
 
std::string javaScriptClass ()
 
void processEvents ()
 
virtual void waitForEvent ()
 
void setAjaxMethod (AjaxMethod method)
 
AjaxMethod ajaxMethod () const
 
WContainerWidgetdomRoot () const
 
WContainerWidgetdomRoot2 () const
 
std::string encodeObject (WObject *object)
 
WObjectdecodeObject (const std::string &objectId) const
 
virtual void initialize ()
 
virtual void finalize ()
 
void setTwoPhaseRenderingThreshold (int size)
 
void setCookie (const std::string &name, const std::string &value, int maxAge, const std::string &domain="", const std::string &path="", bool secure=false)
 
void setCookie (const std::string &name, const std::string &value, const WDateTime &expires, const std::string &domain="", const std::string &path="", bool secure=false)
 
void removeCookie (const std::string &name, const std::string &domain="", const std::string &path="")
 
void addMetaLink (const std::string &href, const std::string &rel, const std::string &media, const std::string &hreflang, const std::string &type, const std::string &sizes, bool disabled)
 
void removeMetaLink (const std::string &href)
 
void addMetaHeader (const std::string &name, const WString &content, const std::string &lang="")
 
void addMetaHeader (MetaHeaderType type, const std::string &name, const WString &content, const std::string &lang="")
 
WString metaHeader (MetaHeaderType type, const std::string &name) const
 
void removeMetaHeader (MetaHeaderType type, const std::string &name="")
 
WLogEntry log (const std::string &type) const
 
void setLoadingIndicator (WLoadingIndicator *indicator)
 
WLoadingIndicatorloadingIndicator () const
 
std::string onePixelGifUrl ()
 
std::string docType () const
 
void quit ()
 
void quit (const WString &restartMessage)
 
bool isQuited () const
 
bool hasQuit () const
 
::int64_t maximumRequestSize () const
 
Signal< ::int64_t > & requestTooLarge ()
 
bool isConnected () const
 
- Public Member Functions inherited from Wt::WObject
 WObject (WObject *parent=0)
 
virtual ~WObject ()
 
virtual const std::string id () const
 
virtual void setObjectName (const std::string &name)
 
virtual std::string objectName () const
 
void resetLearnedSlots ()
 
void resetLearnedSlot (void(T::*method)())
 
WStatelessSlot * implementStateless (void(T::*method)())
 
WStatelessSlot * implementStateless (void(T::*method)(), void(T::*undoMethod)())
 
void isNotStateless ()
 
WStatelessSlot * implementJavaScript (void(T::*method)(), const std::string &jsCode)
 
void addChild (WObject *child)
 
virtual void removeChild (WObject *child)
 
const std::vector< WObject * > & children () const
 
WObjectparent () const
 

Protected Member Functions

virtual WWidgetexamples ()=0
 
virtual WWidgetcreateQuoteForm ()=0
 
virtual WWidgetsourceViewer (const std::string &deployPath)=0
 
virtual std::string filePrefix () const =0
 
void init ()
 
void addLanguage (const Lang &l)
 
WWidgetlinkSourceBrowser (const std::string &examplePath)
 
WString tr (const char *key)
 
std::string href (const std::string &url, const std::string &description)
 
void readReleases (WTable *releaseTable)
 
- Protected Member Functions inherited from Wt::WApplication
virtual void notify (const WEvent &e)
 
virtual bool isExposed (WWidget *w) const
 
virtual void enableAjax ()
 
virtual void unload ()
 
virtual void idleTimeout ()
 
virtual void handleJavaScriptError (const std::string &errorText)
 
- Protected Member Functions inherited from Wt::WObject
virtual WStatelessSlot * getStateless (Method method)
 

Protected Attributes

WTabWidgetexamplesMenu_
 
WTablereleases_
 

Private Member Functions

void createHome ()
 
WWidgetintroduction ()
 
WWidgetblog ()
 
WWidgetstatus ()
 
WWidgetfeatures ()
 
WWidgetdocumentation ()
 
WWidgetcommunity ()
 
WWidgetotherLanguage ()
 
WWidgetdownload ()
 
WWidgetquoteForm ()
 
void readNews (WTable *newsTable, const std::string &newsfile)
 
WWidgetwrapView (WWidget *(Home::*createFunction)())
 
void updateTitle ()
 
void setLanguage (int language)
 
void setLanguageFromPath ()
 
void setup ()
 
void logInternalPath (const std::string &path)
 
void chatSetUser (const WString &name)
 

Private Attributes

Wt::Dbo::SqlConnectionPoolblogDb_
 
WWidgethomePage_
 
WWidgetsourceViewer_
 
WStackedWidgetcontents_
 
WMenumainMenu_
 
int language_
 
WContainerWidgetsideBarContent_
 
std::vector< Langlanguages
 

Additional Inherited Members

- Public Types inherited from Wt::WApplication
enum  AjaxMethod
 
typedef Wt::ApplicationCreator ApplicationCreator
 
typedef boost::function< WApplication *(const WEnvironment &)> ApplicationCreator
 
- Public Types inherited from Wt::WObject
typedef void(WObject::* Method) ()
 
- Static Public Member Functions inherited from Wt::WApplication
static WApplicationinstance ()
 
static bool pathMatches (const std::string &path, const std::string &query)
 
static std::string resourcesUrl ()
 
static std::string relativeResourcesUrl ()
 
static std::string appRoot ()
 
static bool readConfigurationProperty (const std::string &name, std::string &value)
 
- Public Attributes inherited from Wt::WApplication
 XMLHttpRequest
 
 DynamicScriptTag
 
- Static Protected Member Functions inherited from Wt::WObject
static WObjectsender ()
 

Detailed Description

Definition at line 67 of file Home.h.

Constructor & Destructor Documentation

◆ Home()

Home::Home ( const WEnvironment env,
Wt::Dbo::SqlConnectionPool blogDb,
const std::string &  title,
const std::string &  resourceBundle,
const std::string &  cssPath 
)

Definition at line 38 of file Home.C.

43 releases_(0),
44 blogDb_(blogDb),
45 homePage_(0),
47{
48 messageResourceBundle().use(appRoot() + resourceBundle, false);
49
50 useStyleSheet(cssPath + "/wt.css");
51 useStyleSheet(cssPath + "/wt_ie.css", "lt IE 7", "all");
52 useStyleSheet("css/home.css");
53 useStyleSheet("css/sourceview.css");
54 useStyleSheet("css/chatwidget.css");
55 useStyleSheet("css/chatwidget_ie6.css", "lt IE 7", "all");
57
58 setLocale("");
59 language_ = 0;
60}
WTable * releases_
Definition Home.h:94
int language_
Definition Home.h:118
WWidget * homePage_
Definition Home.h:99
WWidget * sourceViewer_
Definition Home.h:100
Wt::Dbo::SqlConnectionPool & blogDb_
Definition Home.h:98
WEnvironment & env()
WMessageResourceBundle & messageResourceBundle()
void setTitle(const WString &title)
static std::string appRoot()
void useStyleSheet(const WLink &link, const std::string &media="all")
void setLocale(const WLocale &locale)
const WString & title() const
void use(const std::string &path, bool loadInMemory=true)

◆ ~Home()

Home::~Home ( )
virtual

Definition at line 34 of file Home.C.

35{
36}

Member Function Documentation

◆ addLanguage()

void Home::addLanguage ( const Lang l)
inlineprotected

Definition at line 86 of file Home.h.

86{ languages.push_back(l); }
std::vector< Lang > languages
Definition Home.h:133

◆ blog()

WWidget * Home::blog ( )
private

Definition at line 258 of file Home.C.

259{
260 const Lang& l = languages[language_];
261 std::string langPath = l.path_;
262 BlogView *blog = new BlogView(langPath + "blog/",
263 blogDb_, "/wt/blog/feed/");
264 blog->setObjectName("blog");
265
266 if (!blog->user().empty())
267 chatSetUser(blog->user());
268
269 blog->userChanged().connect(this, &Home::chatSetUser);
270
271 return blog;
272}
WWidget * blog()
Definition Home.C:258
void chatSetUser(const WString &name)
Definition Home.C:274
virtual void setObjectName(const std::string &name)
Definition Home.h:23
std::string path_
Definition Home.h:33

◆ chatSetUser()

void Home::chatSetUser ( const WString name)
private

Definition at line 274 of file Home.C.

275{
276 WApplication::instance()->doJavaScript
277 ("if (window.chat && window.chat.emit) {"
278 """try {"
279 "" "window.chat.emit(window.chat, 'login', "
280 "" "" + userName.jsStringLiteral() + "); "
281 """} catch (e) {"
282 "" "window.chatUser=" + userName.jsStringLiteral() + ";"
283 """}"
284 "} else "
285 """window.chatUser=" + userName.jsStringLiteral() + ";");
286}

◆ community()

WWidget * Home::community ( )
private

Definition at line 320 of file Home.C.

321{
322 return new WText(tr("home.community"));
323}
WString tr(const char *key)
Definition Home.C:421

◆ createHome()

void Home::createHome ( )
private

Definition at line 113 of file Home.C.

114{
115 WTemplate *result = new WTemplate(tr("template"), root());
116 homePage_ = result;
117
118 WContainerWidget *languagesDiv = new WContainerWidget();
119 languagesDiv->setId("top_languages");
120
121 for (unsigned i = 0; i < languages.size(); ++i) {
122 if (i != 0)
123 new WText("- ", languagesDiv);
124
125 const Lang& l = languages[i];
126
128 WString::fromUTF8(l.longDescription_), languagesDiv);
129 }
130
131 WStackedWidget *contents = new WStackedWidget();
133 contents->setTransitionAnimation(fade);
134 contents->setId("main_page");
135
136 mainMenu_ = new WMenu(contents, Vertical);
137
139 (tr("introduction"), introduction())->setPathComponent("");
140
142 (tr("blog"), deferCreate(boost::bind(&Home::blog, this)));
143
146
148 (tr("documentation"), wrapView(&Home::documentation),
150
152 (tr("examples"), examples(),
154
156 (tr("download"), deferCreate(boost::bind(&Home::download, this)),
158
161
163 (tr("other-language"), wrapView(&Home::otherLanguage),
165
167
169
170 // Make the menu be internal-path aware.
172
174
175 result->bindWidget("languages", languagesDiv);
176 result->bindWidget("menu", mainMenu_);
177 result->bindWidget("contents", contents);
178 result->bindWidget("sidebar", sideBarContent_);
179}
DeferredWidget< Function > * deferCreate(Function f)
Definition Home.h:62
WWidget * otherLanguage()
Definition Home.C:305
WWidget * features()
Definition Home.C:293
WWidget * download()
Definition Home.C:398
void googleAnalyticsLogger()
Definition Home.C:426
WWidget * introduction()
Definition Home.C:253
WWidget * community()
Definition Home.C:320
WWidget * documentation()
Definition Home.C:298
WWidget * wrapView(WWidget *(Home::*createFunction)())
Definition Home.C:310
void updateTitle()
Definition Home.C:235
virtual WWidget * examples()=0
WMenu * mainMenu_
Definition Home.h:116
WContainerWidget * sideBarContent_
Definition Home.h:131
friend friend class WContainerWidget
WContainerWidget * root() const
friend friend class WMenu
virtual void setPathComponent(const std::string &path)
WMenuItem * addItem(const WString &label, WWidget *contents=0, WMenuItem::LoadPolicy policy=WMenuItem::LazyLoading)
Signal< WMenuItem * > & itemSelected()
Signal< WMenuItem * > & itemSelectRendered()
void setInternalPathEnabled(const std::string &basePath="")
void setTransitionAnimation(const WAnimation &animation, bool autoReverse=false)
static WString fromUTF8(const std::string &value, bool checkValid=false)
virtual void bindWidget(const std::string &varName, WWidget *widget)
virtual void setId(const std::string &id)
Vertical
std::string longDescription_
Definition Home.h:33

◆ createQuoteForm()

virtual WWidget * Home::createQuoteForm ( )
protectedpure virtual

Implemented in JWtHome, and WtHome.

◆ documentation()

WWidget * Home::documentation ( )
private

Definition at line 298 of file Home.C.

299{
300 WText *result = new WText(tr("home.documentation"));
301 result->setInternalPathEncoding(true);
302 return result;
303}
void setInternalPathEncoding(bool enabled)

◆ download()

WWidget * Home::download ( )
private

Definition at line 398 of file Home.C.

399{
400 WContainerWidget *result = new WContainerWidget();
401 result->addWidget(new WText(tr("home.download")));
402
403 result->addWidget(new WText(tr("home.download.license")));
404
405#ifdef WT_EMWEB_BUILD
406 result->addWidget(quoteForm());
407#endif // WT_EMWEB_BUILD
408
409 result->addWidget(new WText(tr("home.download.packages")));
410
411 releases_ = new WTable();
413 result->addWidget(releases_);
414
415 result->addWidget(new WText(tr("home.download.other")));
416
417 return result;
418}
void readReleases(WTable *releaseTable)
Definition Home.C:325
WWidget * quoteForm()
virtual void addWidget(WWidget *widget)

◆ examples()

virtual WWidget * Home::examples ( )
protectedpure virtual

Implemented in JWtHome, and WtHome.

◆ features()

WWidget * Home::features ( )
private

Definition at line 293 of file Home.C.

294{
295 return new WText(tr("home.features"));
296}

◆ filePrefix()

virtual std::string Home::filePrefix ( ) const
protectedpure virtual

Implemented in JWtHome, and WtHome.

◆ googleAnalyticsLogger()

void Home::googleAnalyticsLogger ( )

Definition at line 426 of file Home.C.

427{
428 doJavaScript("if (window.ga) ga('send','pageview',"
429 + WWebWidget::jsStringLiteral(environment().deploymentPath()
430 + internalPath()) + ");");
431}
void doJavaScript(const std::string &javascript, bool afterLoaded=true)
std::string internalPath() const
const WEnvironment & environment() const
static std::string jsStringLiteral(const std::string &v, char delimiter='\'')

◆ href()

std::string Home::href ( const std::string &  url,
const std::string &  description 
)
protected

Definition at line 315 of file Home.C.

316{
317 return "<a href=\"" + url + "\" target=\"_blank\">" + description + "</a>";
318}
std::string url(const std::string &internalPath=std::string()) const

◆ init()

void Home::init ( )
protected

Definition at line 62 of file Home.C.

63{
67
68 setup();
69
71}
void setup()
Definition Home.C:73
void logInternalPath(const std::string &path)
Definition Home.C:242
void setLanguageFromPath()
Definition Home.C:213
virtual Wt::Signals::connection connect(WObject *target, WObject::Method method)
Signal< std::string > & internalPathChanged()

◆ introduction()

WWidget * Home::introduction ( )
private

Definition at line 253 of file Home.C.

254{
255 return new WText(tr("home.intro"));
256}

◆ linkSourceBrowser()

WWidget * Home::linkSourceBrowser ( const std::string &  examplePath)
protected

Definition at line 200 of file Home.C.

201{
202 /*
203 * Instead of using a WAnchor, which will not progress properly because
204 * it is wrapped with wrapView() (-- should we not fix that?), we use
205 * a WText which contains an anchor, and enable internal path encoding.
206 */
207 std::string path = "#/" + SRC_INTERNAL_PATH + "/" + example;
208 WText *a = new WText(tr("source-browser-link").arg(path));
210 return a;
211}
static const std::string SRC_INTERNAL_PATH
Definition Home.C:32

◆ logInternalPath()

void Home::logInternalPath ( const std::string &  path)
private

Definition at line 242 of file Home.C.

243{
244 // simulate an access log for the interal paths
245 log("path") << path;
246
247 // If this goes to /src, we need to invoke google analytics method too
248 if (path.size() >= 4 && path.substr(0, 4) == "/src") {
250 }
251}
WLogEntry log(const std::string &type) const

◆ otherLanguage()

WWidget * Home::otherLanguage ( )
private

Definition at line 305 of file Home.C.

306{
307 return new WText(tr("home.other-language"));
308}

◆ quoteForm()

WWidget * Home::quoteForm ( )
private

◆ readNews()

void Home::readNews ( WTable newsTable,
const std::string &  newsfile 
)
private

◆ readReleases()

void Home::readReleases ( WTable releaseTable)
protected

Definition at line 325 of file Home.C.

326{
327 std::ifstream f((filePrefix() + "releases.txt").c_str());
328
329 releaseTable->clear();
330
331 releaseTable->elementAt(0, 0)
332 ->addWidget(new WText(tr("home.download.version")));
333 releaseTable->elementAt(0, 1)
334 ->addWidget(new WText(tr("home.download.date")));
335 releaseTable->elementAt(0, 2)
336 ->addWidget(new WText(tr("home.download.description")));
337
338 releaseTable->elementAt(0, 0)->resize(WLength(15, WLength::FontEx),
340 releaseTable->elementAt(0, 1)->resize(WLength(15, WLength::FontEx),
342
343 int row = 1;
344
345 while (f) {
346 std::string line;
347 getline(f, line);
348
349 if (f) {
350 typedef boost::tokenizer<boost::escaped_list_separator<char> >
351 CsvTokenizer;
352 CsvTokenizer tok(line);
353
354 CsvTokenizer::iterator i=tok.begin();
355
356 std::string fileName = *i;
357 std::string description = *(++i);
358 releaseTable->elementAt(row, 1)->addWidget(new WText(*(++i)));
359 releaseTable->elementAt(row, 2)->addWidget(new WText(*(++i)));
360
361 ++i;
362 std::string url = "http://prdownloads.sourceforge.net/witty/"
363 + fileName + "?download";
364 if (i != tok.end())
365 url = *i;
366
367 releaseTable->elementAt(row, 0)->addWidget
368 (new WText(href(url, description)));
369
370 ++row;
371 }
372 }
373}
std::string href(const std::string &url, const std::string &description)
Definition Home.C:315
virtual std::string filePrefix() const =0
static WLength Auto
virtual void clear()
WTableCell * elementAt(int row, int column)
virtual void resize(const WLength &width, const WLength &height)

◆ setLanguage()

void Home::setLanguage ( int  language)
private

Definition at line 181 of file Home.C.

182{
183 if (homePage_) {
184 const Lang& l = languages[index];
185
186 setLocale(l.code_);
187
188 std::string langPath = l.path_;
190 examplesMenu_->setInternalBasePath(langPath + "examples");
191 BlogView *blog = dynamic_cast<BlogView *>(findWidget("blog"));
192 if (blog)
193 blog->setInternalBasePath(langPath + "blog/");
194 updateTitle();
195
196 language_ = index;
197 }
198}
WTabWidget * examplesMenu_
Definition Home.h:89
WWidget * findWidget(const std::string &name)
void setInternalBasePath(const std::string &basePath)
void setInternalBasePath(const std::string &path)
std::string code_
Definition Home.h:33

◆ setLanguageFromPath()

void Home::setLanguageFromPath ( )
private

Definition at line 213 of file Home.C.

214{
215 std::string langPath = internalPathNextPart("/");
216
217 if (langPath.empty())
218 langPath = '/';
219 else
220 langPath = '/' + langPath + '/';
221
222 int newLanguage = 0;
223
224 for (unsigned i = 0; i < languages.size(); ++i) {
225 if (languages[i].path_ == langPath) {
226 newLanguage = i;
227 break;
228 }
229 }
230
231 if (newLanguage != language_)
232 setLanguage(newLanguage);
233}
void setLanguage(int language)
Definition Home.C:181
std::string internalPathNextPart(const std::string &path) const

◆ setup()

void Home::setup ( )
private

Definition at line 73 of file Home.C.

74{
75 /*
76 * This function switches between the two major components of the homepage,
77 * depending on the internal path:
78 * /src -> source viewer
79 * /... -> homepage
80 *
81 * FIXME: we should take into account language /cn/src ...
82 */
83 std::string base = internalPathNextPart("/");
84
85 if (base == SRC_INTERNAL_PATH) {
86 if (!sourceViewer_) {
87 delete homePage_;
88 homePage_ = 0;
89
90 root()->clear();
91
93 WVBoxLayout *layout = new WVBoxLayout();
94 layout->setContentsMargins(0, 0, 0, 0);
95 layout->addWidget(sourceViewer_);
96 root()->setLayout(layout);
97 }
98 } else {
99 if (!homePage_) {
100 delete sourceViewer_;
101 sourceViewer_ = 0;
102
103 root()->clear();
104
105 createHome();
107
109 }
110 }
111}
void createHome()
Definition Home.C:113
virtual WWidget * sourceViewer(const std::string &deployPath)=0
void addWidget(WWidget *widget, int stretch=0, WFlags< AlignmentFlag > alignment=0)
void setLayout(WLayout *layout)
virtual void clear()
void setContentsMargins(int left, int top, int right, int bottom)

◆ sourceViewer()

virtual WWidget * Home::sourceViewer ( const std::string &  deployPath)
protectedpure virtual

Implemented in JWtHome, and WtHome.

◆ status()

WWidget * Home::status ( )
private

Definition at line 288 of file Home.C.

289{
290 return new WText(tr("home.status"));
291}

◆ tr()

WString Home::tr ( const char *  key)
protected

Definition at line 421 of file Home.C.

422{
423 return WString::tr(key);
424}
static WString tr(const char *key)

◆ updateTitle()

void Home::updateTitle ( )
private

Definition at line 235 of file Home.C.

236{
237 if (mainMenu_->currentItem()) {
238 setTitle(tr("wt") + " - " + mainMenu_->currentItem()->text());
239 }
240}
const WString & text() const
WMenuItem * currentItem() const

◆ wrapView()

WWidget * Home::wrapView ( WWidget *(Home::*)()  createFunction)
private

Definition at line 310 of file Home.C.

311{
312 return makeStaticModel(boost::bind(createWidget, this));
313}
WApplication * createWidget(const WEnvironment &env, SimpleChatServer &server)
Definition simpleChat.C:145

Member Data Documentation

◆ blogDb_

Wt::Dbo::SqlConnectionPool& Home::blogDb_
private

Definition at line 98 of file Home.h.

◆ contents_

WStackedWidget* Home::contents_
private

Definition at line 102 of file Home.h.

◆ examplesMenu_

WTabWidget* Home::examplesMenu_
protected

Definition at line 89 of file Home.h.

◆ homePage_

WWidget* Home::homePage_
private

Definition at line 99 of file Home.h.

◆ language_

int Home::language_
private

Definition at line 118 of file Home.h.

◆ languages

std::vector<Lang> Home::languages
private

Definition at line 133 of file Home.h.

◆ mainMenu_

WMenu* Home::mainMenu_
private

Definition at line 116 of file Home.h.

◆ releases_

WTable* Home::releases_
protected

Definition at line 94 of file Home.h.

◆ sideBarContent_

WContainerWidget* Home::sideBarContent_
private

Definition at line 131 of file Home.h.

◆ sourceViewer_

WWidget* Home::sourceViewer_
private

Definition at line 100 of file Home.h.


The documentation for this class was generated from the following files:

Generated on Fri May 17 2024 for the C++ Web Toolkit (Wt) by doxygen 1.9.8