A Versatile Synthesis Route for Atomically Dispersed Metal Nanoparticles on Nitrogen-doped Porous Carbon Supports