wp_scaffold 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +6 -0
  3. data/.rspec +2 -0
  4. data/Guardfile +8 -0
  5. data/README.md +9 -1
  6. data/bin/wp +19 -8
  7. data/lib/.DS_Store +0 -0
  8. data/lib/wp_scaffold.rb +27 -8
  9. data/lib/wp_scaffold/helpers/text_helpers.rb +19 -0
  10. data/lib/wp_scaffold/models/generator.rb +43 -0
  11. data/lib/wp_scaffold/models/generators/custom_post_type.rb +26 -0
  12. data/lib/wp_scaffold/models/generators/setting.rb +14 -0
  13. data/lib/wp_scaffold/models/generators/theme.rb +21 -0
  14. data/lib/wp_scaffold/templates/custom_post_type/custom-post-types/custom.php +30 -0
  15. data/lib/wp_scaffold/templates/custom_post_type/page-custom.php.erb +38 -0
  16. data/lib/wp_scaffold/templates/custom_post_type/single-custom.php.erb +25 -0
  17. data/lib/wp_scaffold/templates/setting/wp_scaffold_settings.txt.erb +1 -0
  18. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/README.md +1 -1
  19. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/category.php +0 -0
  20. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/footer.php +0 -0
  21. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/front-page.php +0 -0
  22. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/functions.php +8 -4
  23. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/functions/breadcrumbs.php +0 -0
  24. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/header.php +6 -5
  25. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/home.php +0 -0
  26. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/index.php +0 -0
  27. data/lib/wp_scaffold/templates/theme/custom_theme/js/main.js +7 -0
  28. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/js/vendor/fastclick.js +0 -0
  29. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/js/vendor/html5shiv.js +0 -0
  30. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/js/vendor/jquery.easydropdown.min.js +0 -0
  31. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/js/vendor/retina-1.1.0.min.js +0 -0
  32. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/page.php +0 -0
  33. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/partials/content-post.php +0 -0
  34. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/screenshot.png +0 -0
  35. data/lib/wp_scaffold/templates/{theme_base → theme/custom_theme}/single.php +0 -0
  36. data/lib/wp_scaffold/templates/theme/custom_theme/style.css +7 -0
  37. data/lib/wp_scaffold/usage.txt +2 -1
  38. data/lib/wp_scaffold/version.rb +1 -1
  39. data/spec/models/cpt_spec.rb +38 -0
  40. data/spec/models/generator_spec.rb +38 -0
  41. data/spec/models/setting_spec.rb +33 -0
  42. data/spec/models/theme_spec.rb +35 -0
  43. data/spec/spec_helper.rb +31 -0
  44. data/spec/templates/files/php/test_file_3.php.erb +5 -0
  45. data/spec/templates/files/test_file_1.txt +1 -0
  46. data/spec/templates/files/test_file_2.txt.erb +1 -0
  47. data/spec/wp_scaffold_spec.rb +34 -0
  48. data/wp_scaffold.gemspec +4 -1
  49. metadata +95 -36
  50. data/lib/wp_scaffold/generator.rb +0 -81
  51. data/lib/wp_scaffold/helper.rb +0 -11
  52. data/lib/wp_scaffold/templates/.DS_Store +0 -0
  53. data/lib/wp_scaffold/templates/custom_post_type/page-custom.php +0 -50
  54. data/lib/wp_scaffold/templates/custom_post_type/register-cpt.php +0 -31
  55. data/lib/wp_scaffold/templates/custom_post_type/single-custom.php +0 -18
  56. data/lib/wp_scaffold/templates/theme_base/.gitignore +0 -2
  57. data/lib/wp_scaffold/templates/theme_base/coffee/main.coffee +0 -2
  58. data/lib/wp_scaffold/templates/theme_base/functions/theme-settings.php +0 -60
  59. data/lib/wp_scaffold/templates/theme_base/js/main.js +0 -2
  60. data/lib/wp_scaffold/templates/theme_base/style.css +0 -211
  61. data/lib/wp_scaffold/templates/theme_base/styles/_base.scss +0 -36
  62. data/lib/wp_scaffold/templates/theme_base/styles/_grid.scss +0 -327
  63. data/lib/wp_scaffold/templates/theme_base/styles/_normalize.scss +0 -410
  64. data/lib/wp_scaffold/templates/theme_base/styles/style.scss +0 -19
