Terminal goodies for Radiant

If you have a lot of Radiant instances to manage and update, you probably do a lot of repetitive stuff in your terminal. I made some bash functions that I'm sure other people would find usefull too, so here goes:

alias gus='git_update_extension'
alias gusom='git_update_extension_from_origin_master'
alias gusa='git_update_all_extensions'

function git_update_extension {	
  cd vendor/extensions/$1;
  git pull $2 $3;
  cd -;
  git add vendor/extensions/$1;
}
	
function git_update_extension_from_origin_master {
  cd vendor/extensions/$1;
  git pull origin master;
  cd -;
  git add vendor/extensions/$1;
}
# git update all extensions
function git_update_all_extensions {
  for dir in `ls vendor/extensions/`;
    do echo "*** Updating $dir";
    gusom $dir origin master;
  done;
  rake radiant:extensions:update_all;
  undo_gorillafy;
}

function undo_gorillafy { # undo overwrites of sensitive files by gorillafy's update task
  git co public/stylesheets/extensions/gallery/lightbox.css;
  git co public/stylesheets/forms.css;
  git co public/stylesheets/grid.css;
  git co public/stylesheets/ie.css;
  git co public/stylesheets/stylesheet.css;
  git co public/javascripts/extensions/wym_editor_filter/radiant.wymeditor.js;
  git co public/images/body-bg.gif;
}

If you don't know where to put this, ~/.bash_profile is a good idea, assuming you're using the standard Mac OS X terminal.

Now, from your RADIANT_ROOT, you could update the comments extension like this:

MBPjomz:belmodo bennydegezelle$ gus comments
remote: Counting objects: 400, done.
remote: Compressing objects: 100% (149/149), done.
remote: Total 338 (delta 177), reused 338 (delta 177)
Receiving objects: 100% (338/338), 49.60 KiB, done.
Resolving deltas: 100% (177/177), completed with 21 local objects.
From git@github.com:jomz/radiant-comments
   e7f3bcb..0b7469d  master     -> origin/master
