Firefox/Projects/PlacesQueryAPIRedesign: Difference between revisions

Jump to navigation Jump to search
m
Line 108: Line 108:


/* The query can be so configured:
/* The query can be so configured:
  * QueryConf = {
  *
* _QueryConf_ = {
  *  phrase: string.
  *  phrase: string.
  *          Show only pages containing this string in either title, uri or
  *          Containing this string in either title, uri or tags.  Case
  *          tags.  Case insensitive.  Can use ^ and $ to match beginning or
  *          insensitive.  Can use ^ and $ to match at beginning or end.
*          end.
  *  host: string.
  *  host: string.
  *        Show only pages containing this string in the host.  Case
  *        Containing this string in the host.  Case insensitive.
  *        insensitive.  Can use ^ and $ to match beginning or end.
  *        Can use ^ and $ to match at beginning or end.
  *  uri: string.
  *  uri: string.
  *        Show only pages containing this string in the uri.  Case
  *        Containing this string in the uri.  Case insensitive.
  *        insensitive.  Can use ^ and $ to match beginning or end.
  *        Can use ^ and $ to match beginning or end.
  *  annotated: array of strings.
  *  annotated: array of strings.
  *           Show only pages with these annotations (Either page or item).
  *             With these annotations (Either page or item).
  *  bookmarked: object {
  *  bookmarked: object
  *                 tags: array of strings.
{
  *                       Show only pages tagged with these tags.
  *     tags: array of strings.
  *                 folders: array of numbers.
  *           Tagged with these tags.
  *                         Show contents of these folders. (non-recursive)
  *     at: object
  *                id: number.
*    {
  *                     Show only the bookmark with this id.
*      folder: number.
  *                 when: array of 2 Date objects.
  *               Inside this folder. (non-recursive)
  *                       Show only bookmarks created between these times.
*      position: number.
  *                       Can use null beginning or end time to match till epoch
  *                At this position. (relative to folder).
  *                       or now.
*                If undefined or null matches all children.
  *                 modified: array of 2 Date objects.
*    }
  *                           Show only bookmarks modified between these times.
*    id: number.
  *                           Can use null beginning or end time to match till
  *         Bookmarked with this id.
  *                           epoch or now.
  *     when: object
  *                 excludeNonContainers: boolean.
*    {
  *                                       Removes any non-container from results.
*      begin: optional Date object
  *                                       Default is false.
*              Bookmarks created after this time (included).
  *                 excludeReadOnlyContainers: boolean.
  *             Defaults to epoch.
  *                                           Removes read only containers from
  *       end: optional Date object
  *                                           results.  Default is false.
*            Bookmarks created before this time (included).
  *               }
  *           Defaults to now.
  *  visited: object {
  *     }
  *             count: array of numbers.
*    modified: object
  *                     Show only pages with these so many visits.
*    {
  *                     Can use null minimum or maximum to match anything.
*      begin: optional Date object
  *             transitions: array fo transition types.
*              Bookmarks modified after this time (included).
  *                           Show only pages with at least one visit with these
  *             Defaults to epoch.
  *                           transitions.
  *       end: optional Date object
  *             when: array of 2 Date objects.
*            Bookmarks modified before this time (included).
  *                   Show only pages with visits between these times.
  *           Defaults to now.
  *                   Can use null beginning or end time to match till epoch
  *     }
  *                   or now.
*    onlyContainers: boolean.
  *             excludeRedirectSources: boolean.
  *                           Removes any non-container from results.
  *                                     Removes redirects sources from results.
  *                           Default is false.
  *                                     Default is false.
  *     excludeReadOnlyContainers: boolean.
  *             excludeRedirectTargets: boolean.
  *                               Removes read only containers from results.
  *                                     Removes redirects targets from results.
  *                               Default is false.
  *                                     Default is false.
  *   }
  *             includeHidden: boolean.
  *  visited: object
  *                            Returns also pages marked as hidden.
{
  *     count: object
*            This is lazily based on visit_count, thus is not going to work
*            for not counted transitions: embed, download, framed_link.
*    {
*      min: optional number.
*            With more than this many visits.
*            Defaults to 0.
*      max: optional number.
  *           With less than this many visits.
  *           Defaults to inf.
  *     }
*    transitions: array of transition types.
  *                 With at least one visit for each of these transitions.
*    when: object
  *     {
  *       begin: optional Date object
  *             With visits after this time (included).
  *             Defaults to epoch.
  *       end: optional Date object
  *           With visits before this time (included).
  *           Defaults to now.
  *     }
  *     excludeRedirectSources: boolean.
  *                             Removes redirects sources from results.
  *                             Default is false.
  *     excludeRedirectTargets: boolean.
  *                            Removes redirects targets from results.
  *                            Default is false.
  *                            Default is false.
  *             includeVisits: boolean.
  *     includeHidden: boolean.
  *                             Returns all visits.
  *                   Includes also pages marked as hidden.
  *                             Default is false, that means visits are grouped
*                    Default is false.
*                            by uri, and no duplicates are returned.
*    allVisits: boolean.
  *           }
*                Returns all visits ungrouped.
  *  sort: object {
  *               Default is false, that means visits are grouped by uri.
  *           by: string.
  *   }
  *               Either "none", "title", "time", "uri", "accessCount" or
  *  sort: object
*              "lastModified", "frecency".  Defaults to "none".
{
  *           dir: string.
  *     by: string.
  *               Either "asc" or "desc".  Defaults to "asc".
  *         Either "none", "title", "time", "uri", "accessCount", "lastModified",
  *         }
*        "frecency".  Defaults to "none".
  *     dir: string.
  *         Either "asc" or "desc".  Defaults to "asc".
  *   }
  *  group: string.
  *  group: string.
  *          Either "tag", "folder", "day", "month", "year" or "domain".
  *          Either "tags", "containers", "days", "months", "years" or "domains".
  *          Defaults to "none".
  *          Defaults to "none".
*          NOTE: Not yet implemented.
  *  limit: number.
  *  limit: number.
  *          Maximum umber of results to return.  Defaults to all results.
  *          Maximum number of results to return.  Defaults to all results.
  *  merge: string.
  *  merge: string.
  *          How to merge this query's results with others in the same request.
  *          How to merge this query's results with others in the same request.
  *          Either "union", "intersect" or "except".
  *          Valid values:
*          - "union": merge results from the 2 queries.
*          - "except": exclude current results from the previous ones.
*          - "intersect": only current results that are also in previous ones.
  * }
  * }
*
* NOTE: In case of multiple queries, sort, group and limit of the first query
* will be used for the global result.
  *
  *
  *
  *
Line 197: Line 234:
  *  sessionId: visit session or null if not available
  *  sessionId: visit session or null if not available
  *  itemId: bookmark id or null if not bookmarked (see isBookmarked)
  *  itemId: bookmark id or null if not bookmarked (see isBookmarked)
*  isBookmarked: whether this is bookmarked or not
  *  dateAdded: bookmark creation Date() or null if not bookmarked
  *  dateAdded: bookmark creation Date() or null if not bookmarked
  *  lastModified bookmark modification Date() or null if not bookmarked
  *  lastModified bookmark modification Date() or null if not bookmarked
Line 206: Line 244:
  *  visitId: id of the visit or null
  *  visitId: id of the visit or null
  *  referringVisitId: id of the originating visit or null
  *  referringVisitId: id of the originating visit or null
*  referringUri: uri of the originating visit or null
  *  transitionType: transition of this visit or null
  *  transitionType: transition of this visit or null
  *  type: old container implementation type
  *  type: old container implementation type
  *  readableType: "bookmark", "container", "separator", "visit", "page"
  *  readableType: "bookmark", "container", "separator", "visit", "page"
*  isBookmarked: whether this is bookmarked or not
  *  query: if this is a container will return a new PlacesQuery for contents
  *  query: if this is a container will return a new PlacesQuery for contents
  * }
  * }
Line 238: Line 276:
// Folder picker.
// Folder picker.
new PlacesQuery({ bookmarked: {
new PlacesQuery({ bookmarked: {
                       folders: [PlacesUIUtils.allBookmarksFolderId]
                       at: { folder: PlacesUIUtils.allBookmarksFolderId }
                       excludeNonContainers: true,
                       onlyContainers: true,
                       excludeReadOnlyContainers: true
                       excludeReadOnlyContainers: true
                   },
                   },
Line 253: Line 291:
// Most recent tags.
// Most recent tags.
new PlacesQuery({ bookmarked: {},
new PlacesQuery({ bookmarked: {},
                   group: "tag",
                   group: "tags",
                   limit: 5
                   limit: 5
                 });
                 });
Line 259: Line 297:
// Left pane query.
// Left pane query.
new PlacesQuery({ bookmarked: { folders: [PlacesUIUtils.leftPaneFolderId] },
new PlacesQuery({ bookmarked: { folders: [PlacesUIUtils.leftPaneFolderId] },
                   annotated: "Places/OrganizerQuery"
                   annotated: ["Places/OrganizerQuery"]
                   group: "container"
                   group: "containers"
                 });
                 });


Line 267: Line 305:
                       transitions: [PlacesUtils.history.TRANSITION_DOWNLOAD],
                       transitions: [PlacesUtils.history.TRANSITION_DOWNLOAD],
                       includeHidden: true,
                       includeHidden: true,
                       includeVisits: true
                       allVisits: true
                   },
                   },
                   sort: { by: "time", dir: "desc" }
                   sort: { by: "time", dir: "desc" }
Line 298: Line 336:
);
);


// Visited bookmarks containing "foo" but not "bar".
// Visited bookmarks containing "foo" and "bar".
new PlacesQuery([
new PlacesQuery([
     { phrase: "foo",
     { phrase: "foo",
Line 307: Line 345:
       bookmarked: {},
       bookmarked: {},
       visited: {},
       visited: {},
       merge: "except"
       merge: "intersect"
     },
     },
);
);


</pre>
</pre>
Confirmed users
595

edits

Navigation menu