wordpress-tools 0.0.1alpha1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/bin/wp +7 -0
- data/files/footer.php +3 -0
- data/files/header.php +7 -0
- data/files/index.php +2 -0
- data/files/main_gitignore +20 -0
- data/files/plugins_gitignore +1 -0
- data/lib/wordpress-tools.rb +9 -0
- data/lib/wordpress-tools/command_line.rb +123 -0
- data/lib/wordpress-tools/command_line/action.rb +6 -0
- data/lib/wordpress-tools/command_line/action/base.rb +84 -0
- data/lib/wordpress-tools/command_line/action/init.rb +97 -0
- data/lib/wordpress-tools/configuration.rb +63 -0
- data/lib/wordpress-tools/tasks.rb +53 -0
- data/lib/wordpress-tools/template.rb +16 -0
- data/lib/wordpress-tools/version.rb +5 -0
- data/templates/build.properties.erb +9 -0
- data/templates/build.xml.erb +65 -0
- data/templates/functions.php.erb +36 -0
- data/templates/style.css.erb +3 -0
- data/templates/theme_class.php.erb +36 -0
- data/templates/themes_gitignore.erb +4 -0
- data/wordpress-tools.gemspec +29 -0
- metadata +139 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Rodolfo Carvalho
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Wordpress::Tools
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'wordpress-tools'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install wordpress-tools
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/wp
ADDED
data/files/footer.php
ADDED
data/files/header.php
ADDED
data/files/index.php
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
index.php
|
2
|
+
license.txt
|
3
|
+
readme.html
|
4
|
+
wp-activate.php
|
5
|
+
wp-admin/
|
6
|
+
wp-blog-header.php
|
7
|
+
wp-comments-post.php
|
8
|
+
wp-config-sample.php
|
9
|
+
wp-cron.php
|
10
|
+
wp-includes
|
11
|
+
wp-links-opml.php
|
12
|
+
wp-load.php
|
13
|
+
wp-login.php
|
14
|
+
wp-mail.php
|
15
|
+
wp-settings.php
|
16
|
+
wp-signup.php
|
17
|
+
wp-trackback.php
|
18
|
+
xmlrpc.php
|
19
|
+
wp-content/languages
|
20
|
+
.sass-cache/
|
@@ -0,0 +1 @@
|
|
1
|
+
*
|
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'open-uri'
|
3
|
+
require 'tempfile'
|
4
|
+
require 'erb'
|
5
|
+
require 'active_support/core_ext'
|
6
|
+
|
7
|
+
module Wordpress::Tools
|
8
|
+
module CommandLine
|
9
|
+
autoload :Action, 'wordpress-tools/command_line/action'
|
10
|
+
|
11
|
+
class Parser
|
12
|
+
attr_reader :parser, :options, :argv, :args, :action
|
13
|
+
|
14
|
+
ACTIONS = {
|
15
|
+
:init => "Initialize a blank project"
|
16
|
+
}
|
17
|
+
|
18
|
+
def initialize(argv)
|
19
|
+
@argv = argv
|
20
|
+
@options = {
|
21
|
+
:wp_version => "latest",
|
22
|
+
:show_version => false,
|
23
|
+
:show_help => false,
|
24
|
+
:skip_wordpress => false,
|
25
|
+
:dry_run => false,
|
26
|
+
:verbose => false
|
27
|
+
}
|
28
|
+
|
29
|
+
@parser = OptionParser.new { |opts| setup(opts) }
|
30
|
+
end
|
31
|
+
|
32
|
+
def parse!
|
33
|
+
@action, *@args = @parser.parse!(@argv)
|
34
|
+
validate!
|
35
|
+
current_action.run!
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def current_action
|
41
|
+
begin
|
42
|
+
clazz = "Wordpress::Tools::CommandLine::Action::#{action.to_s.camelize}".constantize
|
43
|
+
@action_obj ||= clazz.new(args, options)
|
44
|
+
rescue => ex
|
45
|
+
puts ex
|
46
|
+
puts ex.backtrace
|
47
|
+
nil
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def validate!
|
52
|
+
exit 0 if options[:show_version] || options[:show_help]
|
53
|
+
|
54
|
+
if action.to_s.strip.empty?
|
55
|
+
puts "You must specify an action."
|
56
|
+
puts @parser
|
57
|
+
exit -1
|
58
|
+
end
|
59
|
+
|
60
|
+
unless ACTIONS.keys.any? { |a| a.to_s == action }
|
61
|
+
puts "Invalid action: #{action}"
|
62
|
+
puts @parser
|
63
|
+
exit -2
|
64
|
+
end
|
65
|
+
|
66
|
+
if current_action.nil?
|
67
|
+
puts "Unimplemented action: #{action}"
|
68
|
+
exit -3
|
69
|
+
end
|
70
|
+
|
71
|
+
unless current_action.valid?
|
72
|
+
puts "Invalid parameters for action: #{action}"
|
73
|
+
exit -5
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def setup(opts)
|
78
|
+
opts.banner = "Usage: wp action [OPTIONS]"
|
79
|
+
opts.separator ""
|
80
|
+
opts.separator "Available actions:"
|
81
|
+
opts.separator ACTIONS.keys.map(&:to_s).join(" ")
|
82
|
+
|
83
|
+
opts.separator ""
|
84
|
+
opts.separator "init:"
|
85
|
+
opts.separator "Example: wp init <main_theme_name> [OPTIONS]"
|
86
|
+
|
87
|
+
opts.on("--wordpress-version=[WORDPRESS_VERSION]",
|
88
|
+
"Wordpress Version to use. Default: #{options[:wp_version]}") do |v|
|
89
|
+
options[:wp_version] = v
|
90
|
+
end
|
91
|
+
|
92
|
+
opts.on("--skip-wordpress", "Skips wordpress download (Assumes an existing wordpress site)") do
|
93
|
+
options[:skip_wordpress] = true
|
94
|
+
end
|
95
|
+
|
96
|
+
opts.separator ""
|
97
|
+
opts.separator "Common options:"
|
98
|
+
|
99
|
+
opts.on("-v", "--version", "Show the program version") do
|
100
|
+
options[:show_version] = true
|
101
|
+
puts "wp (wodpress-tools) version #{Wordpress::Tools::VERSION}"
|
102
|
+
end
|
103
|
+
|
104
|
+
opts.on("-V", "--verbose") do
|
105
|
+
options[:verbose] = true
|
106
|
+
end
|
107
|
+
|
108
|
+
opts.on("--dry-run") do
|
109
|
+
options[:dry_run] = true
|
110
|
+
end
|
111
|
+
|
112
|
+
opts.on("-c", "--class-prefix CLASS_PREFIX", "Prefix for all theme-related classes") do |cp|
|
113
|
+
options[:class_prefix] = cp
|
114
|
+
end
|
115
|
+
|
116
|
+
opts.on_tail("-h", "--help", "Print this message") do
|
117
|
+
options[:show_help] = true
|
118
|
+
puts opts
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'colorize'
|
2
|
+
|
3
|
+
module Wordpress::Tools::CommandLine::Action
|
4
|
+
class Base
|
5
|
+
attr_reader :args, :options
|
6
|
+
|
7
|
+
def initialize(args, options={})
|
8
|
+
@args = args
|
9
|
+
@options = options
|
10
|
+
@config = Wordpress::Tools::Configuration.new(args, options)
|
11
|
+
end
|
12
|
+
|
13
|
+
def run!
|
14
|
+
raise NotImplementedError
|
15
|
+
end
|
16
|
+
|
17
|
+
def valid?
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
attr_reader :config
|
23
|
+
|
24
|
+
def dry_run?
|
25
|
+
!!options[:dry_run]
|
26
|
+
end
|
27
|
+
|
28
|
+
def verbose?
|
29
|
+
!!options[:verbose]
|
30
|
+
end
|
31
|
+
|
32
|
+
def create_directory(name, recursive=true)
|
33
|
+
puts "[directory]".green + "\t#{name}" if verbose? or dry_run?
|
34
|
+
return if dry_run?
|
35
|
+
if recursive
|
36
|
+
FileUtils.mkdir_p(name)
|
37
|
+
else
|
38
|
+
FileUtils.mkdir(name)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def run(cmd)
|
43
|
+
puts "[run]".green + "\t\t#{cmd}" if verbose? or dry_run?
|
44
|
+
return if dry_run?
|
45
|
+
puts cmd if verbose?
|
46
|
+
result = %x|#{cmd}|
|
47
|
+
puts result if verbose?
|
48
|
+
end
|
49
|
+
|
50
|
+
def render_template(name, target_path, params={})
|
51
|
+
puts "[template]".green + "\t#{name} -> #{target_path}" if verbose? or dry_run?
|
52
|
+
return if dry_run?
|
53
|
+
template_file = File.expand_path("../../../../../templates/#{name}", __FILE__)
|
54
|
+
template = Wordpress::Tools::Template.new(File.read(template_file), params)
|
55
|
+
|
56
|
+
File.open(target_path, "w") do |f|
|
57
|
+
f << template.render
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def cd_into(path)
|
62
|
+
begin
|
63
|
+
current = FileUtils.pwd
|
64
|
+
puts "[cd]".green + "\t\t#{path}" if verbose? or dry_run?
|
65
|
+
FileUtils.cd path unless dry_run?
|
66
|
+
yield
|
67
|
+
ensure
|
68
|
+
puts "[cd]".green + "\t\t#{current}" if verbose? or dry_run?
|
69
|
+
FileUtils.cd current
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def copy_file(name, target_path)
|
74
|
+
puts "[file]".green + "\t\t#{name} -> #{target_path}" if verbose? or dry_run?
|
75
|
+
return if dry_run?
|
76
|
+
|
77
|
+
static_file = File.expand_path("../../../../../files/#{name}", __FILE__)
|
78
|
+
|
79
|
+
File.open(target_path, "w") do |f|
|
80
|
+
f << File.read(static_file)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
module Wordpress::Tools::CommandLine::Action
|
2
|
+
class Init < Base
|
3
|
+
def run!
|
4
|
+
if args.empty?
|
5
|
+
raise "You must specify a main theme name."
|
6
|
+
end
|
7
|
+
|
8
|
+
unless options[:skip_wordpress]
|
9
|
+
path = download_wp
|
10
|
+
untar_wp(path, target_directory)
|
11
|
+
end
|
12
|
+
|
13
|
+
bootstrap_theme(target_directory, main_theme_name)
|
14
|
+
|
15
|
+
%w(build.xml build.properties).each do |t|
|
16
|
+
render_template "#{t}.erb", "#{target_directory}/#{t}", :theme_name => main_theme_name
|
17
|
+
end
|
18
|
+
|
19
|
+
config.update :theme_name => main_theme_name
|
20
|
+
config.save("#{target_directory}/config.yml") unless dry_run?
|
21
|
+
add_to_vcs(target_directory)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def bootstrap_theme(target_dir, theme_name)
|
27
|
+
theme_path = "#{target_dir}/wp-content/themes/#{theme_name}"
|
28
|
+
classes_path = "#{theme_path}/classes"
|
29
|
+
templates_path = "#{theme_path}/templates"
|
30
|
+
helpers_path = "#{theme_path}/helpers"
|
31
|
+
assets_path = "#{theme_path}/assets"
|
32
|
+
|
33
|
+
[classes_path, templates_path, helpers_path, assets_path].each do |dir|
|
34
|
+
create_directory dir
|
35
|
+
end
|
36
|
+
|
37
|
+
render_template "functions.php.erb", "#{theme_path}/functions.php",
|
38
|
+
:theme_name => theme_name, :class_prefix => options[:class_prefix]
|
39
|
+
|
40
|
+
render_template "theme_class.php.erb", "#{classes_path}/#{options[:class_prefix]}Theme.class.php",
|
41
|
+
:theme_name => theme_name, :class_prefix => options[:class_prefix]
|
42
|
+
|
43
|
+
%w(index header footer).each do |f|
|
44
|
+
copy_file "#{f}.php", "#{theme_path}/#{f}.php"
|
45
|
+
end
|
46
|
+
|
47
|
+
render_template "style.css.erb", File.join(theme_path, "style.css"), :theme_name => theme_name
|
48
|
+
cd_into(assets_path) { run "compass create ." }
|
49
|
+
end
|
50
|
+
|
51
|
+
def add_to_vcs(path)
|
52
|
+
cd_into path do
|
53
|
+
run "git init ."
|
54
|
+
copy_file "main_gitignore", "#{path}/.gitignore"
|
55
|
+
|
56
|
+
render_template "themes_gitignore.erb", "#{File.dirname(theme_path)}/.gitignore",
|
57
|
+
:theme_name => main_theme_name
|
58
|
+
copy_file("plugins_gitignore", "#{target_directory}/wp-content/plugins/.gitignore")
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def untar_wp(from, to)
|
63
|
+
wp_src_dir = "#{File.dirname(from)}/wordpress"
|
64
|
+
|
65
|
+
cmd = "tar -xz#{ "v" if verbose?}f #{from} -C #{File.dirname(from)}"
|
66
|
+
run cmd
|
67
|
+
run "mv -v #{wp_src_dir} #{to}"
|
68
|
+
end
|
69
|
+
|
70
|
+
def download_wp
|
71
|
+
tmp = Tempfile.new('wp')
|
72
|
+
puts "Downloading Wordpress from #{wp_download_link}..." if verbose?
|
73
|
+
|
74
|
+
if dry_run?
|
75
|
+
return "/some/dummy/path/for/wp"
|
76
|
+
else
|
77
|
+
open(wp_download_link) do |io|
|
78
|
+
tmp << io.read
|
79
|
+
tmp.path
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def wp_download_link
|
85
|
+
"http://br.wordpress.org/#{options[:wp_version]}-pt_BR.tar.gz"
|
86
|
+
end
|
87
|
+
|
88
|
+
# Utility Methods
|
89
|
+
def main_theme_name; args.first; end
|
90
|
+
def theme_path
|
91
|
+
"#{target_directory}/wp-content/themes/#{main_theme_name}"
|
92
|
+
end
|
93
|
+
def target_directory
|
94
|
+
@target_directory ||= File.expand_path("#{main_theme_name}")
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module Wordpress::Tools
|
5
|
+
class Configuration
|
6
|
+
TRANSIENT_CONFIG = [
|
7
|
+
:dry_run, :show_version, :show_help, :skip_wordpress,
|
8
|
+
:verbose, :wp_version
|
9
|
+
]
|
10
|
+
|
11
|
+
attr_reader :action
|
12
|
+
|
13
|
+
def initialize(args, options)
|
14
|
+
read_configuration!
|
15
|
+
merge_config!(args, options)
|
16
|
+
end
|
17
|
+
|
18
|
+
def save(path = nil)
|
19
|
+
path = path.nil? ? config_file_path : path
|
20
|
+
File.open(path, "w") { |f| f << @config.dup.delete_if { |k, v| TRANSIENT_CONFIG.include?(k.to_sym) }.to_yaml }
|
21
|
+
end
|
22
|
+
|
23
|
+
def target_path
|
24
|
+
@target_path ||= FileUtils.pwd
|
25
|
+
end
|
26
|
+
|
27
|
+
def class_prefix
|
28
|
+
@config[:class_prefix]
|
29
|
+
end
|
30
|
+
|
31
|
+
def theme_name
|
32
|
+
@config[:theme_name]
|
33
|
+
end
|
34
|
+
|
35
|
+
def wordpress_version
|
36
|
+
@config[:wordpress_version]
|
37
|
+
end
|
38
|
+
|
39
|
+
def update(extra_options)
|
40
|
+
@config.merge! extra_options
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
def merge_config!(args, options)
|
45
|
+
@config.merge!(options)
|
46
|
+
if args.any?
|
47
|
+
@action = args.first
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def config_file_path
|
52
|
+
"#{target_path}/config.yml"
|
53
|
+
end
|
54
|
+
|
55
|
+
def read_configuration!
|
56
|
+
if File.exists? config_file_path
|
57
|
+
@config = YAML.load File.read(config_file_path)
|
58
|
+
else
|
59
|
+
@config = {}
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
$rsync_opts = %w(-avz --progress)
|
2
|
+
$remote_site = "infweb@infweb.web805.uni5.net:~/www"
|
3
|
+
$local_site = File.expand_path("..", __FILE__)
|
4
|
+
$theme_name = "infweb"
|
5
|
+
|
6
|
+
def rsync(from, to, opt=$rsync_opts)
|
7
|
+
cmd = "rsync #{opt.join(" ")} #{from} #{to}"
|
8
|
+
puts "Executing command \"#{cmd}\""
|
9
|
+
out = %x|#{cmd}|
|
10
|
+
puts out if ENV['VERBOSE']
|
11
|
+
out
|
12
|
+
end
|
13
|
+
|
14
|
+
namespace :sync do
|
15
|
+
desc "Sync plugins down to the local site"
|
16
|
+
task :plugins do
|
17
|
+
rsync "#{$remote_site}/wp-content/plugins/",
|
18
|
+
"#{$local_site}/wp-content/plugins/"
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "Sync down theme specified by $THEME"
|
22
|
+
task :theme do
|
23
|
+
theme = ENV['THEME']
|
24
|
+
raise "You must specify a theme passed by THEME env var." if theme.nil?
|
25
|
+
rsync "#{$remote_site}/wp-content/themes/#{theme}",
|
26
|
+
"#{$local_site}/wp-content/themes/#{theme}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "Deploy the local copy to the website"
|
31
|
+
task :deploy do
|
32
|
+
rsync "#{$local_site}/wp-content/themes/#{$theme_name}/",
|
33
|
+
"#{$remote_site}/wp-content/themes/#{$theme_name}/"
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "Bootstrap the app, downloading the latest wordpress to the current directory"
|
37
|
+
task :bootstrap do
|
38
|
+
puts "TODO"
|
39
|
+
end
|
40
|
+
|
41
|
+
namespace :deploy do
|
42
|
+
desc "Deploy the latest versions of plugins to the live website"
|
43
|
+
task :plugins do
|
44
|
+
delete_remote = ENV['DELETE'].to_s == "yes"
|
45
|
+
extra_options = $rsync_opts.dup
|
46
|
+
|
47
|
+
extra_options << "--delete" if delete_remote
|
48
|
+
|
49
|
+
rsync "#{$local_site}/wp-content/plugins/",
|
50
|
+
"#{$remote_site}/wp-content/plugins/",
|
51
|
+
extra_options
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Wordpress::Tools::Template
|
2
|
+
def initialize(template, params={})
|
3
|
+
@params = params
|
4
|
+
@template = template
|
5
|
+
metaclass = class <<self; self; end
|
6
|
+
|
7
|
+
|
8
|
+
params.each do |k, v|
|
9
|
+
metaclass.send(:define_method, k) { v }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def render
|
14
|
+
ERB.new(@template).result(binding)
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<project name="<%= theme_name %>"
|
3
|
+
default="prepare"
|
4
|
+
basedir="."
|
5
|
+
description="Using phing to automate wordpress deploy">
|
6
|
+
|
7
|
+
<property file="build.properties">
|
8
|
+
<filterchain>
|
9
|
+
<expandproperties/>
|
10
|
+
</filterchain>
|
11
|
+
</property>
|
12
|
+
|
13
|
+
<property name="sync.cachedir" value="~/.repo-cache/${sync.application}"/>
|
14
|
+
<property name="sync.files" value="${sync.cachedir}/.gitfiles"/>
|
15
|
+
<property name="message" value="Print instructions for first deploy"/>
|
16
|
+
<property name="rsynccmd" value="rsync -av --progress --files-from=${sync.files}"/>
|
17
|
+
|
18
|
+
<target name="prepare">
|
19
|
+
<echo msg="${message}"/>
|
20
|
+
<exec command="cat README.txt" logoutput="true"/>
|
21
|
+
</target>
|
22
|
+
|
23
|
+
<target name="deploy:prepare">
|
24
|
+
<fail unless="sync.remote.host"
|
25
|
+
msg="Please set the property sync.remote.host on you build.properties file, or using -D switch from the command-line"/>
|
26
|
+
|
27
|
+
<property name="sync.remote.sshcommand"
|
28
|
+
value="mkdir -p $(dirname ${sync.cachedir}) &&
|
29
|
+
echo $([ -d "${sync.cachedir}" ] || git clone ${git.repository} ${sync.cachedir}) &&
|
30
|
+
cd ${sync.cachedir} &&
|
31
|
+
git checkout -f ${git.branch} &&
|
32
|
+
git pull --rebase &&
|
33
|
+
echo $(git ls-files | egrep -v '"'"'(${sync.excludelist})'"'"' > ${sync.files})"/>
|
34
|
+
<echo msg="Executing '${sync.remote.sshcommand}' on remote host ${sync.remote.host}"/>
|
35
|
+
<exec
|
36
|
+
command="ssh ${sync.remote.user}@${sync.remote.host} '${sync.remote.sshcommand}'"
|
37
|
+
logoutput="true"
|
38
|
+
/>
|
39
|
+
</target>
|
40
|
+
|
41
|
+
<target name="deploy:check:all" description="List changes to be sent across all servers">
|
42
|
+
<foreach list="${sync.remote.appservers}" target="deploy:check" param="sync.remote.host"/>
|
43
|
+
</target>
|
44
|
+
|
45
|
+
<target name="deploy:all" description="List changes to be sent across all servers">
|
46
|
+
<foreach list="${sync.remote.appservers}" target="deploy" param="sync.remote.host"/>
|
47
|
+
</target>
|
48
|
+
|
49
|
+
<target name="deploy:check" depends="deploy:prepare" description="List changes to be sent to server">
|
50
|
+
<property name="sync.remote.rsynccommand"
|
51
|
+
value="${rsynccmd} --dry-run ${sync.cachedir} ${sync.destination.projectdir}"/>
|
52
|
+
<exec
|
53
|
+
command="ssh ${sync.remote.user}@${sync.remote.host} '${sync.remote.rsynccommand}'"
|
54
|
+
logoutput="true"/>
|
55
|
+
</target>
|
56
|
+
|
57
|
+
<target name="deploy" depends="deploy:prepare" description="Sync files to the remote server">
|
58
|
+
<property name="sync.remote.rsynccommand"
|
59
|
+
value="${rsynccmd} ${sync.cachedir} ${sync.destination.projectdir}; chmod a+w ${sync.destination.projectdir}/tmp"/>
|
60
|
+
|
61
|
+
<exec
|
62
|
+
command="ssh ${sync.remote.user}@${sync.remote.host} '${sync.remote.rsynccommand}'"
|
63
|
+
logoutput="true"/>
|
64
|
+
</target>
|
65
|
+
</project>
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<?php
|
2
|
+
require_once dirname(__FILE__) . '/classes/<%= class_prefix %>Theme.class.php';
|
3
|
+
|
4
|
+
function <%= theme_name %>setup_theme() {
|
5
|
+
<%= class_prefix %>Theme::themeInitialize();
|
6
|
+
}
|
7
|
+
add_action('after_setup_theme', '<%= theme_name %>setup_theme');
|
8
|
+
|
9
|
+
|
10
|
+
function <%= theme_name %>init() {
|
11
|
+
if (class_exists('STSTheme'))
|
12
|
+
{
|
13
|
+
$theme =& <%= class_prefix %>Theme::getInstance();
|
14
|
+
$theme->init();
|
15
|
+
}
|
16
|
+
else
|
17
|
+
{
|
18
|
+
$msg = __("Please install and/or activate iNF Web Theme Framework", "<%= theme_name %>");
|
19
|
+
if (is_admin())
|
20
|
+
add_action('admin_notices', create_function('',
|
21
|
+
"echo \"<div id='message' class='error'><p><strong>$msg</strong></p></div>\";"
|
22
|
+
));
|
23
|
+
else
|
24
|
+
die($msg);
|
25
|
+
}
|
26
|
+
|
27
|
+
$files = scandir(TEMPLATEPATH . '/helpers', 1);
|
28
|
+
|
29
|
+
if ($files !== false) {
|
30
|
+
foreach ($files as $file) {
|
31
|
+
if (!preg_match('/\.php$/', $file)) continue;
|
32
|
+
include_once dirname(__FILE__ . '/helpers/' . $file);
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
36
|
+
add_action('init', '<%= theme_name %>init');
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<?php <% class_name = "#{class_prefix}Theme" %>
|
2
|
+
class <%= class_name %> {
|
3
|
+
static $instance;
|
4
|
+
static function getInstance() {
|
5
|
+
if (self::$instance == null)
|
6
|
+
self::$instance = new <%= class_name %>();
|
7
|
+
return self::$instance;
|
8
|
+
}
|
9
|
+
|
10
|
+
static function themeInitialize() {
|
11
|
+
$i = self::getInstance();
|
12
|
+
$i->setFeatures();
|
13
|
+
add_action('init', array(&$i, 'init'));
|
14
|
+
}
|
15
|
+
|
16
|
+
function __construct() {
|
17
|
+
$path = get_template_directory() . "/languages";
|
18
|
+
load_theme_textdomain('<%= theme_name %>', $path);
|
19
|
+
}
|
20
|
+
|
21
|
+
function init() {
|
22
|
+
$this->registerPostTypes();
|
23
|
+
}
|
24
|
+
|
25
|
+
function setFeatures() {
|
26
|
+
// Uncomment these lines to add theme support
|
27
|
+
/*
|
28
|
+
add_theme_support('post-thumbnails');
|
29
|
+
add_theme_support('menus');
|
30
|
+
*/
|
31
|
+
}
|
32
|
+
|
33
|
+
function registerPostTypes() {
|
34
|
+
// Register post types here
|
35
|
+
}
|
36
|
+
}
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/wordpress-tools/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Rodolfo Carvalho"]
|
6
|
+
gem.email = ["rodolfo@infweb.net"]
|
7
|
+
gem.description = %q{A gem to create and manage wordpress websites}
|
8
|
+
gem.summary = <<-EOM
|
9
|
+
A gem to create and manage wordpress websites.
|
10
|
+
In this first version, you can use the gem to initialize a blank wordpress website.
|
11
|
+
EOM
|
12
|
+
gem.homepage = "http://github.com/infweb/wordpress-tools"
|
13
|
+
|
14
|
+
gem.license = "MIT"
|
15
|
+
|
16
|
+
gem.required_ruby_version = '>= 1.8.7'
|
17
|
+
|
18
|
+
gem.files = `git ls-files`.split($\)
|
19
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
20
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
21
|
+
gem.name = "wordpress-tools"
|
22
|
+
gem.require_paths = ["lib"]
|
23
|
+
gem.version = Wordpress::Tools::VERSION
|
24
|
+
|
25
|
+
gem.add_dependency "rake"
|
26
|
+
gem.add_dependency "compass"
|
27
|
+
gem.add_dependency "activesupport", "~> 3.2.12"
|
28
|
+
gem.add_dependency "colorize"
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wordpress-tools
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1alpha1
|
5
|
+
prerelease: 5
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Rodolfo Carvalho
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: compass
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: activesupport
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 3.2.12
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.2.12
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: colorize
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :runtime
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
description: A gem to create and manage wordpress websites
|
79
|
+
email:
|
80
|
+
- rodolfo@infweb.net
|
81
|
+
executables:
|
82
|
+
- wp
|
83
|
+
extensions: []
|
84
|
+
extra_rdoc_files: []
|
85
|
+
files:
|
86
|
+
- .gitignore
|
87
|
+
- Gemfile
|
88
|
+
- LICENSE
|
89
|
+
- README.md
|
90
|
+
- Rakefile
|
91
|
+
- bin/wp
|
92
|
+
- files/footer.php
|
93
|
+
- files/header.php
|
94
|
+
- files/index.php
|
95
|
+
- files/main_gitignore
|
96
|
+
- files/plugins_gitignore
|
97
|
+
- lib/wordpress-tools.rb
|
98
|
+
- lib/wordpress-tools/command_line.rb
|
99
|
+
- lib/wordpress-tools/command_line/action.rb
|
100
|
+
- lib/wordpress-tools/command_line/action/base.rb
|
101
|
+
- lib/wordpress-tools/command_line/action/init.rb
|
102
|
+
- lib/wordpress-tools/configuration.rb
|
103
|
+
- lib/wordpress-tools/tasks.rb
|
104
|
+
- lib/wordpress-tools/template.rb
|
105
|
+
- lib/wordpress-tools/version.rb
|
106
|
+
- templates/build.properties.erb
|
107
|
+
- templates/build.xml.erb
|
108
|
+
- templates/functions.php.erb
|
109
|
+
- templates/style.css.erb
|
110
|
+
- templates/theme_class.php.erb
|
111
|
+
- templates/themes_gitignore.erb
|
112
|
+
- wordpress-tools.gemspec
|
113
|
+
homepage: http://github.com/infweb/wordpress-tools
|
114
|
+
licenses:
|
115
|
+
- MIT
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
require_paths:
|
119
|
+
- lib
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ! '>='
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 1.8.7
|
126
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - ! '>'
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: 1.3.1
|
132
|
+
requirements: []
|
133
|
+
rubyforge_project:
|
134
|
+
rubygems_version: 1.8.23
|
135
|
+
signing_key:
|
136
|
+
specification_version: 3
|
137
|
+
summary: A gem to create and manage wordpress websites. In this first version, you
|
138
|
+
can use the gem to initialize a blank wordpress website.
|
139
|
+
test_files: []
|