forge 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,9 @@
1
+ == 0.2 ==
2
+ - Added preliminary LESS support
3
+ - Added ERB processing on templates, functions and assets with filenames that end with .erb
4
+ - Adding --config=filename flag for specifying an alternate config file
5
+ - Scaffolding template cleanup
6
+
1
7
  == 0.1.3 ==
2
8
  - Fixed bug where forge watch crashed when a file was at the root of the includes folder
3
9
 
data/Gemfile CHANGED
@@ -13,6 +13,7 @@ gem "sprockets-sass", "~> 0.3.0"
13
13
  gem "compass", "~> 0.11.5"
14
14
  gem 'rack', '~> 1.3.5'
15
15
  gem "guard-livereload", "~> 0.3.1"
16
+ gem "less", "~> 2.0.7"
16
17
 
17
18
  # Add dependencies to develop your gem here.
18
19
  # Include everything needed to run rake, tests, features, etc.
@@ -46,6 +46,9 @@ GEM
46
46
  git (>= 1.2.5)
47
47
  rake
48
48
  json (1.6.1)
49
+ less (2.0.7)
50
+ therubyracer (~> 0.9.2)
51
+ libv8 (3.3.10.2)
49
52
  multi_json (1.0.3)
50
53
  rack (1.3.5)
51
54
  rake (0.9.2)
@@ -68,6 +71,8 @@ GEM
68
71
  sprockets-sass (0.3.0)
69
72
  sprockets (~> 2.0)
70
73
  term-ansicolor (1.0.6)
74
+ therubyracer (0.9.9)
75
+ libv8 (~> 3.3.10)
71
76
  thor (0.14.6)
72
77
  tilt (1.3.3)
73
78
 
@@ -83,6 +88,7 @@ DEPENDENCIES
83
88
  guard-livereload (~> 0.3.1)
84
89
  jeweler (~> 1.6.4)
85
90
  json (~> 1.6.1)
91
+ less (~> 2.0.7)
86
92
  rack (~> 1.3.5)
87
93
  rcov
88
94
  rspec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.2.0
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "forge"
8
- s.version = "0.1.3"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Andy Adams", "Drew Strojny", "Matt Button"]
12
- s.date = "2011-10-27"
12
+ s.date = "2011-11-12"
13
13
  s.description = "A toolkit for bootstrapping and developing WordPress themes."
14
14
  s.email = "aadams@jestro.com"
15
15
  s.executables = ["forge"]
@@ -31,7 +31,6 @@ Gem::Specification.new do |s|
31
31
  "bin/forge",
32
32
  "features/step_definitions/forge_steps.rb",
33
33
  "features/support/env.rb",
34
- "forge-0.1.2.gem",
35
34
  "forge.gemspec",
36
35
  "layouts/config/config.json.erb",
37
36
  "layouts/config/stylesheet_header.erb",
@@ -53,17 +52,11 @@ Gem::Specification.new do |s|
53
52
  "layouts/default/templates/search.php.erb",
54
53
  "layouts/default/templates/sidebar.php",
55
54
  "layouts/default/templates/single.php.erb",
56
- "layouts/lib/struts/README.md",
57
- "layouts/lib/struts/classes/settings.php",
58
- "layouts/lib/struts/classes/settings/collection.php",
59
- "layouts/lib/struts/classes/settings/option.php",
60
- "layouts/lib/struts/classes/settings/option/select.php",
61
- "layouts/lib/struts/classes/settings/option/text.php",
62
- "layouts/lib/struts/classes/settings/section.php",
63
55
  "lib/forge.rb",
64
56
  "lib/forge/builder.rb",
65
57
  "lib/forge/cli.rb",
66
58
  "lib/forge/config.rb",
59
+ "lib/forge/engines.rb",
67
60
  "lib/forge/error.rb",
68
61
  "lib/forge/generator.rb",
69
62
  "lib/forge/guard.rb",
@@ -97,6 +90,7 @@ Gem::Specification.new do |s|
97
90
  s.add_runtime_dependency(%q<compass>, ["~> 0.11.5"])
98
91
  s.add_runtime_dependency(%q<rack>, ["~> 1.3.5"])
99
92
  s.add_runtime_dependency(%q<guard-livereload>, ["~> 0.3.1"])
93
+ s.add_runtime_dependency(%q<less>, ["~> 2.0.7"])
100
94
  s.add_development_dependency(%q<rspec>, [">= 0"])
101
95
  s.add_development_dependency(%q<cucumber>, [">= 0"])
102
96
  s.add_development_dependency(%q<aruba>, [">= 0"])
@@ -114,6 +108,7 @@ Gem::Specification.new do |s|
114
108
  s.add_dependency(%q<compass>, ["~> 0.11.5"])
115
109
  s.add_dependency(%q<rack>, ["~> 1.3.5"])
116
110
  s.add_dependency(%q<guard-livereload>, ["~> 0.3.1"])
111
+ s.add_dependency(%q<less>, ["~> 2.0.7"])
117
112
  s.add_dependency(%q<rspec>, [">= 0"])
