ZealOS/src/Demo/ToHtmlToTXTDemo/HtmlGen.CC

136 lines
2.9 KiB
HolyC
Raw Normal View History

2020-02-15 20:01:48 +00:00
/* This converts $LK,"::/Demo/ToHtmlToTXTDemo/DemoInPage.DD"$ to
an html document named "OutPage.html".
Notice that an entry like $$TX,"GOOGLE",HTML="http://www.google.com"$$
will be converted to text in the html with an html link.
2021-07-02 09:24:53 +01:00
Terry cheated by hardcoding $LK,"www.templeos.org",A="FF:::/Demo/ToHtmlToTXTDemo/ToHtml.CC,www.templeos.org"$ as the website
2021-07-02 00:53:42 +01:00
for $LK,"ZealOS Links",A="MN:LK_FILE"$. Why don't you copy
2020-02-16 04:57:03 +00:00
$LK,"::/Demo/ToHtmlToTXTDemo/ToHtml.CC"$ to your /Home directory
2020-02-15 20:01:48 +00:00
and modify it? You are welcome to link to
http://www.templeos.org if you want file that come on the
2021-07-02 00:53:42 +01:00
ZealOS distribution.
2020-02-15 20:01:48 +00:00
2020-02-16 04:57:03 +00:00
You can pass html meta data as args to $LK,"ToHtml",A="FF:::/Demo/ToHtmlToTXTDemo/ToHtml.CC,ToHtml"$().
2020-02-15 20:01:48 +00:00
*/
Cd(__DIR__);;
#include "ToHtml"
2021-07-03 03:24:43 +01:00
//ToHtml("DemoInPage.DD", "~/DemoOutPage");
U0 DirIndex(U8 *dest_path, U8 *full_name)
{
U8 *index_path,
*index_path_out,
*index_exe;
CTask *index_task;
CDoc *index_doc;
index_path = MStrPrint("%s/index.DD", dest_path);
index_path_out = MStrPrint("%s/index.html", dest_path);
"%s\n", index_path;
index_exe = MStrPrint("#include \"C:/Demo/ToHtmlToTXTDemo/HtmlDirList\";;;"
"Cls;DirIndexList(\"%s\");View;\n", full_name);
PopUp(index_exe,, &index_task);
TaskWait(index_task);
index_doc = DocNew(index_path);
DocInsDoc(index_doc, index_task->put_doc);
DocWrite(index_doc);
DocDel(index_doc);
TaskWait(index_task);
Kill(index_task);
ToHtml(index_path, index_path_out);
Del(index_path);
Free(index_path);
Free(index_path_out);
Free(index_exe);
}
2021-07-03 03:24:43 +01:00
I64 Dir2Html(U8 *src_files_find_mask, U8 *dst_files_find_mask)
{
CDirEntry *tmpde1 = NULL, *tmpde2;
I64 res = 0;
2021-07-03 07:47:45 +01:00
U8 *dest_path,
*dest_file,
*dest_abs,
*src_abs,
dest_ext[STR_LEN];
2021-07-03 03:24:43 +01:00
2021-07-03 05:07:57 +01:00
tmpde1 = FilesFind(src_files_find_mask, FUF_RECURSE);
2021-07-03 07:47:45 +01:00
dest_abs = DirNameAbs(dst_files_find_mask);
src_abs = DirNameAbs(src_files_find_mask);
2021-07-03 03:24:43 +01:00
if (tmpde1)
{
while (tmpde1)
{
tmpde2 = tmpde1->next;
res++;
dest_file = StrNew(tmpde1->name);
2021-07-03 05:07:57 +01:00
FileExtRemove(dest_file, dest_ext);
2021-07-03 03:24:43 +01:00
2021-07-03 05:07:57 +01:00
"%s\n", tmpde1->full_name;
if (!(tmpde1->attr & RS_ATTR_DIR))
2021-07-03 03:24:43 +01:00
{
2021-07-03 05:07:57 +01:00
if (StrCompare(dest_ext, "BIN.C") &&
StrCompare(dest_ext, "BIN") &&
2021-07-03 07:47:45 +01:00
StrCompare(dest_ext, "ISO.C") &&
2021-07-03 05:07:57 +01:00
StrCompare(dest_ext, "html") &&
StrCompare(dest_ext, "DATA") &&
StrCompare(dest_ext, "MAP"))
{
dest_path = MStrPrint("%s/%s.%s.html", dest_abs, dest_file, dest_ext);
"%s\n\n", dest_path;
2021-07-03 05:07:57 +01:00
ToHtml(tmpde1->full_name, dest_path);
Free(dest_path);
2021-07-03 05:07:57 +01:00
}
2021-07-03 03:24:43 +01:00
}
2021-07-03 05:07:57 +01:00
else
2021-07-03 07:47:45 +01:00
{
dest_path = MStrPrint("%s/%s", dest_abs, dest_file);
DirIndex(dest_path, tmpde1->full_name);
2021-07-03 07:47:45 +01:00
if (StrCompare(tmpde1->full_name, dest_abs))
Dir2Html(tmpde1->full_name, dest_path);
Free(dest_path);
2021-07-03 07:47:45 +01:00
}
2021-07-03 03:24:43 +01:00
DirEntryDel(tmpde1);
tmpde1 = tmpde2;
Free(dest_file);
}
}
Free(dest_abs);
return res;
2021-07-03 05:07:57 +01:00
}
I64 HtmlGen()
{
DocMax;
DocMax;
DelTree("::/HTML/");
2021-07-03 07:47:45 +01:00
DirIndex("::/HTML/", "::/");
2021-07-03 07:47:45 +01:00
return Dir2Html("::/", "::/HTML/");
2021-07-03 03:24:43 +01:00
}