diff --git a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.01B99718-BEB4-42E5-AD0B-722456C7A4D0/7B72027E-5733-4561-9B5A-1B7EC6ADB482.png b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.01B99718-BEB4-42E5-AD0B-722456C7A4D0/7B72027E-5733-4561-9B5A-1B7EC6ADB482.png deleted file mode 100644 index 0d3698b..0000000 Binary files a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.01B99718-BEB4-42E5-AD0B-722456C7A4D0/7B72027E-5733-4561-9B5A-1B7EC6ADB482.png and /dev/null differ diff --git a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.01B99718-BEB4-42E5-AD0B-722456C7A4D0/icon.png b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.01B99718-BEB4-42E5-AD0B-722456C7A4D0/icon.png deleted file mode 100644 index 0d3698b..0000000 Binary files a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.01B99718-BEB4-42E5-AD0B-722456C7A4D0/icon.png and /dev/null differ diff --git a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.01B99718-BEB4-42E5-AD0B-722456C7A4D0/info.plist b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.01B99718-BEB4-42E5-AD0B-722456C7A4D0/info.plist deleted file mode 100644 index f47d147..0000000 --- a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.01B99718-BEB4-42E5-AD0B-722456C7A4D0/info.plist +++ /dev/null @@ -1,88 +0,0 @@ - - - - - bundleid - - connections - - 7B72027E-5733-4561-9B5A-1B7EC6ADB482 - - - destinationuid - BF10B845-468E-4A88-A9D9-8E4C589E387C - modifiers - 0 - modifiersubtext - - - - - createdby - Alpha Chen - description - - disabled - - name - WeatherSpark - objects - - - config - - browser - com.google.Chrome - plusspaces - - url - http://weatherspark.com/forecasts/noaa/USA/WA/Seattle - utf8 - - - type - alfred.workflow.action.openurl - uid - BF10B845-468E-4A88-A9D9-8E4C589E387C - version - 0 - - - config - - argumenttype - 2 - keyword - ws - text - WeatherSpark - withspace - - - type - alfred.workflow.input.keyword - uid - 7B72027E-5733-4561-9B5A-1B7EC6ADB482 - version - 0 - - - readme - - uidata - - 7B72027E-5733-4561-9B5A-1B7EC6ADB482 - - ypos - 10 - - BF10B845-468E-4A88-A9D9-8E4C589E387C - - ypos - 10 - - - webaddress - http://github.com/kejadlen - - diff --git a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_gem.png b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_gem.png deleted file mode 100644 index 7766ab9..0000000 Binary files a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_gem.png and /dev/null differ diff --git a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_go.png b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_go.png deleted file mode 100644 index d73636d..0000000 Binary files a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_go.png and /dev/null differ diff --git a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_man.png b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_man.png deleted file mode 100644 index 087105e..0000000 Binary files a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_man.png and /dev/null differ diff --git a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_markdown.png b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_markdown.png deleted file mode 100644 index 137e32d..0000000 Binary files a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_markdown.png and /dev/null differ diff --git a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_md.png b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_md.png deleted file mode 100644 index d214d9b..0000000 Binary files a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_md.png and /dev/null differ diff --git a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_mongo.png b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_mongo.png deleted file mode 100644 index 9294ac3..0000000 Binary files a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_mongo.png and /dev/null differ diff --git a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_osx.png b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_osx.png new file mode 100644 index 0000000..189533f Binary files /dev/null and b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_osx.png differ diff --git a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_python2.png b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_python2.png deleted file mode 100644 index 296cba2..0000000 Binary files a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_python2.png and /dev/null differ diff --git a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_redis.png b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_redis.png deleted file mode 100644 index b856e81..0000000 Binary files a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_redis.png and /dev/null differ diff --git a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_ruby.png b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_ruby.png index 934633c..9506294 100644 Binary files a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_ruby.png and b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_ruby.png differ diff --git a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_sqlalchemy.png b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_sqlalchemy.png deleted file mode 100644 index ae0d85d..0000000 Binary files a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_sqlalchemy.png and /dev/null differ diff --git a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_vim.png b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_vim.png deleted file mode 100644 index 86ff0b2..0000000 Binary files a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/dash_keyword_vim.png and /dev/null differ diff --git a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/info.plist b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/info.plist index 17f4248..a482f57 100644 --- a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/info.plist +++ b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.35F259A3-BBD9-4A1B-B237-5E149EE1E723/info.plist @@ -55,61 +55,7 @@ Copy - dash_keyword_markdown - - - destinationuid - dash_action_normal - modifiers - 0 - modifiersubtext - - - - destinationuid - dash_action_cmd - modifiers - 1048576 - modifiersubtext - - - - destinationuid - dash_action_alt - modifiers - 524288 - modifiersubtext - - - - dash_keyword_python2 - - - destinationuid - dash_action_normal - modifiers - 0 - modifiersubtext - - - - destinationuid - dash_action_cmd - modifiers - 1048576 - modifiersubtext - - - - destinationuid - dash_action_alt - modifiers - 524288 - modifiersubtext - - - - dash_keyword_redis + dash_keyword_osx destinationuid @@ -163,33 +109,6 @@ - dash_keyword_sqlalchemy - - - destinationuid - dash_action_normal - modifiers - 0 - modifiersubtext - - - - destinationuid - dash_action_cmd - modifiers - 1048576 - modifiersubtext - - - - destinationuid - dash_action_alt - modifiers - 524288 - modifiersubtext - - - createdby Kapeli @@ -428,15 +347,15 @@ That said, you can edit anything else within this workflow (including adding new escaping 110 keyword - markdown + osx runningsubtext Searching for "{query}" script - ./dashAlfredWorkflow "markdown:{query}" + ./dashAlfredWorkflow "osx:{query}" subtext - Search Markdown for "{query}" + Search OS X 10.10 for "{query}" title - Search Markdown + Search OS X 10.10 type 0 withspace @@ -445,65 +364,7 @@ That said, you can edit anything else within this workflow (including adding new type alfred.workflow.input.scriptfilter uid - dash_keyword_markdown - version - 0 - - - config - - argumenttype - 0 - escaping - 110 - keyword - python2 - runningsubtext - Searching for "{query}" - script - ./dashAlfredWorkflow "python2:{query}" - subtext - Search Python 2 for "{query}" - title - Search Python 2 - type - 0 - withspace - - - type - alfred.workflow.input.scriptfilter - uid - dash_keyword_python2 - version - 0 - - - config - - argumenttype - 0 - escaping - 110 - keyword - redis - runningsubtext - Searching for "{query}" - script - ./dashAlfredWorkflow "redis:{query}" - subtext - Search Redis for "{query}" - title - Search Redis - type - 0 - withspace - - - type - alfred.workflow.input.scriptfilter - uid - dash_keyword_redis + dash_keyword_osx version 0 @@ -521,7 +382,7 @@ That said, you can edit anything else within this workflow (including adding new script ./dashAlfredWorkflow "ruby:{query}" subtext - Search Ruby 2 and 1 other for "{query}" + Search Ruby 2 for "{query}" title Search Ruby 2 type @@ -536,35 +397,6 @@ That said, you can edit anything else within this workflow (including adding new version 0 - - config - - argumenttype - 0 - escaping - 110 - keyword - sqlalchemy - runningsubtext - Searching for "{query}" - script - ./dashAlfredWorkflow "sqlalchemy:{query}" - subtext - Search SQLAlchemy for "{query}" - title - Search SQLAlchemy - type - 0 - withspace - - - type - alfred.workflow.input.scriptfilter - uid - dash_keyword_sqlalchemy - version - 0 - readme Usage: @@ -604,30 +436,15 @@ The keyword is either a docset keyword (defined in Preferences > Docsets) or ypos 10 - dash_keyword_markdown + dash_keyword_osx ypos 930 - dash_keyword_python2 - - ypos - 1050 - - dash_keyword_redis - - ypos - 1170 - dash_keyword_ruby ypos - 1290 - - dash_keyword_sqlalchemy - - ypos - 1410 + 1050 dash_note_readme diff --git a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.7E45F1DF-16F4-4335-91F9-B008C0F32243/icon.png b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.7E45F1DF-16F4-4335-91F9-B008C0F32243/icon.png new file mode 100644 index 0000000..f069128 Binary files /dev/null and b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.7E45F1DF-16F4-4335-91F9-B008C0F32243/icon.png differ diff --git a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.7E45F1DF-16F4-4335-91F9-B008C0F32243/info.plist b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.7E45F1DF-16F4-4335-91F9-B008C0F32243/info.plist new file mode 100644 index 0000000..e0b05be --- /dev/null +++ b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.7E45F1DF-16F4-4335-91F9-B008C0F32243/info.plist @@ -0,0 +1,111 @@ + + + + + bundleid + com.alfredapp.david.googlesuggest + connections + + 63F60794-BB56-4415-9372-BAF974C3A7E1 + + + destinationuid + B8FFA3AB-AD7D-4316-A84F-5958A671D4FF + modifiers + 0 + modifiersubtext + + + + + createdby + David Ferguson + description + Get Google Search Suggestions + disabled + + name + Google Suggest + objects + + + config + + argumenttype + 0 + escaping + 36 + keyword + g + runningsubtext + Retrieving search suggestions ... + script + require_once('workflows.php'); +$wf = new Workflows(); + +$orig = "{query}"; +$xml = $wf->request( "http://google.com/complete/search?output=toolbar&q=".urlencode( $orig ) ); +$xml = simplexml_load_string( utf8_encode($xml) ); +$int = 1; + +foreach( $xml as $sugg ): + $data = $sugg->suggestion->attributes()->data; + $wf->result( $int.'.'.time(), "$data", "$data", 'Search Google for '.$data, 'icon.png' ); + $int++; +endforeach; + +$results = $wf->results(); +if ( count( $results ) == 0 ): + $wf->result( 'googlesuggest', $orig, 'No Suggestions', 'No search suggestions found. Search Google for '.$orig, 'icon.png' ); +endif; + +echo $wf->toxml(); + subtext + Search Google with Suggestions + title + Search Google + type + 1 + withspace + + + type + alfred.workflow.input.scriptfilter + uid + 63F60794-BB56-4415-9372-BAF974C3A7E1 + version + 0 + + + config + + searcher + 1635215215 + + type + alfred.workflow.action.systemwebsearch + uid + B8FFA3AB-AD7D-4316-A84F-5958A671D4FF + version + 0 + + + readme + + uidata + + 63F60794-BB56-4415-9372-BAF974C3A7E1 + + ypos + 60 + + B8FFA3AB-AD7D-4316-A84F-5958A671D4FF + + ypos + 60 + + + webaddress + dferg.us + + diff --git a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.7E45F1DF-16F4-4335-91F9-B008C0F32243/workflows.php b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.7E45F1DF-16F4-4335-91F9-B008C0F32243/workflows.php new file mode 100644 index 0000000..871f502 --- /dev/null +++ b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.7E45F1DF-16F4-4335-91F9-B008C0F32243/workflows.php @@ -0,0 +1,462 @@ +path = exec('pwd'); + $this->home = exec('printf $HOME'); + + if ( file_exists( 'info.plist' ) ): + $this->bundle = $this->get( 'bundleid', 'info.plist' ); + endif; + + if ( !is_null( $bundleid ) ): + $this->bundle = $bundleid; + endif; + + $this->cache = $this->home. "/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/".$this->bundle; + $this->data = $this->home. "/Library/Application Support/Alfred 2/Workflow Data/".$this->bundle; + + if ( !file_exists( $this->cache ) ): + exec("mkdir '".$this->cache."'"); + endif; + + if ( !file_exists( $this->data ) ): + exec("mkdir '".$this->data."'"); + endif; + + $this->results = array(); + } + + /** + * Description: + * Accepts no parameter and returns the value of the bundle id for the current workflow. + * If no value is available, then false is returned. + * + * @param none + * @return false if not available, bundle id value if available. + */ + public function bundle() + { + if ( is_null( $this->bundle ) ): + return false; + else: + return $this->bundle; + endif; + } + + /** + * Description: + * Accepts no parameter and returns the value of the path to the cache directory for your + * workflow if it is available. Returns false if the value isn't available. + * + * @param none + * @return false if not available, path to the cache directory for your workflow if available. + */ + public function cache() + { + if ( is_null( $this->bundle ) ): + return false; + else: + if ( is_null( $this->cache ) ): + return false; + else: + return $this->cache; + endif; + endif; + } + + /** + * Description: + * Accepts no parameter and returns the value of the path to the storage directory for your + * workflow if it is available. Returns false if the value isn't available. + * + * @param none + * @return false if not available, path to the storage directory for your workflow if available. + */ + public function data() + { + if ( is_null( $this->bundle ) ): + return false; + else: + if ( is_null( $this->data ) ): + return false; + else: + return $this->data; + endif; + endif; + } + + /** + * Description: + * Accepts no parameter and returns the value of the path to the current directory for your + * workflow if it is available. Returns false if the value isn't available. + * + * @param none + * @return false if not available, path to the current directory for your workflow if available. + */ + public function path() + { + if ( is_null( $this->path ) ): + return false; + else: + return $this->path; + endif; + } + + /** + * Description: + * Accepts no parameter and returns the value of the home path for the current user + * Returns false if the value isn't available. + * + * @param none + * @return false if not available, home path for the current user if available. + */ + public function home() + { + if ( is_null( $this->home ) ): + return false; + else: + return $this->home; + endif; + } + + /** + * Description: + * Returns an array of available result items + * + * @param none + * @return array - list of result items + */ + public function results() + { + return $this->results; + } + + /** + * Description: + * Convert an associative array into XML format + * + * @param $a - An associative array to convert + * @param $format - format of data being passed (json or array), defaults to array + * @return - XML string representation of the array + */ + public function toxml( $a=null, $format='array' ) { + + if ( $format == 'json' ): + $a = json_decode( $a, TRUE ); + endif; + + if ( is_null( $a ) && !empty( $this->results ) ): + $a = $this->results; + elseif ( is_null( $a ) && empty( $this->results ) ): + return false; + endif; + + $items = new SimpleXMLElement(""); // 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 == 'type' ): + $c->addAttribute( 'type', $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] ); + elseif ( $key == 'icon' ): + if ( substr( $b[$key], 0, 9 ) == 'fileicon:' ): + $val = substr( $b[$key], 9 ); + $c->$key = $val; + $c->$key->addAttribute( 'type', 'fileicon' ); + elseif ( substr( $b[$key], 0, 9 ) == 'filetype:' ): + $val = substr( $b[$key], 9 ); + $c->$key = $val; + $c->$key->addAttribute( 'type', 'filetype' ); + else: + $c->$key = $b[$key]; + endif; + else: + $c->$key = $b[$key]; + endif; + endforeach; + endforeach; + + return $items->asXML(); // Return XML string representation of the array + + } + + /** + * Description: + * Remove all items from an associative array that do not have a value + * + * @param $a - Associative array + * @return bool + */ + private function empty_filter( $a ) { + if ( $a == '' || $a == null ): // if $a is empty or null + return false; // return false, else, return true + else: + return true; + endif; + } + + /** + * Description: + * Save values to a specified plist. If the first parameter is an associative + * array, then the second parameter becomes the plist file to save to. If the + * first parameter is string, then it is assumed that the first parameter is + * the label, the second parameter is the value, and the third parameter is + * the plist file to save the data to. + * + * @param $a - associative array of values to save + * @param $b - the value of the setting + * @param $c - the plist to save the values into + * @return string - execution output + */ + public function set( $a=null, $b=null, $c=null ) + { + if ( is_array( $a ) ): + if ( file_exists( $b ) ): + $b = $this->path."/".$b; + elseif ( file_exists( $this->data."/".$b ) ): + $b = $this->data."/".$b; + elseif ( file_exists( $this->cache."/".$b ) ): + $b = $this->cache."/".$b; + else: + $b = $this->data."/".$b; + endif; + else: + if ( file_exists( $c ) ): + $c = $this->path."/".$c; + elseif ( file_exists( $this->data."/".$c ) ): + $c = $this->data."/".$c; + elseif ( file_exists( $this->cache."/".$c ) ): + $c = $this->cache."/".$c; + else: + $c = $this->data."/".$c; + endif; + endif; + + if ( is_array( $a ) ): + foreach( $a as $k => $v ): + exec( 'defaults write "'. $b .'" '. $k .' "'. $v .'"'); + endforeach; + else: + exec( 'defaults write "'. $c .'" '. $a .' "'. $b .'"'); + endif; + } + + /** + * Description: + * Read a value from the specified plist + * + * @param $a - the value to read + * @param $b - plist to read the values from + * @return bool false if not found, string if found + */ + public function get( $a, $b ) { + + if ( file_exists( $b ) ): + $b = $this->path."/".$b; + elseif ( file_exists( $this->data."/".$b ) ): + $b = $this->data."/".$b; + elseif ( file_exists( $this->cache."/".$b ) ): + $b = $this->cache."/".$b; + else: + return false; + endif; + + exec( 'defaults read "'. $b .'" '.$a, $out ); // Execute system call to read plist value + + if ( $out == "" ): + return false; + endif; + + $out = $out[0]; + return $out; // Return item value + } + + /** + * Description: + * Read data from a remote file/url, essentially a shortcut for curl + * + * @param $url - URL to request + * @param $options - Array of curl options + * @return result from curl_exec + */ + public function request( $url=null, $options=null ) + { + if ( is_null( $url ) ): + return false; + endif; + + $defaults = array( // Create a list of default curl options + CURLOPT_RETURNTRANSFER => true, // Returns the result as a string + CURLOPT_URL => $url, // Sets the url to request + CURLOPT_FRESH_CONNECT => true + ); + + if ( $options ): + foreach( $options as $k => $v ): + $defaults[$k] = $v; + endforeach; + endif; + + array_filter( $defaults, // Filter out empty options from the array + array( $this, 'empty_filter' ) ); + + $ch = curl_init(); // Init new curl object + curl_setopt_array( $ch, $defaults ); // Set curl options + $out = curl_exec( $ch ); // Request remote data + $err = curl_error( $ch ); + curl_close( $ch ); // End curl request + + if ( $err ): + return $err; + else: + return $out; + endif; + } + + /** + * Description: + * Allows searching the local hard drive using mdfind + * + * @param $query - search string + * @return array - array of search results + */ + public function mdfind( $query ) + { + exec('mdfind "'.$query.'"', $results); + return $results; + } + + /** + * Description: + * Accepts data and a string file name to store data to local file as cache + * + * @param array - data to save to file + * @param file - filename to write the cache data to + * @return none + */ + public function write( $a, $b ) + { + if ( file_exists( $b ) ): + $b = $this->path."/".$b; + elseif ( file_exists( $this->data."/".$b ) ): + $b = $this->data."/".$b; + elseif ( file_exists( $this->cache."/".$b ) ): + $b = $this->cache."/".$b; + else: + $b = $this->data."/".$b; + endif; + + if ( is_array( $a ) ): + $a = json_encode( $a ); + file_put_contents( $b, $a ); + return true; + elseif ( is_string( $a ) ): + file_put_contents( $b, $a ); + return true; + else: + return false; + endif; + } + + /** + * Description: + * Returns data from a local cache file + * + * @param file - filename to read the cache data from + * @return false if the file cannot be found, the file data if found. If the file + * format is json encoded, then a json object is returned. + */ + public function read( $a ) + { + if ( file_exists( $a ) ): + $a = $this->path."/".$a; + elseif ( file_exists( $this->data."/".$a ) ): + $a = $this->data."/".$a; + elseif ( file_exists( $this->cache."/".$a ) ): + $a = $this->cache."/".$a; + else: + return false; + endif; + + $out = file_get_contents( $a ); + if ( !is_null( json_decode( $out ) ) ): + $out = json_decode( $out ); + endif; + + return $out; + } + + /** + * Description: + * Helper function that just makes it easier to pass values into a function + * and create an array result to be passed back to Alfred + * + * @param $uid - the uid of the result, should be unique + * @param $arg - the argument that will be passed on + * @param $title - The title of the result item + * @param $sub - The subtitle text for the result item + * @param $icon - the icon to use for the result item + * @param $valid - sets whether the result item can be actioned + * @param $auto - the autocomplete value for the result item + * @return array - array item to be passed back to Alfred + */ + public function result( $uid, $arg, $title, $sub, $icon, $valid='yes', $auto=null, $type=null ) + { + $temp = array( + 'uid' => $uid, + 'arg' => $arg, + 'title' => $title, + 'subtitle' => $sub, + 'icon' => $icon, + 'valid' => $valid, + 'autocomplete' => $auto, + 'type' => $type + ); + + if ( is_null( $type ) ): + unset( $temp['type'] ); + endif; + + array_push( $this->results, $temp ); + + return $temp; + } + +} \ No newline at end of file diff --git a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.EBB6171A-6C0B-447C-8BE5-E273C925A74F/info.plist b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.EBB6171A-6C0B-447C-8BE5-E273C925A74F/info.plist index 8d0efde..be59422 100644 --- a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.EBB6171A-6C0B-447C-8BE5-E273C925A74F/info.plist +++ b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.EBB6171A-6C0B-447C-8BE5-E273C925A74F/info.plist @@ -20,16 +20,7 @@ 2E57B3A5-B65F-4AB6-93B2-183BB082414B - - - destinationuid - 30CDA5F5-6107-44A7-8A5D-551DFBD599B6 - modifiers - 0 - modifiersubtext - - - + 960E961A-2EF3-44C4-BFF2-B8BA1466C8EA @@ -442,23 +433,6 @@ version 1 - - config - - paths - - ~/Applications/Mailbox (Beta).app - - toggle - - - type - alfred.workflow.action.launchfiles - uid - 30CDA5F5-6107-44A7-8A5D-551DFBD599B6 - version - 0 - readme @@ -489,11 +463,6 @@ ypos 250 - 30CDA5F5-6107-44A7-8A5D-551DFBD599B6 - - ypos - 850 - 43DCD79F-94B0-4F0D-B7C2-4F04DC7ECE20 ypos diff --git a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.F66C1F98-7B23-4C7A-820C-3F5B37200A80/5E9084C5-202F-4750-9DDC-1077AAAA27B1.png b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.F66C1F98-7B23-4C7A-820C-3F5B37200A80/5E9084C5-202F-4750-9DDC-1077AAAA27B1.png deleted file mode 100644 index 7b41925..0000000 Binary files a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.F66C1F98-7B23-4C7A-820C-3F5B37200A80/5E9084C5-202F-4750-9DDC-1077AAAA27B1.png and /dev/null differ diff --git a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.F66C1F98-7B23-4C7A-820C-3F5B37200A80/icon.png b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.F66C1F98-7B23-4C7A-820C-3F5B37200A80/icon.png deleted file mode 100644 index 7b41925..0000000 Binary files a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.F66C1F98-7B23-4C7A-820C-3F5B37200A80/icon.png and /dev/null differ diff --git a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.F66C1F98-7B23-4C7A-820C-3F5B37200A80/info.plist b/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.F66C1F98-7B23-4C7A-820C-3F5B37200A80/info.plist deleted file mode 100644 index d628e22..0000000 --- a/Alfred 2/Alfred.alfredpreferences/workflows/user.workflow.F66C1F98-7B23-4C7A-820C-3F5B37200A80/info.plist +++ /dev/null @@ -1,86 +0,0 @@ - - - - - bundleid - - connections - - 5E9084C5-202F-4750-9DDC-1077AAAA27B1 - - - destinationuid - 694E5D78-618B-4553-86C1-932DF3D04B1E - modifiers - 0 - modifiersubtext - - - - - createdby - Alpha Chen - description - - disabled - - name - Vimwiki - objects - - - config - - argumenttype - 2 - keyword - vw - text - Vimwiki - withspace - - - type - alfred.workflow.input.keyword - uid - 5E9084C5-202F-4750-9DDC-1077AAAA27B1 - version - 0 - - - config - - escaping - 63 - script - /usr/local/bin/mvim -c VimwikiIndex - type - 5 - - type - alfred.workflow.action.script - uid - 694E5D78-618B-4553-86C1-932DF3D04B1E - version - 0 - - - readme - - uidata - - 5E9084C5-202F-4750-9DDC-1077AAAA27B1 - - ypos - 10 - - 694E5D78-618B-4553-86C1-932DF3D04B1E - - ypos - 10 - - - webaddress - http://github.com/kejadlen - -