Main Page | Namespace List | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals

NHTMLWriter.cp

Go to the documentation of this file.
00001 00023 00024 #define MW_CGI monsterworks::cgi 00025 00026 #include <NHTMLWriter.h> 00027 using MW_CGI::NHTMLWriter; 00028 using std::string; 00029 00030 namespace { 00031 const std::string ourServer = "www.monsterworks.com"; 00032 const std::string ourRealServer = "pc75666.math.cwu.edu"; 00033 const std::string ourEmail = "eeyore@monsterworks.com"; 00034 const std::string ourImageDir = "/~montgomery/"; 00035 const std::string ourPowerImage = "monsterpower.gif"; 00036 const std::string ourHostImage = "monsterhost.gif"; 00037 } 00038 00042 std::string MW_CGI::NHTMLWriter::HTTPHeader( 00043 const std::string& inType, 00044 const std::string& inOtherData) 00045 00046 00047 { 00048 string theResult ("Content-type: "); 00049 theResult += inType; 00050 theResult += "\r\n"; 00051 theResult += inOtherData; 00052 theResult += "\r\n"; 00053 return theResult; 00054 } 00055 00056 00060 std::string MW_CGI::NHTMLWriter::HTMLHeader( 00061 const std::string& inTitle, 00062 const std::string& inOtherData, 00063 const std::string& inBodyTags) 00064 { 00065 string theResult (HTTPHeader("text/html")); 00066 theResult += "<html><head>\r\n" 00067 "<title>"; 00068 theResult += inTitle; 00069 theResult += "</title>\r\n" 00070 "<meta generator='Monsterworks CGI'>\r\n"; 00071 theResult += inOtherData; 00072 theResult += "</head><body"; 00073 theResult += inBodyTags; 00074 theResult += ">\r\n"; 00075 return theResult; 00076 } 00077 00081 std::string MW_CGI::NHTMLWriter::HTMLFooter() 00082 { 00083 return ("</body></html>\r\n"); 00084 } 00085 00086 /* 00087 @returns the footer as a string 00088 */ 00089 string MW_CGI::NHTMLWriter::MonsterworksFooter( 00090 const std::string& inContact) 00091 { 00092 string theReply = ""; 00093 theReply += "<hr>\r\n"; 00094 theReply += "<a href='http://" + ourServer + "'>"; 00095 theReply += "<img src='http://" + ourRealServer + ourImageDir + ourPowerImage + "' align='left' height='78' width='60' border='0'></a>\r\n"; 00096 if (inContact != "") 00097 { 00098 theReply += "<br>For more information about this page, contact: " + inContact + "\r\n"; 00099 } 00100 00101 theReply += "<br>For more information about Monsterworks contact: <a href='mailto:" + ourEmail + "'>" + ourEmail + "</a>\r\n"; 00102 theReply += NHTMLWriter::HTMLFooter(); 00103 00104 return theReply; 00105 } 00106 00111 std::string MW_CGI::NHTMLWriter::RedirectPage( 00112 const std::string& inLocation) 00113 { 00114 string theRedirect = ""; 00115 theRedirect += "<META Http-equiv='refresh' Content='0; Url=" + inLocation + "'>\r\n"; 00116 00117 string theResult = ""; 00118 theResult += HTMLHeader("Redirection Page", theRedirect); 00119 theResult += "<p>Link provided for older browsers:\r\n"; 00120 theResult += "<br><a href='" + inLocation + "'>" + inLocation + "</a>\r\n"; 00121 theResult += HTMLFooter(); 00122 return theResult; 00123 } 00124 00128 std::string MW_CGI::NHTMLWriter::ErrorPage( 00129 const std::string& inMessage, 00130 const std::string& inContact) 00131 { 00132 string theResult = NHTMLWriter::HTMLHeader("CGI Error"); 00133 theResult += "An Error Occurred while processing your request.\r\n"; 00134 00135 if (inMessage != "") 00136 { 00137 if (inContact != "") 00138 { 00139 theResult += "<br>Please provide " + inContact + " with the following information.\r\n"; 00140 } 00141 else 00142 { 00143 theResult += "<br>An uninformative error message is provided below.\r\n"; 00144 } 00145 theResult += "<br><center><font color=\"#FF0000\">" + inMessage + "</font></center>"; 00146 } 00147 00148 theResult += NHTMLWriter::MonsterworksFooter(inContact); 00149 00150 return theResult; 00151 }

monsterworks Code by Monsterworks. Made available under the GNU Public License.
Documentation by doxygen.