Posted by jonhattan on July 25, 2009 at 5:03pm
| Project: | Drush |
| Version: | All-versions-5.x-dev |
| Component: | PM (dl, en, up ...) |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Owen Barton |
| Status: | closed (fixed) |
Issue Summary
Attached is a file with a set of commands to simply list, enable, disable themes in a site. This is the complete set of commands:
theme status Show current status of theme configuration in the site.
theme list List all the available themes for the site.
theme info List all info about a theme.
theme set default Set the default theme.
theme set admin Set the administration theme.
theme enable Enable a theme.
theme disable Disable a theme.It has been tested with drupal 6.x. Must review if compatible with 5.x and 7.x
I include also a dump of a session using the commands:
$ drush theme list
Nombre Título Enabled/Disabled Predeterminado
STARTERKIT Zen Themer’s Starter Kit disabled No
zen_classic Zen Classic disabled No
marvin Marvin disabled No
minnelli Minnelli disabled No
pushbutton Pushbutton disabled No
chrysalis Chrysalis enabled No
zen Zen enabled Si
bluemarine Bluemarine enabled No
chameleon Chameleon enabled No
garland Garland enabled No $ drush theme status
Default theme: <em>zen</em>
Administration theme: <em>garland</em>
Other enabled themes: chrysalis bluemarine chameleon garland
$ drush theme info garland
Name: garland
Title: Garland
Description: Tableless, recolorable, multi-column, fluid width theme (default).
Version: 6.13
Core: 6.x
PHP: 4.3.5
Engine: phptemplate
Regions: Left sidebar, Right sidebar, Content, Header, Footer
Features: comment_user_picture, favicon, mission, logo, name, node_user_picture, search, slogan, primary_links, secondary_links
Stylesheets:
media: all
files: themes/garland/style.css
media: print
files: themes/garland/print.css
Scripts:
files: themes/garland/script.js$ drush theme set default zen
Setting zen as default theme [success]$ drush theme set admin garland
Setting garland as admin theme [success]$ drush theme enable marvin
Enabling marvin [success]$ drush theme disable zen
drush: zen is the default theme. You must set another theme as default before trying to disable this one.
Drush command could not be completed. [error]$ drush theme disable marvin
Disabling marvin [success]| Attachment | Size |
|---|---|
| theme.drush_.inc_.txt | 6.08 KB |
Comments
#1
Forgot to say any comment on the code is very welcome as I don't know drush very deeply.
#2
New attached file is tested with drupal versions 5, 6 and 7 (with patch from #537280: D7 compatibility). Changes are:
* added some help text (implementation of
drush_hook_help())* new command:
drush theme list enabled* both
theme listandtheme list enabledhas a new column indicating if it is the administration theme.The only drupal version specific code is the one to show the theme info, as drupal 5 themes does not have the same info object as versions 6 and 7.
Note: in order to use it download the attachment to ~/.drush/theme/theme.drush.inc
#3
I've placed the code in my cvs sandbox http://cvs.drupal.org/viewvc.py/drupal/contributions/sandbox/jonhattan/d...
new changes:
* all strings now go through dt()
* use of new _drush_get_themes()
any suggestion on other features/commands?
#4
I am fascinated with
drushand use it whenever I can.I was puzzled as why it doesn't handle themes and then I saw your addition. Why is it not part of standard
drush?I tried to implement it but did not succseed: i made
~/drush/theme/folder and placedtheme.drush.incthere but drush did not recognize it?!I tried to move it to
~/drush/and~/drush/includesbut still it didn't work.Can you tell me what am I doing wrong?
You should include some more detailed information on installation and operation of commands. Drush is very powerfull and someone could easily do some irreparable damage so I hope you took precautions like backing up theme prior to upgrade.
Does your theme command works with multisite installation?
People usualy forgot that their subtheme might not work with new version of the theme. They also tend to forget that they changed the original theme in code while not changing name so upgrade could actually destroy developed theme (I've done that).
#5
Hi!
Seems to be a nice hack, but having the same problem here. I downloaded the file, named it theme.drush.inc and put it under ./drush/theme/theme.drush.inc.
# drush -d theme statusDrush bootstrap phase : _drush_bootstrap_drupal_root() [0.063 sec] [bootstrap]
Initialized Drupal 6.13 root directory at /home/homes/satya/public_html/D6 [0.092 [notice]
sec]
Drush bootstrap phase : _drush_bootstrap_drupal_site() [0.1 sec] [bootstrap]
Initialized Drupal site default at sites/default [0.211 sec] [notice]
Drush bootstrap phase : _drush_bootstrap_drupal_configuration() [0.219 sec] [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_database() [0.24 sec] [bootstrap]
Successfully connected to the Drupal database. [0.241 sec] [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_full() [0.263 sec] [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drupal_login() [1.26 sec] [bootstrap]
The command 'drush.php theme status' could not be found. [1.281 sec] [error]
Can you provide some additional info on installation, would be very much appreciated!
Thx
#6
Instructions in #2:
~/.drush/theme/theme.drush.inc.drushis a directory inside the home directory of the user you are running drush as. It starts with a dot. It is.drushand is not the directory where you installed drush. It is just drush the standard way of doing it, as explained in drush documentation.#7
Works perfectly, thank you for the hint.
#8
johnathan version from CVS returns
Fatal error: Call to undefined function _drush_get_themes() in ~/.drush/theme/theme.drush.inc on line 302. 09080 version works alright, anyway.#9
barraponto: this extension works against drush HEAD, where drush_get_themes() was introduced for D7 compat.
#10
Thanks jonhattan!
Where are the maintainers of this proyect?? Looks to me this would be a nice feature to have, and looks to be done (or nearly there).
#11
#12
#13
Subscribe
#14
Sorry, if I do not understand something, I am using drush usually I think your development is very good.
Inside the Drush directory, I make theme directory and put the file theme.drush.inc
ls -l drush
commands
drush
drush.bat
drush.php
example.drush.inc
example.drushrc.php
includes
LICENSE.txt
README.txt
theme
ls -l drush/theme
theme.drush.inc
But
drush -r /var/www/sitios//DRUPAL6/multidrupal -l sitioprueba.arg theme list
The command 'drush theme list' could not be found. [error]
We must do something more? to run commands theme
Thanks.
#15
Rodibox, see comment #6 above. The directory & file need to go in the .drush directory, which is a subdirectory of your home directory. For example... /home/rodubox/.drush
#16
Sorry I'm more stupid every day
Thank you for the excellent complement, I find it very helpful.
#17
The enable + set default are working nicely. a big plus 1 for inclusion
I am running DRUSH commands via the apache user on a multisite install and I'm almost always logged into shell via root. So to help others with that 2 min search to find out how to install this for ANY user, just place it here:
[DRUSH INSTALL DIR]/commands/
eg:
# ls -al drush/commands/
drwxr-xr-x 3 root root 4096 Dec 7 16:18 core/
drwxr-xr-x 5 root root 4096 Dec 7 16:18 pm/
drwxr-xr-x 2 root root 4096 Dec 7 16:18 simpletest/
drwxr-xr-x 2 root root 4096 Dec 7 16:18 sql/
drwxr-xr-x 2 root root 4096 Dec 15 11:11 theme/
# ls -al drush/commands/theme/
-rw-r--r-- 1 root root 10511 Dec 15 11:11 theme.drush.inc
#18
This is very nice. I'll bet many people are happily using it.
My hesitation is with adding a parallel set of commands for themes. In Drupal 7, modules and themes are looking more and more alike (and install profiles too). For example, themes can also participate in alter hooks and are now duplicate names are disallowed between modules and themes.
I'd be interested in a patch which unifies modules and themes better (like dl does, for example).
#19
Attached is a patch with this change to drush: use `list_themes($refresh=true)` instead of `_system_theme_data()` in `_drush_get_themes()` for both environment.inc and environment_7.inc
=> _system_theme_data() is only for drupal 6. It is not available for d5 and d7.
=> list_themes() is available for all versions, use the database if possible and includes theme status (`_system_theme_data()` doesn't).
Attached also a new version of themes command file with those changes:
* spaces to dashes!
* use db_update for d7 instead of db_query
Moshe: I'll work in unification and/or integration whenever possible. I think of those changes:
* remove `theme-status`
* integrate `theme-list` with `pm-status` or `pm-list` as proposed in #678574-12: Add "pm-" namespace to all of the pm commands. With that integration we loose two columns: Default and Administrative theme. That info can be moved to `status` (core).
* in concordance with the proposal at #679020: Extend `pm-list` to list modules, themes and profiles and filter by project status (enabled|disabled|uninstalled...) `theme-list-enabled` could be `pm-list --status=enabled`.
* `theme-info` can land to a new pm-info (if info command is renamed to pm-releases). New code will be written to provide also pm-info for modules (aka `module-info`)
* `pm-enable` and `pm-disable` will be extended to include `theme-enable` and `theme-disable`
* `theme-set-default` and `theme-set-admin` are theme specific operations and can stay the same, or renamed but there's no place for integration with other commands.
#20
I installed theme.drush.inc (per #17 - in /root/drush/commands/theme/). I get no output to my ssh login terminal (logged in as root). After the command 'drush theme-status' is entered on the command line in a valid Drupal root directory, it just sits for a few seconds, then the prompt returns.
[root@drupal1 public_html]# drush theme-status[root@drupal1 public_html]# drush theme-list
[root@drupal1 public_html]#
No output, no results. What did I miss? All other drush functionality is working. Centos 5.4, Apache 2.2, PHP 5.2, MySQL 5.0.
[root@drupal1 public_html]# drush statusPHP configuration : /etc/php.ini
Drupal Root : /home/mydomain/public_html
Drupal version : 6.14
Site Path : sites/default
Site URI : http://default
Database Driver : mysqli
Database Hostname : localhost
Database Username : root
Database Name : my_db
Database Password : mypassword
Database : Connected
Drupal Bootstrap : Successful
Drupal User : Anonymous
[root@drupal1 public_html]#
#21
Anything left to do here?
#22
Already in drush HEAD:
theme-list => pm-list --type=themetheme-list-enabled => pm-list --type=theme --status=enabled
theme-info => pm-info
Currently working on a patch for pm-enable/disable for themes.
Pending:
* `theme-status`. could be status-theme although I prefer adding two lines (default and admin theme) to drush status.
* `theme-set-default` & theme-set-admin`. Can stay the same. Is core.drush.inc the place for them?
#23
IMO, we don't truly need `theme-set-default` & `theme-set-admin`. Folks can use vset for that ... The rest looks good. Adding 2 lines to status sounds good for now.
#24
2 lines for status shipped in #693958: Extend pm-enable/disable to manage themes.
vset is fine, in despite of default theme must be already enabled.
happily closing this issue!
For the record:
This issue has been dismissed in favor of a closer integration witih drush package manager which has been worked out in other issues. Drush 3.x will be available soon. Upgrade your installation and remove theme.drush.inc.
This is the change in commands:
theme-enable => pm-enabletheme-disable => pm-disable
theme-info => pm-info
theme-list => pm-list --type=theme
theme-list-enabled => pm-list --type=theme --status=enabled
theme-set-default => vset theme_default
theme-set-admin => vset admin_theme
theme-status => status theme
#25
#26
Hi Guys,
I'm trying to install the this extension to drush on my ubuntu machine, but I can't find any ~/.drush/ folder in my hard drive, I was using installation guide described here http://groups.drupal.org/node/23487. Does anyone have any idea of how to install this file in my drush installation way? Thank for your help
#27
@vparfaniuc
Read jonhatton's last post.
http://drupal.org/node/530780#comment-2513534
His wording might be confusing, but basically Drush 3.0 has features in it that are comparable to jonhatton's proposed theme-* commands.
So you don't need to use his file.
Use the en, dis, pm-* and vset commands instead.