Skip to content

Commit

Permalink
Added download command
Browse files Browse the repository at this point in the history
  • Loading branch information
Zack Tollman committed Apr 15, 2012
1 parent ace1a7e commit 5ea2db7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
Binary file modified WordPress Plugin Repo Search.alfredextension
Binary file not shown.
2 changes: 1 addition & 1 deletion info.plist
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#Use: wpplugin <slug> <term> [num] #Use: wpplugin <slug> <term> [num]
#Ex: wpplugin version debug bar #Ex: wpplugin version debug bar
#slug: key from the WordPress plugin repo response object. Valid args are: 'name', 'slug', 'version', 'author', 'author_profile', 'contributors', 'requires', 'tested', 'rating', 'num_ratings', 'homepage', 'description', 'homepage', 'short_description'. #slug: key from the WordPress plugin repo response object. Valid args are: 'name', 'slug', 'version', 'author', 'author_profile', 'contributors', 'requires', 'tested', 'rating', 'num_ratings', 'homepage', 'description', 'homepage', 'short_description', 'download'.
#term: search term to search against the WordPress plugin repo #term: search term to search against the WordPress plugin repo
#num: number of results to return. default = 1. #num: number of results to return. default = 1.
Expand Down
22 changes: 19 additions & 3 deletions wp-plugin-search.php
Original file line number Original file line Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php <?php
$slugs = array( 'name', 'slug', 'version', 'author', 'author_profile', 'contributors', 'requires', 'tested', 'rating', 'num_ratings', 'homepage', 'description', 'homepage', 'short_description' ); $slugs = array( 'name', 'slug', 'version', 'author', 'author_profile', 'contributors', 'requires', 'tested', 'rating', 'num_ratings', 'homepage', 'description', 'homepage', 'short_description', 'download' );


// Key 1 is the query send to the script from Alfred // Key 1 is the query send to the script from Alfred
$query = $argv[1]; $query = $argv[1];
Expand Down Expand Up @@ -56,10 +56,26 @@


// Print only the requested piece of information // Print only the requested piece of information
foreach ( $results->plugins as $key => $plugin ) { foreach ( $results->plugins as $key => $plugin ) {
echo $plugin->name . ' (' . $slug . ')' . ":\n"; if ( 'download' != $slug )
echo $plugin->name . ' (' . $slug . ')' . ":\n";


if ( 'contributors' != $slug ) { if ( 'contributors' != $slug && 'download' != $slug ) {
echo strip_tags( $plugin->$slug ) . $delimiter . $delimiter; echo strip_tags( $plugin->$slug ) . $delimiter . $delimiter;
} elseif ( 'download' == $slug ) {
$filename = $plugin->slug . '.zip';
$file_location = 'http://downloads.wordpress.org/plugin/' . $filename;
$local_save = '~/Desktop/' . $filename;

// @todo: find a better way to test this
if ( '' == exec( 'curl ' . $file_location . ' -o ' . $local_save ) ) {
echo $plugin->name . ' downloaded to the desktop.' . "\n";

exec( 'cd ~/Desktop;unzip ' . $filename );
echo $filename . ' unzipped to the desktop.' . "\n";

if ( '' == exec( 'rm ~/Desktop/' . $filename ) )
echo $filename . ' removed.' . $delimiter . $delimiter;
}
} else { } else {
if ( is_array( $plugin->$slug ) ) { if ( is_array( $plugin->$slug ) ) {
echo strip_tags( implode( ', ', array_keys( $plugin->$slug ) ) ) . $delimiter . $delimiter; echo strip_tags( implode( ', ', array_keys( $plugin->$slug ) ) ) . $delimiter . $delimiter;
Expand Down

0 comments on commit 5ea2db7

Please sign in to comment.