|
| Basic Webpage Generator by Bipul | #include<iostream.h>
#include<fstream.h>
#include<string.h>
#include<stdio.h>
#define DEFAULTDIR "//HTMLS//"
#define DEFAULTFILENAME "HTML001.html"
#define DEFAULTSIZ 4
#define DEFAULTFONT "Times New Roman"
#define DEFAULTBGCOL "#aa5533"
#define DEFAULTTITLE "A Simple HTML Page"
#define DEFAULTHEADING "It Starts With One"
#define DEFAULTTXT "Hello World... This works!"
#define SIGN "<FONT size=2>Automatic simple HTML Generation ver 0.001(by i,bipul on 27 March,09)<BR> This thing was written compiled etc etc on UBUNTU 8.04 linux in g++, later ported"
class webpage
{
private: char WebpName[80],WebpTitle[80],WebpHeading[80],WebpFontsty[80],WebpTxt[2000],WebpBG[10];
int WebpFontsiz;
public: webpage()
{
//strcpy(WebpName,DEFAULTDIR);
strcpy(WebpName,DEFAULTFILENAME);
strcpy(WebpTitle,DEFAULTTITLE);
strcpy(WebpHeading,DEFAULTHEADING);
strcpy(WebpFontsty,DEFAULTFONT);
WebpFontsiz=DEFAULTSIZ;
strcpy(WebpTxt,DEFAULTTXT);
strcpy(WebpBG,DEFAULTBGCOL);
}
void getpagename();
void getpagetitle();
void getpageheading();
void gettxt();
//------- Now we create the HTML File -----------//
void setupinfo();
void create();
};
void webpage::getpagename()
{ //char string[80];
cout<<"\n Please Enter the filename for your HTML file with a .html extension :: \n";gets(WebpName);
//strcpy(WebpName,DEFAULTDIR);
//strcat(WebpName,string);
}
void webpage::getpagetitle()
{ cout<<"\n Please Enter a short text that you want on the title bar :: \n";gets(WebpTitle);
}
void webpage::getpageheading()
{ cout<<"\n Enter The Content Heading of your Html page ::\n" ;gets(WebpHeading);
}
void webpage::gettxt()
{ cout<<"\n Now,Enter the Text you would like to see as conent::";
cout<<"\n (Hit (enter) when you want to escape.Line breaks will be automatic.\n";
cout<<"\n but if you want to force a new line write <BR> at that poition in text.)\n Enter now :: \n";
gets(WebpTxt);
}
void webpage::setupinfo()
{ char color[10],ch;
//strcpy(color,DEFAULTBGCOLOR);
getpagename();
getpagetitle();
getpageheading();
gettxt();
cout<<"\n If u want default background color press y else press n:: ";cin>>ch;
if(ch=='N'||ch=='n')
{ cout<<"\n enter the color in #xxyyzz form or in words like red,green,cyan etc. :: ";cin>>color;
strcpy(WebpBG,color);
}
else if(ch=='Y'||ch=='y')
{ strcpy(WebpBG,DEFAULTBGCOL);
}
else
{ cout<<"\n That was a wrong choice... so default is being used \n";
}
cout<<"\n\n Just wait for a few miliseconds as the page gets created...\n";
cout<<"\n ----------------------------------------------------------------->>";
}
void webpage::create()
{ //----------opening the HTML File---------------//
ofstream fout;
fout.open(WebpName,ios::out|ios::trunc);
fout<<"<HTML><HEAD><TITLE>"<<WebpTitle;
fout<<"</TITLE> <SCRIPT LANGUAGE=\"Javascript\">";
fout<<"alert(\" Hi This is an Automatically Generated HTML File!! (by bipul) \");";
fout<<"alert(\" This page is generated by asking a few console questions...no chance of GUI's in near future\");";
fout<<"alert(\" Boy this page also has Javascripts with it, bless the programmer atleast! \");</SCRIPT></HEAD>";
fout<<"<BODY BGCOLOR="<<WebpBG<<">";
fout<<"<FONT FACE="<<WebpFontsty<<" SIZE="<<WebpFontsiz<<">";
fout<<"<H1>"<<WebpHeading<<"</H1><HR><BR>";
fout<<WebpTxt;
fout<<"<BR><BR><BR><BR><HR> <I>"<<SIGN<<"</I></FONT></BODY></HTML>";
fout.close();
//--------HTML Script hadbeen generated----------------//
cout<<"\n Your file has been created,please open thefolder named HTML in the dir of the C++ file to find it.\n";
}
int main()
{
webpage X;
X.setupinfo();
X.create();
return 0;
} | Views 3
Rating 0
Language C++
Category Web Designing
Compiler Turbo C/C++
OS Windows
Last Modified 13th Apr 10 10:45:09 PM
|
|
|
|
|
|