Skip to content

Commit bb7349f

Browse files
committed
Version 1.1.0 - Update for Tailwind CSS v1.0 release
1 parent 53f532f commit bb7349f

File tree

6 files changed

+188
-7
lines changed

6 files changed

+188
-7
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ Just type `tw` followed by your search query.
2020
tw <query>
2121
```
2222

23+
To search the [v0 docs](https://v0.tailwindcss.com/docs), just type `tw0` followed by your search query.
24+
25+
```
26+
tw0 <query>
27+
```
28+
2329
To search the [beta docs](https://next.tailwindcss.com/docs), just type `twb` followed by your search query.
2430

2531
```

beta_tailwindcss.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
$parsedown = new Parsedown;
1616
$algolia = new Algolia('R90K1756AM', 'a6e52654d6b591febdf42b07e0e7374a');
1717

18-
AlgoliaUserAgent::addSuffixUserAgentSegment('TailwindCSS Alfred Workflow', '1.0.0');
18+
AlgoliaUserAgent::addSuffixUserAgentSegment('TailwindCSS Alfred Workflow', '1.1.0');
1919

2020
$index = $algolia->initIndex('beta_tailwindcss');
2121
$search = $index->search($query);

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 3.",
4-
"version": "1.0.0",
4+
"version": "1.1.0",
55
"keywords": ["alfred", "alfred-workflow", "tailwindcss", "algolia"],
66
"homepage": "https://github.com/clnt",
77
"support": {

info.plist

Lines changed: 103 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,19 @@
3434
<false/>
3535
</dict>
3636
</array>
37+
<key>DFF4C67A-3AC2-4322-B452-3CBA2E3E5BF2</key>
38+
<array>
39+
<dict>
40+
<key>destinationuid</key>
41+
<string>55F8BC35-9DE7-4CF5-A4B5-C15201065664</string>
42+
<key>modifiers</key>
43+
<integer>0</integer>
44+
<key>modifiersubtext</key>
45+
<string></string>
46+
<key>vitoclose</key>
47+
<false/>
48+
</dict>
49+
</array>
3750
</dict>
3851
<key>createdby</key>
3952
<string>Matt Clinton</string>
@@ -130,6 +143,72 @@
130143
<key>version</key>
131144
<integer>1</integer>
132145
</dict>
146+
<dict>
147+
<key>config</key>
148+
<dict>
149+
<key>alfredfiltersresults</key>
150+
<false/>
151+
<key>alfredfiltersresultsmatchmode</key>
152+
<integer>0</integer>
153+
<key>argumenttrimmode</key>
154+
<integer>0</integer>
155+
<key>argumenttype</key>
156+
<integer>0</integer>
157+
<key>escaping</key>
158+
<integer>127</integer>
159+
<key>keyword</key>
160+
<string>tw0</string>
161+
<key>queuedelaycustom</key>
162+
<integer>3</integer>
163+
<key>queuedelayimmediatelyinitially</key>
164+
<true/>
165+
<key>queuedelaymode</key>
166+
<integer>0</integer>
167+
<key>queuemode</key>
168+
<integer>1</integer>
169+
<key>runningsubtext</key>
170+
<string>Searching docs for "{query}"...</string>
171+
<key>script</key>
172+
<string>php v0_tailwindcss.php "{query}"</string>
173+
<key>scriptargtype</key>
174+
<integer>0</integer>
175+
<key>scriptfile</key>
176+
<string></string>
177+
<key>subtext</key>
178+
<string>Search the TailwindCSS v0 docs...</string>
179+
<key>title</key>
180+
<string>TailwindCSS v0</string>
181+
<key>type</key>
182+
<integer>0</integer>
183+
<key>withspace</key>
184+
<true/>
185+
</dict>
186+
<key>type</key>
187+
<string>alfred.workflow.input.scriptfilter</string>
188+
<key>uid</key>
189+
<string>89F02255-0DA5-4773-896A-BF05292D2CE8</string>
190+
<key>version</key>
191+
<integer>2</integer>
192+
</dict>
193+
<dict>
194+
<key>config</key>
195+
<dict>
196+
<key>browser</key>
197+
<string></string>
198+
<key>spaces</key>
199+
<string></string>
200+
<key>url</key>
201+
<string>{query}</string>
202+
<key>utf8</key>
203+
<true/>
204+
</dict>
205+
<key>type</key>
206+
<string>alfred.workflow.action.openurl</string>
207+
<key>uid</key>
208+
<string>55F8BC35-9DE7-4CF5-A4B5-C15201065664</string>
209+
<key>version</key>
210+
<integer>1</integer>
211+
</dict>
133212
<dict>
134213
<key>config</key>
135214
<dict>
@@ -173,7 +252,7 @@
173252
<key>type</key>
174253
<string>alfred.workflow.input.scriptfilter</string>
175254
<key>uid</key>
176-
<string>89F02255-0DA5-4773-896A-BF05292D2CE8</string>
255+
<string>DFF4C67A-3AC2-4322-B452-3CBA2E3E5BF2</string>
177256
<key>version</key>
178257
<integer>2</integer>
179258
</dict>
@@ -183,14 +262,20 @@
183262
184263
## Usage
185264
265+
186266
Just type `tw` followed by your search query.
187267
188268
```
189269
tw &lt;query&gt;
190-
tw font-family
191270
```
192271
193-
To search the beta docs at `https://next.tailwindcss.com/docs`, just type `twb` followed by your search query.
272+
To search the [v0 docs](https://v0.tailwindcss.com/docs), just type `tw0` followed by your search query.
273+
274+
```
275+
tw0 &lt;query&gt;
276+
```
277+
278+
To search the [beta docs](https://next.tailwindcss.com/docs), just type `twb` followed by your search query.
194279
195280
```
196281
twb &lt;query&gt;
@@ -206,6 +291,13 @@ Either press `⌘Y` to Quick Look the result, or press `&lt;enter&gt;` to open i
206291
<key>ypos</key>
207292
<integer>250</integer>
208293
</dict>
294+
<key>55F8BC35-9DE7-4CF5-A4B5-C15201065664</key>
295+
<dict>
296+
<key>xpos</key>
297+
<integer>650</integer>
298+
<key>ypos</key>
299+
<integer>410</integer>
300+
</dict>
209301
<key>89F02255-0DA5-4773-896A-BF05292D2CE8</key>
210302
<dict>
211303
<key>xpos</key>
@@ -227,9 +319,16 @@ Either press `⌘Y` to Quick Look the result, or press `&lt;enter&gt;` to open i
227319
<key>ypos</key>
228320
<integer>90</integer>
229321
</dict>
322+
<key>DFF4C67A-3AC2-4322-B452-3CBA2E3E5BF2</key>
323+
<dict>
324+
<key>xpos</key>
325+
<integer>340</integer>
326+
<key>ypos</key>
327+
<integer>410</integer>
328+
</dict>
230329
</dict>
231330
<key>version</key>
232-
<string>1.0.0</string>
331+
<string>1.1.0</string>
233332
<key>webaddress</key>
234333
<string>https://github.com/clnt</string>
235334
</dict>

tailwindcss.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
$parsedown = new Parsedown;
1616
$algolia = new Algolia('R90K1756AM', 'a6e52654d6b591febdf42b07e0e7374a');
1717

18-
AlgoliaUserAgent::addSuffixUserAgentSegment('TailwindCSS Alfred Workflow', '1.0.0');
18+
AlgoliaUserAgent::addSuffixUserAgentSegment('TailwindCSS Alfred Workflow', '1.1.0');
1919

2020
$index = $algolia->initIndex('tailwindcss');
2121
$search = $index->search($query);

v0_tailwindcss.php

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

0 commit comments

Comments
 (0)