diff --git a/README.txt b/README.txt index 4036f96..26bdea7 100644 --- a/README.txt +++ b/README.txt @@ -47,6 +47,11 @@ To submit bug reports and feature suggestions, or to track changes: * Enable the module at Administer >> Site building >> Modules. +-- DRUSH -- + +* You can download the Jquery UI library using the provided Drush command, provided you have Drush installed. + The format of the command is "drush jqueryui-download VERSION PATH" + Both VERSION and PATH are optional as they default to "1.6" and "sites/all/libraries/jquery.ui" when no arguments are provided. -- JQUERY UI 1.7 -- diff --git a/jquery_ui.drush.inc b/jquery_ui.drush.inc new file mode 100644 index 0000000..5734e03 --- /dev/null +++ b/jquery_ui.drush.inc @@ -0,0 +1,47 @@ + 'Download the jQuery UI library.', + 'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT, // No site or config needed. + 'arguments' => array( + 'version' => dt('Optional. A version number for jquery.ui. Should be in the form "1.6" or "1.7.3". Defaults to 1.6.'), + 'path' => dt('Optional. A path to the download folder. If omitted Drush will use the default location (sites/all/libraries/jquery.ui).'), + ), + ); + + return $items; +} + +/** + * Checkout jQuery UI from SVN. + */ +function drush_jquery_ui_jqueryui_download() { + $args = func_get_args(); + + $version = ($args[0]) ? $args[0] : '1.6'; + $path = ($args[1]) ? $args[1] : drush_get_context('DRUSH_DRUPAL_ROOT') . '/sites/all/libraries/jquery.ui'; + + if (drush_shell_exec('svn export http://jquery-ui.googlecode.com/svn/tags/' . $version . '/ ' . $path)) { + drush_log(dt('jQuery UI version @version has been downloaded to @path.', array('@path' => $path, '@version' => $version)), 'success'); + } + else { + drush_log(dt('Drush was unable to download the jQuery UI library version @version to @path.', array('@path' => $path, '@version' => $version)), 'error'); + } +} + +/** + * Implements drush_MODULE_post_COMMAND(). + */ +function drush_jquery_ui_post_enable() { + $modules = func_get_args(); + if (in_array('jquery_ui', $modules)) { + jquery_ui_drush_download(); + } +}