const fs = require('fs'); global.BlogList=[]; global.BlogMap=[]; function ReloadBufer() { global.BlogList=[]; global.BlogMap=[]; global.SendHTMLMap={}; } setInterval(ReloadBufer,60*1000); HostingCaller.TestAddon=function (Params,response,ArrPath) { return "Test. Your params:"+JSON.stringify(Params)+" Path:"+JSON.stringify(ArrPath); } HostingCaller.blog=function (Params,response,ArrPath) { if(ArrPath[1]==="reload") { ReloadBufer(); return "Reload OK"; } var PathUploads="./SITE/blog/uploads/"; if(!global.BlogList.length)//init { var ArrList=fs.readdirSync(PathUploads); for (var i=0;i0) { ToLog("Error file length: "+Data.filename); return 0; } var index=Str.indexOf("=START="); if(index<=0) { ToLog("Error file format: "+Data.filename); return 0; } var Str1=Str.substring(0,index); try { var Data2=JSON.parse(Str1); } catch(e) { ToLog("Error: "+e+"\n\n"+Str1) return 0; } for(var key in Data2) { Data[key]=Data2[key]; } global.BlogMap[Data.id]=Data; if(bBody) { var Str2=Str.substring(index+7); Data.Body=Str2; } //Data.Init=1; } return 1; } //document.body.contentEditable='true'; document.designMode='on'; HostingCaller.GetFileContent=function (Params,response,ArrPath) { if(!global.HTTP_ADMIN_PASSORD) return {result:0,Text:"Not set password"}; if(Params.Password!==global.HTTP_ADMIN_PASSORD) return {result:0,Text:"Error password"}; var Str=GetFileSimple(Params.Path); return {result:1,Body:Str}; } HostingCaller.SaveFileContent=function (Params,response,ArrPath) { if(!global.HTTP_ADMIN_PASSORD) return {result:0,Text:"Not set password"}; if(Params.Password!==global.HTTP_ADMIN_PASSORD) return {result:0,Text:"Error password"}; SaveFileSimple(Params.Path,Params.Body); var Str=GetFileHTMLFromMarkdown(Params.Path); return {result:1,Body:Str}; } // HostingCaller.GetFileMarkdown=function (Params,response,ArrPath) // { // if(!global.HTTP_ADMIN_PASSORD) // return {result:0,Text:"Not set password"}; // if(Params.Password!==global.HTTP_ADMIN_PASSORD) // return {result:0,Text:"Error password"}; // // var Str=GetFileHTMLFromMarkdown(Params.Path); // return {result:1,Body:Str}; // }