@@ -1,81 +0,0 @@
1
- class WpScaffold::Generator
2
-
3
- def create_theme(theme_name)
4
- theme_name = 'New Theme' if theme_name.nil?
5
-
6
- if File.directory?(current_dir + "/" + theme_name.to_underscore)
7
- puts "There is already a theme called #{theme_name}."
8
- else
9
-
10
- # Copy the directory
11
- cp_r file_base + "/templates/theme_base", current_dir + "/"
12
-
13
- # Rename it
14
- File.rename current_dir + "/theme_base", current_dir + "/" + theme_name.to_underscore
15
-
16
-
17
- # Add the name of the theme to the files, where necessary
18
- file_names = ['style.css', 'styles/style.scss']
19
-
20
- file_names.each do |file_name|
21
- file_name = current_dir + "/" + theme_name.to_underscore + "/" + file_name
22
- file_text = File.read(file_name).gsub("___THEME_NAME___", theme_name)
23
- File.open(file_name, "w") {|file| file.puts file_text}
24
- end
25
-
26
- puts "Created the theme #{theme_name}. run 'cd #{theme_name.to_underscore}'."
27
- end
28
- end
29
-
30
-
31
-
32
- def create_custom_post_type(cpt_name)
33
- # Grab out template, and use it to create our cpt object
34
- new_cpt = File.read(file_base + "/templates/custom_post_type/register-cpt.php")
35
- new_cpt = new_cpt.gsub("___CPT_CAPITALIZED___", cpt_name.titleize)
36
- new_cpt = new_cpt.gsub("___CPT_UNDERSCORED___", cpt_name.to_underscore)
37
- new_cpt = new_cpt.gsub("___CPT_CAPITALIZED_PLURAL___", cpt_name.titleize.pluralize)
38
- new_cpt = new_cpt.gsub("___CPT_DOWNCASE_PLURAL___", cpt_name.pluralize.downcase)
39
-
40
- # Append the new custom post type "custom-post-types.php". Crate the file if it doesn't already exist.
41
- File.open(current_dir + "/functions/custom-post-type.php", 'a') {|f| f.write(new_cpt) }
42
-
43
-
44
- # Create the Page Template
45
- page_template = File.read(file_base + "/templates/custom_post_type/page-custom.php")
46
- page_template = page_template.gsub("___CPT_NAME_DASHED_PLURAL___", cpt_name.pluralize.to_underscore.dasherize)
47
- page_template = page_template.gsub("___CPT_NAME___", cpt_name.titleize)
48
- page_template = page_template.gsub("___CPT_NAME_PLURAL___", cpt_name.pluralize.titleize)
49
- page_template = page_template.gsub("___CPT_NAME_UNDERSCORED___", cpt_name.to_underscore)
50
-
51
- File.open(current_dir + "/page-" + cpt_name.pluralize.to_underscore.dasherize + ".php", 'w') {|f| f.write(page_template) }
52
-
53
-
54
- # Create the Single Template
55
- single_template = File.read(file_base + "/templates/custom_post_type/single-custom.php")
56
- single_template = single_template.gsub("___CPT_NAME_DASHED___", cpt_name.to_underscore.dasherize)
57
- single_template = single_template.gsub("___CPT_NAME___", cpt_name.titleize)
58
-
59
- File.open(current_dir + "/single-" + cpt_name.to_underscore.dasherize + ".php", 'w') {|f| f.write(single_template) }
60
-
61
- puts "Created new post type '#{cpt_name.pluralize}'."
62
- end
63
-
64
-
65
- def usage
66
- file = File.open("#{File.expand_path(File.dirname(__FILE__))}/usage.txt", "rb")
67
- puts file.read
68
- file.close
69
- end
70
-
71
- private
72
-
73
- def current_dir
74
- Dir.pwd
75
- end
76
-
77
- def file_base
78
- File.expand_path(File.dirname(__FILE__))
79
- end
80
-
81
- end
@@ -1,11 +0,0 @@
1
- class String
2
-
3
- def to_underscore
4
- self.gsub(/::/, '/').
5
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
6
- gsub(/([a-z\d])([A-Z])/,'\1_\2').
7
- tr("- ", "_").
8
- downcase
9
- end
10
-
11
- end
@@ -1,50 +0,0 @@
1
- <?php /* Template Name: ___CPT_NAME___ Index */ ?>
2
- <!-- This is the page-___CPT_NAME_DASHED_PLURAL___.php file, a page template that lists out "___CPT_NAME___" posts -->
3
-
4
- <?php get_header(); ?>
5
-
6
- <section>
7
- <!-- Start Loop -->
8
- <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
9
-
10
- <div class="breadcrumbs">
11
- <?php get_breadcrumbs($post); ?>
12
- </div>
13
-
14
- <h1><?php the_title(); ?></h1>
15
- <?php the_content(); ?>
16
-
17
-
18
- <?php // List all posts with type "___CPT_NAME_UNDERSCORED___"
19
- $args = array(
20
- 'post_type' => '___CPT_NAME_UNDERSCORED___'
21
- );
22
-
23
- $___CPT_NAME_UNDERSCORED____query = new WP_Query( $args );
24
- ?>
25
-
26
- <!-- Start ___CPT_NAME___ Loop -->
27
- <?php if ( have_posts() ) : ?>
28
-
29
- <ul>
30
- <?php while ( $___CPT_NAME_UNDERSCORED____query->have_posts() ) : $___CPT_NAME_UNDERSCORED____query->the_post(); ?>
31
-
32
- <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
33
-
34
- <?php endwhile; ?>
35
- </ul>
36
-
37
- <?php else: ?>
38
- <p>No ___CPT_NAME_PLURAL___ to display!</p>
39
- <?php endif; ?>
40
- <?php wp_reset_postdata(); ?>
41
- <!-- End ___CPT_NAME___ Loop -->
42
-
43
-
44
- <?php endwhile; else: ?>
45
- <p>Page not found!</p>
46
- <?php endif; ?>
47
- <!-- End Loop -->
48
- </section>
49
-
50
- <?php get_footer(); ?>
@@ -1,31 +0,0 @@
1
- <?php
2
-
3
- // ___CPT_CAPITALIZED_PLURAL___
4
- add_action('init', 'create____CPT_UNDERSCORED____post_type');
5
- function create____CPT_UNDERSCORED____post_type() {
6
- register_post_type( '___CPT_UNDERSCORED___',
7
- array(
8
- 'labels' => array(
9
- 'name' => __( '___CPT_CAPITALIZED_PLURAL___' ),
10
- 'singular_name' => __( '___CPT_CAPITALIZED___' ),
11
- 'add_new' => __( 'Add New ___CPT_CAPITALIZED___' ),
12
- 'add_new_item' => __( 'Add New ___CPT_CAPITALIZED___' ),
13
- 'edit_item' => __( 'Edit ___CPT_CAPITALIZED___' ),
14
- 'new_item' => __( 'Add New ___CPT_CAPITALIZED___' ),
15
- 'view_item' => __( 'View ___CPT_CAPITALIZED___' ),
16
- 'search_items' => __( 'Search ___CPT_CAPITALIZED_PLURAL___' ),
17
- 'not_found' => __( 'No ___CPT_DOWNCASE_PLURAL___ found' ),
18
- 'not_found_in_trash' => __( 'No ___CPT_DOWNCASE_PLURAL___ found in trash'),
19
- 'menu_name' => __( '___CPT_CAPITALIZED_PLURAL___' ),
20
- ),
21
- 'public' => true,
22
- 'rewrite' => array('slug' => '___CPT_UNDERSCORED___'),
23
- //'taxonomies' => array('category'),
24
- 'publicly_queryable' => true,
25
- 'supports' => array('title', 'editor', 'page-attributes')
26
- )
27
- );
28
- }
29
-
30
- ?>
31
-
@@ -1,18 +0,0 @@
1
- <!-- This is the single-___CPT_NAME_DASHED___.php file, which acts as a template for a single "___CPT_NAME___" post type -->
2
-
3
- <?php get_header(); ?>
4
-
5
- <section>
6
- <!-- Start Loop -->
7
- <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
8
-
9
- <h1><?php the_title(); ?></h1>
10
- <?php the_content(); ?>
11
-
12
- <?php endwhile; else: ?>
13
- <p>___CPT_NAME___ not found!</p>
14
- <?php endif; ?>
15
- <!-- End Loop -->
16
- </section>
17
-
18
- <?php get_footer(); ?>
@@ -1,2 +0,0 @@
1
- codekit-config.json
2
- .DS_Store
@@ -1,2 +0,0 @@
1
- jQuery(document).ready ($) ->
2
- console.log "ready to go!"
@@ -1,60 +0,0 @@
1
- <?php
2
-
3
-
4
- # Theme Settings Menu
5
- add_action('admin_menu', 'create_theme_settings_menu');
6
-
7
- # Add the menu item
8
- function create_theme_settings_menu() {
9
- add_menu_page('Theme Settings', 'Theme Settings', 'administrator', __FILE__, 'theme_settings_page', site_url()."/wp-admin/images/media-button-other.gif");
10
- add_action('admin_init', 'register_theme_settings');
11
- }
12
-
13
- # Register our settings
14
- function register_theme_settings() {
15
- register_setting('custom-settings-group', 'phone_number');
16
- register_setting('custom-settings-group', 'support_email');
17
- # register_setting('custom-settings-group', 'ANOTHER_CUSTOM_SETTING');
18
- }
19
-
20
- # Create the admin screen
21
- function theme_settings_page() { ?>
22
- <div class="custom-theme-settings-wrap">
23
- <h1>Theme Settings</h1>
24
- <form method="post" action="options.php">
25
- <?php settings_fields('custom-settings-group'); ?>
26
-
27
-
28
- <div class="group">
29
- <h2>Contact Info</h2>
30
-
31
- <fieldset>
32
- <label>Phone Number</label>
33
- <input type="text" name="phone_number" plcaeholder="1.800.000.0000" value="<?php echo get_option('phone_number'); ?>"/>
34
- </fieldset>
35
-
36
- <fieldset>
37
- <label>Support Email Address</label>
38
- <input type="text" name="support_email" placeholder="name@example.com" value="<?php echo get_option('support_email'); ?>"/>
39
- </fieldset>
40
- </div>
41
-
42
-
43
- <div class="controlls">
44
- <?php submit_button(); ?>
45
- </div>
46
- </form>
47
- </div>
48
- <?php }
49
-
50
-
51
-
52
- # Custom stylesheet for admin screens
53
- function admin_theme_style() {
54
- wp_enqueue_style('admin-theme', get_template_directory_uri() . '/wp-admin.css');
55
- }
56
- add_action('admin_enqueue_scripts', 'admin_theme_style');
57
-
58
-
59
-
60
- ?>
@@ -1,2 +0,0 @@
1
- // Generated by CoffeeScript 1.6.3
2
- (function(){jQuery(document).ready(function(e){return console.log("ready to go!")})}).call(this);
@@ -1,211 +0,0 @@
1
- /*
2
- Theme Name: ___THEME_NAME___
3
- Description: Blank theme with basic Wordpress functions included.
4
- Author: Nathan Hackley
5
- Author URI: http://nathanhackley.com
6
- Version: 0.1
7
- */
8
- /*--- Browser Reset ---*/
9
- * {
10
- margin: 0;
11
- padding: 0;
12
- -webkit-box-sizing: border-box;
13
- -moz-box-sizing: border-box;
14
- box-sizing: border-box; }
15
-
16
- :focus {
17
- outline: none; }
18
-
19
- ::-moz-focus-inner {
20
- border: 0; }
21
-
22
- a {
23
- cursor: pointer; }
24
-
25
- a, img {
26
- border: 0;
27
- outline: none;
28
- text-decoration: none; }
29
-
30
- ul {
31
- list-style: none; }
32
-
33
- html {
34
- height: 100%; }
35
-
36
- body {
37
- text-align: center;
38
- height: 100%; }
39
-
40
- .container {
41
- margin: 0 auto;
42
- min-width: 768px;
43
- max-width: 1200px;
44
- overflow: hidden;
45
- text-align: left; }
46
-
47
- .grid_1, .grid_2, .grid_3, .grid_4, .grid_5, .grid_6, .grid_7, .grid_8, .grid_9, .grid_10, .grid_11, .grid_12, .grid_13, .grid_14, .grid_15, .grid_16, .grid_third, .grid_two_thirds {
48
- float: left;
49
- margin-left: 1%;
50
- margin-right: 1%;
51
- position: relative;
52
- display: inline; }
53
-
54
- .clear:after {
55
- content: ".";
56
- display: block;
57
- clear: both;
58
- visibility: hidden;
59
- line-height: 0;
60
- height: 0; }
61
-
62
- /* --- Float Helpers --- */
63
- .right {
64
- float: right !important; }
65
-
66
- .left {
67
- float: left !important; }
68
-
69
- .container .grid_1 {
70
- width: 4.25%; }
71
-
72
- .container .grid_2 {
73
- width: 10.5%; }
74
-
75
- .container .grid_3 {
76
- width: 16.75%; }
77
-
78
- .container .grid_4 {
79
- width: 23.0%; }
80
-
81
- .container .grid_5 {
82
- width: 29.25%; }
83
-
84
- .container .grid_6 {
85
- width: 35.5%; }
86
-
87
- .container .grid_7 {
88
- width: 41.75%; }
89
-
90
- .container .grid_8 {
91
- width: 48.0%; }
92
-
93
- .container .grid_9 {
94
- width: 54.25%; }
95
-
96
- .container .grid_10 {
97
- width: 60.5%; }
98
-
99
- .container .grid_11 {
100
- width: 66.75%; }
101
-
102
- .container .grid_12 {
103
- width: 73.0%; }
104
-
105
- .container .grid_13 {
106
- width: 79.25%; }
107
-
108
- .container .grid_14 {
109
- width: 85.5%; }
110
-
111
- .container .grid_15 {
112
- width: 91.75%; }
113
-
114
- .container .grid_16 {
115
- width: 98.0%; }
116
-
117
- .container .grid_third {
118
- width: 31.3%; }
119
-
120
- .container .grid_two_thirds {
121
- width: 64.6%; }
122
-
123
- .container .prefix_1 {
124
- margin-left: 7.25%; }
125
-
126
- .container .prefix_2 {
127
- margin-left: 13.5%; }
128
-
129
- .container .prefix_3 {
130
- margin-left: 19.75%; }
131
-
132
- .container .prefix_4 {
133
- margin-left: 26.0%; }
134
-
135
- .container .prefix_5 {
136
- margin-left: 32.25%; }
137
-
138
- .container .prefix_6 {
139
- margin-left: 38.5%; }
140
-
141
- .container .prefix_7 {
142
- margin-left: 44.75%; }
143
-
144
- .container .prefix_8 {
145
- margin-left: 51.0%; }
146
-
147
- .container .prefix_9 {
148
- margin-left: 57.25%; }
149
-
150
- .container .prefix_10 {
151
- margin-left: 63.5%; }
152
-
153
- .container .prefix_11 {
154
- margin-left: 69.75%; }
155
-
156
- .container .prefix_12 {
157
- margin-left: 76.0%; }
158
-
159
- .container .prefix_13 {
160
- margin-left: 82.25%; }
161
-
162
- .container .prefix_14 {
163
- margin-left: 88.5%; }
164
-
165
- .container .prefix_15 {
166
- margin-left: 94.75%; }
167
-
168
- .container .suffix_1 {
169
- margin-right: 7.25%; }
170
-
171
- .container .suffix_2 {
172
- margin-right: 13.5%; }
173
-
174
- .container .suffix_3 {
175
- margin-right: 19.75%; }
176
-
177
- .container .suffix_4 {
178
- margin-right: 26.0%; }
179
-
180
- .container .suffix_5 {
181
- margin-right: 32.25%; }
182
-
183
- .container .suffix_6 {
184
- margin-right: 38.5%; }
185
-
186
- .container .suffix_7 {
187
- margin-right: 44.75%; }
188
-
189
- .container .suffix_8 {
190
- margin-right: 51.0%; }
191
-
192
- .container .suffix_9 {
193
- margin-right: 57.25%; }
194
-
195
- .container .suffix_10 {
196
- margin-right: 63.5%; }
197
-
198
- .container .suffix_11 {
199
- margin-right: 69.75%; }
200
-
201
- .container .suffix_12 {
202
- margin-right: 76.0%; }
203
-
204
- .container .suffix_13 {
205
- margin-right: 82.25%; }
206
-
207
- .container .suffix_14 {
208
- margin-right: 88.5%; }
209
-
210
- .container .suffix_15 {
211
- margin-right: 94.75%; }