Skip to content

Commit 3b08d94

Browse files
committed
basic setup
0 parents  commit 3b08d94

File tree

8 files changed

+231
-0
lines changed

8 files changed

+231
-0
lines changed

Diff for: .gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
composer.lock
2+
/vendor

Diff for: README.md

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# VueJS Docs Workflow for Alfred
2+
3+
An ultra-fast VueJS docs search workflow for Alfred 3.
4+
5+
Adapted from [Alfred Laravel Docs](https://github.com/tillkruss/alfred-laravel-docs), Thanks Till Krüss!
6+
7+
![Screenshot](screenshot.png)
8+
9+
## Installation
10+
11+
1. [Download the latest version](https://github.com/vmitchell85/alfred-vuejs-docs)
12+
2. Install the workflow by double-clicking the `.alfredworkflow` file
13+
3. You can add the workflow to a category, then click "Import" to finish importing. You'll now see the workflow listed in the left sidebar of your Workflows preferences pane.
14+
15+
## Usage
16+
17+
```
18+
vue <query>
19+
```
20+
21+
Just type `vue` followed by your search query.

Diff for: composer.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "tillkruss/alfred-lorem-ipsum",
3+
"description": "An ultra-fast Laravel docs search workflow for Alfred 3",
4+
"version": "0.2.1",
5+
"keywords": ["alfred", "alfred-workflow", "laravel", "algolia"],
6+
"homepage": "https://till.im",
7+
"support": {
8+
"source": "https://github.com/tillkruss/alfred-laravel-docs",
9+
"issues": "https://github.com/tillkruss/alfred-laravel-docs/issues"
10+
},
11+
"license": "MIT",
12+
"require": {
13+
"joetannenbaum/alfred-workflow": "^0.1.0",
14+
"algolia/algoliasearch-client-php": "^1.27"
15+
}
16+
}

Diff for: google.png

5.74 KB
Loading

Diff for: icon.png

30.6 KB
Loading

Diff for: info.plist

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>bundleid</key>
6+
<string>com.vmitchell85.vuejs-docs</string>
7+
<key>connections</key>
8+
<dict>
9+
<key>7B86D057-DA8E-4302-AF17-83B889B48EE2</key>
10+
<array>
11+
<dict>
12+
<key>destinationuid</key>
13+
<string>D449CB87-B64C-41F5-8FF0-C93C75686459</string>
14+
<key>modifiers</key>
15+
<integer>0</integer>
16+
<key>modifiersubtext</key>
17+
<string></string>
18+
<key>vitoclose</key>
19+
<false/>
20+
</dict>
21+
</array>
22+
</dict>
23+
<key>createdby</key>
24+
<string>Vince mitchell</string>
25+
<key>description</key>
26+
<string>An ultra-fast VueJS docs search workflow</string>
27+
<key>disabled</key>
28+
<false/>
29+
<key>name</key>
30+
<string>VueJS Docs</string>
31+
<key>objects</key>
32+
<array>
33+
<dict>
34+
<key>config</key>
35+
<dict>
36+
<key>browser</key>
37+
<string></string>
38+
<key>spaces</key>
39+
<string></string>
40+
<key>url</key>
41+
<string>{query}</string>
42+
<key>utf8</key>
43+
<true/>
44+
</dict>
45+
<key>type</key>
46+
<string>alfred.workflow.action.openurl</string>
47+
<key>uid</key>
48+
<string>D449CB87-B64C-41F5-8FF0-C93C75686459</string>
49+
<key>version</key>
50+
<integer>1</integer>
51+
</dict>
52+
<dict>
53+
<key>config</key>
54+
<dict>
55+
<key>alfredfiltersresults</key>
56+
<false/>
57+
<key>alfredfiltersresultsmatchmode</key>
58+
<integer>0</integer>
59+
<key>argumenttrimmode</key>
60+
<integer>0</integer>
61+
<key>argumenttype</key>
62+
<integer>0</integer>
63+
<key>escaping</key>
64+
<integer>127</integer>
65+
<key>keyword</key>
66+
<string>vue</string>
67+
<key>queuedelaycustom</key>
68+
<integer>3</integer>
69+
<key>queuedelayimmediatelyinitially</key>
70+
<true/>
71+
<key>queuedelaymode</key>
72+
<integer>0</integer>
73+
<key>queuemode</key>
74+
<integer>1</integer>
75+
<key>runningsubtext</key>
76+
<string>Searching docs for "{query}"...</string>
77+
<key>script</key>
78+
<string>php vuejs.php "{query}"</string>
79+
<key>scriptargtype</key>
80+
<integer>0</integer>
81+
<key>scriptfile</key>
82+
<string></string>
83+
<key>subtext</key>
84+
<string>Search the VueJS docs...</string>
85+
<key>title</key>
86+
<string>VueJS</string>
87+
<key>type</key>
88+
<integer>0</integer>
89+
<key>withspace</key>
90+
<true/>
91+
</dict>
92+
<key>type</key>
93+
<string>alfred.workflow.input.scriptfilter</string>
94+
<key>uid</key>
95+
<string>7B86D057-DA8E-4302-AF17-83B889B48EE2</string>
96+
<key>version</key>
97+
<integer>2</integer>
98+
</dict>
99+
</array>
100+
<key>readme</key>
101+
<string></string>
102+
<key>uidata</key>
103+
<dict>
104+
<key>7B86D057-DA8E-4302-AF17-83B889B48EE2</key>
105+
<dict>
106+
<key>xpos</key>
107+
<integer>200</integer>
108+
<key>ypos</key>
109+
<integer>90</integer>
110+
</dict>
111+
<key>D449CB87-B64C-41F5-8FF0-C93C75686459</key>
112+
<dict>
113+
<key>xpos</key>
114+
<integer>510</integer>
115+
<key>ypos</key>
116+
<integer>90</integer>
117+
</dict>
118+
</dict>
119+
<key>variables</key>
120+
<dict>
121+
<key>branch</key>
122+
<string>master</string>
123+
</dict>
124+
<key>version</key>
125+
<string>0.2.1</string>
126+
<key>webaddress</key>
127+
<string>https://vincemitchell.me</string>
128+
</dict>
129+
</plist>

Diff for: screenshot.png

102 KB
Loading

Diff for: vuejs.php

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<?php
2+
3+
use Alfred\Workflows\Workflow;
4+
use AlgoliaSearch\Client as Algolia;
5+
use AlgoliaSearch\Version as AlgoliaUserAgent;
6+
7+
require __DIR__ . '/vendor/autoload.php';
8+
9+
$query = $argv[1];
10+
$branch = empty($_ENV['branch']) ? 'master' : $_ENV['branch'];
11+
12+
$workflow = new Workflow;
13+
$algolia = new Algolia('BH4D9OD16A', '85cc3221c9f23bfbaa4e3913dd7625ea');
14+
15+
AlgoliaUserAgent::addSuffixUserAgentSegment('Alfred Workflow', '0.2.1');
16+
17+
$index = $algolia->initIndex('vuejs');
18+
$search = $index->search($query, ['facetFilters' => 'version:v2']);
19+
$results = $search['hits'];
20+
21+
if (empty($results)) {
22+
$workflow->result()
23+
->title('No matches')
24+
->icon('google.png')
25+
->subtitle("No match found in the docs. Search Google for: \"{$query}\"")
26+
->arg("https://www.google.com/search?q=vuejs+{$query}")
27+
->quicklookurl("https://www.google.com/search?q=vuejs+{$query}")
28+
->valid(true);
29+
30+
echo $workflow->output();
31+
exit;
32+
}
33+
34+
foreach ($results as $hit) {
35+
$hasText = isset($hit['_highlightResult']['content']['value']);
36+
$hasSubtitle = isset($hit['h2']);
37+
38+
$title = $hit['h1'];
39+
$subtitle = $hasSubtitle ? $hit['h2'] : null;
40+
41+
if ($hasText) {
42+
$subtitle = $hit['_highlightResult']['content']['value'];
43+
44+
if ($hasSubtitle) {
45+
$title = "{$title} » {$hit['h2']}";
46+
}
47+
}
48+
49+
$title = $hit['hierarchy']['lvl6'] ?: $hit['hierarchy']['lvl5'] ?: $hit['hierarchy']['lvl4'] ?: $hit['hierarchy']['lvl2'] ?: $hit['hierarchy']['lvl1'] ?: $hit['hierarchy']['lvl0'];
50+
51+
$subtitle = $hit['hierarchy']['lvl0'] . ($hit['hierarchy']['lvl1'] ? ' => ' . $hit['hierarchy']['lvl1'] : '');
52+
53+
$workflow->result()
54+
->uid($hit['objectID'])
55+
->title($title)
56+
->autocomplete($title)
57+
->subtitle($subtitle)
58+
->arg($hit['url'])
59+
->quicklookurl($hit['url'])
60+
->valid(true);
61+
}
62+
63+
echo $workflow->output();

0 commit comments

Comments
 (0)