118
113
  s.add_dependency(%q<cucumber>, [">= 0"])
119
114
  s.add_dependency(%q<aruba>, [">= 0"])
@@ -132,6 +127,7 @@ Gem::Specification.new do |s|
132
127
  s.add_dependency(%q<compass>, ["~> 0.11.5"])
133
128
  s.add_dependency(%q<rack>, ["~> 1.3.5"])
134
129
  s.add_dependency(%q<guard-livereload>, ["~> 0.3.1"])
130
+ s.add_dependency(%q<less>, ["~> 2.0.7"])
135
131
  s.add_dependency(%q<rspec>, [">= 0"])
136
132
  s.add_dependency(%q<cucumber>, [">= 0"])
137
133
  s.add_dependency(%q<aruba>, [">= 0"])
@@ -1,14 +1,13 @@
1
1
  <?php
2
2
 
3
- add_action( 'after_setup_theme', '<%= theme_id %>_setup' );
3
+ add_action( 'wp_enqueue_scripts', '<%= theme_id %>_enqueue_scripts' );
4
4
 
5
- if ( ! function_exists( '<%= theme_id %>_setup' ) ) :
5
+ if ( ! function_exists( '<%= theme_id %>_enqueue_scripts' ) ) :
6
6
 
7
7
  /**
8
- * Set up your theme here
8
+ * Add theme styles and scripts here
9
9
  */
