hschumann2/TempleOS-Source-Code
0847
1 2#help_index "Misc/Blog"3 4U8 *YouTubeGet(U8 *filename="~/Sup1/Sup1Blog/YouTube.DD.Z",U8 *needle)5{6 I64 i=0,line=I64_MIN;7 CDoc *doc=DocRead(filename,DOCF_PLAIN_TEXT_TABS|DOCF_NO_CURSOR),8 *doc2=DocNew;9 U8 *title,*code,*res;10 while (DocFind(doc,line,needle)) {11 if (!(doc->cur_entry->y&1)) {12 title=doc->cur_entry->tag;13 DocGoToLine(doc,doc->cur_entry->y+2);14 if (doc->cur_entry->type_u8==DOCT_TEXT) {15 code=doc->cur_entry->tag;16 DocPrint(doc2,"$MU-UL,\"%s\",LE=0x%X$\n",title,code);17 i++;18 }19 }20 line=doc->cur_entry->y+2;21 }22 switch (i) {23 case 0:24 res=NULL;25 break;26 case 1:27 res=StrNew(code);28 break;29 default:30 res=PopUpMenu(doc2);31 if (res==DOCM_CANCEL)32 res=NULL;33 else34 res=StrNew(res);35 }36 DocDel(doc);37 DocDel(doc2);38 return res;39}40 41U0 YouTubeAdd(U8 *filename="~/Sup1/Sup1Blog/YouTube.DD.Z",42 U8 *title,U8 *code)43{44 CDoc *doc=DocRead(filename,DOCF_PLAIN_TEXT_TABS|DOCF_NO_CURSOR);45 if (!DocFind(doc,,title)) {46 DocBottom(doc);47 DocPrint(doc,"%s\n%s\n",title,code);48 DocTop(doc);49 DocWrite(doc);50 Sort(filename,,2);51 }52 DocDel(doc);53}54 55U8 *WebBookMarks(U8 *filename="~/Sup1/Sup1Blog/Bookmarks.html")56{57 U8 *st;58 CDocEntry *doc_e;59 CDoc *doc=DocNew;60 CCmpCtrl *cc=CmpCtrlNew(MStrPrint("#include \"%s\"",filename));61 while (Lex(cc))62 if (cc->token==TK_STR && *cc->cur_str(U32 *)=='http') {63 DocPrint(doc,"$MU-UL,\"%$Q\",LE=0x%X$\n",cc->cur_str,cc->cur_str);64 cc->cur_str=NULL;65 }66 CmpCtrlDel(cc);67 68 if ((st=PopUpMenu(doc))!=DOCM_CANCEL)69 st=StrNew(st);70 else71 st=NULL;72 73 doc_e=doc->head.next;74 while (doc_e!=doc) {75 if (doc_e->type_u8==DOCT_MENU_VAL)76 Free(doc_e->left_exp);77 doc_e=doc_e->next;78 }79 DocDel(doc);80 81 return st;82}83 84U0 FamilyPhoto()85{86 CFamilyPhotoForm *fp=CAlloc(sizeof(CFamilyPhotoForm));87 fp->width=900;88 fp->height=600;89 fp->part=1;90 if (DocForm(fp)) {91 "$HC,\"<center><img src=\\\"/%s/part%d/%s\\\" "92 "width=\\\"%d\\\" height=\\\"%d\\\" alt=\\\"\\\"></center>\"$",93 DefineSub(fp->volume,"ST_FAMLY_PHOTOS"),94 fp->part,fp->picture,fp->width,fp->height;95 }96}97 98U0 BlogImg()99{100 U8 *st=BlogWebDir;101 CBlogImgForm *bi=CAlloc(sizeof(CBlogImgForm));102 bi->width=900;103 bi->height=600;104 if (DocForm(bi)) {105 "$HC,\"<center><img src=\\\"%s/%s\\\" "106 "width=\\\"%d\\\" height=\\\"%d\\\" alt=\\\"\\\"></center>\"$",107 st,bi->picture,bi->width,bi->height;108 }109}110 111U0 TOSIns()112{113 CWebBibleForm *url=CAlloc(sizeof(CWebBibleForm));114 U8 *tag,*st,*st2;115 116 switch (PopUpPickLst("BiblePassage\0BibleVerse\0"117 "YouTube\0Imgur\0Wikipedia\0WebBookMark\0FamilyPhoto\0BlogImg\0")) {118 case:119 if (DocForm(url(CWebBibleForm *))) {120 tag=url->special;121 st2=URLPercentSpaces(url->special);122 st=MStrPrint("http://www.biblegateway.com/passage/"123 "?search=%s&version=NIV",st2);124 Free(st2);125 if (*url->tag)126 tag=url->tag;127 "$TX,\"%$Q\",HTML=\"%$Q\"$",tag,st;128 Free(st);129 }130 break;131 case:132 if (DocForm(url(CWebBibleForm *))) {133 tag=url->special;134 st2=URLPercentSpaces(url->special);135 st=MStrPrint(136 "http://www.biblegateway.com/verse/en/%s",st2);137 Free(st2);138 if (*url->tag)139 tag=url->tag;140 "$TX,\"%$Q\",HTML=\"%$Q\"$",tag,st;141 Free(st);142 }143 break;144 case:145 if (DocForm(url(CYouTubeForm *))) {146 if (*url->special==CH_SPACE)147 st2=YouTubeGet(,url->tag);148 else149 st2=StrNew(url->special);150 if (st2 && *st2!=CH_SPACE) {151 if (url->min || url->sec)152 st=MStrPrint("%s&hl=enUS&start=%d",st2,url->min*60+url->sec);153 else154 st=StrNew(st2);155 if (*url->special!=CH_SPACE && *url->tag)156 YouTubeAdd(,url->tag,st);157 "$HC,\"<object width=\\\"640\\\" "158 "height=\\\"520\\\"><param name=\\\"movie\\\" "159 "value=\\\"http://www.youtube.com/v/%s\\\"></param><param "160 "name=\\\"allowscriptaccess\\\" "161 "value=\\\"always\\\"></param><embed "162 "src=\\\"http://www.youtube.com/v/%s\\\" "163 "type=\\\"application/x-shockwave-flash\\\" "164 "allowscriptaccess=\\\"always\\\" "165 "width=\\\"640\\\" height=\\\"520\\\">"166 "</embed></object>\"$\n",st,st;167 Free(st);168 Free(st2);169 }170 }171 break;172 case:173 if (DocForm(url(CImgurForm *))) {174 "$HC,\"<center><img src=\\\"http://i.imgur.com/%s\\\" "175 "width=\\\"%d\\\" height=\\\"%d\\\" "176 "alt=\\\"\\\"></center>\"$\n",177 url->special,url->min,url->sec;178 }179 break;180 case:181 if (DocForm(url(CWikipediaForm *))) {182 tag=url->special;183 st=MStrPrint("http://en.wikipedia.org/wiki/%s",url->special);184 if (*url->tag)185 tag=url->tag;186 "$TX,\"%$Q\",HTML=\"%$Q\"$",tag,st;187 Free(st);188 }189 break;190 case:191 if (DocForm(url(CWebBookMarkForm *))) {192 tag=st=WebBookMarks;193 if (*url->tag)194 tag=url->tag;195 "$TX,\"%$Q\",HTML=\"%$Q\"$",tag,st;196 Free(st);197 }198 break;199 case:200 FamilyPhoto;201 break;202 case:203 BlogImg;204 break;205 }206 Free(url);207}208 209#help_index "Misc/TOS/God;God/TOS"210 211public U0 GodCodeJmp()212{//Jump to rand code in OS. See ::/Adam/God/HSNotes.DD.213 CDirEntry *tmpde1=FilesFind("/*",214 FUF_JUST_FILES|FUF_RECURSE|FUF_JUST_SRC|FUF_CLUS_ORDER),215 *tmpde=tmpde1;216 I64 cnt=0,num;217 CDoc *doc;218 U8 *st;219 while (tmpde) {220 doc=DocRead(tmpde->full_name);221 tmpde->user_data=doc->head.y;222 cnt+=doc->head.y;223 DocDel(doc);224 tmpde=tmpde->next;225 }226 227 FifoU8Flush(god.fifo);228 GodBitsIns(GOD_GOOD_BITS,KbdMsEvtTime>>GOD_BAD_BITS);229 num=GodBits(GOD_GOOD_BITS)%cnt;230 231 tmpde=tmpde1;232 while (tmpde) {233 num-=tmpde->user_data;234 if (num<0) {235 st=MStrPrint("FL:%s,%d",tmpde->full_name,-num);236 break;237 }238 tmpde=tmpde->next;239 }240 DirTreeDel(tmpde1);241 Ed(st);242 Free(st);243}244 245U0 GodOffer()246{247 switch (PopUpPickLst("MosesComic\0Fiction\0")) {248 case:249 "---- Moses Comic ---- "250 "(Set in the Numbers 11 "251 "part of the story.)\n"252 "Moses says, \"\"\n"253 "God says, \"\"\n";254 break;255 case:256 "---- Collaborative Fiction ----\n"257 "Once upon a time ";258 break;259 }260}261 