Cluster-based density-functional approach to quantum transport through molecular and atomic contacts