Permalink
Browse files

Updated the namespace from wordpress: to wp: which tightens the comma…

…ndline syntax, cleaned up the classes and combined like tasks
  • Loading branch information...
Adam Stacoviak
Adam Stacoviak committed Dec 7, 2009
1 parent bc1ceaf commit aa3e60b7f0dda560526082d1db858ffe043aea74
Showing with 65 additions and 58 deletions.
  1. +24 −25 README.markdown
  2. +41 −33 wordpress.thor
View
@@ -8,10 +8,10 @@ Before you go ANY FURTHER, using these Thor tasks assumes you have the `haml`, `
## Install WordPress with Thor
-Change directory to the directory you want to install WordPress in. You'll be asked if you want to install [Thematic](http://themeshaper.com/thematic/). These instructions assume you say yes.
+Change directory to the directory you want to install WordPress in. You'll be asked if you want to install [Thematic](http://themeshaper.com/thematic/) and also Starkers. These instructions assume you say yes to Thematic.
cd ~/Sites/mysite/
- thor wordpress:install
+ thor wp:install
Change directory to the theme directory
@@ -24,51 +24,50 @@ Create your new theme directory
Install your new theme with Thor. This assumes that you said yes to using installing Thematic and by default unpacks the Thematic project template located inside the Compass-WordPress gem.
- thor wordpress:theme:install
+ thor wp:install:theme
## Use rsync to deploy your theme
Generate deploy.yaml to your current directory using this command.
You'll be asked (in your terminal) for your `ssh_user` and `remote_root` details. Thor will then create your `deploy.yaml` file for you, populate it with your responses and then add it to your current directory.
- thor wordpress:deploy:generate_config
+ thor wp:deploy:generate_config
Once that's in place you can run this command to deploy your theme to your server.
- thor wordpress:deploy:theme
+ thor wp:deploy:theme
## Thor-WordPress tasks
- wordpress
- ---------
- wordpress:install [--directory=DIRECTORY] [--version=VERSION]
+ wp:install
+ ----------
+ wp:install:app [--directory=DIRECTORY] [--version=VERSION]
# Download and unpack WordPress from the interwebs
- wordpress:theme
- ---------------
- wordpress:theme:install --theme=<theme> [--directory=DIRECTORY] [--theme=THEME]
- # Unpacks the specified <theme> from the compass-wordpress gem
+ wp:install:theme --themename=<theme> --directory=<directory> [--directory=DIRECTORY] [--themename=THEMENAME]
+ # Unpacks the specified <theme> from the compass-wordpress gem (Default task)
- wordpress:styles
- ----------------
- wordpress:styles:generate
- # Clears and Generates the styles
+ wp:styles
+ ---------
+ wp:styles:generate
+ # Clears and Generates the styles (Default task)
- wordpress:styles:clear
+ wp:styles:clear
# Clears the styles
- wordpress:compass
- -----------------
- wordpress:compass:watch
+ wp:styles:watch
# Runs compass --watch
- wordpress:deploy
- ----------------
- wordpress:deploy:theme
- # Deploys the theme
+ wp:deploy
+ ---------
+ wp:deploy:theme
+ # Deploys the theme (Default task)
+
+ wp:deploy:app
+ # Deploys the app
- wordpress:deploy:generate_config
+ wp:deploy:generate_config
# Asks for ssh_user and remote_root, and generates the deploy.yaml file
## Contributors
View
@@ -1,12 +1,12 @@
-module Wordpress
+module Wp
class Install < Thor
- namespace :wordpress
+ default_task :app
- desc "install", "Download and unpack WordPress from the interwebs"
+ desc "app", "Download and unpack WordPress from the interwebs"
method_options :directory => :string, :version => :string
- def install
+ def app
opts = {'directory' => '.', 'version' => 'latest'}
opts = opts.merge(options)
@@ -22,36 +22,34 @@ module Wordpress
cmd = "curl -O http://wordpress.org/extend/themes/download/thematic.0.9.5.1.zip && unzip thematic.0.9.5.1.zip -d #{opts['directory']}/wp-content/themes && rm thematic.0.9.5.1.zip"
system cmd
end
+ if yes?("Download and install Starkers?")
+ cmd = "curl -O http://elliotjaystocks.com/starkers/download/latest.zip && unzip latest.zip -d #{opts['directory']}/wp-content/themes && rm latest.zip"
+ system cmd
+ end
else
say 'Installation aborted'
end
end
-
- end
-
- class Theme < Thor
-
- default_task :install
-
- desc "install --theme=<theme>", "Unpacks the specified <theme> from the compass-wordpress gem"
- method_options :directory => :string, :theme => :string
- def install
- opts = {'directory' => '.', 'theme' => 'thematic'}
+
+ desc "theme --themename=<theme> --directory=<directory>", "Unpacks the specified <theme> from the compass-wordpress gem (Default task)"
+ method_options :directory => :string, :themename => :string
+ def theme
+ opts = {'directory' => '.', 'themename' => 'thematic'}
opts = opts.merge(options)
-
+ system "mkdir -p #{opts['directory']}" unless opts['directory'] == '.'
say "*** Installing Child Theme ***"
- cmd = "compass -r compass-wordpress -f wordpress --sass-dir=sass --css-dir=css -s compressed -p #{opts['theme']} #{opts['directory']}"
+ cmd = "compass -r compass-wordpress -f wordpress --sass-dir=sass --css-dir=css -s compressed -p #{opts['themename']} #{opts['directory']}"
system cmd
- invoke "wordpress:deploy:generate_config"
+ #invoke "wp:deploy:generate_config"
end
-
+
end
class Styles < Thor
default_task :generate
- desc "generate", "Clears and Generates the styles"
+ desc "generate", "Clears and Generates the styles (Default task)"
def generate
invoke :clear
say "*** Generating styles ***"
@@ -63,15 +61,10 @@ module Wordpress
say "*** Clearing styles ***"
system "rm -Rfv css/*"
end
-
- end
-
- class Compass < Thor
-
- default_task :watch
-
+
desc "watch", "Runs compass --watch"
def watch
+ invoke "wp:styles:generate"
system "compass --watch"
end
@@ -81,19 +74,33 @@ module Wordpress
default_task :theme
- desc "theme", "Deploys the theme"
+ desc "theme", "Deploys the theme (Default task)"
def theme
+ config = YAML.load_file("deploy.yaml") rescue nil
+ if config
+ ssh_user = config['ssh_user']
+ remote_root = config['remote_root']
+ current_theme = config['current_theme']
+ else
+ invoke "wp:deploy:generate_config"
+ end
+ invoke "wp:styles:generate"
+ say "*** Deploying the theme ***"
+ system "rsync -avz --delete . #{ssh_user}:#{remote_root}/wp-content/themes/#{current_theme}/"
+ end
+
+ desc "app", "Deploys the app"
+ def app
config = YAML.load_file("deploy.yaml") rescue nil
if config
ssh_user = config['ssh_user']
remote_root = config['remote_root']
else
- ssh_user = ask("What is your ssh username?")
- remote_root = ask("What is your remote root path?")
+ invoke "wp:deploy:generate_config"
end
- invoke "wordpress:styles:generate"
- say "*** Deploying the site ***"
- system "rsync -avz --delete . #{ssh_user}:#{remote_root}"
+ invoke "wp:styles:generate"
+ say "*** Deploying the app ***"
+ system "rsync -avz --delete . #{ssh_user}:#{remote_root}/"
end
desc "generate_config", "Asks for ssh_user and remote_root, and generates the deploy.yaml file"
@@ -102,6 +109,7 @@ module Wordpress
config = {}
config['ssh_user'] = ask("What is your ssh username?")
config['remote_root'] = ask("What is your remote root path?")
+ config['current_theme'] = ask("What is theme name you will use?")
File.open(filename, "w"){ |f| f.puts config.to_yaml }
say "*** Generated #{File.expand_path filename} ***"
end

0 comments on commit aa3e60b

Please sign in to comment.