Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

router #137

Open
lega911 opened this issue Jan 25, 2016 · 88 comments
Open

router #137

lega911 opened this issue Jan 25, 2016 · 88 comments

Comments

@lega911
Copy link
Owner

lega911 commented Jan 25, 2016

https://gist.github.com/fend25/3619d6d730039c30a34d

@fend25
Copy link
Contributor

fend25 commented Jan 25, 2016

https://jsfiddle.net/fend25/e1LLu72c/
better and preferabe variant now,

guys, feel free to comment)

@dev-rke
Copy link
Contributor

dev-rke commented Jan 25, 2016

Haha, thought yesterday how great it would be having some views bound to routes. :D

A good basic router implementation would be this:
http://krasimirtsonev.com/blog/article/A-modern-JavaScript-router-in-100-lines-history-api-pushState-hash-url

My approach would use regexes as parameter of a directive:

<div al-router-view="/main/?">
  <a href="/user/1">User 1</a>
</div>
<div al-router-view="/user/:id/?">
  <a href="/main">Back to overview</a>
</div>

This would allow to define the urls directly in the template, no additional code would be needed for basic features. But there should definitivly be an API to do redirects, handle url errors etc.

@fend25
Copy link
Contributor

fend25 commented Jan 25, 2016

Oleg's reference implementation (ancient one)
http://plnkr.co/edit/QYb53NUnnhIezI5n0JxB?p=preview

@dev-rke
Copy link
Contributor

dev-rke commented Jan 26, 2016

Ok, i just build an absolute simple, quick n dirty views implementation:
https://jsfiddle.net/r9t3ropc/

Some explanation: the al-router-view directive could be extended to watch the expression.
So one could define the url structure in javascript or the url of a view could be changed:

<div al-router-view="myVar.main">Main</div>
<div al-router-view="myVar.user">User</div>
scope.myVar = {
  main: '/main',
  user: '/user'
}

Comments are welcome.

@rumkin
Copy link

rumkin commented Feb 15, 2016

I think it should be separated into two different API's:

  • Router is for router events and state handling
  • View rendering route data into template and managing scope.

The first should have unified interface to change current location and update/rewrite state. Also it should be presented in root scope and should broadcast events. Events could be stopped to prevent page reloading when there is unsaved changes or so.

View should allow to use functions as route value. This functions return async operations to load template and resource specified by route. This is needed to render state dependent routes. By default view listening scope's $routeChanged event. But changes source could be configurable to use exact router instance.

<al-app>
    <al-view al-view.routes = "routes"/>
</al-app>
alight.bootstrap('al-app', {
    routes : {
        // Simple template route
        '/': 'index.html',

        // State dependent route
        '/home': function(route, scope){
            if (scope.user) {
                return {
                    scope: {
                        user: user
                    },
                    template: '/users/home.html'
                }
            } else {
                return '/sign-in.html'
            }
        },
        // Async route
        '/users/:id' : route => {
            var user = users.get(route.id);

            var promise;

            if (! user) {
                promise = loadUser(route.id).then(user => {
                    if (! user) {
                        // User not found, show 404 error page
                        return '/errors/404.html';
                    } else {
                        // User found, use user page template
                        return {
                            scope: {
                                user
                            },
                            template: '/users/item.html'
                        }
                    }
                });
            } else {
                promise = Promise.resolve(user);
            }

            return promise;
        }
    }
});

Also view could has loading view with spinner to indicate intermediate state while resolving promise.

@lega911
Copy link
Owner Author

lega911 commented Feb 15, 2016

@rumkin Can I use common header and footer for "/users/*" in your approach.
In this example by @fend25 I can do this: https://jsfiddle.net/fend25/e1LLu72c/

Events could be stopped to prevent page reloading when there is unsaved changes or so.

It's @onLoseFocus="showPreventWindow()" in the example.

@onSwitchTo="onSwtichToUser()" could be something like this:

