Play Framework 2.4 routing: one route for multiple urls Scala - scala

I have admin part in my project which use React.js and React router.
And I need to render the same view on each request which starts with /admin in case user hit Refresh or come straight to url.
I don't need to pass any parameters to view. How can it be done?

You can define your route like this in play:
/admin/*url controllers.Application.admin(url)

Related

Angular4 - Change state from component not template

In AngularJS I used ui-router for redirecting inside of my app(changing state).
It has 2 possible options to redirect
In template ui-sref='stateName'
In controller $state.go()
I just start play with Angular (4) and I found only way how to change route from template with something like:
Template routerLink="routePath"
Is there some way as there was in ui-router to change route from component?
constructor(private router:Router) {}
changeRoute() {
this.router.navigate(...)
// this.router.navigateByUrl(...)
}
See also https://angular.io/docs/ts/latest/api/router/index/Router-class.html
you can navigate via router like this
router.navigate([URL])
or like this
router.navigateByUrl('whole_string_containing_full_path')
Here router is an instance created in constructor, which is imported from router firstly, basically there is no difference between these two
First one accept array where as second one accept url in the form of string.

FlowRouter Reload Doesn't Route

I'm using FlowRouter. If I start on the homepage everything works well. I can work through the routes (change the pages) without problem. However, if I hit refresh in the browser, I get a series of errors. My url looks like this:
/story/586d536e34821281735b53a4
The ID is being returned in console under the following method:
Tracker.nonreactive(function(){
I think the subscription is being completed, so I'm a little confused as to why reloading a url is different than loading from the home page.
What am I not understanding here?
Reloading a url will make a HTTP request to server to get all the application source. Whereas navigating to a route from another one does not make any HTTP requests to get the application source because they are already available (they were loaded from the previous route), in this case the router will just get the appropriate content and render on the page. This is normal behaviour for Meteor apps and all other single-page apps
The error you encounter is because your data is not yet available on client, to fix it you could simple use a placeholder if the value is undefined.

SailsJs and custom route conflict

I've developed a URL shortener for using internally using SailsJS. Everything is as expected but the issue is with custom route. I've written route this way
'/': "HomeController.index",
'/login/fb': "UsersController.FBlogin",
'/login/ggl': "UsersController.GGLlogin",
'/logout': "UsersController.logout",
'/*': "sController.redirect"
Now the issue is domain/min/production.min.css is being affected for the last route.
How I can disable that routing for assets?
Thanks
you have to set skipAssets: true for the last route
http://sailsjs.org/documentation/concepts/routes/custom-routes and go to paragraph of route-target-options , unfortunately can't link it directly.

ZF2 main router in console

How can I use the url() controller helper inside the console?
I have to generate some urls using an action of the console, but if I call $this->controller->url()->fromRoute(...);, I can only ask for routes defined in the console router.
In other words, I need the ability to call all the routes of the application's main router.
Thanks
I'm not sure, that it is a good decision, but you can change router manually:
// ConsoleController.php
// Change router to HTTP
$this->getEvent()->setRouter($this->getServiceLocator()->get('HttpRouter'));
// Get any HTTP route
var_dump($this->url()->fromRoute('your_http_route'));
// Change it back, if you want
$this->getEvent()->setRouter($this->getServiceLocator()->get('Router'));

Zend framework - duplication in translated url

I have these URLs
cz/kontroler/akce
en/controller/action
Is used transatable route and works it like charm. But problem is, that when you will write
cz/controller/akce
it works as well.
In generally when you have
cz/something-in-czech
en/something-in-english
which route to someController, will be works still
cz/some
en/some
because it is really name of controller.
How solve this duplicity content issue?
You can create a plugin that uses a preDispatch method. Before the request is executed, you can analyze the url requested and check if the requested language match the language of the params in the url (I mean controller and action). If not, you can redirect the user to the url that is in accord to the given language (basically you'll translate the controller and the action and then redirect the user to the right url).