Firefox/Projects/PlacesQueryAPIRedesign: Difference between revisions

Jump to navigation Jump to search
Line 26: Line 26:




== Idea Dump ==
== Places Query Api Redesign ==


Places Query Api Redesign
=== Priciples: ===


Priciples:
Query API redesign is for the new direction/design of Places for Fx 3.7 +
  1. Query API redesign is for the new direction/design of Places for Fx 3.7 +
  2. This design should not take into account existing Places implementation


Design in a nutshell:
This design should not take into account existing Places implementation
 
== Design in a nutshell: ==
 
<pre class="brush:js;">


   // queryObj is an object that configures the current query
   // queryObj is an object that configures the current query


   queryObj = { param:'cnn',  
   queryObj = { param:'cnn',  
                 // the following 'bookmarks' and 'history' are not  
                 // the following 'bookmarks' and 'history' are not  
                 // required, defaults are true for both
                 // required, defaults are true for both
                 bookmarks:true, // search bookmarks - yes (default)
                 bookmarks:true, // search bookmarks - yes (default)
                 history:true,  // search bookmarks - yes (default)
                 history:true,  // search bookmarks - yes (default)
                 // UI Callback function
                 // UI Callback function
                 uiCallback: function (results){ //iterate results object }  
 
                 uiCallback: function (results){ // results is an Iterator }  
               };
               };


   // qResultObj is returned by the QueryProcessor and is  
   // qResultObj is returned by the QueryProcessor and is  
   // an object that has a 'fetch' method used as a callback
   // an object that has a 'fetch' method used as a callback
   // this object has parsed the queryObj, built the SQL,  
   // this object has parsed the queryObj, built the SQL,  
   // and contains an (optional)  UI callback to update the UI.  
   // and contains an (optional)  UI callback to update the UI.  
   // (all queries are performed asynchronously)
   // (all queries are performed asynchronously)


Line 56: Line 68:
    
    
   qResultObj.fetch();
   qResultObj.fetch();
   // fetch will trigger the search in the database and onResult
 
   // fetch will trigger the search in the database and  
 
   // fire the UI callback, with the results chunk
   // fire the UI callback, with the results chunk


 
</pre>
Use Cases
 
== Use Cases ==
 
Location Bar bookmarks navigation:
 
screenshot: [http://people.mozilla.com/~faaborg/files/20091012-personalWeb/bookmarksLocationBar-i1.png]


Location Bar bookmarks navigation:
<pre class="brush:js;">
  screenshot: people.mozilla.com/~faaborg/files/20091012-personalWeb/bookmarksLocationBar-i1.png


   // set up defaults for the operations at hand:  
   // set up defaults for the operations at hand:  
   var query = { bookmarks: true, history: true };
   var query = { bookmarks: true, history: true };


   // add the string to search
   // add the string to search
   query.param = 'Bill';
   query.param = 'Bill';
    
    
   // optional UI callback registration:
   // optional UI callback registration:
   function uiCallbk(results){
   function uiCallbk(results){
     results.length // 1
     results.length // 1
    
    
     for (let item in results) {
     for (let item in results) {
       item.title;  // 'Bills, Resolutions Libary of Congress'
       item.title;  // 'Bills, Resolutions Libary of Congress'
       item.url;    // 'thomas.loc.gov/home/bills_res.html'
       item.url;    // 'thomas.loc.gov/home/bills_res.html'
Line 87: Line 110:
    
    
   // feed the query object into the Places QueryProcessor
   // feed the query object into the Places QueryProcessor
   var qResultObj = new QueryProcessor(query);
   var qResultObj = new QueryProcessor(query);
    
    
Line 93: Line 117:
   // Usage in the wild: 'caller()' is a consumer of the QueryProcessor
   // Usage in the wild: 'caller()' is a consumer of the QueryProcessor
    
    
   function caller(qResultObj) {
   function caller(qResultObj) {
     ...
     ...
     qResultObj.fetch(); // triggers async query and uiCallback
     qResultObj.fetch(); // triggers async query and uiCallback
     // fetch() will throw if anything goes awry
     // fetch() will throw if anything goes awry


     retrun true;
     return true;
   }
   }


</pre>
== Anatomy of a (bookmark folder) 'Item': ==
<pre class="brush:js;">


  // Anatomy of a (bookmark folder) 'Item':
 
   { title:        'Bills',
   { title:        'Bills',
     url:          'bookmark://Apartment/Bills'
     url:          'bookmark://Apartment/Bills'
Line 121: Line 148:
     icon:        (property), // returns faviconItem object
     icon:        (property), // returns faviconItem object
   }
   }
 
 
  // Anatomy of a (history) 'Item':
</pre>
 
 
== Anatomy of a (history) 'Item': ==
 
<pre class="brush:js;">
 
   { title:        "Hurricane Bill's winds weaken",
   { title:        "Hurricane Bill's winds weaken",
     url:          'news.yahoo.com/s/ap/...'
     url:          'news.yahoo.com/s/ap/...'
Line 139: Line 170:
   }
   }


</pre>


2. Location Bar History Ranges
== Location Bar History Ranges ==


  screenshot: people.mozilla.com/~faaborg/files/20091012-personalWeb/historyLocationBar-i1.png
screenshot: [http://people.mozilla.com/~faaborg/files/20091012-personalWeb/historyLocationBar-i1.png]
 
<pre class="brush:js;">


   // taken the above 'default' query object, we add a historyRange property:  
   // taken the above 'default' query object, we add a historyRange property:  
  query.historyRangeKeyword = 'Today';
    
    
   // - or -
  query.historyRangeKeyword = 'Today';
 
  // also, phrases like: 'Last Week', 'This Month', 'Last Year', etc...
 
   // - or -  
 
  // (in reality, these are the internally-called methods to
  // handle the parsed 'historyRangeKeyword')
 
   query.historyRangeFrom = new Date();
   query.historyRangeFrom = new Date();
   query.historyRangeTo = new Date();   
   query.historyRangeTo = new Date();   


   // optionally, we can pre-filter the results with a keyword
   // optionally, we can filter the results with a keyword
 
   query.param = 'news';
   query.param = 'news';
  query.uiCallback = function (results){
    for (let item in results.next()){
      displayInUserInterface(item);
    } 
  };
  // perhaps we have a negative filter as well:
  query.exclude = 'cnn';
    
    
   // feed the query object into the Places QueryProcessor
   // feed the query object into the Places QueryProcessor
   var qResultObj = new QueryProcessor(query);
   var qResultObj = new QueryProcessor(query);
 
  // here it is in the wild:
  function caller(qResultObj) {
         
    qResultObj.fetch();
    return true;
  }
</pre>
== Faceted Searches - Perhaps this is for '4.0'? ==
<pre class="brush:js;">
  // I have seen faceted search apis that do things like:
 
  qResultObj.narrow({referrer:'mozilla.com'});
 
  qResultObj.fetch();
  // the 'narrow' call will return a new qResultObject that
  // can be narrowed futher:
 
  qResultObj.narrow({ year:2009 });
 
  qResultObj.fetch();
  qResultObj.narrow({ tagged:'News' });
 
  qResultObj.fetch();
  qResultObj.narrow({ month:11 });
  qResultObj.fetch();
 
  qResultObj.widen('month', 'year');
 
  qResultObj.widen(); // removes all facets
  // What are all of the facets?       
  // 
  // times, dates, referringDomain, referringFragment, isBookmarked,
  // inTraversal, tagged
  //
  // 'inTraversal' is any historyItem or bookmark in the traversed path
  // that was taken to get to the target url/bookmark
  // 
  // 'inTraversal' will require that we store a more comprehensive
  // "browsing path" data
</pre>


== Goals/Use Cases ==
== Goals/Use Cases ==
564

edits

Navigation menu