scope.onSwtichToUser = route => {
            var user = users.get(route.id).then

            var promise;

            if (! user) {
                promise = loadUser(route.id).then(user => {
                    if (! user) {
                        // User not found, show 404 error page
                        return '/errors/404.html';
                    } else {
                        // User found, use user page template
                        return {
                            scope: {
                                user
                            },
                            template: '/users/item.html'
                        }
                    }
                });
            } else {
                promise = Promise.resolve(user);
            }

            return promise;
}

What do you think? "Configuring" in html can be easier.

@rumkin
Copy link

rumkin commented Feb 15, 2016

@lega911 Yep, it could be done with several view elements. Like this:

<al-view al-view-routes="routes.head">
<al-view al-view-routes="routes.body">
<al-view al-view-routes="routes.footer">

It's not so elegant as HTML configuration but it simply to manage from code. I think configuring in HTML is the most proper way to do this for MVVM app. But it should be also configurable and controllable from code.

@ is not valid HTML attribute name character. Is this some kind of future DSL?

@rumkin
Copy link

rumkin commented Feb 15, 2016

I think it's better to configure router with html and implement fully controllable router and view interfaces with focus on usability.

@lega911
Copy link
Owner Author

lega911 commented Feb 15, 2016

@ is not valid HTML attribute name character. Is this some kind of future DSL?

Yes, but we can make it like this (with the event directive):
al-on:on-lose-focus="showPreventWindow()"
or alias
@on-lose-focus="showPreventWindow()"

and "on-lose-focus" is an event (new CustomEvent), which you can catch even with jQuery. #123

@rumkin
Copy link

rumkin commented Feb 15, 2016

Maybe it's better to avoid on duplication and bind events to target component to avoid mess of events in the future:

al-router:on-reload-requested
al-input:on-lost-focus

@lega911
Copy link
Owner Author

lega911 commented Feb 15, 2016

Maybe, but custom events can be more flexible.

@dev-rke
Copy link
Contributor

dev-rke commented Feb 16, 2016

May it possible to implement url handling like express.js?
Another point is, that using Views which use "templates" would not be useful, because in this case i could redirect the user to a page which shows the content of this "template".
Views should be used inline, to easily switch between views by a changing url.
I also think it is not useful to bind a view to a scope variable.

My approach uses a global routes object, where regexes are defined.
Using al-route or by adding routes to the object, new routes can be defined.
Also a custom route can be defined in this object, which will be referenced by a given element selector.

<div id="home"></div>
<div id="players"></div>
<div al-route="/users/:user"></div>
alight.routes = {
  '/home': (scope) ->
    return '#home'
  '/players/:id': (scope, id) ->
    scope.id = id
    return '#players'
}
alight.d.al.route = (scope, exp, element, env) ->
  alight.routes[exp] = ->
    return element

What do you think?

@lega911
Copy link
Owner Author

lega911 commented Feb 16, 2016

My approach uses a global routes object,

I agree

