A unifying view of gamma-ray burst afterglows