Skip to content

Commit 866f417

Browse files
authored
Merge pull request #13 from clnt/3.0.0-dev
TailwindCSS v3 Initial Support
2 parents 957ba67 + 2f651cf commit 866f417

File tree

7 files changed

+201
-36
lines changed

7 files changed

+201
-36
lines changed

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ Adapted from [Alfred VueJS Docs](https://github.com/vmitchell85/alfred-vuejs-doc
1111

1212
> **macOS Monterey:** PHP is no longer shipped with macOS, before attempting to use this workflow ensure you have installed the php binary via Homebrew.
1313
14-
1. [Download the latest version](https://github.com/clnt/alfred-tailwindcss-docs/releases/download/v2.0.1/TailwindCSSDocs.alfredworkflow)
14+
1. [Download the latest version](https://github.com/clnt/alfred-tailwindcss-docs/releases/download/v3.0.0/TailwindCSSDocs.alfredworkflow)
1515
2. Install the workflow by double-clicking the `.alfredworkflow` file
1616
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.
1717

1818
## Usage
1919

20-
To search the [v2 docs](https://tailwindcss.com/docs), just type `tw` followed by your search query.
20+
To search the [v3 docs](https://tailwindcss.com/docs), just type `tw` followed by your search query.
2121

2222
```
2323
tw <query>
2424
```
2525

26-
To search the [v0 docs](https://v0.tailwindcss.com/docs), just type `tw0` followed by your search query.
26+
To search the [v2 docs](https://v2.tailwindcss.com/docs), just type `tw2` followed by your search query.
2727

2828
```
29-
tw0 <query>
29+
tw2 <query>
3030
```
3131

3232
To search the [v1 docs](https://v1.tailwindcss.com/docs), just type `tw1` followed by your search query.
@@ -35,4 +35,10 @@ To search the [v1 docs](https://v1.tailwindcss.com/docs), just type `tw1` follow
3535
tw1 <query>
3636
```
3737

38+
To search the [v0 docs](https://v0.tailwindcss.com/docs), just type `tw0` followed by your search query.
39+
40+
```
41+
tw0 <query>
42+
```
43+
3844
![Search by Algolia](algolia.png)

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "clnt/alfred-tailwindcss-docs",
33
"description": "An ultra-fast TailwindCSS docs search workflow for Alfred 4.",
4-
"version": "2.0.1",
4+
"version": "3.0.0",
55
"keywords": ["alfred", "alfred-workflow", "tailwindcss", "algolia"],
66
"homepage": "https://github.com/clnt",
77
"support": {

info.plist

Lines changed: 134 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@
2121
<false/>
2222
</dict>
2323
</array>
24+
<key>B6C8B22C-FF5D-43C9-ADD6-A89E98787B42</key>
25+
<array>
26+
<dict>
27+
<key>destinationuid</key>
28+
<string>A4601CBF-5351-4B71-8D48-F97FACF4BE7F</string>
29+
<key>modifiers</key>
30+
<integer>0</integer>
31+
<key>modifiersubtext</key>
32+
<string></string>
33+
<key>vitoclose</key>
34+
<false/>
35+
</dict>
36+
</array>
2437
<key>BA0F1293-0A15-462E-966E-7C84BCFBC501</key>
2538
<array>
2639
<dict>
@@ -58,25 +71,6 @@
5871
<string>TailwindCSSDocs</string>
5972
<key>objects</key>
6073
<array>
61-
<dict>
62-
<key>config</key>
63-
<dict>
64-
<key>browser</key>
65-
<string></string>
66-
<key>spaces</key>
67-
<string></string>
68-
<key>url</key>
69-
<string>{query}</string>
70-
<key>utf8</key>
71-
<true/>
72-
</dict>
73-
<key>type</key>
74-
<string>alfred.workflow.action.openurl</string>
75-
<key>uid</key>
76-
<string>A0BE7549-BF89-4E85-86DC-E30C0D797564</string>
77-
<key>version</key>
78-
<integer>1</integer>
79-
</dict>
8074
<dict>
8175
<key>config</key>
8276
<dict>
@@ -117,7 +111,7 @@ fi</string>
117111
<key>scriptfile</key>
118112
<string></string>
119113
<key>subtext</key>
120-
<string>Search the TailwindCSS docs...</string>
114+
<string>Search the TailwindCSS v3 docs...</string>
121115
<key>title</key>
122116
<string>TailwindCSS</string>
123117
<key>type</key>
@@ -147,7 +141,7 @@ fi</string>
147141
<key>type</key>
148142
<string>alfred.workflow.action.openurl</string>
149143
<key>uid</key>
150-
<string>1BC09BF1-F684-4789-897B-F70B225A4D72</string>
144+
<string>A0BE7549-BF89-4E85-86DC-E30C0D797564</string>
151145
<key>version</key>
152146
<integer>1</integer>
153147
</dict>
@@ -206,6 +200,25 @@ fi</string>
206200
<key>version</key>
207201
<integer>3</integer>
208202
</dict>
203+
<dict>
204+
<key>config</key>
205+
<dict>
206+
<key>browser</key>
207+
<string></string>
208+
<key>spaces</key>
209+
<string></string>
210+
<key>url</key>
211+
<string>{query}</string>
212+
<key>utf8</key>
213+
<true/>
214+
</dict>
215+
<key>type</key>
216+
<string>alfred.workflow.action.openurl</string>
217+
<key>uid</key>
218+
<string>1BC09BF1-F684-4789-897B-F70B225A4D72</string>
219+
<key>version</key>
220+
<integer>1</integer>
221+
</dict>
209222
<dict>
210223
<key>config</key>
211224
<dict>
@@ -280,18 +293,98 @@ fi</string>
280293
<key>version</key>
281294
<integer>3</integer>
282295
</dict>
296+
<dict>
297+
<key>config</key>
298+
<dict>
299+
<key>browser</key>
300+
<string></string>
301+
<key>spaces</key>
302+
<string></string>
303+
<key>url</key>
304+
<string>{query}</string>
305+
<key>utf8</key>
306+
<true/>
307+
</dict>
308+
<key>type</key>
309+
<string>alfred.workflow.action.openurl</string>
310+
<key>uid</key>
311+
<string>A4601CBF-5351-4B71-8D48-F97FACF4BE7F</string>
312+
<key>version</key>
313+
<integer>1</integer>
314+
</dict>
315+
<dict>
316+
<key>config</key>
317+
<dict>
318+
<key>alfredfiltersresults</key>
319+
<false/>
320+
<key>alfredfiltersresultsmatchmode</key>
321+
<integer>0</integer>
322+
<key>argumenttreatemptyqueryasnil</key>
323+
<false/>
324+
<key>argumenttrimmode</key>
325+
<integer>0</integer>
326+
<key>argumenttype</key>
327+
<integer>0</integer>
328+
<key>escaping</key>
329+
<integer>127</integer>
330+
<key>keyword</key>
331+
<string>tw2</string>
332+
<key>queuedelaycustom</key>
333+
<integer>3</integer>
334+
<key>queuedelayimmediatelyinitially</key>
335+
<true/>
336+
<key>queuedelaymode</key>
337+
<integer>0</integer>
338+
<key>queuemode</key>
339+
<integer>1</integer>
340+
<key>runningsubtext</key>
341+
<string>Searching docs for "{query}"...</string>
342+
<key>script</key>
343+
<string>if [ -f "/opt/homebrew/bin/php" ]; then
344+
/opt/homebrew/bin/php v2_tailwindcss.php "{query}"
345+
elif [ -f "/usr/local/bin/php" ]; then
346+
/usr/local/bin/php v2_tailwindcss.php "{query}"
347+
elif [ -f "/usr/bin/php" ]; then
348+
/usr/bin/php v2_tailwindcss.php "{query}"
349+
fi</string>
350+
<key>scriptargtype</key>
351+
<integer>0</integer>
352+
<key>scriptfile</key>
353+
<string></string>
354+
<key>subtext</key>
355+
<string>Search the TailwindCSS v2 docs...</string>
356+
<key>title</key>
357+
<string>TailwindCSS v2</string>
358+
<key>type</key>
359+
<integer>0</integer>
360+
<key>withspace</key>
361+
<true/>
362+
</dict>
363+
<key>type</key>
364+
<string>alfred.workflow.input.scriptfilter</string>
365+
<key>uid</key>
366+
<string>B6C8B22C-FF5D-43C9-ADD6-A89E98787B42</string>
367+
<key>version</key>
368+
<integer>3</integer>
369+
</dict>
283370
</array>
284371
<key>readme</key>
285372
<string>An ultra-fast TailwindCSS docs search workflow for Alfred 3.
286373
287374
## Usage
288375
289-
To search the [v2 docs](https://tailwindcss.com/docs), just type `tw` followed by your search query.
376+
To search the [v3 docs](https://tailwindcss.com/docs), just type `tw` followed by your search query.
290377
291378
```
292379
tw &lt;query&gt;
293380
```
294381
382+
To search the [v2 docs](https://v2.tailwindcss.com/docs), just type `tw2` followed by your search query.
383+
384+
```
385+
tw2 &lt;query&gt;
386+
```
387+
295388
To search the [v1 docs](https://v1.tailwindcss.com/docs), just type `tw1` followed by your search query.
296389
297390
```
@@ -312,21 +405,21 @@ Either press `⌘Y` to Quick Look the result, or press `&lt;enter&gt;` to open i
312405
<key>xpos</key>
313406
<integer>650</integer>
314407
<key>ypos</key>
315-
<integer>250</integer>
408+
<integer>225</integer>
316409
</dict>
317410
<key>55F8BC35-9DE7-4CF5-A4B5-C15201065664</key>
318411
<dict>
319412
<key>xpos</key>
320413
<integer>650</integer>
321414
<key>ypos</key>
322-
<integer>410</integer>
415+
<integer>365</integer>
323416
</dict>
324417
<key>89F02255-0DA5-4773-896A-BF05292D2CE8</key>
325418
<dict>
326419
<key>xpos</key>
327420
<integer>340</integer>
328421
<key>ypos</key>
329-
<integer>250</integer>
422+
<integer>225</integer>
330423
</dict>
331424
<key>A0BE7549-BF89-4E85-86DC-E30C0D797564</key>
332425
<dict>
@@ -335,6 +428,20 @@ Either press `⌘Y` to Quick Look the result, or press `&lt;enter&gt;` to open i
335428
<key>ypos</key>
336429
<integer>90</integer>
337430
</dict>
431+
<key>A4601CBF-5351-4B71-8D48-F97FACF4BE7F</key>
432+
<dict>
433+
<key>xpos</key>
434+
<integer>650</integer>
435+
<key>ypos</key>
436+
<integer>505</integer>
437+
</dict>
438+
<key>B6C8B22C-FF5D-43C9-ADD6-A89E98787B42</key>
439+
<dict>
440+
<key>xpos</key>
441+
<integer>340</integer>
442+
<key>ypos</key>
443+
<integer>505</integer>
444+
</dict>
338445
<key>BA0F1293-0A15-462E-966E-7C84BCFBC501</key>
339446
<dict>
340447
<key>xpos</key>
@@ -347,13 +454,13 @@ Either press `⌘Y` to Quick Look the result, or press `&lt;enter&gt;` to open i
347454
<key>xpos</key>
348455
<integer>340</integer>
349456
<key>ypos</key>
350-
<integer>410</integer>
457+
<integer>365</integer>
351458
</dict>
352459
</dict>
353460
<key>variablesdontexport</key>
354461
<array/>
355462
<key>version</key>
356-
<string>2.0.1</string>
463+
<string>3.0.0</string>
357464
<key>webaddress</key>
358465
<string>https://github.com/clnt/alfred-tailwindcss-docs</string>
359466
</dict>

tailwindcss.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
$workflow = new Workflow;
1414
$algolia = Algolia::create('R90K1756AM', 'a6e52654d6b591febdf42b07e0e7374a');
1515

16-
AlgoliaUserAgent::addCustomUserAgent('TailwindCSS Alfred Workflow', '2.0.1');
16+
AlgoliaUserAgent::addCustomUserAgent('TailwindCSS Alfred Workflow', '3.0.0');
1717

18-
$results = getResults($algolia, 'v2_tailwindcss', $query);
18+
$results = getResults($algolia, 'v3_tailwindcss', $query);
1919

2020
if (empty($results)) {
2121
$workflow->result()

v0_tailwindcss.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
$workflow = new Workflow;
1414
$algolia = Algolia::create('R90K1756AM', 'a6e52654d6b591febdf42b07e0e7374a');
1515

16-
AlgoliaUserAgent::addCustomUserAgent('TailwindCSS Alfred Workflow', '2.0.1');
16+
AlgoliaUserAgent::addCustomUserAgent('TailwindCSS Alfred Workflow', '3.0.0');
1717

1818
$results = getResults($algolia, 'v0_tailwindcss', $query);
1919

v1_tailwindcss.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
$workflow = new Workflow;
1414
$algolia = Algolia::create('R90K1756AM', 'a6e52654d6b591febdf42b07e0e7374a');
1515

16-
AlgoliaUserAgent::addCustomUserAgent('TailwindCSS Alfred Workflow', '2.0.1');
16+
AlgoliaUserAgent::addCustomUserAgent('TailwindCSS Alfred Workflow', '3.0.0');
1717

1818
$results = getResults($algolia, 'tailwindcss', $query);
1919

v2_tailwindcss.php

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
use Alfred\Workflows\Workflow;
4+
5+
use Algolia\AlgoliaSearch\SearchClient as Algolia;
6+
use Algolia\AlgoliaSearch\Support\UserAgent as AlgoliaUserAgent;
7+
8+
require __DIR__ . '/vendor/autoload.php';
9+
require __DIR__ . '/functions.php';
10+
11+
$query = $argv[1];
12+
13+
$workflow = new Workflow;
14+
$algolia = Algolia::create('R90K1756AM', 'a6e52654d6b591febdf42b07e0e7374a');
15+
16+
AlgoliaUserAgent::addCustomUserAgent('TailwindCSS Alfred Workflow', '3.0.0');
17+
18+
$results = getResults($algolia, 'v2_tailwindcss', $query);
19+
20+
if (empty($results)) {
21+
$workflow->result()
22+
->title('No matches')
23+
->icon('google.png')
24+
->subtitle("No match found in the docs. Search Google for: \"TailwindCSS+{$query}\"")
25+
->arg("https://www.google.com/search?q=tailwindcss+{$query}")
26+
->quicklookurl("https://www.google.com/search?q=tailwindcss+{$query}")
27+
->valid(true);
28+
29+
echo $workflow->output();
30+
exit;
31+
}
32+
33+
foreach ($results as $hit) {
34+
list($title, $titleLevel) = getTitle($hit);
35+
36+
if ($title === null) {
37+
continue;
38+
}
39+
40+
$title = html_entity_decode($title);
41+
42+
$workflow->result()
43+
->uid($hit['objectID'])
44+
->title($title)
45+
->autocomplete($title)
46+
->subtitle(html_entity_decode(getSubtitle($hit, $titleLevel)))
47+
->arg($hit['url'])
48+
->quicklookurl($hit['url'])
49+
->valid(true);
50+
}
51+
52+
echo $workflow->output();

0 commit comments

Comments
 (0)