Updating e7f3bcb..0b7469d
Fast forward
 README.rdoc                                        |   10 +-
 app/controllers/admin/comments_controller.rb       |   74 ++++++----
 app/controllers/comments_controller.rb             |    4 +-
 app/helpers/admin/comments_helper.rb               |    7 +
 app/models/akismet_spam_filter.rb                  |   37 +++++
 app/models/comment.rb                              |  155 ++++++--------------
 app/models/mollom_spam_filter.rb                   |   52 +++++++
 app/models/simple_spam_filter.rb                   |   38 +++++
 app/models/spam_filter.rb                          |   43 ++++++
 app/views/admin/comments/_comment.rhtml            |   58 ++++----
 app/views/admin/comments/_form.rhtml               |   78 +++++------
 app/views/admin/comments/edit.rhtml                |    4 +-
 app/views/admin/comments/index.rhtml               |   69 +++++----
 app/views/admin/pages/_index_view_comments.rhtml   |    4 +-
 comments_extension.rb                              |   65 ++++-----
 db/migrate/002_create_snippets.rb                  |    4 +-
 lib/comment_page_extensions.rb                     |   41 +++++
 lib/comment_tags.rb                                |   28 +++-
 lib/mollom.rb                                      |   18 +-
 lib/tasks/comments_extension_tasks.rake            |   48 ++++++-
 public/images/admin/comment_edit.png               |  Bin 0 -> 644 bytes
 public/images/admin/comments.png                   |  Bin 0 -> 557 bytes
 public/images/admin/comments_delete.png            |  Bin 0 -> 670 bytes
 public/images/admin/delete.png                     |  Bin 0 -> 715 bytes
 public/images/admin/email.png                      |  Bin 0 -> 641 bytes
 public/images/admin/error.png                      |  Bin 0 -> 666 bytes
 public/images/admin/link.png                       |  Bin 0 -> 343 bytes
 public/images/admin/page_white_edit.png            |  Bin 0 -> 618 bytes
 public/images/admin/table_save.png                 |  Bin 0 -> 723 bytes
 public/images/admin/tick.png                       |  Bin 0 -> 537 bytes
 public/stylesheets/admin/comments.css              |   41 +++++
 spec/controllers/admin/comments_controller_spec.rb |    4 +-
 spec/controllers/admin/comments_routing_spec.rb    |   43 ++++++
 spec/controllers/page_postback_spec.rb             |   51 +++++++
 spec/models/akismet_spam_filter_spec.rb            |   61 ++++++++
 spec/models/comment_spec.rb                        |  138 ++++++------------
 spec/models/comment_tags_spec.rb                   |   44 ++++++-
 spec/models/mollom_spam_filter_spec.rb             |  103 +++++++++++++
 spec/models/simple_spam_filter_spec.rb             |   44 ++++++
 spec/models/spam_filter_spec.rb                    |   38 +++++
 40 files changed, 1008 insertions(+), 396 deletions(-)
 create mode 100644 app/helpers/admin/comments_helper.rb
 create mode 100644 app/models/akismet_spam_filter.rb
 create mode 100644 app/models/mollom_spam_filter.rb
 create mode 100644 app/models/simple_spam_filter.rb
 create mode 100644 app/models/spam_filter.rb
 create mode 100644 lib/comment_page_extensions.rb
 create mode 100644 public/images/admin/comment_edit.png
 create mode 100644 public/images/admin/comments.png
 create mode 100644 public/images/admin/comments_delete.png
 create mode 100644 public/images/admin/delete.png
 create mode 100644 public/images/admin/email.png
 create mode 100644 public/images/admin/error.png
 create mode 100644 public/images/admin/link.png
 create mode 100644 public/images/admin/page_white_edit.png
 create mode 100644 public/images/admin/table_save.png
 create mode 100644 public/images/admin/tick.png
 create mode 100644 public/stylesheets/admin/comments.css
 create mode 100644 spec/controllers/admin/comments_routing_spec.rb
 create mode 100644 spec/controllers/page_postback_spec.rb
 create mode 100644 spec/models/akismet_spam_filter_spec.rb
 create mode 100644 spec/models/mollom_spam_filter_spec.rb
 create mode 100644 spec/models/simple_spam_filter_spec.rb
 create mode 100644 spec/models/spam_filter_spec.rb
/Users/bennydegezelle/rails/belmodo
MBPjomz:belmodo bennydegezelle$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD ..." to unstage)
#
#	modified:   vendor/extensions/comments
#
MBPjomz:belmodo bennydegezelle$

As you can see, the extension is updated, and this update staged and ready to commit. You can also specify which remote and branch you want to pull from, as you would with a normal git pull.

More interesting is the 'git_update_all_extensions' or 'gusa' function. This will go over all your extensions and try to pull from origin master, and then run rake radiant:extensions:update_all. Which, as you probably know, copies all public assets per extension.

The 'undo_gorillafy' function lastly, is something i run after the update_all task, because our Gorillafy extension copies default CSS files that we start each project with. These are public-facing files that are changed from time to time, so we don't want to ruin a site's looks by resetting it's CSS to our (new) defaults.

Use these functions as are, or tweak them to match your own workflow. Any improvements or remarks appreciated in the comments.

In a reading mood?

Have something to add?



  • (required, but not displayed)

  • (optional)

About this article

You’re reading an entry titled “Terminal goodies for Radiant”. Written

undefined tag `time_ago_in_words'
ago (01/09/2009) — and archived under bash, radiant, terminal. So far, 0 people (dis)agreed with me, what do you think?

What the fuzz is all about

  1. 2 pages are tagged with WYM
  2. 1 page is tagged with absolute-urls
  3. 1 page is tagged with arrrrcamp
  4. 2 pages are tagged with documentation
  5. 2 pages are tagged with editor
  6. 2 pages are tagged with extension
  7. 2 pages are tagged with extensions
  8. 1 page is tagged with minitorial
  9. 1 page is tagged with navigation
  10. 10 pages are tagged with radiant
  11. 4 pages are tagged with rails
  12. 2 pages are tagged with ruby
  13. 2 pages are tagged with shell
  14. 1 page is tagged with sifr
  15. 2 pages are tagged with troubleshooting

Github activity

More places where you can find me

Back to top