Using AJAX, How to Make Your Site Crawlable

AJAX_Crawler-image

Why Ajax?

AJAX is used to load the contents into the page faster with providing a superior user experience. It happens so as the data exchanges with a server and the web page reflects the changed data without reloading. So AJAX is gaining popularity among the developers.

Problems with AJAX usage:

However, it has its own limitation for not allowing Google and other search engines to crawl an AJAX based website. As a result of which AJAX can damage the SEO of the site, because the browser address bar does not change with AJAX load. You need to generate SEO friendly URL dynamically.

Solution:

Here I discuss how to balance out both AJAX as well as SEO. That means, the site can still be crawlable with AJAX on.

Step-1: Load the AJAX content with the change in browser address bar:

  • We need to manage the address bar using client side code and add ‘#’ at the end of the URL, before the AJAX page name or parameters.
  1. If about-us page loads in AJAX, the URL will be: https://www.mysite.com/#about-us
  2. NOTE: the hash fragments are never sent to server
  • After refreshing the page, we can get the hash fragments using client side code and avail the AJAX contents

Step2: Change the URL format to crawl by the crawlers

  • ‘Googlebot’ still cannot crawl the content of ‘about-us’ page, because the crawler cannot get the content using client side scripting.
  1. Solution: it can be solved by adding an  ‘!’ after ‘#
  2. Example: https://www.mysite.com/#!about-us
  • The hash fragment (#!) works as a signal to Googlebot, to use an alternative URL (Ugly URL) for creating a snapshot of the page including the AJAX-loaded contents.

Step3: Avail the AJAX content to the crawler

  • Pretty URL: The URLs loaded on the client browser that loads dynamic content.
  1. Example: https://www.mysite.com/#!about-us
  • Ugly URL: The alternate URLs of Pretty URLs which is used by ‘Googlebot’ to get the content of the page “? _escaped_fragment_=” in place of “”#!”
  1. Example: https://www.mysite.com/?_escaped_fragment_=about-us
  • Important: There should be same page or content while accessing both the URLs.

Step4: Avail the crawlable URL format

  • Always have the Pretty URL (URL with “#!“) link on all <a href> attribute to load the AJAX content.
  • Add Pretty URLs to the XML sitemap.

How it works?

  • ‘Googlebot’ spider finds the Pretty URL “https://www.mysite.com/#!about-us” from the sitemap or from the webpage.
  • It would fetch the Pretty URL as “https://www.mysite.com/?_escaped_fragment_=about-us
  • The indexer sorts every word and stores the resulting index of words in Google database.
  • The query processor returns Pretty URLs to the user on the search results as  “https://www.mysite.com/#!about-us

Final Tidbits:

  • A URL may contain at most one hash fragment
  • Do not include links such as https://www.mysite.com/?_escaped_fragment_=about-us in the website sitemap; ‘Googlebot’ does not follow links that contain “_escaped_fragment_”
  • When “? _escaped_fragment_=about-us”is activated, you can only provide the “snapshot” of the page.
  • The crawler escapes certain characters in the fragment during the transformation. To retrieve the original fragment, make sure to un-escape all %XX characters in the fragment; specifically, %26 should become &, %20 should become a space, %23 should become #, and %25 should become %, and so on.
  • Test the crawl-ability of your app: see what the crawler sees with https://support.google.com/webmasters/answer/158587?hl=en

An Introduction Of PHP Frameworks Guides For Developers

A framework is a structure that developers choose to build their application. It determines the structure of the application and facilitates it to connect with many different API’s. A proficient PHP framework enables developers to develop PHP application faster, efficiently and assist in building stable applications thereby reducing the amount of repetitive coding for PHP programmers.

Frameworks provide scaffolding features that facilitates the development team to build faster and cleaner application. They often provide tool sets for both the UI components and the database access.

Note: It is advisable to use the latest stable version of a framework.

Never miss an update from us. Join 10,000+ marketers and leaders.

Here are few aspects of a proficient PHP framework:

MVC Architecture:

  • The framework should make use of Model View Controller (MVC) architecture. Some of the best frameworks also provide libraries, plug-ins, helpers, and extensions to assist developers. It would be smart and efficient to employ a framework that has at least two of these options.

Database Support:

  • It is one of the most crucial aspects of every PHP development framework. You need decide your framework depending on the database you are going to use for your web application.

For Example:  ‘CodeIgniter’ supports MySQL, Oracle, and SQLite, whereas the ‘Kohana’ framework doesn’t.

Community & Documentation:

  • The framework should be supported by a strong community, not just in terms of size but also in terms of activity and usefulness. Even if it’s a small community, you should be able to get ample support from the community.

A PHP framework should also have good documentation. It should be comprehensive and up-to-date.

Below, I have provided a list of some popular and commonly used PHP frameworks.

CakePHP 2.x:

  • CakePHP is a rapid development framework for PHP. It’s a foundational structure for programmers to create web applications. CakePHP has an active developer team and community, bringing great value to the project. It is also the most preferred development framework.

        Source:http://book.cakephp.org/2.0/en/index.html

Symfony 2.x:

  • Speed up the creation and maintenance of your PHP web applications. Replace the repetitive coding tasks by power, control and pleasure.

        Source: http://symfony.com/

CodeIgniter 2.x:

  • CodeIgniter is a powerful PHP framework with a very small footprint, built for PHP coders who need a simple and elegant toolkit to create full-featured web applications.

         Source: http://ellislab.com/codeigniter

Zend Framework 2:

  • It is an open source framework for developing web applications and services using PHP 5.3+. Zend Framework 2 uses 100% object-oriented code and utilizes most of the new features of PHP 5.3, namely namespaces, late static binding, lambda functions and closures.
  • Zend Framework 2 evolved from Zend Framework 1, a successful PHP framework with over 15 million.

        Source: http://framework.zend.com

Yii Framework 1.1.x:

  • Yii comes with rich features: MVC, DAO/ActiveRecord, I18N/L10N, caching, authentication and role-based access control, scaffolding, testing, etc. It will reduce your development time significantly.

        Source: http://www.yiiframework.com

Kohana 3.x:

  • An elegant HMVC (Hierarchical model–view–controller) PHP5 framework that provides a rich set of components for building web applications.

        Source: http://kohanaframework.org/

FuelPHP:

  • It is a simple, flexible, community driven PHP 5.3+ framework, based on the best ideas of other frameworks.

        Source: http://fuelphp.com/

There are a number of PHP development frameworks in the market which enables the development team to do more with the programming language. Development frameworks makes coding for PHP more manageable and programmers can take its advantage by making use of a convenient development framework.

Things You Should Know Before Planning Your Mobile App-Part-I

When you are looking at all the popular apps, you too are tempted to have one of your own; however, it can’t be done overnight. It is because; there are thousands of mobile app programmers and companies who may be thinking of doing the very much similar things. To have a successful mobile app it takes lots of hard work and well defined requirements.  You need to think about the main development aspects before planning to go for your mobile app.

Basic Steps You Need to Know For Developing Mobile App:

From our experiences, here are some guidelines you must go through if you are planning to develop a successful mobile app:

  1. The most crucial step is to come up with an innovative idea. Here, you need to make sure that there is little or no competition for it.
  2. Identify your targeted audience and build your app form their perspective, something that is more likely to be appreciated by these users.
  3.  Judge and determine major pain points and challenges that you expect to face for your application. You should hire a dedicated development team who could understand your specific business requirements and turn your ideas into a working app.
  4. Make sure that your app provides good usability and practical values to the users i.e., they should find your app useful and productive.
  5. Your app should have a solid built with no loose ends. Make sure to run a vigorous crash test and beta test phase before actually publishing it. User experience must be intuitive as well as engaging. If you are willing to implement APIs, ensure that it is robust and doesn’t generate any glitches in the application.
  6. After publishing your app to the application stores, you need to start promoting and market your application. One of the best ways to reach a wider audience is by promoting it over social media. Next, you will have to avail as much positive feedback from users as possible.
  7. You should offer constant support to your customers by addressing their comments, expectations and complaints. Then you should release updates and new features for your app to woo your existing customers as well as attracting the attention of new ones.
  8. Offering basic features for free and then selling premium stuff is a popular way to keep users hooked up and to gain traction. Also make sure that the app is noticed and favored by your customer.

iOS application development and Android app development can be easily executed and managed with the help of expertise mobile app developers. Moreover, it is advisable to outsource mobile application development tasks to development companies. Hiring a professional development company would facilitate you to build flawless and unique mobile apps which would greatly leverage revenue.

How to put custom Gradient backgrounds in IOS App

iOS_screenshot-196x300

Introduction:

It is essential to have a unique design for every iPhone application; in order to deliver the most intriguing and compelling interfaces, customization is necessary in every step. A great place to start is to implement your own background and use a clear table view background. Many iOS apps are now following this. Another way is to add a custom background colour. It is as easy as setting the cells background color property.

I tried both the above methods, and still not satisfied with it. There are numerous applications that have pretty similar interfaces. That’s why I thought about putting a gradient view as the background.

Core Graphics is a great resource that helped me in the right direction. It is supposed to customize the background of a cell, but I used it as a basis for my code to draw a gradient.

Here is an example of GradientView

GradientView.h

[sourcecode]#import <UIKit/UIKit.h>
@interface GradientView : UIView
{
}
@end[/sourcecode]

GradientView.m

[sourcecode]#import "GradientView.h"
#import <QuartzCore/QuartzCore.h>
@implementation GradientView
//
// layerClass
//
// returns a CAGradientLayer class as the default layer class for this view
//
+ (Class)layerClass
{
return [CAGradientLayer class];
}
//
// setupGradientLayer
//
// Construct the gradient for either construction method
//
– (void)setupGradientLayer
{
CAGradientLayer *gradientLayer = (CAGradientLayer *)self.layer;
gradientLayer.colors =
[NSArray arrayWithObjects:
(id)[UIColor colorWithRed:0.85 green:0.85 blue:0.85 alpha:0.8].CGColor,(id)[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1].CGColor,
(id)[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1].CGColor,(id)[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1].CGColor,
nil];
self.backgroundColor = [UIColor clearColor];
}
//
// initWithFrame:
//
// Initialise the view.
//
– (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
CAGradientLayer *gradientLayer = (CAGradientLayer *)self.layer;
//gradientLayer.cornerRadius = 10;
gradientLayer.colors =
[NSArray arrayWithObjects:
(id)[UIColor colorWithRed:0.255/255.0 green:0.215/255.0 blue:0.0/255.0 alpha:0.5].CGColor,(id)[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1].CGColor,
(id)[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1].CGColor,(id)[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1].CGColor,(id)[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1].CGColor,
nil];
self.backgroundColor = [UIColor clearColor];
}
return self;
}
@end[/sourcecode]

Then u can use this class object in “cellForRowAtIndex” method of “UITableViewController” class as follows

[sourcecode]- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault         reuseIdentifier:CellIdentifier] ;            cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.backgroundView = [[[GradientView alloc] init] autorelease];
}
// Configure the cell.
cell.textLabel.text = [self.allFolder objectAtIndex:indexPath.row];
cell.textLabel.backgroundColor = [UIColor clearColor];
cell.imageView.image=[UIImage imageNamed:@"folder.png"];
return cell;
}[/sourcecode]

Conclusion:

Many times, we need to make the application stand out from the crowd. While redesigning, we need something that would make our list of contents distinct from all the other table views. Hence, implementing custom background tables in ‘UITableView’ will be a smart way to start.

The Best Practices for Rails App Development

“Rails” is an amazing framework to develop web applications quickly through its inbuilt helper libraries. However, there are certain best practices that you should follow to get your rails app perform better.

Conventional programming methods:

Most developers love to place the logic inside the controller and use the model for the “Active Record” operation only.

This leads to a “Fat controller and skinny model” interface which eventually kills an app’s performance and looses the maintainability of the code. This way, application stops responding when the load is high.

What should be the best practices?

Below, I have mentioned some of the most essential and useful practices that should be followed by every Ruby on Rails developer.

Fat Model, Skinny Controller

Write all the non-response-related logics inside the model with nice and testable methods; and don’t forget to use comments.

You should follow the Ruby on Rails motto i.e. “Fat Model, Skinny Controller”. Because the “skinny” controller offers a nice interface between the view and model.

By moving any logic that isn’t about the response (for example, setting a flash message, or choosing whether to redirect or render a view) to the model instead of the controller, not only you can reuse the codes where

possible but you’ve also made it possible to test your code.

Reusable Scopes

A scope is a set of constraints on database interactions (such as a condition, limit, or offset) that are chainable and reusable.

