Closed book closed 8 years ago
The code seems very reasonable to me.
It is a little awkward to see a global variable, but I don't know if there is a better way to do it.
Another thing that got me curious is the way the dashboard classes are loaded now. Is there any side effects in skipping import
on those, and loading them on runtime instead of compile time? I haven't tested them myself, but just wondering if there is some magic Dancer2 might do that is skipped now because of that...
Otherwise, I'd say :shipit:
I don't like the global variable either, but the only solution I found that did not involve one was to pass the settings to the url method. Doing something like [% post.url_for( settings ) %]
in every template is much more of a pain to do than [% post.url %]
. So I think the global variable is an acceptable compromise.
I've been trying to find out if the various PearlBee::Dashboard::
modules had an import
method or not. It looks like the use Dancer2 appname => 'PearlBee';
line provides them with one.
I wonder if Dancer2 does that on purpose, or if that method "leaked" somehow.
After looking at the Dancer2 source code, an actual import
method is indeed created by Dancer2 in the corresponding namespaces. The code of that import is visible here and is equivalent to:
sub import {
my ( $self, %options ) = @_;
my $with = $options{with};
for my $key ( keys %$with ) {
$self->dancer_app->setting( $key => $with->{$key} );
}
}
That code only does something if there's a list of parameters given, so in our case (no arguments to the use
calls) there are no consequences.
Great! I agree that it is an acceptable compromise, and that the global is much better than post.url_for( settings )
.
And good that there are no consequences in replacing the use
s for require
s.
So... let's merge it? @xsawyerx?
@book and I decided on the next actions in order to merge this feature in. I'll work on it further and merge it.
Cool, @xsawyerx and @book :smile:
Per conversations with @book and @andrewalker I have taken the following actions:
The commits in this branch had been merged, so the PR is effectively merged. Closing this ticket. :+1: !
This PR is related to xsawyerx/PearlBee#19.
Summary of changes:
$PearlBee::is_static
variable.uri
,edit_uri
, anddelete_uri
methods, to simplify link creation in the templates.PearlBee::Dashboard
modules are not loaded ifstatic = 1
, so the/dashboard/
URL will all return 404 errors.The remaining work is to fix the templates to use the various
uri
methods.