Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Mar 28 13:37
    LuckyCyborg commented #27
  • Mar 28 13:36

    LuckyCyborg on 4.2

    Update MigrationMakeCommand.php Merge pull request #27 from nic… (compare)

  • Mar 28 13:36
    LuckyCyborg closed #27
  • Mar 01 11:29
    nicolas2 opened #27
  • Feb 07 16:17

    LuckyCyborg on 4.2

    Improve the Users module (compare)

  • Jan 29 08:08
    LuckyCyborg closed #2122
  • Jan 29 08:08
    LuckyCyborg commented #2122
  • Jan 28 21:30
    nicolas2 commented #2122
  • Jan 28 21:28
    nicolas2 commented #2122
  • Jan 28 11:50
    LuckyCyborg commented #2122
  • Jan 28 11:48
    LuckyCyborg commented #2122
  • Jan 28 11:46
    LuckyCyborg commented #2122
  • Jan 28 11:45
    LuckyCyborg commented #2122
  • Jan 27 17:59
    nicolas2 opened #2122
  • Sep 29 2020 22:35

    LuckyCyborg on 4.2

    Small changes (compare)

  • Sep 29 2020 21:18

    LuckyCyborg on 4.2

    Improve the Localization (compare)

  • Sep 29 2020 20:49

    LuckyCyborg on 4.2

    Small changes (compare)

  • Sep 29 2020 20:40

    LuckyCyborg on 4.2

    Improve the Localization (compare)

  • Sep 29 2020 20:21

    LuckyCyborg on 4.2

    Improve the Localization (compare)

  • Sep 29 2020 19:53

    LuckyCyborg on 4.2

    Small changes (compare)

Andro
@l2wok
@LuckyCyborg hi. thx
In the Themes, in the file layouts there is a header-css block like this <?= Asset::position('header', 'css'); ?>. Please tell me how to correctly pass the array of parameters I need from the controller to it. I think need like this View::shares(name, arr) but what name?
LuckyCyborg
@LuckyCyborg
@l2wok The Asset Positions are a feature of Assets Manager, and they aren't setup via View facade, as you think.
Basically, is about defining somewhere in Controllers, or whatever, in a programmatically way the assets which will be loaded in certain positions.
And for this is used Asset::register()
Long story short, the Asset facade is for the Assets Manager, found as Nova\Routing\Assets\AssetManager which is rather smaller class and I invite you to study it, even there are not docs.
LuckyCyborg
@LuckyCyborg
Like I said, the method responsible for registering assets for positions is
    /**
     * Register new Assets.
     *
     * @param  string|array $assets
     * @param  string $type
     * @param  string $position
     * @param  int $order
     * @param  string $mode
     *
     * @return void
     * @throws \InvalidArgumentException
     */
    public function register($assets, $type, $position, $order = 0, $mode = 'default')
    {
        if (! in_array($type, $this->types)) {
            throw new InvalidArgumentException("Invalid assets type [${type}]");
        } else if (! in_array($mode, array('default', 'inline', 'view'))) {
            throw new InvalidArgumentException("Invalid assets mode [${mode}]");
        }

        // The assets type and mode are valid.
        else if (! empty($items = $this->parseAssets($assets, $order, $mode))) {
            // We will merge the items for the specified type and position.

            Arr::set($this->positions, $key = "${type}.${position}", array_merge(
                Arr::get($this->positions, $key, array()), $items
            ));
        }
    }
