/Articles/Forth/PHP/GenerateHTML.cfg
6,7 → 6,6
// Source Files
$CFG["SourceDir"]="../../../../amforth/trunk/";
$CFG["SourceAsm"]="amforth.asm";
$CFG["SvnInfoFileName"]=".svn-info.txt";
 
// Template Files
$CFG["TemplateDir"]="../Templates/";
/Articles/Forth/PHP/GenerateHTML.php
165,7 → 165,6
print " EnableApache={0|1} - Enable to run in Apache\n";
print " SourceDir=path - path to asm source directory\n";
print " SourceAsm=file - name of top level asm source file\n";
print " SvnInfoFileName - name of Svn Info File\n";
print " TemplateDir=path - path to HTML template\n";
print " DestinationDir=path - path to destination HTML\n";
Error("\n");
175,11 → 174,12
function Parameters(&$CFG)
// Function process Command Line parameters
{
// Info
print "Parameters\n";
// Dummy values
$CFG["EnableApache"] = 0; // Do not allow run in Apache
$CFG["SourceDir"] = "";
$CFG["SourceAsm"] = "";
$CFG["SvnInfoFileName"] = "";
$CFG["TemplateDir"] = "";
$CFG["DestinationDir"] = "";
// Default values (in cfg file)
208,13 → 208,6
}
}
 
// Check if alowed to run in Apache
if ($_SERVER["argc"]==0 & ! $CFG["EnableApache"])
return "<b>This Script is configured so that it will not run in Apache.</b>";
 
// Info
print "Parameters\n";
 
// Correct paths and existence
foreach($CFG as $Key => $Value)
{
240,6 → 233,10
print " $Key=$Value\n";
print "\n";
 
// Check if alowed to run in Apache
if ($_SERVER["argc"]==0 & ! $CFG["Apache"])
return "This Script is configured so that it will not run in Apache.";
 
// No Error
return "";
}
431,7 → 428,7
}
 
 
function GenerateWordList($TemplateDir, $SvnInfoFileName, $DestinationDir, &$LabelList, &$WordList)
function GenerateWordList($TemplateDir, $DestinationDir, &$LabelList, &$WordList)
// Creates HTML pages with Word List
// Returns Error String
// IN $TemplateDir - template directory (file WordList.*.html)
452,34 → 449,6
if ($Error!="")
return $Error;
 
// Find <<SvnInfo>>
if (!preg_match("/( *)(<<SvnInfo>>)/i",$FileContent,$Matches))
{
unset($FileContent);
return "Missing <<SvnInfo>> in template file";
}
$Indent=$Matches[1];
 
// Read Svn Info file
$Error=MyReadFileString($SvnInfoFileName, $SvnInfoFile);
if ($Error!="")
{
// We do not have Svn Info File
$SvnInfoFile="";
}
else
{
// We have Svn Info File
$SvnInfoFile=preg_replace("/^((?:URL|Repository|Last)[^:]*):(.*$)|^.*$/im","<tr><td>$1</td><td>$2</td></tr>",$SvnInfoFile);
$SvnInfoFile=preg_replace("~<tr><td></td><td></td></tr>\n~i","",$SvnInfoFile);
$SvnInfoFile="<tr><th colspan=\"2\">Subversion Info</th></tr>".$SvnInfoFile;
}
 
// Put Svn Info into HTML template
$FileContent=str_ireplace("<<SvnInfo>>", $SvnInfoFile, $FileContent);
#print $FileContent;
 
 
// Find <<WordList>>
if (!preg_match("/( *)(<<WordList>>)/i",$FileContent,$Matches))
{
518,8 → 487,7
// Indent and Concatenate lines
foreach($WordListHTML as $Key => $Value)
{
if ($Key>0)
$WordListHTML[$Key]=$Indent.preg_replace("/\n/","<br>",$Value);
$WordListHTML[$Key]=$Indent.preg_replace("/\n/","<br>",$Value);
}
$WordListHTML=implode("\n",$WordListHTML);
618,11 → 586,7
Error(CreateWordList($CFG["SourceDir"], $LabelList, $WordList));
 
// Create HTML WordList
Error(GenerateWordList(
$CFG["TemplateDir"],
$CFG["SourceDir"].$CFG["SvnInfoFileName"],
$CFG["DestinationDir"],
$LabelList, $WordList));
Error(GenerateWordList($CFG["TemplateDir"], $CFG["DestinationDir"], $LabelList, $WordList));
 
// Copy ASM files and convert them into HTML
Error(GenerateAsmFiles($CFG["TemplateDir"], $CFG["SourceDir"], $SourceAsmFiles, $CFG["DestinationDir"]));
631,8 → 595,7
print "O.K.\n";
return
 
// Zpracování readme autora
// Vyplatilo by se udělat samostatny formatovaci a nahrazovaci mechanizmus
// Zpracování readme autora + verze
// Zpracování templejtů do samostatného podprogramu (vyřešit indent...)
// tím se vyřeší i en/cs verze Asm souboru
// Generovat log do souboru místo printu (zvážit) oddělit chyby a varování
/Articles/Forth/PHP/amforth
100,7 → 100,6
EnableApache="0" \
SourceDir="$WorkingDir/source-exported/" \
SourceAsm="amforth.asm" \
SvnInfoFile="$SvnInfoFile" \
TemplateDir="$WebForthInPath/Templates/" \
DestinationDir="$WebForthOutPath/HTML/" \
> $LogFileGenerate 2>> $LogFile