Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
wolasss committed Mar 1, 2017
0 parents commit ba72b80
Show file tree
Hide file tree
Showing 10 changed files with 217 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.DS_Store
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.gif
*.alfredworkflow
Binary file added B1CFE20E-B1DB-451D-80ED-59F9F4673719.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# alfred-webpack-docs

> [Alfred 3](https://www.alfredapp.com) workflow that gives you a super quick access to webpack documentation.
<img src="https://raw.githubusercontent.com/wolasss/alfred-webpack-docs/master/alfred-webpack-docs.gif">

## Install

```
$ npm install --global alfred-webpack-docs
```

or download it from [here](https://raw.githubusercontent.com/wolasss/alfred-webpack-docs/master/alfred-webpack-docs.alfredworkflow)

*Requires [Node.js](https://nodejs.org) 4+ and the Alfred 3 [Powerpack](https://www.alfredapp.com/powerpack/).*

## Usage

In Alfred, type `wpd` followed by a keyword you want to search the documentation through.

## License

MIT © [Adam Wolski](https://adamwolski.com)
Binary file added alfred-webpack-docs.alfredworkflow
Binary file not shown.
Binary file added alfred-webpack-docs.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const alfy = require("alfy");
const query = alfy.input;
const Entities = require('html-entities').XmlEntities;
const entities = new Entities();
const merge = require('merge')

const search = (items, ret) => {
items.forEach(item => {
if ((item.title && item.title.toLowerCase().indexOf(query.toLowerCase()) >= 0) || (item.url && item.url.toLowerCase().indexOf(query.toLowerCase()) >= 0)) {
ret.push(item);
}

if (item.pages && item.pages.length) {
search(item.pages, ret);
}
});

return ret;
}

alfy.fetch('https://webpack.js.org/', {
json: false
}).then(data => {
const props = data.match(/data-props\=\"([^\"]+)\"/gm);

const docs = {};

props.forEach(prop => {
try {
const properties = JSON.parse(entities.decode(prop.replace(/data-props\="/, "").replace(/\"$/, "")));
docs = merge(docs, properties);
} catch (e) {}
});

const result = search(docs.sections, []).map(item => {
return {
title: item.title,
subtitle: item.url,
arg: `https://webpack.js.org/${item.url}`
}
});

alfy.output(result);
});
120 changes: 120 additions & 0 deletions info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>bundleid</key>
<string>webpackdocs</string>
<key>category</key>
<string>Tools</string>
<key>connections</key>
<dict>
<key>B1CFE20E-B1DB-451D-80ED-59F9F4673719</key>
<array>
<dict>
<key>destinationuid</key>
<string>E70F4F54-D52D-46D2-B981-4C5005FE223B</string>
<key>modifiers</key>
<integer>0</integer>
<key>modifiersubtext</key>
<string></string>
<key>vitoclose</key>
<false/>
</dict>
</array>
</dict>
<key>createdby</key>
<string>Adam Wolski</string>
<key>description</key>
<string>Search through webpack documentation</string>
<key>disabled</key>
<false/>
<key>name</key>
<string>alfred-webpack-docs</string>
<key>objects</key>
<array>
<dict>
<key>config</key>
<dict>
<key>browser</key>
<string></string>
<key>spaces</key>
<string></string>
<key>url</key>
<string>{query}</string>
<key>utf8</key>
<true/>
</dict>
<key>type</key>
<string>alfred.workflow.action.openurl</string>
<key>uid</key>
<string>E70F4F54-D52D-46D2-B981-4C5005FE223B</string>
<key>version</key>
<integer>1</integer>
</dict>
<dict>
<key>config</key>
<dict>
<key>alfredfiltersresults</key>
<false/>
<key>argumenttype</key>
<integer>1</integer>
<key>escaping</key>
<integer>127</integer>
<key>keyword</key>
<string>wpd</string>
<key>queuedelaycustom</key>
<integer>1</integer>
<key>queuedelayimmediatelyinitially</key>
<false/>
<key>queuedelaymode</key>
<integer>0</integer>
<key>queuemode</key>
<integer>1</integer>
<key>runningsubtext</key>
<string>Searching...</string>
<key>script</key>
<string>./node_modules/.bin/run-node index.js "$1"</string>
<key>scriptargtype</key>
<integer>1</integer>
<key>scriptfile</key>
<string></string>
<key>subtext</key>
<string></string>
<key>title</key>
<string>Search Webpack docs</string>
<key>type</key>
<integer>0</integer>
<key>withspace</key>
<true/>
</dict>
<key>type</key>
<string>alfred.workflow.input.scriptfilter</string>
<key>uid</key>
<string>B1CFE20E-B1DB-451D-80ED-59F9F4673719</string>
<key>version</key>
<integer>2</integer>
</dict>
</array>
<key>readme</key>
<string></string>
<key>uidata</key>
<dict>
<key>B1CFE20E-B1DB-451D-80ED-59F9F4673719</key>
<dict>
<key>xpos</key>
<integer>240</integer>
<key>ypos</key>
<integer>50</integer>
</dict>
<key>E70F4F54-D52D-46D2-B981-4C5005FE223B</key>
<dict>
<key>xpos</key>
<integer>440</integer>
<key>ypos</key>
<integer>50</integer>
</dict>
</dict>
<key>webaddress</key>
<string>https://www.adamwolski.com</string>
</dict>
</plist>
26 changes: 26 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"name": "alfred-webpack-docs",
"version": "1.0.0",
"description": "Workflow for searching through webpack documentation.",
"main": "index.js",
"scripts": {
"test": "test",
"postinstall": "alfy-init",
"preuninstall": "alfy-cleanup"
},
"author": {
"name": "Adam Wolski",
"email": "[email protected]",
"url": "http://adamwolski.com"
},
"repository": {
"type": "git",
"url": "https://github.com/wolasss/alfred-webpack-docs"
},
"license": "MIT",
"dependencies": {
"alfy": "^0.6.0",
"html-entities": "^1.2.0",
"merge": "^1.2.0"
}
}

0 comments on commit ba72b80

Please sign in to comment.