routing

Expression Language in conditional routing - service in context

送分小仙女□ 提交于 2019-12-06 16:17:58
According to docs , there are only two things available by default, while using expression language in conditional routes - context and request . I would like to use foo service with boolean bar() method to determine condition. How to inject foo service into this condition? So far I've tried: some_route: path: /xyz defaults: {_controller: "SomeController"} condition: "service('foo').bar()" and some_route: path: /xyz defaults: {_controller: "SomeController"} condition: "service('foo').bar() === true" but all I get is: The function "service" does not exist around position 1. P.s.: I'm using

CakePHP routing in pages controller

放肆的年华 提交于 2019-12-06 16:10:09
问题 I am creating a site with CakePHP, and I need to set some URLs for static pages, which are handled by the pages controller. Basically I want to have two different types of static pages, with the URLS mysyte.com/page which should map to app/views/pages/page.ctp and mysite.com/special/page which should map to app/views/pages/special-page.ctp . Note that in the first case page can be 'special' as well. I am a bit lost with the routing I have to set up for this situation. I have tried to use the

Reactivesearch - search from any route

泄露秘密 提交于 2019-12-06 16:08:34
I'm experimenting with ReactiveSearch and using the ReactiveList component. I'm trying to figure out how I can navigate though my React app and still be able to search. Say I'm on the home route '/' , use DataSearch component for autocomplete and that takes me to the results page '/results but I don't get any results!! In order to get results, I have to search and stay on the '/results' page. Is there a prop that I'm missing on my DataSearch component in the Header: <DataSearch componentId="SearchSensor" dataField={["original_title"]} className="search-bar" showIcon={true} iconPosition="right"

Old Classic ASP pages getting caught in MVC Route

允我心安 提交于 2019-12-06 15:56:45
I am converting an existing classic ASP website to (VB) MVC and I don't want any of the existing URLs to break. I have read many posts (like this one: Routing Classic ASP Requests To .NET - SEO Redirects ) about how to do the proper 301 redirect. With the latest MVC release, I've gathered that Response.RedirectPermanent(objRedirect.new_url, True) is all that is needed. I have entered all of my old URLs in a database table with a corresponding column of the new URL. I have added code in my custom 404 page to get the original URL: Dim strURL As String = Request.RawUrl.Substring(Request.RawUrl

Linux C: How to know the default interface for internet access?

拥有回忆 提交于 2019-12-06 15:53:46
I want to find out the default network in use. My current method was to find all IP addresses and compare it to the default gateway IP address, but that sounds silly. What is the correct way of doing it ? UPDATE I want to use a C program, not by commands ... You can try a slightly dirtier but infinitely easier approach: cnicutar@lemon:~$ ip route show to 0.0.0.0/0 default via X.Y.Z.T dev eth0 proto static ^^^^ So you can try: FILE *cmd = popen("ip route show", "r"); fgets(str, LEN, cmd); Then you can use strtok , strstr etc. 来源: https://stackoverflow.com/questions/10513673/linux-c-how-to-know

Phalcon PHP: Modify a request URL before it gets dispatched

倾然丶 夕夏残阳落幕 提交于 2019-12-06 15:50:31
I'm looking for a way to modify a request URL before it gets dispatched. For instance, the following URLs should be handled by the same controller/action: /en/paris /de/paris /paris I would like to capture the country code if it is present, then rewrite the URL without it so that controllers don't have to deal with it. I tried the 'dispatch:beforeDispatchLoop' event but it doesn't seam to be designed for that. Any idea? If you can convention that all country code comes first in the path, perhaps an additional rewrite rule can help you: <IfModule mod_rewrite.c> RewriteCond %{REQUEST_FILENAME} !

Different routes but using the same controller for model subclasses in Rails

一曲冷凌霜 提交于 2019-12-06 15:22:55
I have a Model Property which has subclasses using STI, and which I would like all to use the same controller with only different view partials depending on the subclass. Property Restaurant < Property Landmark < Property It works find except I'm not sure how to discern the subclass inside the controller to render the correct view. Ie. /restaurants works and goes to the properties controller but I can't tell that they want the Restaurant subclass? map.resources :restaurant, :controller => :properties map.resources :properties Tomas Markauskas A simple way to fi the problem would be to create a

Ho do I change the base path of routes in CakePHP?

依然范特西╮ 提交于 2019-12-06 15:00:29
问题 I'm using CakePHP to produce a Facebook application (though the problem is not Facebook specific). As usual, I'm struggling to get the reverse routing to work properly. Previously I've abandoned the routing functionality, but this time I'd really like to make it work. The problem is basically that Cake produces URLs relative to the base of the host server, but we need URLs relative to the Facebook canvas page. So, when I type: echo $html->link(__('New Question', true), array('action'=>'add'))

After searching once not able to search again

為{幸葍}努か 提交于 2019-12-06 14:54:39
问题 File Structure: I have a input textbox , there i type something and pass that value to a function named onRecievingResults() and pass that value to another component using params and make http request and i get the results if i search again i am not able to get the results. faq.component.ts onRecievingResults() { this.router.navigate(['results', this.inputValue], {relativeTo: this.route}); } search-results.component.ts export class SearchResultsComponent implements OnInit { data: any[]; item:

best way to transfer data from flask to d3

[亡魂溺海] 提交于 2019-12-06 14:23:27
问题 I have csv tables, processed in Pandas, that I would like to serve from Flask to the browser so that I can use d3 to display the information. How do I transfer the data from Flask to the browser? 回答1: Use the to_csv method of the Pandas dataframe, and return that from your flask server: # app.py @app.route('/my/data/entpoint') def get_d3_data(): df = pandas.DataFrame(...) # Constructed however you need it return df.to_csv() Then on the front end, direct d3.tsv to your endpoint above: <!--