LuckyCyborg
@LuckyCyborg
With the notes: $type should be css or js, $position is the (freely named) position, $order is obviously the rendering order and with a special note for $mode which usually should be default to give you the classic files URLs, or inline when you want to inject inline snippets like <style></style> or <javascript></javascript>
Finally, there's another mode: view when you inject inline the content of CSS and/or JS files located on the Views locations.
Probably is not known by many, but our Views Service is aware of CSS and JS type Views. :smiling_imp:
Andro
@l2wok
thanks!
mikweb
@mikweb
Hi all, i found a little issue :)
https://github.com/nova-framework/novapress/blob/1.1/modules/Contacts/Controllers/Messages.php#L54
$item->rules rules not rule.
Now, all validation are skiped :(
LuckyCyborg
@LuckyCyborg

Hi, @mikweb

I will take a look to this problem on this evening. Thank you for reporting! :+1:

carvelle
@carvelle

Hi Guys, I am having issues with browser caching. My app is returning cached pages with incorrorect details if I switch users.

Where can I find the Configuration to turn off browser Caching on Nova framework?

Facultys2
@Facultys2
hello
I can't do my config.php configuration for an oracle database
can you help me plz ?
ZhaoLin1457
@ZhaoLin1457

@Facultys2 I am afraid that Nova Framework has no support for Oracle DB. Most likely someone can write a Database extension for Oracle DB, but I think that's not a trivial task and I see here only two capable to do this task: @daveismyname and @LuckyCyborg who are also the maintainers.

@carvelle I do not think that Nova does something particular with the browser caching, at least for the standard pages, because the assets dispatcher does some kind of browser caching setup.

So, I think that Nova uses the Symfony's defaults. At least talking about the framework and its default app: https://github.com/nova-framework/app

With Novapress is another story, it does some complicated caching on pages and parts of pages. And I am not pretty sure that's designed for on-fly users switching.

Anyways, I believe that the Maintainers could give you a much better response, but I bet that it will be something like use a custom Middleware like:

class SetupBrowserCaching
{
    /**
     * Handle an incoming request.
     *
     * @param  \Nova\Http\Request  $request
     * @param  \Closure  $next
     * @return mixed
     */
    public function handle(Request $request, Closure $next)
    {
        $response = $next($request);

        // prepare the response here (to customize the browser caching) if isn't a file response.

       return $response;
    }
}

This Middleware most likely should be put on top of web group, to be one of the last ones which process the response.

carvelle
@carvelle
Thanks @ZhaoLin1457
Keyur
@keyur27
When I am going to migrate module database first time, I am getting this ERROR! "There are no commands defined in the "module" namespace."
Help me.
plz
carvelle
@carvelle
Hi, Is it possible to use Auth implementation with database table named other than "nova_users"?
carvelle
@carvelle
never mind, found the info in old V3 documentation.
jimgwhit
@jimgwhit

@daveismyname or @LuckyCyborg in the old SMVC router you had parameters:

Router::get('blog/(:any)', 'Controllers\\Blog@index');

// or you could

Router::get('blog/index/(:any)', 'Controllers\\Blog@index');

But the main part in both (the key) is

'blog/

or

'blog/index/

Those parts are stable, but the (:any) is dynamic. I cannot figure how you made sure a match took place, i.e., blog/index was a match so you had the correct route. If you you get this can you explain. because the (:any) part couldn't be a key? is that correct.

Like:

if (array_key_exists($key_to_check, self::$routes)) {  /// just example

// where  $key_to_check would be blog/index in this case...

How does the router get just key and discord the parameters part for a match?

LuckyCyborg
@LuckyCyborg

@jimgwhit Hi, Jim!

The SMVCF 2.2 makes distinction between "base path" and its "path with (unnamed) parameters" counterpart.

Then, you should define both routes, like this:

Router::get('blog', 'Controllers\\Blog@index');         // Matches https://mypetshop/blog
Router::get('blog/(:any)', 'Controllers\\Blog@index');  // Matches https://mypetshop/blog/new-dogs-for-adoption

As you see, you need to define TWO routes for handling this job.

Regarding the routes checking, it is simple: it tries to find the routes with no regexes - if any is defined for the current URI , otherwise it tries to match the routes with regexes

LuckyCyborg
@LuckyCyborg
What may look confusing for you is the fact that SMVCF 2.2 keeps the defined routes methods in a separate list, then even there is a match for URI, it grabs all routes methods defined for current URI and then check if there's a literal match or an ANY specification for method.
Nova3 and Nova4 differs there, as they keep the routes organized by methods, and 'ANY' has the significance that the route is inserted in all methods lists. Then, it can do a single check over "direct matching" by path, grabbing the list of routes defined for the current HTTP method.
In other hand, Nova3 and Nova4 does not need a separate route for base path. Then you can do something like:
// A route for matching both  https://mypetshop/blog and https://mypetshop/blog/new-dogs-for-adoption

Router::get('blog/{slug?}', 'App\Controllers\Blog@index');
LuckyCyborg
@LuckyCyborg
That ? character in the named parameter definition has the significance that it is optional.
David Carr
@dcblogdev
@jimgwhit hey Jim nice to heaar from you.
@LuckyCyborg hi, been awhile!
LuckyCyborg
@LuckyCyborg
@dcblogdev Hi, Dave!
jimgwhit
@jimgwhit

@LuckyCyborg @dcblogdev hope you are fine:

I am writing a small router and yes just trying to figure out if uri matches a route.

Just my "test data" here

        $routes = [
            'dog' => '\\Mini\\Controller\\DogController@indexAdmin@1',
            'dog/index' => '\\Mini\\Controller\\DogController@indexAdmin@2',
            'dog/indexadmin' => '\\Mini\\Controller\\DogController@indexAdmin@4',
            'dog/edit' => '\\Mini\\Controller\\DogController@edit@2',
            'dog/add' => '\\Mini\\Controller\\DogController@add@2',
            'dog/delete' => '\\Mini\\Controller\\DogController@delete@2',
            'admin/logout' => '\\Mini\\Controller\\AdminController@logout@2',
            'cat/edit' => '\\Mini\\Controller\\DogController@index@2'
        ];
        return $routes;
$key_to_check = self::chkUri(self::$uri[2], self::$uri[3]);
i.e.     dog/index    dog is self::$uri[2]  etc
// chkUri just checks for safety does htmlentities, in case someone changes values...
function returns dog/index cleaned.

In router if I do

if (array_key_exists($key_to_check, self::$routes)) {
      $torun = self::$routes[$key_to_check];
       self::run($torun, $auth);
 } else {
       self::autoDispatch();
 }

The router works perfect as long as the routes have 2 part keys like:

blog/index
dog/index
dog/edit
//etc

Where I show @4 above, it means a regular key like

dog/indexadmin

and 2 parameters, so uri

site.com/dog/indexadmin/c/no

All works good.

But I cannot figure out how to get a key to compare if

blog/{slug?}
or
blog/index/{slug?}

How does the router verify blog/index/Lucky is one of the routes.
Lucky can change to bob, john, etc. How do you determine the key in this case to compare?

I am wanting

blog/index/{slug?}

instead of

blog/index      with the @3 in this case at the end.

I have gone over the smvc router, but I am somehow missing how it verifies the route is a good route.

jimgwhit
@jimgwhit

I will probably stick with routes like:

'blog/index'
'dog/index'

so array would be

'dog/index' => '\\Mini\\Controller\\DogController@index@2',
'blog/index' => '\\Mini\\Controller\\DogController@edit@3',

Then url above would be

site.com/blog/index/some_parameter
// the @3 means normal key 'blog/index' then one parameter @4 would be 2 parameters  etc

Eventually I call

self::load($controller, $action, self::$last);

which is:

    public static function load($controller, $action, $last = array())
    {
        $c = new $controller;
        return $c->$action(...array_values($last));
    }
LuckyCyborg
@LuckyCyborg

@jimgwhit Cowboy, you have some very simplified examples about implementing routers with optional parameters there:

https://github.com/nova-framework/mini-router/blob/master/system/Routing/Router.php is a router with named parameters like Nova4
https://github.com/nova-framework/mini-router/blob/master/system/Routing/Router2.php is a router with unnamed parameters like SMVCF 2.2, but with optional parameters support.

Both lacks the support for groups and middlewares - for the sake of simplicity.

I suggest you to look on the code of those routers for your custom router.

BTW, what the heck is @3 on your routes? The PHP language does not accepts variables starting with numbers.
jimgwhit
@jimgwhit

@LuckyCyborg you remembered my nickname.

The @3 is used here

        if (self::$auth === 'isauth') {
            $uparts = explode('@', $torun);
            $controller = isset($uparts[0]) ? $uparts[0] : null;
            $action = isset($uparts[1]) ? $uparts[1] : null;
            $thiscount = isset($uparts[2]) ? $uparts[2] : null;
            $tvar = self::$uriCount - 2;
            if ($tvar <> $thiscount) {
                 throw new \Exception('Route not allowed.');
                die;
            }
            self::load($controller, $action, self::$last);
        } else {
            self::defaultController();
        }

It's just the number of allowed parameters.

Route:

dog/indexadmin' => '\\Mini\\Controller\\DogController@indexAdmin@4

Allows 2 extra parameters

  • dog = 1
  • indexadmin = 2
  • some parameter = 3
  • another parameter = 4
somesite.com/dog/indexadmin/c/n   good

somesite.com/dog/indexadmin/c/n/whatever   error

But thanks, I will look at the other router you mentioned.

LuckyCyborg
@LuckyCyborg

@jimgwhit I believe that your idea to configure the number of "accepted parameters" on actions (controller methods) via routes and doing checks only on the base paths is, well... quite bad. I dare to say: terrible.

Because you can have same base path but different controllers. And no HTTP method checking is epic bad.

Then, how you solve in your way something like this?

    // The Menus CRUD.
    Route::paginate( 'menus', 'Menus@index');

    Route::post('menus',              'Menus@store');
    Route::post('menus/{id}',         'Menus@update');
    Route::post('menus/{id}/destroy', 'Menus@destroy');

    // The Menu Items CRUD.
    Route::get( 'menus/{id}',                        'MenuItems@index');
    Route::post('menus/{id}/items/{itemId}',         'MenuItems@update');
    Route::post('menus/{id}/items/{itemId}/destroy', 'MenuItems@destroy');

    Route::post('menus/{id}/{mode}', 'MenuItems@store')->where('mode', '(posts|taxonomies|custom)');

    Route::post('menus/{id}/items', 'MenuItems@order');

This is just an part of routing from Content module from Nova Press.

There, menus/{id} on POST method goes to Menus@update and the GET one goes to MenuItems@index

And there is menus/{id}/{mode} and menus/{id}/items which are basically quite similar as paths, but they points to different actions.

Alexander Grigorev
@visavi

Hi, tell me how to correctly redirect with soft deletion from the view page
Now it returns me to the same page

If soft delete disable returns to the list page, I need to also

Frantisek Jasik
@end_if_twitter
@LuckyCyborg hi, only fast questions: 1st - mini is updated parallel with framework? and 2nd - how to install mini via composer? thanx for answers
LuckyCyborg
@LuckyCyborg

@end_if_twitter Hi!

I guess that by "mini" you talk about this repository: https://github.com/nova-framework/mini

First, the Mini is just an experiment for a standalone MVC framework, kinda like a much simplified Nova, with no modules, themes or packages, and lacking many other things.

Please note that it is experimental code, and you should consider it alpha quality. And yes, you can say that it is "updated" in parallel with Nova.

If there will be interest for Mini, maybe I will consolidate its code to publish a stable release, but for now there are no plans for.

Secondly, there is not support for installing Mini via composer. However, you can always clone the repository via GIT.

LuckyCyborg
@LuckyCyborg
You are welcome to test this code, eventualy to report back the found issues or even to make pull requests to fix things.
Frantisek Jasik
@end_if_twitter
@LuckyCyborg thanx, i`ll try it, with eventually bugs reporting... i have experience with earlier versions, so i can report complexicity vs simplicity state
ZhaoLin1457
@ZhaoLin1457

OMG! They will preserve the Nova Framework source code for at least 1000 years as an Open Source Treasure worth of Arctic Code Vault!

@dcblogdev @LuckyCyborg Sincere congratulations for becoming both Arctic Code Vault Contributor !

:clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap: :clap:

David Carr
@dcblogdev
Good news 😎
LuckyCyborg
@LuckyCyborg

@ZhaoLin1457 Thanks! Indeed, good news! :smirk:

However, I feel a bit uneasy thinking that my grammar mistakes risks to be quoted somewhere around A.D. 2500 in academic works with titles like A syntactical analysis of the Old Engrish ...

LuckyCyborg
@LuckyCyborg

@end_if_twitter

@LuckyCyborg thanx, i`ll try it, with eventually bugs reporting... i have experience with earlier versions, so i can report complexicity vs simplicity state

Feel free to use this Mini as you like.

However, I will ask you again to be kind to bear in mind that the Mini framework has no real relationship with Nova other than it is a playground of one of Nova's developers, me.