User Tools

Site Tools


public:tellmaps_url_and_seo

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
public:tellmaps_url_and_seo [2014/04/30 16:05]
honzik [Javascript implementation - version B (revised)]
public:tellmaps_url_and_seo [2014/05/05 07:27] (current)
honzik
Line 58: Line 58:
  
 ===== Javascript implementation ===== ===== Javascript implementation =====
- 
-The main idea is to create a Javascript service which can be called from existing system modules to perform URL-based operations. We shall call it ''​TellmapsURIService''​. 
- 
-API should provide: 
- 
-<code javascript>​ 
- 
-/** 
- * Register a given path. 
- * @param uri_string string with path. May contain variables in the format of '':​variable''​ - will be passed to callback on request. 
- * @param callback - a function in the form of function(passed_vars,​ get_vars, path_not_changed) 
- ​* ​  ​passed_vars is a collection of { variable_name:​ variable_value } 
- ​* ​  ​get_vars is a collection of param set (GET) in form of { param_name: param_value } with automatic completion from default_params_object 
- ​* ​  ​path_not_changed is true if path component changed from last state, false if only params / local hash changed 
- ​* ​  ​function will be called whenever URI matches on URI change 
- * @param default_params_object - contains default GET values in form of { param_name: param_def_value } 
- * @return none 
- **/ 
-function registerURI( uri_string, callback, default_params_object ) { 
-... 
- 
-/** 
- * 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 
- **/ 
-function onURIFail( callback ) { 
-... 
- 
-/** 
- * Manual call to path change 
- * @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 true/false on success / fail 
- **/ 
-function changeURI( path, get_params, local_hash ) { 
-... 
-</​code>​ 
- 
-So, on the side of implementor into existing system, the role is to: call the ''​TellmapsURIService.registerURI''​ in the setup phase of the application and register a callback to provide given task, for every "​static"​ piece of content. 
- 
-Whenever somebody clicks on a link with the hashbang syntax, uses browser history or manually changes the location, callbacks should trigger. 
- 
-''​TellmapsURIService''​ should handle events of location change and/or parse the [variable, get, local hash] data before use. 
- 
-===== Javascript implementation - version B (revised) ===== 
- 
-A more thought-through approach to API: 
  
 <code javascript>​ <code javascript>​
Line 133: Line 81:
  ​* ​ - debug - boolean - provide console.log outputs on various operations of this registerURI block              ​  ​* ​ - debug - boolean - provide console.log outputs on various operations of this registerURI block              ​
  * @return none  * @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 ) { function registerUri( settings ) {
Line 144: Line 97:
  ​* ​  ​function will be called on URI parse failed  ​* ​  ​function will be called on URI parse failed
  * @return none  * @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 ) { function onUriFail( callback ) {
Line 149: Line 107:
  
 /** /**
- ​* ​Manual call to path change+ ​* ​Get proper URI string ​to be used in parts of the app
  * @param path - string, path component part  * @param path - string, path component part
  * @param get_params - get param collection in the form of { param_name : param_value }  * @param get_params - get param collection in the form of { param_name : param_value }
  * @param local_hash - string, local hash part  * @param local_hash - string, local hash part
- * @return ​true/false on success / fail+ * @return ​string final string
  **/  **/
-function ​changeUri( path, get_params, local_hash ) {+function ​getUriString( path, get_params, local_hash ) {
 ... ...
  
-/** 
- * Manual call to path-only change, get_params and local_hash remains the same 
- * @param path - string, path component part 
- * @return true/false on success / fail 
- **/ 
-function changeUriPath( path ) { 
-... 
- 
-/** 
- * Manual call to params-only change, path and local_hash remains the same 
- * @param get_params - get param collection in the form of { param_name : param_value } 
- * @return true/false on success / fail 
- **/ 
-function changeUriParams( get_params ) { 
-... 
- 
-/** 
- * Manual call to local_hash-only change, path and params remains the same 
- * @param local_hash - string, local hash part 
- * @return true/false on success / fail 
- **/ 
-function changeUriLocalHash( local_hash ) { 
-... 
 </​code>​ </​code>​
  
public/tellmaps_url_and_seo.1398873918.txt.gz · Last modified: 2014/04/30 16:05 by honzik