Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Blaine Schmeisser
committed
Jul 28, 2016
0 parents
commit acc27df
Showing
6 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "zazu-chrome-bookmarks", | ||
"version": "1.0.0", | ||
"description": "Chrome bookmark searcher for Zazu.", | ||
"keywords": [ | ||
"zazu", | ||
"search", | ||
"chrome", | ||
"bookmarks" | ||
], | ||
"author": "Blaine Schmeisser", | ||
"license": "MIT", | ||
"dependencies": { | ||
"fuzzyfind": "^1.2.0", | ||
"traverse": "^0.6.6" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
## Chrome Bookmarks | ||
|
||
Chrome bookmark searcher for Zazu. | ||
|
||
## Installing | ||
|
||
Add the package to your plugins array in `./zazurc.js`. | ||
|
||
~~~ javascript | ||
'tinytacoteam/zazu-chrome-bookmarks', | ||
~~~ | ||
|
||
By default we look for your default profile located at: | ||
|
||
~~~ | ||
/Users/bschmeisser/Library/Application Support/Google/Chrome/Default/Bookmarks | ||
~~~ | ||
|
||
To overwrite it, set the `file` variable: | ||
|
||
~~~ javascript | ||
{ | ||
name: 'tinytacoteam/zazu-chrome-bookmarks', | ||
variables: { | ||
file: '~/Library/Application Support/Google/Chrome/Profile 1/Bookmarks', | ||
}, | ||
} | ||
~~~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
'use strict' | ||
const fs = require('fs') | ||
const os = require('os') | ||
const traverse = require('traverse') | ||
const fuzzyfind = require('fuzzyfind') | ||
|
||
const file = '~/Library/Application Support/Google/Chrome/Default/Bookmarks' | ||
|
||
module.exports = (pluginContext) => { | ||
return (query, env) => { | ||
const variables = env || {} | ||
const bookmarkFile = (variables['file'] || file).replace(/^~/, os.homedir()) | ||
return new Promise((resolve, reject) => { | ||
fs.readFile(bookmarkFile, (err, data) => { | ||
const rawData = JSON.parse(data) | ||
// Find | ||
const bookmarks = [] | ||
traverse(rawData).forEach((item) => { | ||
const isBookmark = item['type'] === 'url' | ||
if (isBookmark) { | ||
const bookmark = { | ||
title: item['name'], | ||
subtitle: item['url'], | ||
value: item['url'], | ||
} | ||
bookmarks.push(bookmark) | ||
} | ||
}) | ||
// Filter | ||
// toLowerCase() is required - https://github.com/amjith/fuzzyfind/pull/3 | ||
const filteredBookmarks = fuzzyfind(query.toLowerCase(), bookmarks, (bookmark) => { | ||
return (bookmark.title + bookmark.subtitle).toLowerCase() | ||
}) | ||
resolve(filteredBookmarks) | ||
}) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module.exports = { | ||
name: 'Chrome Bookmarks', | ||
version: '1.0.0', | ||
description: 'Chrome bookmark searcher for Zazu.', | ||
icon: 'assets/chrome.png', | ||
blocks: { | ||
input: [ | ||
{ | ||
id: 'search', | ||
type: 'PrefixScript', | ||
space: true, | ||
args: 'Required', | ||
prefix: ',b', | ||
script: 'search.js', | ||
connections: ['Open'], | ||
}, | ||
], | ||
output: [ | ||
{ | ||
id: 'Open', | ||
type: 'OpenInBrowser', | ||
url: '{value}', | ||
}, | ||
], | ||
}, | ||
} |