post_create.js - overhaul

moved things into functions and used postutil and fileutil