OmEspHelpers
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
OmWebPages Class Reference

A class that routes and serves web pages, and manages control values, typically works with OmWebServer for the network interface. More...

#include <OmWebPages.h>

Public Member Functions

 OmWebPages ()
 
void setBuildDateAndTime (const char *date, const char *time, const char *file=NULL)
 say p.setBuildDateAndTime(DATE, TIME) so the info web page can display it.
 
void beginPage (const char *pageName)
 Start defining a new page. Subsequent calls like addButton() affect this page. If a page of this name already exists, it is reset to empty. You can rebuild the page from scratch, if for example the set of controls needs to change.
 
void addPageLink (const char *pageLink, OmWebActionProc proc=NULL, int ref1=0, void *ref2=0)
 Add a link on the current page that goes to another page. Also can call an action proc.
 
OmWebPageItemaddButton (const char *buttonName, OmWebActionProc proc=NULL, int ref1=0, void *ref2=0)
 Add a button on the current page. Calls the action proc with value 1 for press, 0 for release.
 
OmWebPageItemaddButtonWithLink (const char *buttonName, const char *url, OmWebActionProc proc=NULL, int ref1=0, void *ref2=0)
 Add a button on the current page, which fires a page redirect after the button-up. The OmWebActionProc would often be NULL here, if the button's main purpose is to go to another web page.
 
OmWebPageItemaddSlider (const char *sliderName, OmWebActionProc proc=NULL, int value=0, int ref1=0, void *ref2=0)
 Add a slider control on the current page. The range is 0 to 100, and calls your param proc when changed.
 
OmWebPageItemaddSlider (int rangeLow, int rangeHigh, const char *sliderName, OmWebActionProc proc=NULL, int value=0, int ref1=0, void *ref2=0)
 Add a slider control on the current page, with a specific range.
 
OmWebPageItemaddTime (const char *itemName, OmWebActionProc proc=NULL, int value=0, int ref1=0, void *ref2=0)
 Add a time-input.
 
OmWebPageItemaddColor (const char *itemName, OmWebActionProc proc=NULL, int value=0, int ref1=0, void *ref2=0)
 Add a color-input, int value is 0xRRGGBB.
 
OmWebPageItemaddSelect (const char *itemName, OmWebActionProc proc=NULL, int value=0, int ref1=0, void *ref2=0)
 Begin a menu select control. Choices are added with addSelectOption()
 
void addSelectOption (const char *optionName, int optionValue)
 Add one selectable item, and its integer value if selected.
 
OmWebPageItemaddCheckbox (const char *itemName, const char *checkboxName, OmWebActionProc proc=NULL, int value=0, int ref1=0, void *ref2=0)
 Add a single checkbox. If checkboxName is NULL, then the first checkbox will be added by addCheckboxX The int value of the control is binary, where the nth checkbox adds 2^(n-1) to the value.
 
void addCheckboxX (const char *checkboxName, int value=0)
 Add additional checkboxes.
 
void addHtml (HtmlProc proc, int ref1=0, void *ref2=0)
 Add a block of custom dynamic HTML to the page. Your proc is called each time the page is requested.
 
void addStaticHtml (String staticHtml)
 Add a string of static prebuilt HTML. Included in web page unchecked, you're on your own!
 
void allowHeader (bool allowHeader)
 By default, any header proc is used on every page. Disable for current page here.
 
void allowFooter (bool allowFooter)
 By default, any footer proc is used on every page. Disable for current page here.
 
void addUrlHandler (const char *path, OmUrlHandlerProc proc, int ref1=0, void *ref2=0)
 Add an arbitrary URL handler.
 
void addUrlHandler (OmUrlHandlerProc proc, int ref1=0, void *ref2=0)
 Add a wildcard url handler, if no page or specific handler gets it.
 
bool handleRequest (OmIByteStream *consumer, const char *pathAndQuery, OmRequestInfo *requestInfo)
 Explicitly process a request. (Not typically used.) If you used omWebServer.setHandler(omWebPages), then this is called by the web server on your behalf. In other scenarios you can call it directly with the output buffer and request. The request is the part of the URI after the host name, like "/somepage" or "/info?arg=value". now with streamed variation overloaded on top.
 
void renderPageButton (OmXmlWriter &w, const char *pageName)
 Within an HtmlProc: Adds a floating link-button to another page.
 
void setHeaderProc (HtmlProc headerProc)
 Override the default header html.
 
void setFooterProc (HtmlProc footerProc)
 Override the default footer html.
 
void setBgColor (int bgColor)
 set the background color for next web request, 0xRRGGBB
 
void renderInfo (OmXmlWriter &w)
 
void renderStatusXml (OmXmlWriter &w)
 
void renderHttpResponseHeader (const char *contentType, int response)
 in a OmUrlHandlerProc, set the mimetype (like "text/plain") and response code (200 is OK)
 
void renderDefaultFooter (OmXmlWriter &w)
 
void setValue (const char *pageName, const char *itemName, int value)
 
int getValue (const char *pageName, const char *itemName)
 

Static Public Member Functions

static void renderPageBeginning (OmXmlWriter &w, const char *pageTitle="", int bgColor=0xffffff)
 in a OmUrlHandlerProc Render the beginning of the page, leaving <body> element open and ready. More...
 
static void renderPageBeginningWithRedirect (OmXmlWriter &w, const char *redirectUrl, int redirectSeconds, const char *pageTitle="", int bgColor=0xffffff)
 

Public Attributes

unsigned int requestsAll = 0
 
unsigned int requestsParam = 0
 
unsigned int greatestRenderLength = 0
 
char httpBase [32]
 
OmRequestInfori = 0
 

Detailed Description

A class that routes and serves web pages, and manages control values, typically works with OmWebServer for the network interface.

Constructor & Destructor Documentation

◆ OmWebPages()

OmWebPages::OmWebPages ( )

No argument constructor

Member Function Documentation

◆ renderPageBeginning()

void OmWebPages::renderPageBeginning ( OmXmlWriter w,
const char *  pageTitle = "",
int  bgColor = 0xffffff 
)
static

in a OmUrlHandlerProc Render the beginning of the page, leaving <body> element open and ready.

Render the beginning of the page, leaving <body> element open and ready.

Member Data Documentation

◆ greatestRenderLength

unsigned int OmWebPages::greatestRenderLength = 0

Maximum size of pages served

◆ requestsAll

unsigned int OmWebPages::requestsAll = 0

Total number of requests served

◆ requestsParam

unsigned int OmWebPages::requestsParam = 0

Total number of parameter-change requests served


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