Cleanup permalink generation

Fix permalink generation to not contain various smells. See verbose description in the last commit in this PR.
@dkubb I see that only master depends on `>= 2.1` where both spree 2.4 and 2.3 are still on `>= 1.9`. I'll change that code back to make it upstreamable.