wordpress-scaffold 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/bin/wp-scaffold +4 -0
- data/changelog.md +0 -0
- data/doc/getting-started.md +1 -0
- data/lib/wordpress-scaffold.rb +6 -0
- data/lib/wordpress-scaffold/cli.rb +56 -0
- data/lib/wordpress-scaffold/version.rb +5 -0
- data/readme.md +0 -0
- data/scaffold/Gemfile +16 -0
- data/scaffold/Guardfile +4 -0
- data/scaffold/Rakefile +2 -0
- data/scaffold/config/env.php +3 -0
- data/scaffold/index.php +48 -0
- data/scaffold/php/asset.class.php +46 -0
- data/scaffold/php/router.class.php +42 -0
- data/scaffold/php/view.class.php +40 -0
- data/scaffold/style.css +8 -0
- data/scaffold/tasks/assets.rake +57 -0
- data/scaffold/tasks/build.rake +26 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bf70792391f28e48e512ae427a8e602ac101bd1d
|
4
|
+
data.tar.gz: 2127a0717331c2d66eee3d8976c6284d6962fe27
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 62ce9d9a820fed3131caddc88fd9c48937c3fe7afcec89125ae63762a65db733dbeb01a4a568f2d695a78cf919585b7a43bb60e0e2efc821162373bef0f1c797
|
7
|
+
data.tar.gz: 7c0dea79aded367bd0c9905c1c9d17f445ad88075e9e6cf6642490dcf46b900815c7a2abb37519ed34dc15a2e9833f5df9798cb09dc4da1170c459c546cc6934
|
data/bin/wp-scaffold
ADDED
data/changelog.md
ADDED
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
# Getting Started
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require "thor"
|
2
|
+
require "wordpress-scaffold"
|
3
|
+
|
4
|
+
module Wordpress
|
5
|
+
module Scaffold
|
6
|
+
module Cli
|
7
|
+
|
8
|
+
class Base < Thor
|
9
|
+
|
10
|
+
desc "version", "display version"
|
11
|
+
def version
|
12
|
+
say "Wordpress::Scaffold #{Wordpress::Scaffold::VERSION}"
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "scaffold [options]", "scaffold wordpress theme"
|
16
|
+
method_option "name",
|
17
|
+
desc: "directory where project will be created"
|
18
|
+
method_option "existing_project",
|
19
|
+
aliases: "-e",
|
20
|
+
type: :boolean,
|
21
|
+
default: true,
|
22
|
+
desc: "ignore existing files if an existing project"
|
23
|
+
method_option "dry_run",
|
24
|
+
aliases: "-n",
|
25
|
+
type: :boolean,
|
26
|
+
default: false,
|
27
|
+
desc: "show what files would have been transfered"
|
28
|
+
|
29
|
+
|
30
|
+
def scaffold
|
31
|
+
destination_path = options[:name]
|
32
|
+
rsync_files destination_path
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def scaffold_dir
|
38
|
+
File.join File.expand_path( '../../../', __FILE__ ),
|
39
|
+
'scaffold'
|
40
|
+
end
|
41
|
+
|
42
|
+
def rsync_files destination_path
|
43
|
+
flags = ["-av"]
|
44
|
+
flags << "--dry-run" if options[:dry_run]
|
45
|
+
flags << "--ignore-existing" if options[:existing_project]
|
46
|
+
|
47
|
+
destination = destination_path.sub(/\/$/, '')
|
48
|
+
system "mkdir -p #{destination}" unless options[:dry_run]
|
49
|
+
system "rsync #{flags.join(' ')} #{scaffold_dir}/ #{destination}/"
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/readme.md
ADDED
File without changes
|
data/scaffold/Gemfile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
|
3
|
+
# assets
|
4
|
+
gem "sass", "~> 3.2.14"
|
5
|
+
gem "uglifier", "~> 2.2.1"
|
6
|
+
gem "coffee-script", "~> 2.2.0"
|
7
|
+
|
8
|
+
# util
|
9
|
+
gem "therubyracer", "~> 0.12.0"
|
10
|
+
gem "rake", "~> 10.1.0"
|
11
|
+
gem "colorize", "~> 0.6.0"
|
12
|
+
gem "borrower", "~> 0.7.0"
|
13
|
+
|
14
|
+
# guard
|
15
|
+
gem "guard", "~> 1.8.3"
|
16
|
+
gem "guard-shell", "~> 0.5.1"
|
data/scaffold/Guardfile
ADDED
data/scaffold/Rakefile
ADDED
data/scaffold/index.php
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
/* Setup include paths
|
4
|
+
------------------------------------------------- */
|
5
|
+
|
6
|
+
define( 'THEME_DIR', get_template_directory() );
|
7
|
+
define( 'THEME_URL', get_bloginfo('template_url') );
|
8
|
+
set_include_path( THEME_DIR );
|
9
|
+
|
10
|
+
|
11
|
+
/* Setup environment specific details
|
12
|
+
------------------------------------------------- */
|
13
|
+
|
14
|
+
require_once 'config/env.php';
|
15
|
+
|
16
|
+
if ( ENV == 'development' ) {
|
17
|
+
error_reporting(E_ALL);
|
18
|
+
}
|
19
|
+
|
20
|
+
|
21
|
+
/* Setup autoload for helpers & lib files
|
22
|
+
------------------------------------------------- */
|
23
|
+
|
24
|
+
$_load_paths = array(
|
25
|
+
'views/helpers',
|
26
|
+
'lib'
|
27
|
+
);
|
28
|
+
|
29
|
+
spl_autoload_register( function ( $class_name ) {
|
30
|
+
global $_load_paths;
|
31
|
+
foreach ( $_load_paths as $load_path ) {
|
32
|
+
if ( file_exists( THEME_DIR . '/' . $load_path.'/'.$class_name.'.php' ) ) {
|
33
|
+
require_once $load_path.'/'.$class_name.'.php';
|
34
|
+
return;
|
35
|
+
}
|
36
|
+
}
|
37
|
+
});
|
38
|
+
|
39
|
+
|
40
|
+
/* Setup Router
|
41
|
+
------------------------------------------------- */
|
42
|
+
|
43
|
+
Router::map( array(
|
44
|
+
'is_404' => '404',
|
45
|
+
'default' => 'index'
|
46
|
+
));
|
47
|
+
|
48
|
+
?>
|
@@ -0,0 +1,46 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
class Asset {
|
4
|
+
|
5
|
+
/*
|
6
|
+
** Get a url for a script with the cache busting string
|
7
|
+
**
|
8
|
+
** @param $script_name [String] name of the script, without the .js
|
9
|
+
** @return [String] url of the script
|
10
|
+
*/
|
11
|
+
public static function script_url( $script_name ) {
|
12
|
+
return self::url( $script_name.'.js', 'scripts' );
|
13
|
+
}
|
14
|
+
|
15
|
+
/*
|
16
|
+
** Get a url for a stylesheet with the cache busting string
|
17
|
+
**
|
18
|
+
** @param $stylesheet_name [String] name of the stylesheet, without the .css
|
19
|
+
** @return [String] url of the stylesheet
|
20
|
+
*/
|
21
|
+
public static function stylesheet_url( $stylesheet_name ) {
|
22
|
+
return self::url( $stylesheet_name.'.css', 'css' );
|
23
|
+
}
|
24
|
+
|
25
|
+
|
26
|
+
/*
|
27
|
+
** Get a url for an asset with it's filename and directory
|
28
|
+
** relative to '/assets/'
|
29
|
+
**
|
30
|
+
** @param $asset [String] name of the asset includeing file ext.
|
31
|
+
** @param $directory [String] directory relative to /assets
|
32
|
+
** @return [String] url of the stylesheet
|
33
|
+
*/
|
34
|
+
public static function url ( $asset, $directory ) {
|
35
|
+
$pathinfo = pathinfo( $directory.'/'.$asset );
|
36
|
+
|
37
|
+
$mod_time = filemtime( THEME_DIR.'/assets/'.$directory.'/'.$asset );
|
38
|
+
$filename = $pathinfo['filename'];
|
39
|
+
$ext = $pathinfo['extension'];
|
40
|
+
|
41
|
+
return THEME_URL.'/assets/'.$pathinfo['dirname'].'/'.$filename.'.'.$mod_time.'.'.$ext;
|
42
|
+
}
|
43
|
+
|
44
|
+
}
|
45
|
+
|
46
|
+
?>
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
class Router {
|
4
|
+
|
5
|
+
/*
|
6
|
+
** Maps routes as conditional_function => view
|
7
|
+
** a default is also required and called if no
|
8
|
+
** other routes match
|
9
|
+
**
|
10
|
+
** @example:
|
11
|
+
**
|
12
|
+
** Router::map( array(
|
13
|
+
** 'is_single' => 'single',
|
14
|
+
** 'default' => 'index'
|
15
|
+
** ));
|
16
|
+
**
|
17
|
+
** @param $routes_array [Array]
|
18
|
+
** @return [Void]
|
19
|
+
*/
|
20
|
+
public static function map ( $routes_array, $format='default' ) {
|
21
|
+
if ( $format != 'default' &&
|
22
|
+
( !isset($_GET['format']) || $format != $_GET['format'] ) ) {
|
23
|
+
return;
|
24
|
+
}
|
25
|
+
|
26
|
+
$default = $routes_array['default'];
|
27
|
+
unset( $routes_array['default'] );
|
28
|
+
|
29
|
+
foreach( $routes_array as $conditional => $view ) {
|
30
|
+
if( call_user_func($conditional) ) {
|
31
|
+
View::render( $view, $format );
|
32
|
+
exit();
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
View::render( $default, $format );
|
37
|
+
exit();
|
38
|
+
}
|
39
|
+
|
40
|
+
}
|
41
|
+
|
42
|
+
?>
|
@@ -0,0 +1,40 @@
|
|
1
|
+
<?php
|
2
|
+
|
3
|
+
class View {
|
4
|
+
|
5
|
+
/*
|
6
|
+
** Include a layout with the view passed, intended to
|
7
|
+
** wrap the chosen view in the chosen layout
|
8
|
+
**
|
9
|
+
** @param $view [String] name of the view to render
|
10
|
+
** @param $layout [String] default: "default", layout to use
|
11
|
+
** @return [Void]
|
12
|
+
*/
|
13
|
+
public static function render( $view, $layout = "default" ) {
|
14
|
+
include ( 'layouts/' . $layout . '.php' );
|
15
|
+
}
|
16
|
+
|
17
|
+
/*
|
18
|
+
** Include a view
|
19
|
+
**
|
20
|
+
** @param $view [String] view to include
|
21
|
+
** @return [Void]
|
22
|
+
*/
|
23
|
+
public static function yield( $view ) {
|
24
|
+
include ( 'views/' . $view . '.php' );
|
25
|
+
}
|
26
|
+
|
27
|
+
/*
|
28
|
+
** Include Partial
|
29
|
+
**
|
30
|
+
** @param $partial [String] partial to include
|
31
|
+
** @return [Void]
|
32
|
+
*/
|
33
|
+
public static function partial( $partial, $data=array() ) {
|
34
|
+
extract($data);
|
35
|
+
include ( 'views/partials/' . $partial . '.php' );
|
36
|
+
}
|
37
|
+
|
38
|
+
}
|
39
|
+
|
40
|
+
?>
|
data/scaffold/style.css
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'borrower'
|
2
|
+
require 'uglifier'
|
3
|
+
require 'sass'
|
4
|
+
require 'coffee-script'
|
5
|
+
|
6
|
+
Borrower.manifest do |m|
|
7
|
+
m.dir "assets/css/_src"
|
8
|
+
m.dir "assets/scripts/_src"
|
9
|
+
end
|
10
|
+
|
11
|
+
namespace :assets do
|
12
|
+
|
13
|
+
desc 'asset tasks that require compiling files'
|
14
|
+
namespace :compile do
|
15
|
+
|
16
|
+
desc "compile sass files"
|
17
|
+
task :sass do
|
18
|
+
app_sass_dir = 'assets/css/_src'
|
19
|
+
|
20
|
+
Sass.load_paths << app_sass_dir
|
21
|
+
|
22
|
+
stylesheets = Dir[ File.join( app_sass_dir, '*.css.scss') ].map { |f| f.scan(/(?:.*)\/(.+?).css.scss/)[0][0] }
|
23
|
+
|
24
|
+
stylesheets.each do |sheet|
|
25
|
+
puts "compiling #{sheet}.css"
|
26
|
+
borrow "#{sheet}.css.scss", to: "assets/css/#{sheet}.css" do |source|
|
27
|
+
Sass.compile( source, style: :compressed )
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "merge & compile javascripts"
|
34
|
+
task :scripts do
|
35
|
+
|
36
|
+
scripts = Dir['assets/scripts/_src/*.js'].map { |f| f.scan(/(?:.*)\/(.+?).js/)[0][0] }
|
37
|
+
coffeescripts = Dir['assets/scripts/_src/*.js.coffee'].map { |f| f.scan(/(?:.*)\/(.+?).js.coffee/)[0][0] }
|
38
|
+
|
39
|
+
scripts.each do |script|
|
40
|
+
puts "compiling #{script}.js"
|
41
|
+
borrow "#{script}.js", to: "assets/scripts/#{script}.min.js", merge: true, type: 'js' do |source|
|
42
|
+
Uglifier.compile source
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
coffeescripts.each do |script|
|
47
|
+
puts "compiling #{script}.js"
|
48
|
+
borrow "#{script}.js", to: "assets/scripts/#{script}.min.js", merge: true do |source|
|
49
|
+
Uglifier.compile CoffeeScript.compile(source)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'borrower'
|
2
|
+
|
3
|
+
desc 'package theme for deployment'
|
4
|
+
task :build do
|
5
|
+
# file whitelist
|
6
|
+
file_list = []
|
7
|
+
|
8
|
+
# add root files
|
9
|
+
file_list.push *['.htaccess', 'index.php', 'functions.php', 'screenshot.png', 'style.css', 'favicon.ico' ]
|
10
|
+
|
11
|
+
# add dir files
|
12
|
+
file_list.push *Dir[ 'assets/**/*', 'layouts/**/*', 'config/**/*', 'lib/**/*', 'views/**/*' ]
|
13
|
+
|
14
|
+
# move files to release
|
15
|
+
file_list.each do |file|
|
16
|
+
next if File.directory? file
|
17
|
+
|
18
|
+
puts "copying #{file}"
|
19
|
+
borrow file, to: "release/#{file}"
|
20
|
+
end
|
21
|
+
|
22
|
+
# change env to production
|
23
|
+
borrow 'release/config/env.php', to: 'release/config/env.php' do |contents|
|
24
|
+
contents.gsub("development", "production")
|
25
|
+
end
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wordpress-scaffold
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Steven Sloan
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-06-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: borrower
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: " Common patterns & ruby workflow applied for wordpress development "
|
42
|
+
email: stevenosloan@gmail.com
|
43
|
+
executables:
|
44
|
+
- wp-scaffold
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- bin/wp-scaffold
|
49
|
+
- changelog.md
|
50
|
+
- doc/getting-started.md
|
51
|
+
- lib/wordpress-scaffold.rb
|
52
|
+
- lib/wordpress-scaffold/cli.rb
|
53
|
+
- lib/wordpress-scaffold/version.rb
|
54
|
+
- readme.md
|
55
|
+
- scaffold/Gemfile
|
56
|
+
- scaffold/Guardfile
|
57
|
+
- scaffold/Rakefile
|
58
|
+
- scaffold/config/env.php
|
59
|
+
- scaffold/index.php
|
60
|
+
- scaffold/php/asset.class.php
|
61
|
+
- scaffold/php/router.class.php
|
62
|
+
- scaffold/php/view.class.php
|
63
|
+
- scaffold/style.css
|
64
|
+
- scaffold/tasks/assets.rake
|
65
|
+
- scaffold/tasks/build.rake
|
66
|
+
homepage: http://github.com/stevenosloan/wordpress-scaffold
|
67
|
+
licenses:
|
68
|
+
- MIT
|
69
|
+
metadata: {}
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 2.0.0
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 2.2.2
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: Common patterns & ruby workflow applied for wordpress development
|
90
|
+
test_files: []
|