Skip to content

Commit 592a523

Browse files
committed
Version 0.1.0
1 parent 3d1fbdb commit 592a523

File tree

9 files changed

+267
-2
lines changed

9 files changed

+267
-2
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
composer.lock
2+
/vendor

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Matt Clinton
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

100644100755
Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,21 @@
1-
# alfred-tailwindcss-docs
2-
An ultra-fast Laravel docs search workflow for Alfred 3
1+
# TailwindCSS Docs Workflow for Alfred
2+
3+
An ultra-fast TailwindCSS docs search workflow for Alfred 3.
4+
5+
Adapted from [Alfred VueJS Docs](https://github.com/vmitchell85/alfred-vuejs-docs), which is adapted from [Alfred Laravel Docs](https://github.com/tillkruss/alfred-laravel-docs), Thanks [Till Krüss](https://twitter.com/tillkruss)!
6+
7+
![Screenshot](screenshot.png)
8+
9+
## Installation
10+
11+
1. [Download the latest version](https://github.com/clnt/alfred-tailwindcss-docs/releases/download/0.1.0/TailwindCSS.Docs.alfredworkflow)
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+
tw <query>
19+
```
20+
21+
Just type `tw` followed by your search query.

composer.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "clnt/alfred-tailwindcss-docs",
3+
"description": "An ultra-fast TailwindCSS docs search workflow for Alfred 3.",
4+
"version": "0.1.0",
5+
"keywords": ["alfred", "alfred-workflow", "tailwindcss", "algolia"],
6+
"homepage": "https://github.com/clnt",
7+
"support": {
8+
"source": "https://github.com/clnt/alfred-tailwindcss-docs",
9+
"issues": "https://github.com/clnt/alfred-tailwindcss-docs/issues"
10+
},
11+
"license": "MIT",
12+
"require": {
13+
"joetannenbaum/alfred-workflow": "^0.1.0",
14+
"algolia/algoliasearch-client-php": "^1.27",
15+
"erusev/parsedown": "^1.7"
16+
}
17+
}

google.png

5.74 KB
Loading

icon.png

18 KB
Loading

info.plist

Lines changed: 137 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,137 @@
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.clnt.tailwindcss-docs</string>
7+
<key>category</key>
8+
<string>Productivity</string>
9+
<key>connections</key>
10+
<dict>
11+
<key>BA0F1293-0A15-462E-966E-7C84BCFBC501</key>
12+
<array>
13+
<dict>
14+
<key>destinationuid</key>
15+
<string>A0BE7549-BF89-4E85-86DC-E30C0D797564</string>
16+
<key>modifiers</key>
17+
<integer>0</integer>
18+
<key>modifiersubtext</key>
19+
<string></string>
20+
<key>vitoclose</key>
21+
<false/>
22+
</dict>
23+
</array>
24+
</dict>
25+
<key>createdby</key>
26+
<string>Matt Clinton</string>
27+
<key>description</key>
28+
<string>An ultra-fast TailwindCSS docs search workflow</string>
29+
<key>disabled</key>
30+
<false/>
31+
<key>name</key>
32+
<string>TailwindCSS Docs</string>
33+
<key>objects</key>
34+
<array>
35+
<dict>
36+
<key>config</key>
37+
<dict>
38+
<key>browser</key>
39+
<string></string>
40+
<key>spaces</key>
41+
<string></string>
42+
<key>url</key>
43+
<string>{query}</string>
44+
<key>utf8</key>
45+
<true/>
46+
</dict>
47+
<key>type</key>
48+
<string>alfred.workflow.action.openurl</string>
49+
<key>uid</key>
50+
<string>A0BE7549-BF89-4E85-86DC-E30C0D797564</string>
51+
<key>version</key>
52+
<integer>1</integer>
53+
</dict>
54+
<dict>
55+
<key>config</key>
56+
<dict>
57+
<key>alfredfiltersresults</key>
58+
<false/>
59+
<key>alfredfiltersresultsmatchmode</key>
60+
<integer>0</integer>
61+
<key>argumenttrimmode</key>
62+
<integer>0</integer>
63+
<key>argumenttype</key>
64+
<integer>0</integer>
65+
<key>escaping</key>
66+
<integer>127</integer>
67+
<key>keyword</key>
68+
<string>tw</string>
69+
<key>queuedelaycustom</key>
70+
<integer>3</integer>
71+
<key>queuedelayimmediatelyinitially</key>
72+
<true/>
73+
<key>queuedelaymode</key>
74+
<integer>0</integer>
75+
<key>queuemode</key>
76+
<integer>1</integer>
77+
<key>runningsubtext</key>
78+
<string>Searching docs for "{query}"...</string>
79+
<key>script</key>
80+
<string>php tailwindcss.php "{query}"</string>
81+
<key>scriptargtype</key>
82+
<integer>0</integer>
83+
<key>scriptfile</key>
84+
<string></string>
85+
<key>subtext</key>
86+
<string>Search the TailwindCSS docs...</string>
87+
<key>title</key>
88+
<string>TailwindCSS</string>
89+
<key>type</key>
90+
<integer>0</integer>
91+
<key>withspace</key>
92+
<true/>
93+
</dict>
94+
<key>type</key>
95+
<string>alfred.workflow.input.scriptfilter</string>
96+
<key>uid</key>
97+
<string>BA0F1293-0A15-462E-966E-7C84BCFBC501</string>
98+
<key>version</key>
99+
<integer>2</integer>
100+
</dict>
101+
</array>
102+
<key>readme</key>
103+
<string>An ultra-fast TailwindCSS docs search workflow for Alfred 3.
104+
105+
## Usage
106+
107+
Just type `tw` followed by your search query.
108+
109+
```
110+
tw &lt;query&gt;
111+
tw preview mailables
112+
```
113+
114+
Either press `⌘Y` to Quick Look the result, or press `&lt;enter&gt;` to open it in your web browser.</string>
115+
<key>uidata</key>
116+
<dict>
117+
<key>A0BE7549-BF89-4E85-86DC-E30C0D797564</key>
118+
<dict>
119+
<key>xpos</key>
120+
<integer>510</integer>
121+
<key>ypos</key>
122+
<integer>90</integer>
123+
</dict>
124+
<key>BA0F1293-0A15-462E-966E-7C84BCFBC501</key>
125+
<dict>
126+
<key>xpos</key>
127+
<integer>200</integer>
128+
<key>ypos</key>
129+
<integer>90</integer>
130+
</dict>
131+
</dict>
132+
<key>version</key>
133+
<string>0.1.0</string>
134+
<key>webaddress</key>
135+
<string>https://github.com/clnt</string>
136+
</dict>
137+
</plist>

screenshot.png

234 KB
Loading

tailwindcss.php

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
use Alfred\Workflows\Workflow;
4+
5+
use AlgoliaSearch\Client as Algolia;
6+
use AlgoliaSearch\Version as AlgoliaUserAgent;
7+
8+
require __DIR__ . '/vendor/autoload.php';
9+
10+
$query = $argv[1];
11+
12+
$workflow = new Workflow;
13+
$parsedown = new Parsedown;
14+
$algolia = new Algolia('R90K1756AM', 'cd63556797a9e2dc23249752a4e33b67');
15+
16+
AlgoliaUserAgent::addSuffixUserAgentSegment('TailwindCSS Alfred Workflow', '0.1.0');
17+
18+
$index = $algolia->initIndex('tailwindcss');
19+
$search = $index->search($query);
20+
$results = $search['hits'];
21+
22+
if (empty($results)) {
23+
if (empty($results)) {
24+
$workflow->result()
25+
->title('No matches')
26+
->icon('google.png')
27+
->subtitle("No match found in the docs. Search Google for: \"TailwindCSS+{$query}\"")
28+
->arg("https://www.google.com/search?q=tailwindcss+{$query}")
29+
->quicklookurl("https://www.google.com/search?q=tailwindcss+{$query}")
30+
->valid(true);
31+
32+
echo $workflow->output();
33+
exit;
34+
}
35+
exit;
36+
}
37+
38+
foreach ($results as $hit) {
39+
$highestLvl = $hit['hierarchy']['lvl6'] ? 6 : (
40+
$hit['hierarchy']['lvl5'] ? 5 : (
41+
$hit['hierarchy']['lvl4'] ? 4 : (
42+
$hit['hierarchy']['lvl3'] ? 3 : (
43+
$hit['hierarchy']['lvl2'] ? 2 : (
44+
$hit['hierarchy']['lvl1'] ? 1 : 0
45+
)
46+
)
47+
)
48+
)
49+
);
50+
51+
$title = $hit['hierarchy']['lvl' . $highestLvl];
52+
$currentLvl = 0;
53+
$subtitle = $hit['hierarchy']['lvl0'];
54+
while ($currentLvl < $highestLvl) {
55+
$currentLvl = $currentLvl + 1;
56+
$subtitle = $subtitle . ' » ' . $hit['hierarchy']['lvl' . $currentLvl];
57+
}
58+
59+
$workflow->result()
60+
->uid($hit['objectID'])
61+
->title($title)
62+
->autocomplete($title)
63+
->subtitle($subtitle)
64+
->arg($hit['url'])
65+
->quicklookurl($hit['url'])
66+
->valid(true);
67+
}
68+
69+
echo $workflow->output();

0 commit comments

Comments
 (0)