This repository has been archived by the owner on May 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
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 810f54b
Showing
10 changed files
with
283 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,2 @@ | ||
dist | ||
node_modules |
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,10 @@ | ||
#!/bin/sh | ||
|
||
#./node_modules/.bin/gulp --silent | ||
red=`tput setaf 1` | ||
bold=`tput bold` | ||
reset=`tput sgr0` | ||
|
||
echo "${red}${bold}** Don't forget to rebuild the workflow **${reset}" | ||
|
||
exit $? |
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 @@ | ||
Copyright (c) 2015 Gil Barbara | ||
|
||
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. |
Binary file not shown.
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,9 @@ | ||
CrashPlan Control | ||
================= | ||
Provides an easy way to control CrashPlan service with Alfred 2. | ||
|
||
 | ||
|
||
## Getting Started | ||
|
||
You can download this with [packal](https://github.com/packal/repository/raw/master/org.kollectiv.crashPlan/crashplancontrol.alfredworkflow) for easy updates or directly from [here](https://github.com/gilbarbara/crashplan-control/raw/master/CrashPlanControl.alfredworkflow). |
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,34 @@ | ||
var gulp = require('gulp'), | ||
$ = require('gulp-load-plugins')(), | ||
del = require('del'); | ||
|
||
var name = 'MDNSearch.alfredworkflow'; | ||
|
||
gulp.on('err', function (e) { | ||
$.util.log('Build failed: ', $.util.colors.red(e.err.message)); | ||
process.exit(1); | ||
}); | ||
|
||
gulp.task('copy', function () { | ||
return gulp.src(['info.plist', 'search.php', 'icon.png']) | ||
.pipe(gulp.dest('dist')); | ||
}); | ||
|
||
gulp.task('build', ['copy'], function () { | ||
return gulp.src('dist/*') | ||
.pipe($.zip(name)) | ||
.pipe(gulp.dest('./')); | ||
}); | ||
|
||
gulp.task('clean', function (cb) { | ||
return del(['dist/*', 'MDNSearch.alfredworkflow'], cb); | ||
}); | ||
|
||
gulp.task('hooks', function () { | ||
del('.git/hooks/pre-commit'); | ||
return gulp.src('.pre-commit') | ||
.pipe($.symlink('.git/hooks/pre-commit', { log: false })) | ||
|
||
}); | ||
|
||
gulp.task('default', ['hooks', 'clean', 'build']); |
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,108 @@ | ||
<?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.gilbarbara.mdn-search</string> | ||
<key>category</key> | ||
<string>Developer</string> | ||
<key>connections</key> | ||
<dict> | ||
<key>B8068536-AE17-4368-AB7E-9AB402E79AAB</key> | ||
<array> | ||
<dict> | ||
<key>destinationuid</key> | ||
<string>B880FB3B-9AAA-48ED-A646-05935287E399</string> | ||
<key>modifiers</key> | ||
<integer>0</integer> | ||
<key>modifiersubtext</key> | ||
<string></string> | ||
</dict> | ||
</array> | ||
</dict> | ||
<key>createdby</key> | ||
<string>Gil Barbara</string> | ||
<key>description</key> | ||
<string>Search Mozilla Developer Network</string> | ||
<key>disabled</key> | ||
<false/> | ||
<key>name</key> | ||
<string>MDN Search</string> | ||
<key>objects</key> | ||
<array> | ||
<dict> | ||
<key>config</key> | ||
<dict> | ||
<key>concurrently</key> | ||
<false/> | ||
<key>escaping</key> | ||
<integer>102</integer> | ||
<key>script</key> | ||
<string>open {query}</string> | ||
<key>type</key> | ||
<integer>0</integer> | ||
</dict> | ||
<key>type</key> | ||
<string>alfred.workflow.action.script</string> | ||
<key>uid</key> | ||
<string>B880FB3B-9AAA-48ED-A646-05935287E399</string> | ||
<key>version</key> | ||
<integer>0</integer> | ||
</dict> | ||
<dict> | ||
<key>config</key> | ||
<dict> | ||
<key>argumenttype</key> | ||
<integer>0</integer> | ||
<key>escaping</key> | ||
<integer>62</integer> | ||
<key>keyword</key> | ||
<string>mdn</string> | ||
<key>queuedelaycustom</key> | ||
<integer>3</integer> | ||
<key>queuedelayimmediatelyinitially</key> | ||
<false/> | ||
<key>queuedelaymode</key> | ||
<integer>0</integer> | ||
<key>queuemode</key> | ||
<integer>2</integer> | ||
<key>runningsubtext</key> | ||
<string>Searching...</string> | ||
<key>script</key> | ||
<string>php -f search.php -- "{query}"</string> | ||
<key>subtext</key> | ||
<string>ex: mdn addEventListener</string> | ||
<key>title</key> | ||
<string>mdn {search}</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>B8068536-AE17-4368-AB7E-9AB402E79AAB</string> | ||
<key>version</key> | ||
<integer>0</integer> | ||
</dict> | ||
</array> | ||
<key>readme</key> | ||
<string></string> | ||
<key>uidata</key> | ||
<dict> | ||
<key>B8068536-AE17-4368-AB7E-9AB402E79AAB</key> | ||
<dict> | ||
<key>ypos</key> | ||
<real>10</real> | ||
</dict> | ||
<key>B880FB3B-9AAA-48ED-A646-05935287E399</key> | ||
<dict> | ||
<key>ypos</key> | ||
<real>10</real> | ||
</dict> | ||
</dict> | ||
<key>webaddress</key> | ||
<string>https://github.com/gilbarbara/mdn-search</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,24 @@ | ||
{ | ||
"name": "mdn-search", | ||
"description": "Search MDN with Alfred", | ||
"version": "1.0.0", | ||
"homepage": "https://github.com/gilbarbara/mdn-search", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/gilbarbara/mdn-search.git" | ||
}, | ||
"author": { | ||
"name": "Gil Barbara", | ||
"email": "[email protected]", | ||
"url": "https://github.com/gilbarbara" | ||
}, | ||
"devDependencies": { | ||
"del": "^2.0", | ||
"gulp": "^3.9", | ||
"gulp-load-plugins": "^0.8", | ||
"gulp-symlink": "^2.1", | ||
"gulp-util": "^3.0", | ||
"gulp-zip": "^3.0" | ||
}, | ||
"license": "MIT" | ||
} |
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,89 @@ | ||
<?php | ||
$url = 'https://developer.mozilla.org/en-US/'; | ||
$search_url = $url . 'search.json?q='; | ||
|
||
$query = $argv[1]; | ||
$results = array(); | ||
|
||
function toxml($a = null, $format = 'array') { | ||
global $results; | ||
|
||
if ($format == 'json'): | ||
$a = json_decode($a, TRUE); | ||
endif; | ||
|
||
if (is_null($a) && !empty($results)): | ||
$a = $results; | ||
elseif (is_null($a) && empty($results)): | ||
return false; | ||
endif; | ||
|
||
$items = new SimpleXMLElement("<items></items>"); // Create new XML element | ||
|
||
foreach ($a as $b): // Lop through each object in the array | ||
$c = $items->addChild('item'); // Add a new 'item' element for each object | ||
$c_keys = array_keys($b); // Grab all the keys for that item | ||
foreach ($c_keys as $key): // For each of those keys | ||
if ($key == 'uid'): | ||
$c->addAttribute('uid', $b[$key]); | ||
elseif ($key == 'arg'): | ||
$c->addAttribute('arg', $b[$key]); | ||
elseif ($key == 'valid'): | ||
if ($b[$key] == 'yes' || $b[$key] == 'no'): | ||
$c->addAttribute('valid', $b[$key]); | ||
endif; | ||
elseif ($key == 'autocomplete'): | ||
$c->addAttribute('autocomplete', $b[$key]); | ||
else: | ||
$c->$key = $b[$key]; | ||
endif; | ||
endforeach; | ||
endforeach; | ||
|
||
return $items->asXML(); // Return XML string representation of the array | ||
|
||
} | ||
|
||
$results[] = array( | ||
'uid' => 'placeholder', | ||
'title' => 'Go to the website', | ||
'subtitle' => $url, | ||
'arg' => $url, | ||
'icon' => 'icon.png', | ||
'valid' => 'yes' | ||
); | ||
|
||
$curl = curl_init(); | ||
curl_setopt_array($curl, array( | ||
CURLOPT_RETURNTRANSFER => 1, | ||
CURLOPT_URL => $search_url . $query, | ||
)); | ||
$output = curl_exec($curl); | ||
curl_close($curl); | ||
$data = json_decode($output); | ||
|
||
$results = array(); | ||
|
||
if (!empty($data) && $data->count > 0) { | ||
foreach ($data->documents as $d): | ||
$results[] = array( | ||
'uid' => $d->slug, | ||
'title' => $d->title, | ||
'subtitle' => strip_tags($d->excerpt), | ||
'arg' => $d->url, | ||
'icon' => 'icon.png', | ||
'valid' => 'yes' | ||
); | ||
endforeach; | ||
} else { | ||
$results[] = array( | ||
'uid' => 'placeholder', | ||
'title' => 'No documents were found that matched "'.$query.'".', | ||
'subtitle' => 'Click to see the results for yourself', | ||
'arg' => $url . 'search?q=' . $query, | ||
'icon' => 'icon.png', | ||
'valid' => 'yes' | ||
); | ||
} | ||
|
||
echo toxml(); |