div id="home"></div>
<div id="players"></div>
<div al-route="/users/:user"></div>```

should it work like al-if with dependency on url?

@lega911
Copy link
Owner Author

lega911 commented Feb 16, 2016

What about this one?

<div>
  <div al-route:group @switch-to="onSwtichToAuth()">
    <div al-route="/login" al-ctrl="App"/>
    <div al-route="/register" al-ctrl="App"/>
  </div>
  <div al-route:group @switch-to="onSwtichToApp()" @lose-focus="showPreventWindow()">
    <Header/>
    <div al-route="/posts" al-ctrl="Posts"/>
    <div al-route="/feed" al-ctrl="Feed"/>
    <div al-route="/user">
      <div al-ctrl="userList"></div>
      <div al-route="/user/:userId" al-ctrl="userItem" @lose-focus="checkIfUserSaved()">
        <div al-if="!user">Loading...</div>
        <div al-if="user" al-include="/templates/userItem.html"></div>
      </div>
    </div>
    <div al-route="*">
      No page 404
    </div>
    <Footer/>
  </div>
</div>

when url = "/user/:userId", then controller al-ctrl="userItem" is activated, there you can load a user,
a template can be loaded by al-include when a user is loaded <div al-if="user" al-include="/templates/userItem.html"></div>,
and you can see this before user is loaded <div al-if="!user">Loading...</div>

so, visible html for /user/:userid would be

<div>
  <div al-route:group @switch-to="onSwtichToApp()" @lose-focus="showPreventWindow()">
    <Header/>
    <div al-route="/user">
      <div al-ctrl="userList"></div>
      <div al-route="/user/:userId" al-ctrl="userItem" @lose-focus="checkIfUserSaved()">
        <div al-if="!user">Loading...</div>
        <div al-if="user" al-include="/templates/userItem.html"></div>
      </div>
    </div>
    <Footer/>
  </div>
</div>

visible html for /user would be

<div>
  <div al-route:group @switch-to="onSwtichToApp()" @lose-focus="showPreventWindow()">
    <Header/>
    <div al-route="/user">
      <div al-ctrl="userList"></div>
    </div>
    <Footer/>
  </div>
</div>

visible html for /login would be

<div>
  <div al-route:group @switch-to="onSwtichToAuth()">
    <div al-route="/login" al-ctrl="App"/>
  </div>
</div>

@rumkin
Copy link

rumkin commented Feb 16, 2016

I agree. It looks exciting. And it should to allow to load subroutes with al-include for complex components.

@lega911
Copy link
Owner Author

lega911 commented Feb 16, 2016

@rumkin al-include is deprecated, look at http://angular-light.readthedocs.org/en/latest/directive/html.html , it's more flexible :)

@rumkin
Copy link

rumkin commented Feb 16, 2016

@lega911 I will. But you're using al-include in your example.

Let's focus on modular structure, easy of use and flexibility. And thus it should to use al-html to load subroutes.

@dev-rke
Copy link
Contributor

dev-rke commented Feb 17, 2016

should it work like al-if with dependency on url?

Yes, you have a pretty good understanding of what i mean. :-)

al-route:group

I do not understand how this works.
I understand that it groups some requests.
But how is defined that a specific request should be used?
Which request is the first if you are visiting url "/"?

What i also thought about are subroutes:

<div al-route="/user">
  <div al-route="/:id"></div>
  <div al-route="/details"></div>
</div>

Which would be matched when accessing:
/user
/user/:id
/user/details

Maybe it would be great to also handle redirects in the global route object:

alight.routes = {
  '/home': '/'
  '/players/:id': (scope, id) ->
    scope.id = id
    return '#players'
}

which would redirect "/home" to "/".

@lega911
Copy link
Owner Author

lega911 commented Feb 17, 2016

al-route:group
I do not understand how this works.

It's easy, one rule - if there is a route that maches to url, then it should be visible, then all parent DOM should be visible, other route-elements should be hidden.
I changed your example in this style:

<div al-route>
  <header />
  <div al-route="/profile"></div>
  <div al-route="/user/:id/view"></div>
  <div al-route="/user/details"></div>
  <footer />
</div>

for url "/user/details" we will have:

<div al-route>
  <header />
  <div al-route="/user/details"></div>
  <footer />
</div>

In your approach we have to copy-past header and footer for "/profile".
On the other side, your approach works well for loaded html (al-html).

@dev-rke
Copy link
Contributor

dev-rke commented Feb 17, 2016

Hm. This is a bit confusing for me.
The grouping attribute is there to render a specific header an a footer, right?
The content for a route is inside of

<div al-route="/profile">
  <h1>My user profile</h1>
</div>

So when accessing /profile i will see this:

<header />
<div al-route="/profile">
  <h1>My user profile</h1>
</div>
<footer/>

Am i right?

@lega911
Copy link
Owner Author

lega911 commented Feb 17, 2016

So when accessing /profile i will see this:
Am i right?

Yes.
Actually for example above we don't need a "group" route:

<div>
  <header />
  <div al-route="/profile"></div>
  <div al-route="/user/:id/view"></div>
  <div al-route="/user/details"></div>
  <footer />
</div>

In a simple, "group route" just holds all child routes, like al-route="/profile; /user/:id/view; /user/details", but it takes them automatically.

@lega911
Copy link
Owner Author

lega911 commented Feb 17, 2016

The grouping attribute is there to render a specific header an a footer, right?

Not exactly, it renders all DOM, except routes that don't match to URL

@dev-rke
Copy link
Contributor

dev-rke commented Feb 17, 2016

Not exactly, it renders all DOM, except routes that don't match to URL

I like the approach. :-)

@lega911
Copy link
Owner Author

lega911 commented Feb 17, 2016

@rumkin
Copy link

rumkin commented Feb 17, 2016

There is an regex router with params and tail capturing:
https://jsfiddle.net/rumkin/y6xLu1sm/

@lega911
Copy link
Owner Author

lega911 commented Feb 17, 2016

Here an regex router with params and tail capturing:

I took it for my example

@lega911
Copy link
Owner Author

lega911 commented Feb 17, 2016

You can get arguments using event al-on.route-to

<div al-route="/user/:name/view" @route-to="username=$event.value.name">

@lega911
Copy link
Owner Author

lega911 commented Feb 17, 2016

One more example: http://plnkr.co/edit/pQBycumCKE1DJb3oVaPE?p=preview

  • you can use the same routes a few times in different places (al-route="/user/details" in the example)
  • default route
        <div al-route="*">
          404 - Not found
        </div>

@dev-rke
Copy link
Contributor

dev-rke commented Feb 18, 2016

You can get arguments using event al-on.route-to

Why not providing these variables automatically in a scope variable?
E.g.

scope.$route.name

Parsing from URL shouldn't be so difficult:

"/user/:id/name/:name/view/:action".match(/:\w+/g)

@lega911
Copy link
Owner Author

lega911 commented Feb 18, 2016

Why not providing these variables automatically in a scope variable?

It can give you collisions for routes "/users/:name", "/users/root" they both will be visible on url="/users/root"

@dev-rke
Copy link
Contributor

dev-rke commented Feb 22, 2016

Hm, what about this:

One defines his application e.g. /users/

<div al-route="/users/:id"></div>
<div al-route="/users/:id/social"></div>
<div al-route="/users/detail/:id/edit"></div>
<div al-route="/users">CatchAll for /users instead of al-route:default, e.g. when one removes paramters from the url</div>

<a href="/login">Redirects to a page /login</a>
<a href="/groups">Redirects to a page /groups</a>

This would be definitively more flexible than handling urls by using an extra directive.
It's interesting that you were against an own directive in combination with templates, but you prefer a own directive for routing. I am not against an own directive for routing, but i think it is not required.
It would be better to provide a simple API, e.g.:

<img @click="alight.go(/users/1234)" />

This would give more flexibility than a directive, because the directive is bound to a specific event, e.g. click event. But what when a view should be shown when something is hovered?

<img @mouseover="alight.go(/image/1234/large)" />
<div al-route="/image/:id/large">
  <img src="/resources/images/{{$route.id}}-large.jpg" />
</div>

This is a simple preview box of a large image, when the user hovers over a thumbnail image.
The great thing about this is, that each large image has an own url, so one can share this url. :-)

@dev-rke
Copy link
Contributor

dev-rke commented Feb 22, 2016

Better API proposal:

<img @click="$route.go(/users/1234)" />

@lega911
Copy link
Owner Author

lega911 commented Feb 22, 2016

you were against an own directive in combination with templates, but you prefer a own directive for routing

Because template directives are all about one thing - inserting templates and I can reuse the code, no double code.
al-link has unique code, and it's shorter than al-route.link

something is hovered?

a good idea, it's done

    <a @click="$route.go('/user/ubuntu/view')" href>User Ubuntu</a> <br/>

But you have a limitation here - you should use al-ctrl if you want to have "scope.$route"

@lega911
Copy link
Owner Author

lega911 commented Feb 22, 2016

But you have a limitation here - you should use al-ctrl if you want to have "scope.$route"

I can place $route in every scope, but I think it's can be bothersome e.g. my timepicker component doesn't need it.
So $route is placed in child scope of al-route (al-route doesn't make a child scope), you can use al-ctrl to make a child scope where $route is appeared.

@lega911
Copy link
Owner Author

lega911 commented Feb 22, 2016

<div al-route="/users">CatchAll for /users instead of al-route:default

"/user" - is a simple route, need a key-symbol, maybe "/user/*"?

@dev-rke
Copy link
Contributor

dev-rke commented Feb 22, 2016

"/user" - is a simple route, need a key-symbol, maybe "/user/*"?

Nope, i explicitly mean /user.
This could be some kind of userlist or something, because it has no id in the url.
Matching against "/user/*" would exclude "/user", so it would not be a default handler.
If you append anything else, it would be matched by "/user/:id".

@lega911
Copy link
Owner Author

lega911 commented Feb 23, 2016

It seems we talk about different things, your route "/user" works.

@dev-rke
Copy link
Contributor

dev-rke commented Feb 23, 2016

It seems we talk about different things

No, we talk about the same.
You want to implement a catchall handler, that catches all urls that are not matched by the given urls in a group, right.
I recommend to make the catchall configurable, by defining custom catchall handlers.
And i would like to see handling normal links.

What do you think about making the al-link directive as additional attribute, e.g. like:

<a href="/user/1234/detail" al-link>User 1234</a>

If al-link has no parameters, it tries to fetch the link from href attribute or from action attribute (for form elements) or from src attributes (for images). Is this a compromise? :-)

@lega911
Copy link
Owner Author

lega911 commented Feb 24, 2016

CatchAll for /users instead of al-route:default, e.g. when one removes paramters from the url

I don't like this mark-way, what if I want "/user" as usuall route, it has no sign for this.
So, we can make special sign for this, we can make a special type for routes (e.g. :catch"),:

<div al-route="/users/:id"></div>
<div al-route="/users/:id/social"></div>
<div al-route="/users/detail/:id/edit"></div>
<div al-route:catch="/users**">CatchAll for /users #1</div>
<div al-route:catch="/users**">CatchAll for /users #2</div>
<div al-route:catch="/**">CatchAll #3</div>

While al-route works in parallel (a few routes can be visible), al-route:catch depends on an order - only first al-route:catch will be visible, so for "/users/wrong/link/here" CatchAll for /users #1 will be visible, for other urls it will be CatchAll #3

You can propose another sign for this

@dev-rke
Copy link
Contributor

dev-rke commented Feb 24, 2016

I don't like this mark-way, what if I want "/user" as usuall route, it has no sign for this.

You can do this. The idea is NOT to define a DEFAULT route using a special directive or directive modifier.
You define your url handling, as it is done e.g. by express.
If you want to handle a 404, you need to specify on which route the 404 should be activated.
E.g. you define

<div al-route="/users/details/:id"></div>
<div al-route="/users/details/:id/social"></div>
<div al-route="/users/details/:id/edit"></div>
<div al-route="/users">This is your /users route</div>
<div al-route="/users/.*">Catch, when no other route matches /users/(.*)</div>

Another example:

<div al-route="/community/users/:id"></div>
<div al-route="/community/users/:id/social"></div>
<div al-route="/community/users/detail/:id/edit"></div>
<div al-route="/community/:anything">This is the catcher, anything matches anything except users/*</div>

In this example any parameter, that does not match a given route, needs to be handled after other urls. We only need to define a processing priority, to ensure, that urls containing parameters are handled last. This can be done when adding new routes to the global routes object.

While al-route works in parallel (a few routes can be visible), al-route:catch depends on an order - only first al-route:catch will be visible, so for "/users/wrong/link/here" CatchAll for /users #1 will be visible, for other urls it will be CatchAll #3

I understand, what you like to do, but we do not need a directive modifier for this behaviour.
Its always the same handling structure.

@lega911
Copy link
Owner Author

lega911 commented Feb 24, 2016

If you want to handle a 404, you need to specify on which route the 404 should be activated.
E.g. you define

<div al-route="/users/details/:id"></div>
<div al-route="/users/details/:id/social"></div>
<div al-route="/users/details/:id/edit"></div>
<div al-route="/users">This is your /users route</div>
<div al-route="/users/.*">Catch, when no other route matches /users/(.*)</div>

It doesn't work now, because all routes work in parallel, e.g. if url = "/users/details/id123" then this DOM will be visible:

<div al-route="/users/details/:id"></div>
<div al-route="/users/.*">Catch, when no other route matches /users/(.*)</div>

to ensure, that urls containing parameters are handled last

<div al-route="/users/details/details/:id"></div>
<div al-route="/users/details/:id/details"></div>

which one should be a last? (what if url = "/users/details/details/details")?

I understand, what you like to do, but we do not need a directive modifier for this behaviour.
Its always the same handling structure.

We have two modes for routes: parallel and sequence, and we need to know which where.
Example:

<div al-route="/users/root"></div>

<div al-route:catch="/users/props/.*">props</div>
<div al-route:catch="/users/.*">Catch, when no other route matches /users/(.*)</div>
<div al-route:catch="/users/info/.*">info</div>  <!-- similar to props -->

<div al-route="/users/details/:id"></div>
<div al-route="/users/:id"></div>

For url="/users/root", result DOM: (It's Important case - two blocks are visible.)

<div al-route="/users/root"></div>

<div al-route="/users/:id"></div>  <!-- Double of route -->

url="/users/details/id123", result DOM:

<div al-route="/users/details/:id"></div>

url="/users/props/id123", result DOM:

<div al-route:catch="/users/props/.*">props</div>

url="/users/info/id123", result DOM:

<div al-route:catch="/users/.*">Catch, when no other route matches /users/(.*)</div>

It's Important case, you have al-route:catch="/users/.*" instead of al-route:catch="/users/info/.*", because of sequence (position in DOM)

What is your Skype? (mine: lega911), it will be easier ;)

@dev-rke
Copy link
Contributor

dev-rke commented Feb 24, 2016

which one should be a last? (what if url = "/users/details/details/details")?

/users/details/:id
has precedence before
/users/:id/details

Why? Because static defined routes are more specific than routes containing a variable.
Also the segment length of a given route should be respected:

It's Important case, you have al-route:catch="/users/.*" instead of al-route:catch="/users/info/.*", because of sequence (position in DOM)

Your html:

<div al-route:catch="/users/.*">Catch, when no other route matches /users/(.*)</div>
<div al-route:catch="/users/info/.*">info</div>  <!-- similar to props -->

First /users/info/.* would be processed, afterwards /users/.*.
Why? Because /users/info/.* are three segments ['users', 'info', '.*'] and /users/.* are only two segments ['users', '.*']

We need to sort segments by length and we need to resolve position of all dynamic segments (variables like .* or :id).

What is your Skype? (mine: lega911), it will be easier ;)

Talking wouldn't be that easy for me, because i need some time to think about what the best approach would be. If it is ok for you we can chat, but then we also could use the git chat application that you provided in another issue. :-)

@lega911
Copy link
Owner Author

lega911 commented Feb 24, 2016

Talking wouldn't be that easy for me

I meant for chatting, it seems no one visits gitter

First /users/info/.* would be processed, afterwards /users/.*.

Ok, I see logic, but using the order of routes is easier, because you don't need to think of "static defined", count of segments etc.

More important - how can you do this:

For url="/users/root", result DOM: (It's Important case - two blocks are visible.)

<div al-route="/users/root"></div>
<div al-route="/users/:id"></div>  <!-- Double of route -->

These two blocks should be visible together for url "/users/root".
ngRoute has died because it had no this feauter, it had only one ngView

@dev-rke
Copy link
Contributor

dev-rke commented Feb 26, 2016

There are problems when adding a Route using JavaScript. So you need to sort the routes before processing them or it wont work.

To your second question: i see no case when two routes should be visible. There is exactly one visible DOM segment.

@lega911
Copy link
Owner Author

lega911 commented Feb 26, 2016

To your second question: i see no case when two routes should be visible. There is exactly one visible DOM segment.

No, it exactly why ngRouter is dead, there are a lot of cases.
When you change url - top menu should be changed, left menu, body and footer. For this case you need use 4 similar routes, and they should be visible together.

@dev-rke
Copy link
Contributor

dev-rke commented Feb 27, 2016

Wouldn't it be more flexible to apply al-if instead of al-route?
E.g.:

<div al-if="$route.is('/users/:id')"></div>

But yes, i understand your case.

@lega911
Copy link
Owner Author

lega911 commented Feb 28, 2016

Wouldn't it be more flexible

It's not easy to implement "confirm on exit" for this.
Also it is fired on every scan loop while al-route is working on url changing only (a better berformance).

I've also added al-route-out2 - it is fired on url chaning,
al-route-out is fired when you leave a "group"/route.

@dev-rke
Copy link
Contributor

dev-rke commented Feb 28, 2016

Wouldnt it be better to implement custom events?

<div @al.route.out="left()"></div>

@lega911
Copy link
Owner Author

lega911 commented Feb 28, 2016

It's good idea, I'll try it

<div @route-out="confirmToOut($url)"></div>

What about al-route and al-route:catch? Need good names for them.

@dev-rke
Copy link
Contributor

dev-rke commented Feb 28, 2016

<div @route-out="confirmToOut($url)"></div>

I'd recommend to prefix framework specific events.
It's easier to understand what the code is about.

What about al-route and al-route:catch? Need good names for them.

The problem is, it should not do a segment less catchall only (e.g. catching / for 404).
It only catches a specific route (e.g. to catch /users without parameters).
I accept al-route:catch.

We also need to discuss al-link vs. using the href attribute.
Would it be possible to enable href attributes using a config flag or by defining an empty al-link attribute?

@lega911
Copy link
Owner Author

lega911 commented Feb 28, 2016

Would it be possible to enable href attributes using a config flag or by defining an empty al-link attribute?

yes

it should not do a segment less catchall only (e.g. catching / for 404).

Do you mean, al-route:catch="/" should catch all "/.*"?

@dev-rke
Copy link
Contributor

dev-rke commented Feb 29, 2016

Do you mean, al-route:catch="/" should catch all "/.*"?

All, except already defined routes.
We do not need to define variable segments using .*, because it is a "catcher", it has to catch all urls that do not match any defined route.
The good thing is, that we do not need to process .* in any url.
We can always force the user to define a variable name, e.g. "/:id" or "/:anything".

@dev-rke
Copy link
Contributor

dev-rke commented Mar 6, 2016

I'd like to push on this, because it will be a great feature.
It is also ok when the first implementation hasn't a final API, because we can introduce this as not stable feature.
The API get's better and better when we can use the unstable API for development and test purposes,
this will show up which other feature are required for productive usage.

Do you need any further information to implement this?
Or do you like to focus on other features?
Then i would implement a quick proposal.

@lega911
Copy link
Owner Author

lega911 commented Mar 6, 2016

I will append it to package "ext"

@dev-rke
Copy link
Contributor

dev-rke commented Mar 6, 2016

Where will it be found? In the regular repository?

@lega911
Copy link
Owner Author

lega911 commented Mar 7, 2016

In the regular repository?

Yes

@dev-rke
Copy link
Contributor

dev-rke commented Mar 22, 2016

Is it ready? I'd like to play with it. :-)

@dev-rke
Copy link
Contributor

dev-rke commented Apr 2, 2016

Great to have you back. :-)
Is it contained in the bower package?
I'll give it a try tomorrow :-)

@lega911
Copy link
Owner Author

lega911 commented Apr 3, 2016

Is it contained in the bower package?

Not yet, but it will be there in next version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants