Table of Contents

Tellmaps: URL, SEO

This document proposes new URL format for tellmaps to resolve these issues:

URL format

We propose a shebang syntax, which is backward-compatible with most browsers and uses a hash-trick to allow dynamic changes of the URL. It is also directly supported by search engines such as Google.

Shebang syntax is defined as follows:

http://server.name/#!/path/to/web/feature?param1=value&param2=value#local-hash 

which can be decomposed to three major parts:

[Implementation details] code to retriveve params from hash part: https://gist.github.com/miohtama/1570295

URLs for Tellmaps

We propose to use the above parts this way:

Path component

Should contain a path to resource. We propose:

The general rule of thumb is: if we have a content we want to serve to search engine as a static document, it should have an unique path component.

Param set

Should contain all kinds of data we don't need a SEO representation of. Such as filtering, pagination, views. Due to it's nature it should be in a format of property_name=property_value. We shall have a way on how to define defaults for these values if ommited in the application.

Examples of params (names - values):

Advantages of param set over path set (such as /tellmap/WDAWORLD01/date/1974/focus/BRA/cartogram/true):

Params will be parsed rather simply - we won't support arrays.

local hash

Will only be used if we need to scroll to some element ID. Because we don't have a way to do this if using shebang syntax directly, we can parse the additional # at the end of a path and programatically scroll to given DOM ID element. This will enable scroll to top / certain element.

Javascript implementation

/**
 * revised version with one settings object and multiple callback definitions
 * @param settings - collection {}, specify these properties:
 *  - path - string - define a path component with possible :variable notation
 *  - onPathSet - function(variables) - pass in a callback to be called whenever a path changes
 *                    - @param variables - collection of passed :variable values 
 *                        in format { variable_name: variable_value }
 *  - onPathOut - function() - pass in a callback to as destructor function
 *              - is called whenever path components change from this path
 *  - onParamsChange - function(params) - pass in a callback to be called whenever a param string changes
 *                     - @param params - collections of passed GET params
 *                         in format { param_name: param_value }
 *  - defaultParams - collection - define an array of default GET values - they automatically pre-fill the 
 *                   params in onParamsChange callback if not provided from GET
 *  - onHashChange - function(local_hash) - pass in a callback to be called whenever a local hash part changes
 *                     - @param local_hash - provides new value of local_hash
 *     - @default if not defined, will perform a scroll to page top / element of ID #local_hash,
 *                as standard hash does
 *  - debug - boolean - provide console.log outputs on various operations of this registerURI block              
 * @return none
 * 
 * notes:
 *  - all callbacks have "this" set which can access the following:
 *    getHash(), getParams(), getParamString(), getPath()
 *    please do not use their "set" counterparts directly.
 **/
function registerUri( settings ) {
...
 
/**
 * Register a callback to be executed on URI parse fail
 * @param callback - a function in the form of function(current_uri, error_message)
 *   current_uri is the processed shebang that failed
 *   error_message does show a messages the class outputted on fail
 *   function will be called on URI parse failed
 * @return none
 * 
 * notes:
 *  - callback has "this" set which can access the following:
 *    getHash(), getParams(), getParamString(), getPath()
 *    please do not use their "set" counterparts directly.
 **/
function onUriFail( callback ) {
...
 
/**
 * Get proper URI string to be used in parts of the app
 * @param path - string, path component part
 * @param get_params - get param collection in the form of { param_name : param_value }
 * @param local_hash - string, local hash part
 * @return string final string
 **/
function getUriString( path, get_params, local_hash ) {
...

This solution has these advantages:

(change a path component) -> trigger onPathSet -> trigger onParamChange -> trigger onHashChange
(change a params part) -> trigger onParamChange only
(change a local hash part) -> trigger onHashChange only

Server-side implementation

Old URI redirection

Should perform a redirection from old to new format using rules described above. Should be done server-side with R=301 redirects.

SEO - support

Shebang format has an advantage in that it allows search engines to crawl them. When it notices the shebang format such as http://example.com/#!/some/path, it automatically requests http://example.com?_escaped_fragment=/some/path and this can be processed using the server and serving the search engine with custom SEO-ready content version of a given resource.

This will need much more through-thinking but the URL part is a good start.