Let’s see a simple example:

[sourcecode language=”plain”]
def index
@paid_users= User.where(“is_active=? AND is_paid=?”,true, true).order(“name”)
@unpaid_users= User.where(“is_active=? AND is_paid=?”, true, false).order(“name”)
[/sourcecode]

You can change it to this:

[sourcecode language=”plain”]
def index
@paid_users= User.paid.all
@unpaid_users= User.unpaid.all
end[/sourcecode]

Then, you can move the logic to your User model, where it might look like this:

[sourcecode language=”plain”]
scope :paid, lambda { where(“is_active=? AND is_paid=?”,true, true).order(“name”) }
scope :unpaid, lambda { where(“is_active=? AND is_paid=?”,true, false).order(“name”) }
[/sourcecode]

Using the methods User.paid.all and User.unpaid.all, we’ve not only made it simpler to test our code, but also made it possible to reuse that same set of conditions in another location.

You should avoid the use of default_scope because:

  1. You can’t override default scope
  2. default_scope will affect your model initialization

Package Your Code into Gems and Plugins

Writing a particular set code more than once for different applications is exhausting as well as redundant, hence, it is advisable to create a plugin or gem to use it further. It will save your development time and effort.

Manage Your Attribute Access

While creating or updating an object, Rails app usually assigns every attribute without checking the data. Validation only prevents the bad data but doesn’t exactly prevent it from overwriting an attribute that we don’t want to change.

