The recent canonical URL fix highlighted that URL generation logic is spread across the application. Consider moving URL construction into model objects via a HasURL role.
Something like this:
role Succession::Role::HasURL {
requires qw[identifier];
method prefix { return undef }
method url {
return join '/',
'',
grep { defined && length }
$self->prefix,
$self->identifier;
}
}
And then, in the Person class:
method prefix { 'p' }
method identifier { $self->slug }
Might need a Date class too:
method identifier { $self->canonical_date }
And, perhaps, we can also use it for the reference pages.
The recent canonical URL fix highlighted that URL generation logic is spread across the application. Consider moving URL construction into model objects via a HasURL role.
Something like this:
And then, in the Person class:
Might need a Date class too:
And, perhaps, we can also use it for the reference pages.