Download Home/TOS/TOSBlog.txt from hschumann2/TempleOS-Source-Code: direct link, hf CLI and curl.
- Browser
- Download file 4.33 kB
-
https://huggingface.co/datasets/hschumann2/TempleOS-Source-Code/resolve/main/Home/TOS/TOSBlog.txt
- Command line
-
hf download hf://datasets/hschumann2/TempleOS-Source-Code/Home/TOS/TOSBlog.txt
-
curl -L -o TOSBlog.txt https://huggingface.co/datasets/hschumann2/TempleOS-Source-Code/resolve/main/Home/TOS/TOSBlog.txt
4.33 kB
| #help_index "Misc/Blog" | |
| public Bool IsTOSBlog(U8 *filename) | |
| {//Is this in the TOSBlog dir? | |
| Bool res; | |
| U8 *st=DirNameAbs(filename),*home=DirNameAbs("~"); | |
| I64 l=StrLen(home); | |
| if (StrLen(st)>=l+12 && !StrNCmp(st+1,home+1,l-1) && | |
| st[l]=='/' && !StrNCmp(st+l+4,"/TOSBlog",8)) | |
| res=TRUE; | |
| else | |
| res=FALSE; | |
| Free(st); | |
| Free(home); | |
| return res; | |
| } | |
| public U8 *TOSBlogAbs(U8 *filename) | |
| {//Absolute filename, adjusted for moving TOSBlog. | |
| U8 *st=DirNameAbs(filename),*home=DirNameAbs("~"); | |
| I64 l=StrLen(home); | |
| if (IsTOSBlog(st)) { | |
| MemCpy(st+l+5,st+l+1,3); | |
| MemCpy(st+l+1,"Web",3); | |
| StrCpy(st+l+8,st+l+12); | |
| } | |
| Free(home); | |
| return st; | |
| } | |
| public U8 *BlogLocalDir(CDate cdt=0) | |
| {//MAlloc dirname of blog for date. | |
| static U8 dir[STR_LEN]; | |
| CDateStruct ds; | |
| if (!cdt) cdt=Now+local_time_offset; | |
| Date2Struct(&ds,cdt); | |
| StrPrint(dir,BLOG_LOCAL_SRC "/%d%Z",ds.year,ds.mon-1,"ST_MONTHS"); | |
| if (!FileFind(dir,,FUF_JUST_DIRS)) | |
| DirMk(dir); | |
| return dir; | |
| } | |
| public U8 *BlogLocalFile(CDate cdt=0) | |
| {//MAlloc filename of blog for date. | |
| static U8 file[STR_LEN]; | |
| CDateStruct ds; | |
| if (!cdt) cdt=Now+local_time_offset; | |
| Date2Struct(&ds,cdt); | |
| StrPrint(file,"%s/" INS_REG_PERSONAL_INITIALS "%02d%02d%02d.DD.Z", | |
| BlogLocalDir(cdt),ds.year%100,ds.mon,ds.day_of_mon); | |
| return file; | |
| } | |
| public U8 *BlogWebDir(CDate cdt=0) | |
| {//MAlloc D:/Wb/dirname of blog for date. | |
| static U8 dir[STR_LEN]; | |
| CDateStruct ds; | |
| if (!cdt) cdt=Now+local_time_offset; | |
| Date2Struct(&ds,cdt); | |
| StrPrint(dir,BLOG_WEB_DST "/%d%Z", | |
| ds.year,ds.mon-1,"ST_MONTHS"); | |
| return dir; | |
| } | |
| public U8 *BlogWebFile(CDate cdt=0) | |
| {//MAlloc D:/Wb/filename of blog for date. | |
| static U8 file[STR_LEN]; | |
| CDateStruct ds; | |
| if (!cdt) cdt=Now+local_time_offset; | |
| Date2Struct(&ds,cdt); | |
| StrPrint(file,"%s/" INS_REG_PERSONAL_INITIALS "%02d%02d%02d.DD.Z", | |
| BlogWebDir(cdt),ds.year%100,ds.mon,ds.day_of_mon); | |
| return file; | |
| } | |
| public U8 *FileNameNumNext(U8 *files_find_mask,U8 *fmt) | |
| {//Cnt files in a mask. Create next filename. | |
| CDirEntry *tmpde=FilesFind(files_find_mask); | |
| U8 *res=MStrPrint(fmt,FileCnt(tmpde)); | |
| DirTreeDel(tmpde); | |
| return res; | |
| } | |
| public U0 BlogDCImgWrite(CDC *dc,CDate cdt=0) | |
| {//Add dc to blog as BMP file. | |
| U8 file_mask[STR_LEN],file_name[STR_LEN],*st,*st2; | |
| if (!cdt) cdt=Now+local_time_offset; | |
| StrPrint(file_mask,"%s/Img*",BlogLocalDir(cdt)); | |
| StrPrint(file_name,"%s/Img%%03d.BMP",BlogLocalDir(cdt)); | |
| st=FileNameNumNext(file_mask,file_name); | |
| BMPWrite(st,dc); | |
| st2=TOSBlogAbs(st); | |
| Free(st); | |
| st=MStrPrint("/Wb%s",st2+2); | |
| Free(st2); | |
| "$HC,\"<img src=\\\"%s\\\" width=\\\"%d\\\" " | |
| "height=\\\"%d\\\" alt=\\\"\\\">\"$\n",st,dc->width,dc->height; | |
| Free(st); | |
| } | |
| public U0 BlogScrnShot() | |
| {//Add scrn shot to blog as BMP file. | |
| Bool old_cursor=DocCursor,old_silent; | |
| CDC *dc1,*dc2; | |
| U8 *old_fp_draw_ms=gr.fp_draw_ms; | |
| gr.fp_draw_ms=NULL; | |
| Refresh(2); | |
| dc1=DCScrnCapture; | |
| dc2=DCExt(dc1,0,FONT_HEIGHT,GR_WIDTH-1,GR_HEIGHT-1); | |
| BlogDCImgWrite(dc2); | |
| gr.fp_draw_ms=old_fp_draw_ms; | |
| DCDel(dc1); | |
| DCDel(dc2); | |
| DocCursor(old_cursor); | |
| old_silent=Silent; | |
| FreshenBlog; | |
| Silent(old_silent); | |
| } | |
| public U0 FreshenBlog() | |
| {//Regen html files for D:/Home/Web. | |
| DirMk("D:/Wb"); | |
| DirMk("D:/Wb/Home"); | |
| DirMk("D:/Wb/Home/Web"); | |
| DirMk("D:/Wb/Home/Web/" INS_REG_PERSONAL_INITIALS); | |
| DirMk("D:/Wb/Home/Web/" INS_REG_PERSONAL_INITIALS "/BlogDir"); | |
| FreshenWebDir("/Home/Web"); | |
| FreshenWebDir("/Home/" INS_REG_PERSONAL_INITIALS "/TOSBlog"); | |
| FreshenWebDir(BlogLocalDir+2); | |
| Drv('C'); | |
| } | |
| public U0 Blog(Bool god_misc2=FALSE) | |
| {//Make entry in blog. | |
| if (!FileFind(BlogLocalFile,,FUF_JUST_FILES)) | |
| Copy("~/" INS_REG_PERSONAL_INITIALS "/TOSBlog/DailyBlogHeader.DD.Z", | |
| BlogLocalFile); | |
| AutoComplete; | |
| WinBorder; | |
| WinMax; | |
| Msg(MSG_KEY_DOWN_UP,0,SC_CURSOR_DOWN|SCF_CTRL); | |
| if (god_misc2) | |
| Msg(MSG_KEY_DOWN_UP,0,SC_F7|SCF_SHIFT|SCF_ALT); | |
| else { | |
| Msg(MSG_KEY_DOWN_UP,0,SC_F6|SCF_ALT); | |
| Msg(MSG_KEY_DOWN_UP,'\n',0); | |
| } | |
| Msg(MSG_KEY_DOWN_UP,CH_CTRLS,0x61F0000061F); | |
| if (Ed(BlogLocalFile,EDF_WAS_WRITE)) { | |
| DocOpt(BlogLocalFile,"-r"); | |
| Copy(BlogLocalFile,"::" DAILY_SRC ".DD.Z"); | |
| Copy(BlogLocalFile,"D:" DAILY_SRC ".DD.Z"); | |
| Copy(BlogLocalFile,"D:/Wb" DAILY_DST ".DD.Z"); | |
| TOSWebFile("D:/Wb" DAILY_DST ".DD.Z"); | |
| FreshenBlog; | |
| } | |
| } | |