To solve this issue, ActiveRecord is implemented which uses two methods: attr_protected and attr_accessibile.

Using attr_protected, you can declare a blacklist of variables you don’t want to be assigned and using attr_accessible, you can declare a list of variables that can be assigned.

By implementing above steps, you could prevent any mass assignment that could occur via your application’s forms; because if the form does not have the field for a given attribute, doesn’t mean a hacker can’t add it to the request.

From a security perspective, using attr_accessible and attr_protected forces you to think about what should be editable and how to protect the ways in which your class’s attributes are set.

Use Non-database-backed Models

In Rails app, Model is not restricted to associate with table. To organize application logic, write it down by creating a new model.

Virtual Attributes

If you are manipulating data before passing it to a model, use virtual attributes instead.

Virtual attributes are a simple own getter and setter methods.

For example
To set a user’s name:

[sourcecode language=”plain”]
@user = User.new(params[:user])
@user.first_name, @user.last_name = params[:user][:name].split(" ", 2)
[/sourcecode]

By using virtual method inside the model

[sourcecode language=”plain”]
def name=(value)
self.first_name, self.last_name = value.to_s.split(“ ”, 2)
end[/sourcecode]

Whenever you set the name attribute, your model will automatically set the first_name and last_name attributes for you, even though name doesn’t exist in the database.

Use Translations

Rails i18n framework makes it easy to declare the map of an abstract context to a string.

All you need to do is maintain a YAML file of translations, and use I18n.t / t in your code where there is data shown to the use.

I18n is useful to avail your app to more locales.

Using of after_commit callback

Use “after_commit” instead of using after_create/after_update/after_destroy callbacks to start background processes. Because, in relational database, several operations are wrapped in one unit and pass or fail of transaction depends upon all the operations.

If you use after_create/after_update/after_destroy in first model and if any error occurs in the second model then the background process will raise NotFoundError.

Use select in ActiveRecord association

Use select with has_many and belongs_to on Active Record Associations to speed up the query.

For example:

[sourcecode language=”plain”]
class Patient < ActiveRecord::Base
belongs_to :physician, :select => ‘id,name, surname’
end

class Physician < ActiveRecord::Base
has_many :patients, :select => ‘id,name, physician_id’
end
[/sourcecode]

Fix N+1 Queries

N+1 Queries is a serious database performance problem. Use “Bullet” gem to avoid N+1 query problem

Conclusion:

Employing the above mentioned Rails best practices would keep the code cleaner and reusable.

The application performance would increases tremendously and the maintenance of the code will be easier.

Why Rails Framework is Popular Among Ruby Developers?

Most companies whether it’s a start-up or an established enterprise have evidently landed to the conclusion that Ruby on Rails is the most viable option for rapid and cost efficient web app development.

