Factor out id → path handling into util.

Also use it in publishing, plotting.