Prefixing routes with locale in Symfony2 - internationalization

Here is my setup, a bit changed standard edition.
# app/config/routing.yml
_internal:
resource: "#AcmeDemoBundle/Controller/"
prefix: /{_locale}
requirements:
_locale: en|sr
And added /{_locale} in security.yml.
Routes before:
Name Method Pattern
_welcome ANY /
_demo_login ANY /demo/secured/login
_security_check ANY /demo/secured/login_check
_demo_logout ANY /demo/secured/logout
acme_demo_secured_hello ANY /demo/secured/hello
_demo_secured_hello ANY /demo/secured/hello/{name}
_demo_secured_hello_admin ANY /demo/secured/hello/admin/{name}
_demo ANY /demo/
_demo_hello ANY /demo/hello/{name}
_demo_contact ANY /demo/contact
_wdt ANY /_wdt/{token}
_profiler_search ANY /_profiler/search
_profiler_purge ANY /_profiler/purge
_profiler_import ANY /_profiler/import
_profiler_export ANY /_profiler/export/{token}.txt
_profiler_search_results ANY /_profiler/{token}/search/results
_profiler ANY /_profiler/{token}
_configurator_home ANY /_configurator/
_configurator_step ANY /_configurator/step/{index}
_configurator_final ANY /_configurator/final
Routes after:
Name Method Pattern
_welcome ANY /
_wdt ANY /_wdt/{token}
_profiler_search ANY /_profiler/search
_profiler_purge ANY /_profiler/purge
_profiler_import ANY /_profiler/import
_profiler_export ANY /_profiler/export/{token}.txt
_profiler_search_results ANY /_profiler/{token}/search/results
_profiler ANY /_profiler/{token}
_configurator_home ANY /_configurator/
_configurator_step ANY /_configurator/step/{index}
_configurator_final ANY /_configurator/final
_demo_login ANY /{_locale}/demo/secured/login
_security_check ANY /{_locale}/demo/secured/login_check
_demo_logout ANY /{_locale}/demo/secured/logout
acme_demo_secured_hello ANY /{_locale}/demo/secured/hello
_demo_secured_hello ANY /{_locale}/demo/secured/hello/{name}
_demo_secured_hello_admin ANY /{_locale}/demo/secured/hello/admin/{name}
_demo ANY /{_locale}/
_demo_hello ANY /{_locale}/hello/{name}
_demo_contact ANY /{_locale}/contact
Which ofc leads to No route found for "GET /en/demo/hello/World" for /en/demo/hello/World url.
Any idea how to fix this?
Additionally, I would like to implement per domain locale. I was trying https://github.com/schmittjoh/JMSI18nRoutingBundle, but for some reason it does not work with latest Symfony 2.0.9, at least for me. I was following the doc, but I got similar 404 error when trying prefixed urls.

Defining default values and requirements for placeholders in prefix is not possible in Symfony version 2.0.9. You'd have to upgrade to 2.1, which is currently in active development.

Related

Ruby Hash and Tumblr API