Ruby on Rails or simply called ‘Rails’ is an open-source, full-scale multilevel web app framework that implements MVC development architecture for the Ruby programming language and is supported by a strong community around it.

Several reasons lie to use Ruby on rails, the main one is that it is a better choice than any other tools. However, before proceed forward let’s have a quick look on:

What Is Ruby On Rails?

Ruby is a dynamic, general purpose, interpreted language used for object oriented programming. The Framework has simple coding that a non-technical person can understand to some extent.

Developing new software using Ruby seems to be bit tedious. Rails, a special tool, was developed to optimize the development process.

Rails is the web development framework which is written in the Ruby language. After 9 years of development, Ruby was introduced.

Never miss an update from us. Join 10,000+ marketers and leaders.

With this development the ruby on rails developers can easily makes the web app programming.

Ruby on Rails(Source: Clariontech)

Let’s take a quick look on the features of ROR:

Mature Framework

Ruby on Rails was first released in 2003, which possessed several large and actively maintained APIs that make application development faster, easier and more manageable. One of the best examples is CSRF (Cross Site Request Forgery) protection; using which, you don’t have to do anything to add CSRF. Active Record is an extremely powerful feature in terms of building usable data models.

MVC Architecture:

With Ruby on Rails development is based on the model, controller and view pattern, widely used web application architecture. Therefore, developers using other MVC framework languages can find Ruby on Rails to be more user-friendly.

By using Ruby on Rails architecture, you can get separate codes for different functions, i.e. data layer, presentation layer, and can maintain a resource layer.

Generators/Scaffolding:

It’s a rapid prototyping tool; Rails’ scaffold will generate a starting point that allows us to list, add, remove, edit, and view things. It will explain the command, the model name and related database table, naming conventions, attributes and types.

The generated script will produce files of Ruby code that the application can use to interact with the database. It is somewhat less convenient than dynamic scaffolding, but gives the programmer the flexibility of modifying and customizing the generated APIs.

Gems/Plugin:

Ruby gems are highly portable chunks of Ruby code that can be used inside any Ruby script or application.

Rails plugins have the flexibility to hook into every part of Rails, including generators, rake tasks and tests/specs. Rails-specific features cannot be used with other Ruby frameworks like Merb, Sinatra, etc.

Active Record ORM:

Object-Relational Mapping (ORM) is a technique that connects the rich objects of an application to tables in a relational database management system.

Active record pattern is an architectural pattern found in Ruby on Rails that stores its data in relational databases. It relies heavily on the naming in that it uses class and association names to establish mappings between respective database tables and foreign key columns.

Integrated Testing Tools:

Rails features a convenient testing tool, for which, it automatically starts producing the skeleton test code in background whilst you are creating the application models and controllers.

Rails tests can also simulate browser requests and thus you can test your application’s response without having to test it over the browser.

Some convenient tools for testing Rails application:

  • Test Unit
  • RSpec
  • Cucumber
  • Mocha
  • Flexmock
  • Factory Girl

Version Control Systems:

There are numerous version control systems. CVS was the first system widely used in the open-source community. Several years ago, it was largely replaced by Subversion (SVN). And in early 2008, most of the Rails world moved to a newer version control system, called GIT.

I’ve worked with the team at Andolasoft on multiple websites. They are professional, responsive, & easy to work with. I’ve had great experiences & would recommend their services to anyone.

Ruthie Miller, Sr. Mktg. Specialist

Salesforce, Houston, Texas

LEARN MORE

Git is usually the best choice if you are new to Ruby, because nearly all code that you need to fetch as examples or libraries will be available via a GIT repository.

Conclusion

With Ruby on Rails providing a programming framework that includes reusable, easily configurable components commonly used for creating web-based applications, it is gaining traction with developers.

From the recent studies on the job growth trends, it is seen that Ruby on Rails developers are a very hot commodity. Ruby as the language of the cloud, the job market will continue to show high demand for the developers. It’s nearly impossible to be an unemployed Ruby on Rails developer.

RoR_graph_new1-1024x532 (1)

If you are in search of a dedicated developer, to create your ruby application, then contact us.

Our dedicated ruby developers will deliver a quick and efficient solution by developing a web application of your requirement.