Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
WebBrowser automation
Message
From
18/11/2010 16:32:12
 
 
To
18/11/2010 04:20:11
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Miscellaneous
Thread ID:
01489079
Message ID:
01489677
Views:
74
>>>BTW, the whole site works on Fox generated pages ftp'd using Chilkat COM object. It's all static, but as dynamic as static gets.
>>
>>Dragan
>>
>>I had thought of doing something similar. I'd be interested to know how you generate the pages in Fox.
>
>I guess 200 lines of code won't be too much for a message...
>
>
* normal.h
>#define cr chr(13)
>#define lf chr(10)
>#define ff chr(12)
>#define crlf cr+lf
>#define c_tab chr(9)
>#define c_quote ["]
>#define c_apo	[']
>#define c_tz	[;]
>#define c_bslash	[\]
>#define c_delim " -.,()$!?#/&\|[]@{}"+c_quote+c_apo
>#define c_prazna ""
>
>
>* dcHtml.prg
>#include normal.h
>
>
>define class cHtml as custom
>	nPretextLevel=0
>	cCellClass=""
>	cRowClass=""
>	cTableClass=""
>	cTitle=""
>	cCSS=""
>	descr=""
>	keywords="VFP, Visual, FoxPro, Visual FoxPro"
>	language="en-us"
>	cPreFooter=""
>	ccrlf=chr(13)+chr(10)
>
>*******************************
>	procedure destroy()
>		_pretext=""
>	endproc
>
>*******************************
>	procedure IncPretext()
>		this.nPretextLevel = this.nPretextLevel + 1
>		_pretext=replicate(c_tab, this.nPretextLevel)
>	endproc
>*******************************
>	procedure DecPretext()
>		this.nPretextLevel = max(this.nPretextLevel - 1, 0)
>		_pretext=replicate(c_tab, this.nPretextLevel)
>	endproc
>
>
>*******************************
>	procedure MakeCell(c, cAttrib)
>		local cClass
>		if empty(c)
>			c=" "
>		endif
>		this.IncPretext()
>		cClass=iif(empty(this.cCellClass)," ",[ class="]+this.cCellClass+[" ])
>		cClass = cClass + iif(empty(cAttrib), "", cAttrib)
>		c="<td"+cClass+">"+this.ccrlf+;
>			this.indent(c)+ this.ccrlf+;
>			"</td>"
>		this.DecPretext()
>		return c
>*******************************
>	procedure MakeHeaderCell(c, cAttrib)
>		local cClass
>		if empty(c)
>			c="&nbsp;"
>		endif
>		this.IncPretext()
>		cClass=iif(empty(this.cCellClass)," ",[ class="]+this.cCellClass+[" ])
>		cClass = cClass + iif(empty(cAttrib), "", cAttrib)
>		c=_pretext+"<th"+cClass+">"+this.ccrlf+;
>			this.indent(c)+ this.ccrlf+;
>			"</th>"
>		this.DecPretext()
>		return c
>*******************************
>	procedure MakeRow(c, cAttrib)
>		local c, cClass
>		this.IncPretext()
>		cClass=iif(empty(this.cRowClass)," ",[ class="]+this.cRowClass+[" ])
>		cClass = cClass + iif(empty(cAttrib), "", cAttrib)
>		c=_pretext+"<tr"+cClass+">"+this.ccrlf+;
>			this.indent(c)+ this.ccrlf+;
>			"</tr>"
>		this.DecPretext()
>		return c
>*******************************
>	procedure MakeTable(c, cAttrib)
>		local c, cClass
>		this.IncPretext()
>		cClass=iif(empty(this.cTableClass)," ",[ class="]+this.cTableClass+[" ])
>		cClass = cClass + iif(empty(cAttrib), "", cAttrib)
>		c=crlf+_pretext+"<table"+cClass+">"+crlf+;
>			this.indent(c)+ crlf+;
>			"</table>"
>		this.DecPretext()
>		return c
>*******************************
>	procedure PageHeader
>		local c, cS
>		if empty(this.cCSS)
>			cS=""
>		else
>			cS=crlf+c_tab+[<link rel="stylesheet" href="]+this.cCSS+[" type="text/css">]
>		endif
>		this.descr=iif(empty(this.descr), this.cTitle, this.descr)
>*-- TEXT BLOCK BEGIN
>		text TO c NOSHOW TEXTMERGE
><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
>   "http://www.w3.org/TR/html4/loose.dtd">
> <HTML>
><HEAD>
>	<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=windows-1250">
>	<META NAME="Author" CONTENT="Dragan Nedeljković, ndragan@ndragan.com">
>	<META NAME="GENERATOR" CONTENT="<<sys(16,1)>>, <<ttoc(datetime())>>">
>	<meta name="keywords" content="<<this.keywords>>">
>	<meta name="revisit-after" content="15 days">
>	<meta name="robots" content="index,follow">
>	<meta name="language" content="<<this.language>>">
>	<meta name="rating" content="General">
>	<meta name="resource-type" content="document">
>	<meta name="distribution" content="Global">
>	<meta name="copyright" content="Copyright <<Year(Date())>> Dragan Nedeljkovich">
>	<META NAME="Description" CONTENT="<<this.descr>>">
>	<TITLE><<this.cTitle>></TITLE><<cS>>
></HEAD>
><BODY >
>
>		ENDTEXT
>*-- TEXT BLOCK END
>
>		return c
>	endproc
>*******************************
>	procedure PageFooter
>		local c
>		c=crlf+this.cPreFooter+crlf+"</BODY>"+crlf+"</HTML>"
>		return c
>	endproc
>
>*******************************
>	procedure MakeComment(cComm)
>		local c
>		c=crlf+_pretext+"<!-- "+cComm+" -->"
>		return c
>	endproc
>*******************************
>	procedure indent(c)
>		local a[1], n, i
>		n=alines(a,c)
>		c=""
>		for i=1 to n
>			c = c + c_tab+a[i]+crlf
>		endfor
>		return c
>	endproc
>
>*********************
>	procedure ReColor(tnColor, tnFactor)
>* return the html string for the color multiplied by the factor
>		local r,g,b, lcColor, lnNewColor
>		store 0 to r,g,b
>		if vartype(tnColor)="C"
>			tnColor=evaluate("0x"+tnColor)
>		endif
>		rgbcomp(tnColor, @r, @g, @b)
>		lnNewColor=rgb(r*tnFactor,g*tnFactor,b*tnFactor)
>		lcColor="#"+right(transform(lnNewColor, "@0"),6)
>		return lcColor
>	endproc
>
>
>*******************************
>	procedure wraptag(c, cTag)
>		c="<"+cTag+">"+c+"</"+getwordnum(cTag,1)+">"
>		return c
>	endproc
>
>*******************************
>	procedure AddKeyword(cKW)
>		this.keywords = this.keywords + ", "+cKW
>	endproc
>
>*******************************
>	procedure ResetKeywords()
>		this.keywords="VFP, Visual, FoxPro, Visual FoxPro"
>	endproc
>
>*******************************
>*[2006/12/21 18:24:28] dragan - load template and replace all properties in comments
>*-- with their values
>	procedure LoadTemplate(oP, tcTemplate)
>		#define lGR "<!--"
>		#define dGR	"-->"
>		#define lTemp "#1#"
>		#define dTemp "#2#"
>*-- if it contains the delimiter, it's a template, else it's a filename of one
>		if not lGR$tcTemplate
>			c=filetostr(tcTemplate)
>		else
>			c=tcTemplate
>		endif
>		n=occurs(lGR, c)
>		for i=1 to n
>			lcChop=strextract(c, lGR, dGR,1,1+4)
>			lcToRepl=strextract(lcChop, lGR, dGR)
>			do case
>				case 	inlist(lcToRepl, space(1), chr(9))
>*-- do nothing, this is a comment
>					lcRepl=lTemp+lcToRepl+dTemp
>				case type(lcToRepl)#"U"
>*-- it's an expression
>					lcRepl=transform(evaluate(lcToRepl))
>				case pemstatus(oP,lcToRepl,5)
>*-- it's a property of the parameter object
>					lcRepl=transform(getpem(oP,lcToRepl))
>				otherwise
>					lcRepl=lTemp+lcToRepl+dTemp
>			endcase
>			if lcRepl#lcChop
>				c=strtran(c, lcChop, lcRepl)
>			endif
>		endfor
>*-- we kept this one just to keep the number of occurrences constant, now it can go.
>*	c=Strtran(c, lGR+" OK "+dGR, "")
>		c=strtran(c, lTemp, lGR)
>		c=strtran(c, dTemp, dGR)
>		return c
>enddefine
>
>
>Then any generator has its own instance of this class, fills in the properties, provides a template, calls the code to get html text, strtofile()s it and then ftps it to the site. And it's blazingly fast.

Dragan

Excellent!
I'll work thru it.

Many thanks
Cyril
Previous
Reply
Map
View

Click here to load this message in the networking platform