Esempio n. 1
0
<?php

require_once __DIR__ . '/vendor/autoload.php';
use Alfred\Workflow;
use Guzzle\Http\Client;
$wf = new Workflow('com.ryanparman.workflow.packagist');
$http = new Client();
$int = 0;
$query = isset($argv[1]) ? $argv[1] : "{query}";
$request = $http->get("https://packagist.org/search.json?q=" . urlencode($query));
$response = $request->send()->json();
foreach ($response['results'] as $result) {
    $int++;
    $wf->result(array('uid' => $result['name'] . time(), 'arg' => $result['url'], 'title' => $result['name'], 'subtitle' => $result['description'], 'icon' => __DIR__ . '/icon.png', 'valid' => 'yes', 'autocomplete' => 'autocomplete'));
}
if (count($wf->results) === 0) {
    $wf->result(array('uid' => 'none', 'arg' => $query, 'title' => 'No results', 'subtitle' => 'No results found.', 'icon' => __DIR__ . '/icon.png', 'valid' => 'no'));
}
echo $wf->toXML();
Esempio n. 2
0
<?php

require_once __DIR__ . '/vendor/autoload.php';
use Alfred\Workflow;
$wf = new Workflow('com.ryanparman.workflow.manpages');
$int = 0;
$query = isset($argv[1]) ? $argv[1] : "{query}";
$query = stripslashes($query);
$pieces = explode(' ', $query);
$command = array_shift($pieces);
$args = implode('+', $pieces);
$url = "http://www.explainshell.com/explain/{$command}";
if ($args) {
    $url .= "?args={$args}";
}
$wf->result(array('uid' => time(), 'arg' => $url, 'title' => "Explain command for `{$command}`", 'subtitle' => '$ ' . $query, 'icon' => __DIR__ . '/icon.png', 'valid' => 'yes'));
echo $wf->toXML();
Esempio n. 3
0
<?php

require_once __DIR__ . '/vendor/autoload.php';
use Alfred\Workflow;
use Guzzle\Http\Client;
$wf = new Workflow('com.ryanparman.workflow.redbox');
$http = new Client();
$query = stripslashes($argv[1]);
$request = $http->get("https://content.atomz.com/autocomplete/sp10/04/a1/b7/?query=" . urlencode($query));
$r = $request->send()->getBody(true);
// Do some cleanup
$r = trim(substr(trim($r), 1, -1));
$r = preg_replace('/\\s+/i', ' ', $r);
$r = json_decode($r, true);
function uc($s)
{
    $s = ucwords($s);
    $s = str_ireplace('blu-ray', 'Blu-ray', $s);
    return $s;
}
if (count($r) > 0) {
    foreach ($r as $i => $result) {
        $result = uc($result);
        $wf->result(array('uid' => sha1($query . $i . time()), 'arg' => rawurlencode($result), 'title' => $result, 'subtitle' => "Search Redbox for \"{$result}\"", 'icon' => __DIR__ . '/icon.png', 'valid' => 'yes'));
    }
} else {
    $wf->result(array('uid' => sha1($query . $i . time()), 'arg' => rawurlencode($query), 'title' => 'No results found for "' . uc($query) . '"', 'subtitle' => "Try using fewer keywords.", 'icon' => __DIR__ . '/icon.png', 'valid' => 'no'));
}
echo $wf->toXML();
Esempio n. 4
0
<?php

require_once __DIR__ . '/vendor/autoload.php';
use Alfred\Workflow;
use Skyzyx\Components\Mimetypes\Mimetypes;
$bundle_id = 'com.ryanparman.workflow.mime';
$wf = new Workflow($bundle_id);
$int = 0;
$query = $argv[1];
$mimes = Mimetypes::getInstance()->getMimeTypes();
$extensions = array_keys($mimes);
$matching_extensions = array_filter($extensions, function ($extension) use($query, $mimes, $wf, &$int) {
    $int++;
    if (preg_match('/' . $query . '/i', $extension)) {
        $wf->result(array('uid' => "{$extension}-{$query}-{$int}", 'arg' => $mimes[$extension], 'title' => $extension . ': ' . $mimes[$extension], 'subtitle' => 'Copy to clipboard', 'icon' => __DIR__ . '/icon.png'));
        return true;
    }
    return false;
});
if (count($matching_extensions) === 0) {
    $wf->result(array('uid' => 'none', 'arg' => $query, 'title' => 'No results', 'subtitle' => 'No results found.', 'icon' => __DIR__ . '/icon.png', 'valid' => 'no'));
}
echo $wf->toXML();
Esempio n. 5
0
<?php

require_once __DIR__ . '/vendor/autoload.php';
use Alfred\Workflow;
use Guzzle\Http\Client;
$wf = new Workflow('com.ryanparman.workflow.geo');
$http = new Client();
$int = 0;
$query = $argv[1];
$request = $http->get("http://freegeoip.net/json/" . urlencode($query));
$r = $request->send()->json();
extract($r);
$wf->result(array('uid' => 'geocity' . time(), 'arg' => "{$city}, {$region_name}, {$country_name}", 'title' => "{$city}, {$region_name}, {$country_name}", 'subtitle' => "Data for {$ip}", 'icon' => __DIR__ . '/icon.png', 'valid' => 'no', 'autocomplete' => $ip));
$wf->result(array('uid' => 'geolatlong' . time(), 'arg' => "{$latitude},{$longitude}", 'title' => "Lat/Long: {$latitude},{$longitude}", 'subtitle' => "Copy to clipboard", 'icon' => __DIR__ . '/icon.png', 'valid' => 'yes'));
$wf->result(array('uid' => 'geoip' . time(), 'arg' => $ip, 'title' => "Public IP: {$ip}", 'subtitle' => "Copy to clipboard", 'icon' => __DIR__ . '/icon.png', 'valid' => 'yes'));
$wf->result(array('uid' => 'geomap' . time(), 'arg' => "https://maps.google.com/maps?t=v&z=12&ll={$latitude},{$longitude}", 'title' => "Show map of {$latitude},{$longitude}", 'subtitle' => "Open in Google Maps", 'icon' => __DIR__ . '/icon.png', 'valid' => 'yes'));
echo $wf->toXML();