-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a82af5a
Showing
10 changed files
with
242 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
composer.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2016 Till Krüss | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Laravel Docs Workflow for Alfred | ||
|
||
An ultra-fast Laravel docs search workflow for Alfred 3. | ||
|
||
![Screenshot](screenshot.png) | ||
|
||
## Installation | ||
|
||
1. [Download the latest version](https://github.com/tillkruss/alfred-laravel-docs/releases/download/v0.1.0/Laravel.Docs.alfredworkflow) | ||
2. Install the workflow by double-clicking the `.alfredworkflow` file | ||
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. | ||
|
||
## Usage | ||
|
||
``` | ||
ld <query> | ||
``` | ||
|
||
Just type `ld` followed by your search query. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"require": { | ||
"joetannenbaum/alfred-workflow": "^0.1.0", | ||
"algolia/algoliasearch-client-php": "^1.27", | ||
"erusev/parsedown": "^1.7" | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
<?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>com.tillkruss.laravel-docs</string> | ||
<key>category</key> | ||
<string>Development</string> | ||
<key>connections</key> | ||
<dict> | ||
<key>7B86D057-DA8E-4302-AF17-83B889B48EE2</key> | ||
<array> | ||
<dict> | ||
<key>destinationuid</key> | ||
<string>D449CB87-B64C-41F5-8FF0-C93C75686459</string> | ||
<key>modifiers</key> | ||
<integer>0</integer> | ||
<key>modifiersubtext</key> | ||
<string></string> | ||
<key>vitoclose</key> | ||
<false/> | ||
</dict> | ||
</array> | ||
</dict> | ||
<key>createdby</key> | ||
<string>Till Krüss</string> | ||
<key>description</key> | ||
<string>An ultra-fast Laravel docs search workflow</string> | ||
<key>disabled</key> | ||
<false/> | ||
<key>name</key> | ||
<string>Laravel 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>D449CB87-B64C-41F5-8FF0-C93C75686459</string> | ||
<key>version</key> | ||
<integer>1</integer> | ||
</dict> | ||
<dict> | ||
<key>config</key> | ||
<dict> | ||
<key>alfredfiltersresults</key> | ||
<false/> | ||
<key>alfredfiltersresultsmatchmode</key> | ||
<integer>0</integer> | ||
<key>argumenttrimmode</key> | ||
<integer>0</integer> | ||
<key>argumenttype</key> | ||
<integer>0</integer> | ||
<key>escaping</key> | ||
<integer>127</integer> | ||
<key>keyword</key> | ||
<string>ld</string> | ||
<key>queuedelaycustom</key> | ||
<integer>3</integer> | ||
<key>queuedelayimmediatelyinitially</key> | ||
<true/> | ||
<key>queuedelaymode</key> | ||
<integer>0</integer> | ||
<key>queuemode</key> | ||
<integer>1</integer> | ||
<key>runningsubtext</key> | ||
<string>Searching docs for "{query}"...</string> | ||
<key>script</key> | ||
<string>php laravel.php "{query}"</string> | ||
<key>scriptargtype</key> | ||
<integer>0</integer> | ||
<key>scriptfile</key> | ||
<string></string> | ||
<key>subtext</key> | ||
<string>Search the Laravel docs...</string> | ||
<key>title</key> | ||
<string>Laravel</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>7B86D057-DA8E-4302-AF17-83B889B48EE2</string> | ||
<key>version</key> | ||
<integer>2</integer> | ||
</dict> | ||
</array> | ||
<key>readme</key> | ||
<string></string> | ||
<key>uidata</key> | ||
<dict> | ||
<key>7B86D057-DA8E-4302-AF17-83B889B48EE2</key> | ||
<dict> | ||
<key>xpos</key> | ||
<integer>200</integer> | ||
<key>ypos</key> | ||
<integer>90</integer> | ||
</dict> | ||
<key>D449CB87-B64C-41F5-8FF0-C93C75686459</key> | ||
<dict> | ||
<key>xpos</key> | ||
<integer>510</integer> | ||
<key>ypos</key> | ||
<integer>90</integer> | ||
</dict> | ||
</dict> | ||
<key>variables</key> | ||
<dict> | ||
<key>branch</key> | ||
<string>5.6</string> | ||
</dict> | ||
<key>version</key> | ||
<string>0.1.0</string> | ||
<key>webaddress</key> | ||
<string>https://till.im</string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
use Alfred\Workflows\Workflow; | ||
|
||
use AlgoliaSearch\Client as Algolia; | ||
use AlgoliaSearch\Version as AlgoliaUserAgent; | ||
|
||
require __DIR__ . '/vendor/autoload.php'; | ||
|
||
$query = $argv[1]; | ||
$branch = $_ENV['branch'] ?? '5.6'; | ||
|
||
$workflow = new Workflow; | ||
$parsedown = new Parsedown; | ||
$algolia = new Algolia('8BB87I11DE', '8e1d446d61fce359f69cd7c8b86a50de'); | ||
|
||
AlgoliaUserAgent::addSuffixUserAgentSegment('Alfred Workflow', '0.1.0'); | ||
|
||
$index = $algolia->initIndex('docs'); | ||
$search = $index->search($query, ['tagFilters' => $branch]); | ||
$results = $search['hits']; | ||
|
||
if (empty($results)) { | ||
$workflow->result() | ||
->title('No matches') | ||
->icon('google.png') | ||
->subtitle("No match found in the {$branch} docs. Search Google for: \"{$query}\"") | ||
->arg("https://www.google.com/search?q={$query}") | ||
->quicklookurl("https://www.google.com/search?q={$query}") | ||
->valid(true); | ||
|
||
echo $workflow->output(); | ||
exit; | ||
} | ||
|
||
foreach ($results as $hit) { | ||
$hasText = isset($hit['_highlightResult']['content']['value']); | ||
$hasSubtitle = isset($hit['h2']); | ||
|
||
$title = $hit['h1']; | ||
$subtitle = $hasSubtitle ? $hit['h2'] : null; | ||
|
||
if ($hasSubtitle && $hasText) { | ||
$title = $hit['h2']; | ||
$subtitle = $hit['_highlightResult']['content']['value']; | ||
} | ||
|
||
$title = strip_tags(html_entity_decode($title, ENT_QUOTES, 'UTF-8')); | ||
|
||
$subtitle = $parsedown->line($subtitle); | ||
$subtitle = strip_tags(html_entity_decode($subtitle, ENT_QUOTES, 'UTF-8')); | ||
|
||
$workflow->result() | ||
->uid($hit['objectID']) | ||
->title($title) | ||
->autocomplete($title) | ||
->subtitle($subtitle) | ||
->arg("https://laravel.com/docs/{$branch}/{$hit['link']}") | ||
->quicklookurl("https://laravel.com/docs/{$branch}/{$hit['link']}") | ||
->valid(true); | ||
} | ||
|
||
echo $workflow->output(); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.