preaction / Yancy

The Best Web Framework Deserves the Best Content Management System
http://preaction.me/yancy/
Other
54 stars 21 forks source link

Example of usage of Yancy::Plugin::Editor::route - URL customization #90

Closed pavelsr closed 4 years ago

pavelsr commented 4 years ago

Hi Doug,

Could you please provide an example of usage route config param?

My purpose is to customize URL - set /admin instead of /yancy.

I don't understand how it's possible to do with config - seems like Yancy::Plugin::Editor code expect Mojolicious::Routes::Route object, not a string.

If I set route => 'admin' or route => '/admin' I get Can't locate object method "to" via package ".admin" error

Setting app->routes->any( '/admin' )->name('admin'); gives same error.

preaction commented 4 years ago

Ah, yes, there should be an example there. Also, it could see if it got a string and make the right route for you. But, here's how it works:

sub startup( $app ) {
    my $route = $app->routes->any( '/admin' );
    $app->plugin( Yancy => {
        ...
        editor => {
            route => $route,
        },
    } );
}

So it's not possible using the standalone yancy command just yet.

pavelsr commented 4 years ago

Ok, got it. So for now it's impossible to customize URL just by string in config, need to redefine it in startup.