Rails 3. Cannot validate URLs for http prefix - validation

I am developing an application in Rails 3 and in this application I let the users add URLs to websites. The current problem I am facing is that some of the users forget to include the http or https prefixes which results in a non working link.
Unfortunately there seems to be no way to validate this out of the box?
How can I go about to validate if the submitted URL includes http?
Thankful for all help!

There is a plugin named validates_url_format_of that seems to work for Rails 3. Otherwise you can write your own custom validator.

Related

Does the Pinterest validator work?

I'm trying to embed rich pins to our website. I used Schema.org for Product. While Google validates correctly the page, when I m trying the Pinterest validator I'm always getting the following error:
The data we scraped from your site could not be validated. Please make sure all required tags are present and you aren't serving different pages depending on different user agents.
Anybody had the same experience and somehow managed to solve this?
For me the answer was quite simply to use "http://www.example.com" instead of "http://example.com"
That was it. Didn't need to change anything else.
So I notice you're also using:
https://sealsmile.com/products/search?keyphrase=smart&category=&resultType=product
try using:
https://www.sealsmile.com/products/search?keyphrase=smart&category=&resultType=product

Ubuntu Nginx 403 error when posting form data including <iframe>

I have a Ubuntu Nginx server (using laravel forge to set it up)
I am now getting 403 errors when posting form data including which I was not getting previously.
The form is posted by a javascript button $('#my-form').submit(); if this is relevant.
Other forms are working fine as long as I remove the tags (used for youtube embedding)
Open up developer console and see more details about the POST request in network tab or console itself. 4XX is a group for client errors, not server or runtime, so expect the issue to be in your implementation. Maybe you use some package that is supposed to "automagically" authenticate or check user permissions when accepting this specific request, and so it fails because you are not passing some header or custom field? Hard to tell without more details.
Add relevant code (at very least your form html) if you want more specific tips.
In this case - I also had a wordpress blog installed with a wordfence plugin operating. The wordfence configuration was enforcing security settings which were preventing any website forms from posting and tags

Customized look on first login

I'm working on a java Spring webapp. There is requirement that each user will have possibility to customize the webapp look & feel. I'd like if the user will see the customized look, even on his first login. How would you do that?
My ideas are for the time being
multiple contexts(per customer), but it is not dynamic
send user a link with some attribute, then set the custom info to cookies
in Spring I can possibly create some path variable (#RequestMapping(value = "/{customerId}/login"))
just create universal login page, which will be not customizable
How would you achieve that?
If you want to offer customized looks to every user, you can use use Portlets. Spring also supports Portlet development.
You can give separate URLs to each user, could be using sub-domain or url parameters. Then fetch the request URL in your handling page to deliver specific look-n-feel.
You could also try to explore GrooveUI, which is a third party tool that allows you to define website theme based on access URL.

Passing get variables to index page in codeigniter

I am creating a social networking web application using codeigniter. The web application has features similar to facebook pages. I need to accomplish something which seems to be impossible. Since codeigniter recognizes controllers and functions based on the URL order, I am unable to directly pass an argument to the controller index function. I am trying to access a page as "www.mywebsite.com/page/CodeIgniter" where 'CodeIgniter' will be the page name which the 'page' controller will accept it as an argument and accordingly parse the page. Since codeigniter parses url as "www.mywebsite.com/{controller}/{function}", I am unable to link to a page as how we do in facebook. Could anyone help me out on how to overcome this issue.
Using routes should solve this issue;
config/routes.php
$route['page/(\w+)'] = 'page/index/$1';
This example is simple, but do note that it will "hijack" most other calls which have only 2 segments.
If you got a few values which you will pass, do consider something such as:
$route['page/(CodeIgniter|Drupal|Joomla)'] = 'page/index/$1';
Or a preffix:
$route['page/cms_(\w+)'] = 'page/index/$1';
And have the url domain.com/page/cms_CodeIgniter instead.

Sina Weibo API callback problem

Has anyone here been able to connect to the Sina Weibo API?
I hit a brick wall when it comes to the callback URL.
I seems it will only allow a root folder as URL
so www.example.com works but www.example.com/sina doesn't
anyone knows a work around?
thanks
In case anyone has the same problem, you have probably entered the URL under the "security" heading rather than the Authorization settings heading (at the top) on the developer settings page). The URL it is asking for in the security section is a base url with which the application can be used (hence why it only takes .com domains) whereas the one above can take any format that you want your callback url to be.
Hope that helps, the settings page in question is here:
http://open.weibo.com/apps/yourappid/info/advanced (replacing the your app id as appropriate)
Do you mean Sina OAuth callback page? Your callback URL should be URL encoded according to the API document. Maybe that's your problem.
I m using PHP libweibo http://code.google.com/p/libweibo/
i m succesfully implement that script demo.
i m facing that problem too.
if youare using oauth2.0,
you need to make sure that your callback FILE exactly same as callback URL in weibo apps page.

Resources