10
- function <%= theme_id %>_setup() {
11
- add_theme_support( 'post-thumbnails' );
10
+ function <%= theme_id %>_enqueue_scripts() {
12
11
 
13
12
  if ( ! is_admin() ) {
14
13
  wp_enqueue_style(
@@ -16,6 +15,20 @@ function <%= theme_id %>_setup() {
16
15
  get_bloginfo( 'stylesheet_url' )
17
16
  );
18
17
  }
18
+
19
+ }
20
+
21
+ endif; // <%= theme_id %>_enqueue_scripts
22
+
23
+ add_action( 'after_setup_theme', '<%= theme_id %>_setup' );
24
+
25
+ if ( ! function_exists( '<%= theme_id %>_setup' ) ) :
26
+
27
+ /**
28
+ * Set up your theme here
29
+ */
30
+ function <%= theme_id %>_setup() {
31
+ add_theme_support( 'post-thumbnails' );
19
32
  }
20
33
 
21
- endif; // <%= theme_id %>_setup
34
+ endif; // <%= theme_id %>_setup
@@ -1,8 +1,10 @@
1
1
  require 'sprockets'
2
2
  require 'sprockets-sass'
3
3
  require 'sass'
4
+ require 'less'
4
5
  require 'zip/zip'
5
6
  require 'compass'
7
+ require 'forge/engines'
6
8
 
7
9
  module Forge
8
10
  class Builder
@@ -76,12 +78,35 @@ module Forge
76
78
 
77
79
  def copy_templates
78
80
  template_paths.each do |template_path|
79
- FileUtils.cp template_path, @project.build_path unless File.directory?(template_path)
81
+ # Skip directories
82
+ next if File.directory?(template_path)
83
+
84
+ if template_path.end_with?('.erb')
85
+ # Chop the .erb extension off the filename
86
+ destination = File.join(@project.build_path, File.basename(template_path).slice(0..-5))
87
+
88
+ write_erb(template_path, destination)
89
+ else
90
+ # Regular old copy of PHP-only files
91
+ FileUtils.cp template_path, @project.build_path
92
+ end
80
93
  end
81
94
  end
82
95
 
96
+ def clean_functions
97
+ FileUtils.rm File.join(@project.build_path, 'functions.php')
98
+ end
99
+
83
100
  def copy_functions
84
- FileUtils.cp_r File.join(@functions_path, 'functions.php'), @project.build_path
101
+ functions_erb_path = File.join(@functions_path, 'functions.php.erb')
102
+ functions_php_path = File.join(@functions_path, 'functions.php')
103
+
104
+ if File.exists?(functions_erb_path)
105
+ destination = File.join(@project.build_path, 'functions.php')
106
+ write_erb(functions_erb_path, destination)
107
+ elsif File.exists?(functions_php_path)
108
+ FileUtils.cp functions_php_path, @project.build_path
109
+ end
85
110
  end
86
111
 
87
112
  def clean_includes
@@ -96,9 +121,6 @@ module Forge
96
121
  # Iterate over all files in source/includes, so we can exclude if necessary
97
122
  paths = Dir.glob(File.join(@includes_path, '**', '*'))
98
123
  paths.each do |path|
99
- # Skip over hidden files and folders (.git, .svn, etc)
100
- continue if File.basename(path)[0] == '.'
101
-
102
124
  # Remove @includes_path from full file path to get the relative path
103
125
  relative_path = path.gsub(@includes_path, '')
104
126
  destination = File.join(@project.build_path, 'includes', relative_path)
@@ -168,11 +190,16 @@ module Forge
168
190
  @sprockets.append_path File.join(@assets_path, dir)
169
191
  end
170
192
 
171
- @sprockets.context_class.instance_eval do
172
- def config
173
- return {:name => 'asd'}
174
- p "CALLING CONFIG"
175
- @project.config
193
+ # Add assets/styleshets to load path for Less Engine
194
+ Tilt::LessTemplateWithPaths.load_path = File.join(@assets_path, 'stylesheets')
195
+
196
+ @sprockets.register_engine '.less', Tilt::LessTemplateWithPaths
197
+
198
+ # Passing the @project instance variable to the Sprockets::Context instance
199
+ # used for processing the asset ERB files. Ruby meta-programming, FTW.
200
+ @sprockets.context_class.instance_exec(@project) do |project|
201
+ define_method :config do
202
+ project.config
176
203
  end
177
204
  end
178
205
  end
@@ -202,5 +229,20 @@ module Forge
202
229
  file = @task.find_in_source_paths(File.join('config', 'stylesheet_header.erb'))
203
230
  @stylesheet_header = File.expand_path(file)
204
231
  end
232
+
233
+ # Write an .erb from source to destination, catching and reporting errors along the way
234
+ def write_erb(source, destination)
235
+ begin
236
+ @task.shell.mute do
237
+ @task.create_file(destination) do
238
+ @project.parse_erb(source)
239
+ end
240
+ end
241
+ rescue Exception => e
242
+ @task.say "Error while building #{File.basename(source)}:"
243
+ @task.say e.message + "\n", Thor::Shell::Color::RED
244
+ exit
245
+ end
246
+ end
205
247
  end
206
248
  end
@@ -14,7 +14,6 @@ module Forge
14
14
  end
15
15
 
16
16
  desc "create DIRECTORY", "Creates a Forge project"
17
- method_option :struts, :type => :boolean, :desc => "Include Struts Options Framework"
18
17
  def create(dir)
19
18
  theme = {}
20
19
  theme[:name] = dir
@@ -35,8 +34,9 @@ module Forge
35
34
 
36
35
  desc "watch", "Start watch process"
37
36
  long_desc "Watches the source directory in your project for changes, and reflects those changes in a compile folder"
37
+ method_option :config, :type => :string, :desc => "Name of alternate config file"
38
38
  def watch
39
- project = Forge::Project.new('.', self)
39
+ project = Forge::Project.new('.', self, nil, options[:config])
40
40
 
41
41
  # Empty the build directory before starting up to clean out old files
42
42
  FileUtils.rm_rf project.build_path
@@ -46,19 +46,24 @@ module Forge
46
46
  end
47
47
 
48
48
  desc "build DIRECTORY", "Build your theme into specified directory"
49
+ method_option :config, :type => :string, :desc => "Name of alternate config file"
49
50
  def build(dir='build')
50
- project = Forge::Project.new('.', self)
51
+ project = Forge::Project.new('.', self, nil, options[:config])
51
52
 
52
53
  builder = Builder.new(project)
53
54
  builder.build
54
55
 
55
- FileUtils.rm_rf Dir.glob(File.join(dir, '*'))
56
+ Dir.glob(File.join(dir, '**', '*')).each do |file|
57
+ shell.mute { remove_file(file) }
58
+ end
59
+
56
60
  directory(project.build_path, dir)
57
61
  end
58
62
 
59
63
  desc "package FILENAME", "Compile and zip your project to FILENAME.zip"
64
+ method_option :config, :type => :string, :desc => "Name of alternate config file"
60
65
  def package(filename=nil)
61
- project = Forge::Project.new('.', self)
66
+ project = Forge::Project.new('.', self, nil, options[:config])
62
67
 
63
68
  builder = Builder.new(project)
64
69
  builder.build
@@ -0,0 +1,12 @@
1
+ module Tilt
2
+ class LessTemplateWithPaths < LessTemplate
3
+ class << self
4
+ attr_accessor :load_path
5
+ end
6
+
7
+ def prepare
8
+ parser = ::Less::Parser.new(:filename => eval_file, :line => line, :paths => [self.class.load_path])
9
+ @engine = parser.parse(data)
10
+ end
11
+ end
12
+ end
@@ -66,15 +66,6 @@ module Forge
66
66
  self
67
67
  end
68
68
 
69
- def copy_settings_library
70
- settings_path = @task.find_in_source_paths(File.join('lib', 'struts', 'classes'))
71
-
72
- source = File.expand_path(settings_path)
73
- target = File.expand_path(File.join(@project.includes_path, 'struts', '.'))
74
-
75
- @task.directory(source, target)
76
- end
77
-
78
69
  def copy_functions
79
70
  source = File.expand_path(File.join(self.layout_path, 'functions', 'functions.php.erb'))
80
71
  target = File.expand_path(File.join(@project.source_path, 'functions', 'functions.php'))
@@ -93,7 +84,6 @@ module Forge
93
84
  copy_javascript
94
85
  copy_templates
95
86
  copy_functions
96
- copy_settings_library if @task.options[:struts]
97
87
  return self
98
88
  end
99
89
 
@@ -16,10 +16,11 @@ module Forge
16
16
 
17
17
  attr_accessor :root, :config, :task
18
18
 
19
- def initialize(root, task, config={})
19
+ def initialize(root, task, config={}, config_file=nil)
20
20
  @root = File.expand_path(root)
21
21
  @config = config || {}
22
22
  @task = task
23
+ @config_file = config_file
23
24
 
24
25
  self.load_config if @config.empty?
25
26
  end
@@ -15,6 +15,7 @@ module Guard
15
15
 
16
16
  def run_all
17
17
  UI.info "Rebuilding all functions"
18
+ ::Forge::Guard.builder.clean_functions
18
19
  ::Forge::Guard.builder.copy_functions
19
20
  ::Forge::Guard.builder.clean_includes
20
21
  ::Forge::Guard.builder.copy_includes
@@ -23,6 +24,7 @@ module Guard
23
24
  # Called on file(s) modifications
24
25
  def run_on_change(paths)
25
26
  UI.info "Functions have changed, copying over"
27
+ ::Forge::Guard.builder.clean_functions
26
28
  ::Forge::Guard.builder.copy_functions
27
29
  ::Forge::Guard.builder.clean_includes
28
30
  ::Forge::Guard.builder.copy_includes
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,11 +11,11 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2011-10-27 00:00:00.000000000 Z
14
+ date: 2011-11-12 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: thor
18
- requirement: &2152502800 !ruby/object:Gem::Requirement
18
+ requirement: &2156553020 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
21
  - - ~>
@@ -23,10 +23,10 @@ dependencies:
23
23
  version: 0.14.6
24
24
  type: :runtime
25
25
  prerelease: false
26
- version_requirements: *2152502800
26
+ version_requirements: *2156553020
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: guard
29
- requirement: &2152502260 !ruby/object:Gem::Requirement
29
+ requirement: &2156552520 !ruby/object:Gem::Requirement
30
30
  none: false
31
31
  requirements:
32
32
  - - ~>
@@ -34,10 +34,10 @@ dependencies:
34
34
  version: 0.8.4
35
35
  type: :runtime
36
36
  prerelease: false
37
- version_requirements: *2152502260
37
+ version_requirements: *2156552520
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: sprockets
40
- requirement: &2152501740 !ruby/object:Gem::Requirement
40
+ requirement: &2156552040 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ~>
@@ -45,10 +45,10 @@ dependencies:
45
45
  version: 2.0.2
46
46
  type: :runtime
47
47
  prerelease: false
48
- version_requirements: *2152501740
48
+ version_requirements: *2156552040
49
49
  - !ruby/object:Gem::Dependency
50
50
  name: rubyzip
51
- requirement: &2152495220 !ruby/object:Gem::Requirement
51
+ requirement: &2156551540 !ruby/object:Gem::Requirement
52
52
  none: false
53
53
  requirements:
54
54
  - - ~>
@@ -56,10 +56,10 @@ dependencies:
56
56
  version: 0.9.4
57
57
  type: :runtime
58
58
  prerelease: false
59
- version_requirements: *2152495220
59
+ version_requirements: *2156551540
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: json
62
- requirement: &2152494720 !ruby/object:Gem::Requirement
62
+ requirement: &2156551000 !ruby/object:Gem::Requirement
63
63
  none: false
64
64
  requirements:
65
65
  - - ~>
@@ -67,10 +67,10 @@ dependencies:
67
67
  version: 1.6.1
68
68
  type: :runtime
69
69
  prerelease: false
70
- version_requirements: *2152494720
70
+ version_requirements: *2156551000
71
71
  - !ruby/object:Gem::Dependency
72
72
  name: sass
73
- requirement: &2152494160 !ruby/object:Gem::Requirement
73
+ requirement: &2156550500 !ruby/object:Gem::Requirement
74
74
  none: false
75
75
  requirements:
76
76
  - - ~>
@@ -78,10 +78,10 @@ dependencies:
78
78
  version: 3.1.8
79
79
  type: :runtime
80
80
  prerelease: false
81
- version_requirements: *2152494160
81
+ version_requirements: *2156550500
82
82
  - !ruby/object:Gem::Dependency
83
83
  name: sprockets-sass
84
- requirement: &2152493460 !ruby/object:Gem::Requirement
84
+ requirement: &2156531840 !ruby/object:Gem::Requirement
85
85
  none: false
86
86
  requirements:
87
87
  - - ~>
@@ -89,10 +89,10 @@ dependencies:
89
89
  version: 0.3.0
90
90
  type: :runtime
91
91
  prerelease: false
92
- version_requirements: *2152493460
92
+ version_requirements: *2156531840
93
93
  - !ruby/object:Gem::Dependency
94
94
  name: compass
95
- requirement: &2152492820 !ruby/object:Gem::Requirement
95
+ requirement: &2156531300 !ruby/object:Gem::Requirement
96
96
  none: false
97
97
  requirements:
98
98
  - - ~>
@@ -100,10 +100,10 @@ dependencies:
100
100
  version: 0.11.5
101
101
  type: :runtime
102
102
  prerelease: false
103
- version_requirements: *2152492820
103
+ version_requirements: *2156531300
104
104
  - !ruby/object:Gem::Dependency
105
105
  name: rack
106
- requirement: &2152491980 !ruby/object:Gem::Requirement
106
+ requirement: &2156530740 !ruby/object:Gem::Requirement
107
107
  none: false
108
108
  requirements:
109
109
  - - ~>
@@ -111,10 +111,10 @@ dependencies:
111
111
  version: 1.3.5
112
112
  type: :runtime
113
113
  prerelease: false
114
- version_requirements: *2152491980
114
+ version_requirements: *2156530740
115
115
  - !ruby/object:Gem::Dependency
116
116
  name: guard-livereload
117
- requirement: &2152490940 !ruby/object:Gem::Requirement
117
+ requirement: &2156530260 !ruby/object:Gem::Requirement
118
118
  none: false
119
119
  requirements:
120
120
  - - ~>
@@ -122,10 +122,21 @@ dependencies:
122
122
  version: 0.3.1
123
123
  type: :runtime
124
124
  prerelease: false
125
- version_requirements: *2152490940
125
+ version_requirements: *2156530260
126
+ - !ruby/object:Gem::Dependency
127
+ name: less
128
+ requirement: &2156529780 !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ~>
132
+ - !ruby/object:Gem::Version
133
+ version: 2.0.7
134
+ type: :runtime
135
+ prerelease: false
136
+ version_requirements: *2156529780
126
137
  - !ruby/object:Gem::Dependency
127
138
  name: rspec
128
- requirement: &2152490340 !ruby/object:Gem::Requirement
139
+ requirement: &2156529280 !ruby/object:Gem::Requirement
129
140
  none: false
130
141
  requirements:
131
142
  - - ! '>='
@@ -133,10 +144,10 @@ dependencies:
133
144
  version: '0'
134
145
  type: :development
135
146
  prerelease: false
136
- version_requirements: *2152490340
147
+ version_requirements: *2156529280
137
148
  - !ruby/object:Gem::Dependency
138
149
  name: cucumber
139
- requirement: &2152489540 !ruby/object:Gem::Requirement
150
+ requirement: &2156528800 !ruby/object:Gem::Requirement
140
151
  none: false
141
152
  requirements:
142
153
  - - ! '>='
@@ -144,10 +155,10 @@ dependencies:
144
155
  version: '0'
145
156
  type: :development
146
157
  prerelease: false
147
- version_requirements: *2152489540
158
+ version_requirements: *2156528800
148
159
  - !ruby/object:Gem::Dependency
149
160
  name: aruba
150
- requirement: &2152488740 !ruby/object:Gem::Requirement
161
+ requirement: &2156528320 !ruby/object:Gem::Requirement
151
162
  none: false
152
163
  requirements:
153
164
  - - ! '>='
@@ -155,10 +166,10 @@ dependencies:
155
166
  version: '0'
156
167
  type: :development
157
168
  prerelease: false
158
- version_requirements: *2152488740
169
+ version_requirements: *2156528320
159
170
  - !ruby/object:Gem::Dependency
160
171
  name: bundler
161
- requirement: &2152487620 !ruby/object:Gem::Requirement
172
+ requirement: &2156527780 !ruby/object:Gem::Requirement
162
173
  none: false
163
174
  requirements:
164
175
  - - ~>
@@ -166,10 +177,10 @@ dependencies:
166
177
  version: 1.0.0
167
178
  type: :development
168
179
  prerelease: false
169
- version_requirements: *2152487620
180
+ version_requirements: *2156527780
170
181
  - !ruby/object:Gem::Dependency
171
182
  name: jeweler
172
- requirement: &2152487000 !ruby/object:Gem::Requirement
183
+ requirement: &2156527240 !ruby/object:Gem::Requirement
173
184
  none: false
174
185
  requirements:
175
186
  - - ~>
@@ -177,10 +188,10 @@ dependencies:
177
188
  version: 1.6.4
178
189
  type: :development
179
190
  prerelease: false
180
- version_requirements: *2152487000
191
+ version_requirements: *2156527240
181
192
  - !ruby/object:Gem::Dependency
182
193
  name: rcov
183
- requirement: &2152486500 !ruby/object:Gem::Requirement
194
+ requirement: &2156526640 !ruby/object:Gem::Requirement
184
195
  none: false
185
196
  requirements:
186
197
  - - ! '>='
@@ -188,7 +199,7 @@ dependencies:
188
199
  version: '0'
189
200
  type: :development
190
201
  prerelease: false
191
- version_requirements: *2152486500
202
+ version_requirements: *2156526640
192
203
  description: A toolkit for bootstrapping and developing WordPress themes.
193
204
  email: aadams@jestro.com
194
205
  executables:
@@ -211,7 +222,6 @@ files:
211
222
  - bin/forge
212
223
  - features/step_definitions/forge_steps.rb
213
224
  - features/support/env.rb
214
- - forge-0.1.2.gem
215
225
  - forge.gemspec
216
226
  - layouts/config/config.json.erb
217
227
  - layouts/config/stylesheet_header.erb
@@ -233,17 +243,11 @@ files:
233
243
  - layouts/default/templates/search.php.erb
234
244
  - layouts/default/templates/sidebar.php
235
245
  - layouts/default/templates/single.php.erb
236
- - layouts/lib/struts/README.md
237
- - layouts/lib/struts/classes/settings.php
238
- - layouts/lib/struts/classes/settings/collection.php
239
- - layouts/lib/struts/classes/settings/option.php
240
- - layouts/lib/struts/classes/settings/option/select.php
241
- - layouts/lib/struts/classes/settings/option/text.php
242
- - layouts/lib/struts/classes/settings/section.php
243
246
  - lib/forge.rb
244
247
  - lib/forge/builder.rb
245
248
  - lib/forge/cli.rb
246
249
  - lib/forge/config.rb
250
+ - lib/forge/engines.rb
247
251
  - lib/forge/error.rb
248
252
  - lib/forge/generator.rb
249
253
  - lib/forge/guard.rb
Binary file
@@ -1,43 +0,0 @@
1
- ## Struts is a simple theme options framework for WordPress.
2
-
3
- The goal of this library is to abstract away as much of the WordPress settings API as possible, and make setting up options a breeze!
4
-
5
- ## Basic setup
6
-
7
- * Clone this repository
8
- * Symlink the 'classes' folder from this library into your functions folder in your theme
9
- * In your functions.php file, use this code to setup your theme's options:
10
-
11
- <?php
12
-
13
- add_action( 'after_setup_theme', 'react_options' );
14
-
15
- function react_options() {
16
- require( dirname( __FILE__ ) . '/functions/settings/settings.php' );
17
-
18
- global $react_options;
19
-
20
- $react_options = new Settings_Collection( 'react', 'theme_react_options' );
21
-
22
- $react_options->add_section( 'first_section', 'Text for First Section' );
23
- $react_options->add_section( 'second_section', 'Text for Second Section' );
24
-
25
- $react_options->add_option( 'my_first_option', 'text', 'first_section' )
26
- ->default_value( 'The default text' )
27
- ->tab( 'general')
28
- ->label( 'Enable Featured Slider' );
29
-
30
- $react_options->add_option( 'select_this', 'select', 'second_section' )
31
- ->valid_values( array(
32
- 'one' => 'ONE',
33
- 'two' => 'TWO',
34
- 'three' => 'THREE' ) )
35
- ->default_value( 'two' )
36
- ->label( 'Select Your Character' );
37
-
38
- /* More options go here... */
39
-
40
- $react_options->initialize();
41
- }
42
-
43
- Bam! You have theme options!
@@ -1,11 +0,0 @@
1
- <?php
2
-
3
- require( dirname( __FILE__ ) . '/settings/collection.php' );
4
- require( dirname( __FILE__ ) . '/settings/option.php' );
5
- require( dirname( __FILE__ ) . '/settings/section.php' );
6
- require( dirname( __FILE__ ) . '/settings/option/text.php' );
7
- require( dirname( __FILE__ ) . '/settings/option/select.php' );
8
-
9
- class Settings {
10
-
11
- }
@@ -1,190 +0,0 @@
1
- <?php
2
-
3
- class Settings_Collection {
4
- protected $_sections, $_options, $_name, $_slug;
5
-
6
- public function __construct( $slug, $name ) {
7
- $this->sections( array() );
8
- $this->options( array() );
9
- $this->slug( $slug );
10
- $this->name( $name );
11
- $this->register_hooks();
12
- }
13
-
14
- /***** Attribute accessors *****/
15
- public function sections( $sections = NULL ) {
16
- if ( NULL === $sections )
17
- return $this->_sections;
18
-
19
- $this->_sections = $sections;
20
-
21
- return $this;
22
- }
23
-
24
- public function options( $options = NULL ) {
25
- if ( NULL === $options )
26
- return $this->_options;
27
-
28
- $this->_options = $options;
29
-
30
- return $this;
31
- }
32
-
33
- public function slug( $slug = NULL ) {
34
- if ( NULL === $slug )
35
- return $this->_slug;
36
-
37
- $this->_slug = $slug;
38
-
39
- return $this;
40
- }
41
-
42
- public function name( $name = NULL ) {
43
- if ( NULL === $name )
44
- return $this->_name;
45
-
46
- $this->_name = $name;
47
-
48
- return $this;
49
- }
50
-
51
- /***** WordPress setup *****/
52
-
53
- public function register_hooks() {
54
- // Load the Admin Options page
55
- add_action( 'admin_menu', array( &$this, 'add_options_page' ) );
56
- // Register the sections and options
57
- add_action( 'admin_init', array( &$this, 'register' ) );
58
- }
59
-
60
- public function initialize() {
61
- $option_values = get_option( $this->name() );
62
-
63
- if ( false === $option_values || empty( $option_values ) ) {
64
- $option_values = $this->defaults();
65
- }
66
- update_option( $this->name(), $option_values );
67
-
68
- foreach ( $option_values as $name => $value ) {
69
- foreach ( $this->_options as $option ) {
70
- if ( $option->name() == $name ){
71
- $option->value($value);
72
- }
73
- }
74
- }
75
- }
76
-
77
- public function add_options_page() {
78
- add_theme_page(
79
- 'Theme Options',
80
- 'Theme Options',
81
- 'edit_theme_options',
82
- $this->slug() . '-settings',
83
- array( &$this, 'echo_form_html' ) );
84
- }
85
-
86
- public function register() {
87
- register_setting( $this->name(), $this->name(), array( &$this, 'validate' ) );
88
- $this->register_sections();
89
- $this->register_options();
90
- }
91
-
92
- protected function register_options() {
93
- foreach( $this->options() as $option ) {
94
- $option->register();
95
- }
96
- }
97
-
98
- protected function register_sections() {
99
- foreach( $this->sections() as $section ) {
100
- $section->register();
101
- }
102
- }
103
-
104
- public function validate( $inputs ) {
105
- $validated_input = array();
106
-
107
- foreach ( $inputs as $key => $value ) {
108
- $option = $this->_options[$key];
109
- $validated_input[$key] = $option->validate( $value );
110
- }
111
-
112
- return $validated_input;
113
- }
114
-
115
- /**
116
- *
117
- */
118
- public function add_section( $id, $title, $description = NULL ) {
119
- $this->_sections[] = new Settings_Section( $id, $title, $description, $this->name() );
120
- }
121
-
122
- /**
123
- * Adds an option with the given name and type to this collection
124
- * Sets the option's parent_name to this collection's name, and returns the option
125
- *
126
- * @param $name - unique (within the collection ) name for this option
127
- * @param $type - type of option (text/select/checkbox/etc)
128
- * @param $section - name of the section this option goes in
129
- *
130
- * @return Settings_Option
131
- */
132
- public function add_option( $name, $type, $section = NULL ) {
133
- $option_class = 'Settings_Option_' . ucfirst( $type );
134
-
135
- $option = new $option_class;
136
- $option->name( $name );
137
- $option->parent_name( $this->name() );
138
- $option->section( $section );
139
-
140
- $this->_options[$name] = $option;
141
-
142
- return $option;
143
- }
144
-
145
- public function get_value( $option_name ) {
146
- $options = $this->options();
147
- $option = $options[$option_name];
148
- return $option->value();
149
- }
150
-
151
- /**
152
- * Returns the default values of all options in this collection as a hash
153
- *
154
- * @return array
155
- */
156
- public function defaults() {
157
- $defaults = array();
158
-
159
- $options = $this->options();
160
-
161
- foreach( $options as $option ) {
162
- $defaults[ $option->name() ] = $option->default_value();
163
- }
164
-
165
- return $defaults;
166
- }
167
-
168
- /***** HTML Output *****/
169
-
170
- public function echo_form_html() { ?>
171
- <div class="wrap">
172
- <?php echo $this->settings_updated_html(); ?>
173
- <form action="options.php" method="post">
174
- <?php
175
- settings_fields( $this->name() );
176
- do_settings_sections( $this->name() );
177
- ?>
178
- <input type="submit" class="button-primary" value="<?php esc_attr_e('Save Settings'); ?>" />
179
- <input type="submit" class="button-secondary" value="<?php esc_attr_e('Reset Defaults'); ?>" />
180
- </form>
181
- </div>
182
- <?php }
183
-
184
- public function settings_updated_html() {
185
- if ( isset( $_GET['settings-updated'] ) )
186
- return "<div class='updated'><p>Theme settings updated successfully.</p></div>";
187
- }
188
- }
189
-
190
- class SectionNotFoundException extends Exception { }
@@ -1,125 +0,0 @@
1
- <?php
2
-
3
- abstract class Settings_Option {
4
- protected $_name, $_valid_values, $_value, $_type, $_default_value,
5
- $_tab, $_label, $_description, $_parent_name, $_validation_function;
6
-
7
- public function name( $name = NULL ) {
8
- if ( NULL === $name )
9
- return $this->_name;
10
-
11
- $this->_name = $name;
12
- return $this;
13
- }
14
-
15
- public function valid_values( $valid_values = NULL ) {
16
- if ( NULL === $valid_values )
17
- return $this->_valid_values;
18
-
19
- $this->_valid_values = $valid_values;
20
- return $this;
21
- }
22
-
23
- public function value( $value = NULL ) {
24
- if ( NULL === $value ) {
25
- return $this->_value;
26
- }
27
-
28
- $this->_value = $value;
29
- return $this;
30
- }
31
-
32
- public function type( $type = NULL ) {
33
- if ( NULL === $type )
34
- return $this->_type;
35
-
36
- $this->_type = $type;
37
- return $this;
38
- }
39
-
40
- public function default_value( $default_value = NULL ) {
41
- if ( NULL === $default_value )
42
- return $this->_default_value;
43
-
44
- $this->_default_value = $default_value;
45
- return $this;
46
- }
47
-
48
- public function tab( $tab = NULL ) {
49
- if ( NULL === $tab )
50
- return $this->_tab;
51
-
52
- $this->_tab = $tab;
53
- return $this;
54
- }
55
-
56
- public function label( $label = NULL ) {
57
- if ( NULL === $label )
58
- return $this->_label;
59
-
60
- $this->_label = $label;
61
- return $this;
62
- }
63
-
64
- public function description( $description = NULL ) {
65
- if ( NULL === $description )
66
- return $this->_description;
67
-
68
- $this->_description = $description;
69
- return $this;
70
- }
71
-
72
- public function parent_name( $parent_name = NULL ) {
73
- if ( NULL === $parent_name )
74
- return $this->_parent_name;
75
-
76
- $this->_parent_name = $parent_name;
77
- return $this;
78
- }
79
-
80
- public function section( $section = NULL ) {
81
- if ( NULL === $section )
82
- return $this->_section;
83
-
84
- $this->_section = $section;
85
- return $this;
86
- }
87
-
88
- public function validation_function( $validation_function = NULL ) {
89
- if ( NULL === $validation_function )
90
- return $this->_validation_function;
91
-
92
- $this->_validation_function = $validation_function;
93
- return $this;
94
- }
95
-
96
- // The HTML ID takes the form 'parentname-optionname'
97
- protected function html_id() {
98
- return $this->parent_name() . '-' . $this->name();
99
- }
100
-
101
- // Name takes the form 'parentname[optionname]'
102
- protected function html_name() {
103
- return $this->parent_name() . '[' . $this->name() . ']';
104
- }
105
-
106
- public function register() {
107
- add_settings_field(
108
- $this->name(),
109
- $this->label(),
110
- array( &$this, 'to_html' ),
111
- $this->parent_name(),
112
- $this->section() );
113
- }
114
-
115
- public function validate( $value ) {
116
- if ( $validation_function = $this->validation_function() ) {
117
- return $validation_function( $value );
118
- } else {
119
- return $this->standard_validation( $value );
120
- }
121
- }
122
-
123
- abstract public function to_html();
124
- abstract protected function standard_validation( $value );
125
- }
@@ -1,30 +0,0 @@
1
- <?php
2
-
3
- class Settings_Option_Select extends Settings_Option {
4
- public function to_html() {
5
- $id = $this->html_id();
6
- $name = $this->html_name();
7
-
8
- $output = "<select id='$id' name='$name'>";
9
-
10
- foreach ( $this->valid_values() as $value => $text ) {
11
- // If this value is selected, mark it so
12
- $selected = selected( $this->value(), $value, false );
13
-
14
- $output .= "<option value='$value' $selected >$text</option>";
15
- }
16
-
17
- $output .= "</select>";
18
-
19
- echo $output;
20
- }
21
-
22
- protected function standard_validation( $value ) {
23
- $valid_values = $this->valid_values();
24
- if ( array_key_exists( $value, $valid_values ) ) {
25
- return $value;
26
- }
27
-
28
- return $this->default_value();
29
- }
30
- }
@@ -1,15 +0,0 @@
1
- <?php
2
-
3
- class Settings_Option_Text extends Settings_Option {
4
- public function to_html() {
5
- $id = $this->html_id();
6
- $name = $this->html_name();
7
- $value = $this->value();
8
-
9
- echo "<input type='text' id='$id' name='$name' value='$value' />";
10
- }
11
-
12
- protected function standard_validation( $value ) {
13
- return trim( $value );
14
- }
15
- }
@@ -1,56 +0,0 @@
1
- <?php
2
-
3
- class Settings_Section {
4
- protected $_id, $_title, $_description, $_parent_name;
5
-
6
- public function __construct( $id, $title, $description, $parent_name ) {
7
- $this->id( $id );
8
- $this->title( $title );
9
- $this->description( $description );
10
- $this->parent_name( $parent_name );
11
- }
12
-
13
- public function id( $id = NULL ) {
14
- if ( NULL === $id )
15
- return $this->_id;
16
-
17
- $this->_id = $id;
18
- return $this;
19
- }
20
-
21
- public function title( $title = NULL ) {
22
- if ( NULL === $title )
23
- return $this->_title;
24
-
25
- $this->_title = $title;
26
- return $this;
27
- }
28
-
29
- public function description( $description = NULL ) {
30
- if ( NULL === $description )
31
- return $this->_description;
32
-
33
- $this->_description = $description;
34
- return $this;
35
- }
36
-
37
- public function parent_name( $parent_name = NULL ) {
38
- if ( NULL === $parent_name )
39
- return $this->_parent_name;
40
-
41
- $this->_parent_name = $parent_name;
42
- return $this;
43
- }
44
-
45
- public function description_html() {
46
- echo "<p>{$this->description()}</p>";
47
- }
48
-
49
- public function register() {
50
- add_settings_section(
51
- $this->id(),
52
- $this->title(),
53
- array( &$this, 'description_html' ),
54
- $this->parent_name() );
55
- }
56
- }