Skip to content

Commit

Permalink
microblog creation
Browse files Browse the repository at this point in the history
  • Loading branch information
xriss committed Jan 6, 2024
1 parent 8adf1ee commit f63463b
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
10 changes: 10 additions & 0 deletions js/cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@ if( argv._[0]=="blog" )
var plated=require("./plated.js").create(argv);
return await plated.blog();
}
else
if( argv._[0]=="micro" )
{
var plated=require("./plated.js").create(argv);
return await plated.micro();
}

// help text
console.log(
Expand All @@ -174,6 +180,10 @@ console.log(
"\tCreate an empty blogpost with todays date and the given title in the source blog directory.\n"+
"\t\t--blog=blog -- choose the blog folder. \n"+
"\t\t...same options as build\n"+
"> plated micro I had buttered scones for tea. \n"+
"\tCreate a microblogpost with todays date-time and the given text as markdown content.\n"+
"\t\t--blog=blog -- choose the blog folder. \n"+
"\t\t...same options as build\n"+
"\n"+
"");

Expand Down
37 changes: 37 additions & 0 deletions js/plated.js
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,43 @@ Type words here.
}

};
/***************************************************************************
--[[#js.plated.micro
plated.micro()
Create a starting microblogpost with todays date-time in the main blog directory.
Markdown text is taken from opts._[1] onwards IE the command line.
]]*/
plated.micro=async function()
{
let blogtext=""
if( opts._ && opts._[1] )
{
for( let i=1 ; i<opts._.length ; i++ )
{
blogtext=blogtext+" "+opts._[i]
}
}
blogtext=blogtext.trim()+"\n"

let d=new Date()
let dd=[ d.getFullYear() , d.getMonth()+1 , d.getDate() , d.getHours() , d.getMinutes() , d.getSeconds() ]

let unixtime=Date.UTC(dd[0],dd[1]-1,dd[2],dd[3],dd[4],dd[5])/1000
let dateyear=("0000" + dd[0]).substr(-4,4)
let datedash=("0000" + dd[0]).substr(-4,4)+"-"+("00" + dd[1]).substr(-2,2)+"-"+("00" + dd[2]).substr(-2,2)
let timedash=datedash+"-"+("00" + dd[3]).substr(-2,2)+("00" + dd[4]).substr(-2,2)+("00" + dd[5]).substr(-2,2)


let fname=plated.files.joinpath(opts.source,opts.blog,"micro-"+dateyear,timedash+".md")
await plated.files.write( fname, blogtext );

console.log( fname );

};

// load default plugins

Expand Down

0 comments on commit f63463b

Please sign in to comment.