controller page, Json output from api
I'm trying to display posts from the users tumblr account on my view page using ruby. I have never done anything with api's before. I'm trying to use Hash tables. my controller code is as such:
#Posts = client.posts"zombieprocess1.tumblr.com"
on my view page using html I have
<%=Posts%>
the response is such
{"blog"=>{"title"=>"Untitled", "name"=>"zombieprocess1", "total_posts"=>1, "posts"=>1, "url"=>"URL", "updated"=>1478191052, "description"=>"", "is_nsfw"=>false, "ask"=>false, "ask_page_title"=>"Ask me anything", "ask_anon"=>false, "followed"=>false, "can_send_fan_mail"=>true, "is_blocked_from_primary"=>false, "share_likes"=>true, "likes"=>1, "twitter_enabled"=>false, "twitter_send"=>false, "facebook_opengraph_enabled"=>"N", "tweet"=>"N", "facebook"=>"N", "followers"=>0, "primary"=>true, "admin"=>true, "messages"=>0, "queue"=>0, "drafts"=>0, "type"=>"public", "reply_conditions"=>3, "subscribed"=>false, "can_subscribe"=>false}, "posts"=>[{"blog_name"=>"zombieprocess1", "id"=>152689921093, "post_url"=>"URL", "slug"=>"", "type"=>"photo", "date"=>"2016-11-03 16:37:32 GMT", "timestamp"=>1478191052, "state"=>"published", "format"=>"html", "reblog_key"=>"NCDqGTzW", "tags"=>[], "short_url"=>"URL", "summary"=>"", "recommended_source"=>nil, "recommended_color"=>nil, "followed"=>false, "liked"=>true, "note_count"=>1, "caption"=>"", "reblog"=>{"tree_html"=>"", "comment"=>""}, "trail"=>[], "image_permalink"=>"url", "photos"=>[{"caption"=>"", "alt_sizes"=>[{"url"=>"URL", "width"=>400, "height"=>544}, {"url"=>"URL", "width"=>250, "height"=>340}, {"url"=>"URL", "width"=>100, "height"=>136}, {"url"=>"URL", "width"=>75, "height"=>75}], "original_size"=>{"url"=>"URL", "width"=>400, "height"=>544}}], "can_like"=>false, "can_reblog"=>true, "can_send_in_message"=>true, "can_reply"=>true, "display_avatar"=>true}], "total_posts"=>1}
I have tried many different formats and can't seem to just get the post url. My thought is to get the post_url and embed each of them so it shows as it would in tumblr on my webpage. Can anyone help me?
Try this:
#posts['posts'].first['post_url']
Or if your response contains more than one post you can return them all like this:
(0...#posts['total_posts']).map { |i| #posts['posts'][i]['post_url'] }
EDIT: Fixed capitalization in second line of code. I assume you are using lowercase variable as per Ruby convention, '#posts'. If not, you should change to a lowercase variable as this may be confusing something.

Codeigniter Routing with HMVC not working

I'm using Codeigniter with HMVC, I Have a sub controller with a name differed from Module name
- modules
- manage
- controllers
- manage.php
- views
- dashboard.php
- properties
- controllers
- properties.php
- manage.php
- views
- properties.php
- manage.php
- projects
- controllers
- projects.php
- manage.php
- views
- projects.php
- manage.php
if the url like this (index only working)
sitename.com/manage/proprties
this working fine, but if I passed some parameters,( Error 404)
sitename.com/manage/properties/add
OR
sitename.com/manage/properties/edit/10
My Routing like this
$route['manage/(:any)'] ="$1/manage";
$route['manage/(:any)/(:any)'] ="$1/manage/$2";
$route['manage/(:any)/(:any)/(:num)'] ="$1/manage/$2/$3";
How to make URL sitename.com/manage/properties/edit/10 working?
In routes you have wrong. Depending on your version of codeigniter.
https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc
Examples:
$route['default_controller'] =" folder/controller/index"; // Only works codeigniter 2 so far codeigniter 3 will not allow is bug in codeigniter 3
$route['name'] =" folder/controller/index"; // Example
$route['manage'] =" manage/manage/index";
$route['manage/add'] =" manage/manage/add";
$route['manage/update/(:any)'] =" manage/manage/update/$1"; // (:any) sbsu2783
$route['manage/update/(:num)'] =" manage/manage/update/$1"; // (:num) 2783
$route['manage/update/(:any)/(:any)'] =" manage/manage/update/$1/$2"; // Just example
$route['manage/delete'] =" manage/manage/delete";
$route['manage/(:any)'] =" manage/manage/index/$1/$2"; // Not need most of the time
sitename.com/manage/edit/10
You may need to include the index.php or may not as not sure if you have configured your htaccess.
For example on controller site_url('manage/update') .'/'. $this->uri->segment(4);
If you are using HMVC then for calling function of Inner Controller does not require any routing. Just configure it correctly.
Second. name of your module and controller both are same. so when
you call
localhost/manage it redirects it to manage/manage/index by default but when you call
localhost/manage/update it try to find controller named update. so call like this
localhost/manage/manage/update

Whitelisting all the Google JDBC Service IP addresses in CPanel

I am trying to connect a Google Docs extension to a MySQL database via JDBC Service. The MySQL database is running on a shared server that requires using CPanel. CPanel only lets me add one whitelist rule at a time, and I can only use the % wildcard character (which matches to 0 or more of any type of character). I wrote a script to generate rules in this format from the IP address ranges, but there are more than 300 of them. I'm trying to find an easier way to do this.
Is there a domain name for the Google JDBC Service that I can whitelist instead of the IP address ranges? Does CPanel have a more efficient whitelisting mechanism that I'm not aware of? Is there a program that could automate filling out CPanel's webform with my whitelist?
Here is the CPanel-formatted whitelist I generated, in case someone with the same problem finds my question.
64.18.0.%
64.18.1.%
64.18.2.%
64.18.3.%
64.18.4.%
64.18.5.%
64.18.6.%
64.18.7.%
64.18.8.%
64.18.9.%
64.18.10.%
64.18.11.%
64.18.12.%
64.18.13.%
64.18.14.%
64.233.160.%
64.233.161.%
64.233.162.%
64.233.163.%
64.233.164.%
64.233.165.%
64.233.166.%
64.233.167.%
64.233.168.%
64.233.169.%
64.233.170.%
64.233.171.%
64.233.172.%
64.233.173.%
64.233.174.%
64.233.175.%
64.233.176.%
64.233.177.%
64.233.178.%
64.233.179.%
64.233.180.%
64.233.181.%
64.233.182.%
64.233.183.%
64.233.184.%
64.233.185.%
64.233.186.%
64.233.187.%
64.233.188.%
64.233.189.%
64.233.190.%
66.102.0.%
66.102.1.%
66.102.2.%
66.102.3.%
66.102.4.%
66.102.5.%
66.102.6.%
66.102.7.%
66.102.8.%
66.102.9.%
66.102.10.%
66.102.11.%
66.102.12.%
66.102.13.%
66.102.14.%
66.249.80.%
66.249.81.%
66.249.82.%
66.249.83.%
66.249.84.%
66.249.85.%
66.249.86.%
66.249.87.%
66.249.88.%
66.249.89.%
66.249.90.%
66.249.91.%
66.249.92.%
66.249.93.%
66.249.94.%
72.14.192.%
72.14.193.%
72.14.194.%
72.14.195.%
72.14.196.%
72.14.197.%
72.14.198.%
72.14.199.%
72.14.200.%
72.14.201.%
72.14.202.%
72.14.203.%
72.14.204.%
72.14.205.%
72.14.206.%
72.14.207.%
72.14.208.%
72.14.209.%
72.14.210.%
72.14.211.%
72.14.212.%
72.14.213.%
72.14.214.%
72.14.215.%
72.14.216.%
72.14.217.%
72.14.218.%
72.14.219.%
72.14.220.%
72.14.221.%
72.14.222.%
72.14.223.%
72.14.224.%
72.14.225.%
72.14.226.%
72.14.227.%
72.14.228.%
72.14.229.%
72.14.230.%
72.14.231.%
72.14.232.%
72.14.233.%
72.14.234.%
72.14.235.%
72.14.236.%
72.14.237.%
72.14.238.%
72.14.239.%
72.14.240.%
72.14.241.%
72.14.242.%
72.14.243.%
72.14.244.%
72.14.245.%
72.14.246.%
72.14.247.%
72.14.248.%
72.14.249.%
72.14.250.%
72.14.251.%
72.14.252.%
72.14.253.%
72.14.254.%
74.125.%
173.194.%
207.126.144.%
207.126.145.%
207.126.146.%
207.126.147.%
207.126.148.%
207.126.149.%
207.126.150.%
207.126.151.%
207.126.152.%
207.126.153.%
207.126.154.%
207.126.155.%
207.126.156.%
207.126.157.%
207.126.158.%
209.85.128.%
209.85.129.%
209.85.130.%
209.85.131.%
209.85.132.%
209.85.133.%
209.85.134.%
209.85.135.%
209.85.136.%
209.85.137.%
209.85.138.%
209.85.139.%
209.85.140.%
209.85.141.%
209.85.142.%
209.85.143.%
209.85.144.%
209.85.145.%
209.85.146.%
209.85.147.%
209.85.148.%
209.85.149.%
209.85.150.%
209.85.151.%
209.85.152.%
209.85.153.%
209.85.154.%
209.85.155.%
209.85.156.%
209.85.157.%
209.85.158.%
209.85.159.%
209.85.160.%
209.85.161.%
209.85.162.%
209.85.163.%
209.85.164.%
209.85.165.%
209.85.166.%
209.85.167.%
209.85.168.%
209.85.169.%
209.85.170.%
209.85.171.%
209.85.172.%
209.85.173.%
209.85.174.%
209.85.175.%
209.85.176.%
209.85.177.%
209.85.178.%
209.85.179.%
209.85.180.%
209.85.181.%
209.85.182.%
209.85.183.%
209.85.184.%
209.85.185.%
209.85.186.%
209.85.187.%
209.85.188.%
209.85.189.%
209.85.190.%
209.85.191.%
209.85.192.%
209.85.193.%
209.85.194.%
209.85.195.%
209.85.196.%
209.85.197.%
209.85.198.%
209.85.199.%
209.85.200.%
209.85.201.%
209.85.202.%
209.85.203.%
209.85.204.%
209.85.205.%
209.85.206.%
209.85.207.%
209.85.208.%
209.85.209.%
209.85.210.%
209.85.211.%
209.85.212.%
209.85.213.%
209.85.214.%
209.85.215.%
209.85.216.%
209.85.217.%
209.85.218.%
209.85.219.%
209.85.220.%
209.85.221.%
209.85.222.%
209.85.223.%
209.85.224.%
209.85.225.%
209.85.226.%
209.85.227.%
209.85.228.%
209.85.229.%
209.85.230.%
209.85.231.%
209.85.232.%
209.85.233.%
209.85.234.%
209.85.235.%
209.85.236.%
209.85.237.%
209.85.238.%
209.85.239.%
209.85.240.%
209.85.241.%
209.85.242.%
209.85.243.%
209.85.244.%
209.85.245.%
209.85.246.%
209.85.247.%
209.85.248.%
209.85.249.%
209.85.250.%
209.85.251.%
209.85.252.%
209.85.253.%
209.85.254.%
216.239.32.%
216.239.33.%
216.239.34.%
216.239.35.%
216.239.36.%
216.239.37.%
216.239.38.%
216.239.39.%
216.239.40.%
216.239.41.%
216.239.42.%
216.239.43.%
216.239.44.%
216.239.45.%
216.239.46.%
216.239.47.%
216.239.48.%
216.239.49.%
216.239.50.%
216.239.51.%
216.239.52.%
216.239.53.%
216.239.54.%
216.239.55.%
216.239.56.%
216.239.57.%
216.239.58.%
216.239.59.%
216.239.60.%
216.239.61.%
216.239.62.%
Oday,
Your suggestion won't work as the IP ranges aren't all inclusive. Here is the list that Google says to whitelist.
As an example...how do I white list 64.18.0.x to 64.18.15.x
I should have looked harder in stackoverflow. For others that stumble upon this post, here is the answer that I found at
Whitelist IP addresses ranges using cPanel
64.18.0-15.%
64.233.160-191.%
64.102.0-15.%
66.249.80-95.%
72.14.192-255.%
74.125.%
173.194.%
207.126.144-159.%
209.85.128-255.%
216.239.32-63.%
This is long overdue, but the easiest solution is to use the % wildcard like this to make it easier:
64.18.%.%
64.233.%.%
66.102.%.%
...etc

What are all the tld's recognized by NSDataDetector?

When testing Cocoa data detector I found that forecast.io isn't picked up but www.forecast.io and forecast.com are.
What are all the top level domains found by NSDataDetector without prefixing them with www.?
I wrote about how to pick an Apple friendly TLD and my findings are recounted below.
I just took the text file from ICANN and prepended all the extensions with 'example.' and the only ones detected at least in my locale(US) were these:
Uppercase:
example.com
example.EDU
example.EU
example.GOV
example.LY
example.NET
example.ORG
Lowercase:
example.ar
example.at
example.au
example.be
example.br
example.ca
example.ch
example.cn
example.de
example.dk
example.edu
example.es
example.eu
example.fi
example.fr
example.gov
example.gr
example.hk
example.hu
example.il
example.is
example.it
example.jp
example.kr
example.lu
example.ly
example.ma
example.mx
example.net
example.nl
example.no
example.nz
example.org
example.pt
example.ru
example.se
example.sg
example.th
example.tn
example.tr
example.tw
example.ua
example.uk
example.us
From my own testing, it looks like anything with www. on the front will be detected.
As an update to Steve's answer, here are the lowercased tld's that were detected for me, as of Nov 1, 2016:
example.ar
example.at
example.au
example.cc
example.ch
example.cn
example.co
example.com
example.de
example.dk
example.edu
example.es
example.eu
example.fi
example.fm
example.fr
example.gov
example.gr
example.hk
example.hr
example.hu
example.ie
example.il
example.info
example.io
example.is
example.it
example.kr
example.lu
example.ly
example.ma
example.me
example.mx
example.net
example.nl
example.no
example.nz
example.org
example.pt
example.pw
example.rs
example.ru
example.se
example.sg
example.si
example.th
example.tn
example.tr
example.tw
example.ua
example.uk
example.us

web services calling error in flex

When i call web services, i got below mentioned error
[FaultEvent fault=[RPC Fault faultString="Error #1098: Illegal prefix ns0 for no namespace." faultCode="EncodingError" faultDetail="null"] messageId=null type="fault" bubbles=false cancelable=true eventPhase=2]
<mx:WebService id="myWebService1" wsdl="URL">
<mx:operation name="loginservice" result="getMonths_result(event);" fault="getMonths_fault(event);">
</mx:operation>
</mx:WebService>
I know nothing about flex4 but it seems that there is a XML document somewere wich has prefixed elements (<ns0:Element>) but it has not a defined namespace (xmlns:ns0 = "URI").
OR
There is not an URI in the namespace definition (xmlns:ns0 = "")

Resources