Skip to content
This repository was archived by the owner on Sep 3, 2024. It is now read-only.

Commit 81c5c36

Browse files
committed
Merge pull request #30 from synapticism/develop
Develop
2 parents a40b9fe + 3511f71 commit 81c5c36

File tree

9 files changed

+38
-35
lines changed

9 files changed

+38
-35
lines changed

gulpconfig.js

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ module.exports = {
5353
, chunks: { // Chunks are arrays of paths or globs matching a set of source files; this way you can organize a bunch of scripts that go together into pieces that can then be bundled (above)
5454
// The core chunk is loaded no matter what; put essential scripts that you want loaded by your theme in here
5555
core: [
56-
src+'js/responsive-menu.js'
56+
modules+'timeago/jquery.timeago.js'
57+
, src+'js/responsive-menu.js'
5758
, src+'js/core.js'
5859
]
5960
// The pageloader chunk provides an example of how you would add a user-configurable feature to your theme; you can delete this if you wish
@@ -84,13 +85,9 @@ module.exports = {
8485
src: src+'scss/**/*.scss'
8586
, dest: build
8687
}
87-
, dist: {
88-
src: dist+'**/*.css'
89-
, dest: dist
90-
}
9188
, compiler: 'libsass' // Choose a Sass compiler: 'libsass' or 'rubysass'
9289
, autoprefixer: { browsers: ['> 3%', 'last 2 versions', 'ie 9', 'ios 6', 'android 4'] } // This tool is magic and you should use it in all your projects :)
93-
, minify: { keepSpecialComments: 1, roundingPrecision: 4 } // Keep special comments preserves the bits we need for WordPress to recognize the theme's stylesheet
90+
, minify: { safe: true }
9491
, rubySass: { // Requires the Ruby implementation of Sass; run `gem install sass` if you use this; Compass is *not* included by default
9592
loadPath: ['./src/scss', bower, modules] // Adds Bower and npm directories to the load path so you can @import directly
9693
, precision: 6

gulpfile.js/tasks/main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ gulp.task('setup', ['utils-normalize']);
1111
// Build a working copy of the theme
1212
gulp.task('build', ['images', 'scripts', 'styles', 'theme']);
1313

14-
// Dist task chain: wipe -> build -> clean -> copy -> images/styles
14+
// Dist task chain: wipe -> build -> clean -> copy -> compress images
1515
// NOTE: this is a resource-intensive task!
16-
gulp.task('dist', ['images-dist', 'styles-dist']);
16+
gulp.task('dist', ['images-dist']);

gulpfile.js/tasks/styles.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ gulp.task('styles-rubysass', function() {
1313
return plugins.rubySass(config.build.src, config.rubySass)
1414
.on('error', gutil.log) // Log errors instead of killing the process
1515
.pipe(plugins.postcss(processors))
16+
.pipe(plugins.cssnano(config.minify))
1617
.pipe(plugins.sourcemaps.write('./')) // No need to init; this is set in the configuration
1718
.pipe(gulp.dest(config.build.dest)); // Drops the unminified CSS file into the `build` folder
1819
});
@@ -23,16 +24,10 @@ gulp.task('styles-libsass', function() {
2324
.pipe(plugins.sourcemaps.init())
2425
.pipe(plugins.sass(config.libsass))
2526
.pipe(plugins.postcss(processors))
27+
.pipe(plugins.cssnano(config.minify))
2628
.pipe(plugins.sourcemaps.write('./')) // Writes an external sourcemap
2729
.pipe(gulp.dest(config.build.dest)); // Drops the unminified CSS file into the `build` folder
2830
});
2931

30-
// Copy stylesheets from the `build` folder to `dist` and minify them along the way
31-
gulp.task('styles-dist', ['utils-dist'], function() {
32-
return gulp.src(config.dist.src)
33-
.pipe(plugins.minifyCss(config.minify))
34-
.pipe(gulp.dest(config.dist.dest));
35-
});
36-
3732
// Easily configure the Sass compiler from `/gulpconfig.js`
3833
gulp.task('styles', ['styles-'+config.compiler]);

package.json

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wordpress-gulp-starter-kit",
3-
"version": "0.2.0",
3+
"version": "0.2.1",
44
"description": "A starter kit for developing WordPress themes with Gulp",
55
"homepage": "https://github.com/synapticism/wordpress-gulp-starter-kit",
66
"repository": {
@@ -25,30 +25,31 @@
2525
"main": "gulpfile.js",
2626
"private": true,
2727
"devDependencies": {
28-
"autoprefixer": "^6.1.1",
29-
"browser-sync": "^2.10.0",
30-
"del": "^2.1.0",
31-
"gulp": "^3.9.0",
28+
"autoprefixer": "^6.3.3",
29+
"browser-sync": "^2.11.1",
30+
"del": "^2.2.0",
31+
"gulp": "^3.9.1",
3232
"gulp-changed": "^1.3.0",
3333
"gulp-concat": "^2.6.0",
34+
"gulp-cssnano": "^2.1.1",
3435
"gulp-imagemin": "^2.4.0",
3536
"gulp-jshint": "^2.0.0",
3637
"gulp-livereload": "^3.8.1",
37-
"gulp-load-plugins": "^1.1.0",
38-
"gulp-minify-css": "^1.2.1",
39-
"gulp-postcss": "^6.0.1",
38+
"gulp-load-plugins": "^1.2.0",
39+
"gulp-postcss": "^6.1.0",
4040
"gulp-rename": "^1.2.2",
4141
"gulp-ruby-sass": "^2.0.6",
42-
"gulp-sass": "^2.1.0",
42+
"gulp-sass": "^2.2.0",
4343
"gulp-sourcemaps": "^1.6.0",
44-
"gulp-uglify": "^1.5.1",
44+
"gulp-uglify": "^1.5.2",
4545
"gulp-util": "^3.0.7",
46-
"html5-history-api": "^4.2.4",
46+
"html5-history-api": "^4.2.5",
4747
"merge-stream": "^1.0.0",
4848
"normalize.css": "^3.0.3",
4949
"require-dir": "^0.3.0",
50-
"scut": "^1.3.0",
50+
"scut": "^1.4.0",
5151
"spin.js": "^2.3.2",
52+
"timeago": "^1.5.2",
5253
"wp-ajax-page-loader": "^0.2.0"
5354
},
5455
"scripts": {

readme.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Why use this project instead of any of the alternatives? A few advantages:
1010
* You should be able to easily drop your own theme into the `src` folder and start hacking without much additional setup.
1111
* Documentation and comments in the code assume a novice level of understanding.
1212
* Builds on existing WordPress and Gulp best practices without doing anything too crazy.
13-
* Will save you a ton of time and help you make better, more readily optimized themes once you learn how it all works.
13+
* This kind of workflow will save you a ton of time and help you make better, more readily-optimized themes once you learn how it all works.
1414

1515

1616

@@ -46,9 +46,9 @@ If you're already up and running with most of the usual Node ecosystem tools thi
4646

4747
Previously this project shipped without a working theme included. I figured that with all the great starter themes out there (for instance, [_s](https://github.com/Automattic/_s), [Roots](https://github.com/roots/roots), and [Bones](https://github.com/eddiemachado/bones)) it wouldn't be hard to drop one in and start theming. I don't personally use any of these so I was a little surprised to discover how tricky this can be. Starter themes, despite their "bare bones" reputation, are often bulky and opinionated. Some even ship with their own build processes already in place!
4848

49-
It seems there is a need for what I'd call a *minimum viable theme*: a truly bare bones WordPress starter theme featuring only the essentials to get up and running, something that you can assess at a glance. For the purposes of this project I have created such a theme, tentatively named `voidx`. It isn't pretty and isn't up to [WordPress standards](https://wordpress.org/plugins/theme-check/) but it works well enough to show off some of the power of this workflow. Feel free to play with or discard it as you wish. All files under `src` can be replaced by your own files, you just have to be sure to wire things up properly in the `gulpconfig.js` file if you swap in your own stuff.
49+
It seems there is a need for what I'd call a *minimum viable theme*: a truly bare bones WordPress starter theme featuring only the essentials to get up and running, something that you can assess at a glance. For the purposes of this project I have created such a theme, tentatively named `voidx`. It isn't pretty and isn't up to [WordPress standards](https://wordpress.org/plugins/theme-check/) but it works well enough to show off some of the power of this workflow. Feel free to play with or discard it as you wish. All files under `src` can be replaced by your own files, you just have to be sure to wire things up properly in the `gulpconfig.js` file if you swap in your own stuff. I've already integrated [timeago](http://timeago.yarp.com/), a simple script to transform timestamps into something more human-readable, but this is easily removed if you don't like it (which is sort of the point of having such scaffolding, so you can easily swap stuff in and out).
5050

51-
There are two components worth a closer look, however:
51+
There are two components worth a closer look:
5252

5353
* The script variable and enqueuing functions in `src/inc/assets.php`; these are tightly coupled with the output of the build process.
5454
* The theme configuration pattern described in `functions.php` and `functions-config-defaults.php`.
@@ -131,7 +131,7 @@ Like images, PHP (and language) files can go anywhere under `src` and will be co
131131

132132

133133

134-
## A SAMPLE INTEGRATION
134+
## EXAMPLE INTEGRATION
135135

136136
Let's say you run across a cool project like [Headroom.js](http://wicky.nillia.ms/headroom.js/) and decide you'd like to try it out. Here's how you would do that with the tools and workflow outlined in this repo:
137137

@@ -142,7 +142,7 @@ Let's say you run across a cool project like [Headroom.js](http://wicky.nillia.m
142142
* Add the switch to `inc/assets.php`: `if ( VOIDX_SCRIPTS_HEADROOM ) : $script_name .= '-hr';`.
143143
* Add an option to `scss/_config.scss` to allow for the styling to be turned on or off: `$plugin-headroom: true;`.
144144
* Add the necessary styling to `scss/_plugins.scss` wrapped in a conditional check: `@if ($plugin-headroom) { // Style }`.
145-
* Create an additional script at `src/js/headroom.js` to invoke the main script (code to follow).
145+
* Create an additional script at `src/js/headroom.js` to invoke the main script:
146146

147147
```language-javascript
148148
// Invoke Headroom.js

src/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<h1><a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></h1>
1111
</header>
1212
<footer class="entry-meta">
13-
<?php printf( __( 'Posted on %1$s by %2$s. ', 'voidx' ), get_the_date(), get_the_author() ); ?>
13+
<?php printf( __( 'Posted <time datetime="%1$s">%2$s</time> by %3$s. ', 'voidx' ), get_post_time('c'), get_the_date(), get_the_author() ); ?>
1414
<?php _e( 'Categories: ', 'voidx' ); the_category( ', ' ); echo '. '; ?>
1515
</footer>
1616
<div class="entry-content">

src/js/core.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
// A simple wrapper for all your custom jQuery; everything in this file will be run on every page
44
;(function($){
55
$(function(){
6-
// Insert jQuery code here!
6+
// Example integration: JavaScript-based human-readable timestamps
7+
if ($.timeago) {
8+
$('time').timeago();
9+
}
710
});
811
}(jQuery));

src/js/page-loader.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,12 @@
44
;(function($){
55
$(function(){
66
$(document.body).ajaxPageLoader();
7+
8+
// If jQuery.timeago exists also update timestamps on AJAX page load; if you remove the timeago script this can be deleted
9+
if ($.timeago) {
10+
document.addEventListener("DOMContentLoaded", function (event) {
11+
$('time').timeago();
12+
});
13+
}
714
});
815
}(jQuery));

src/scss/_config.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ $_metadata: (
3030
, theme-author: "Alexander Synaptic"
3131
, theme-author-uri: "http://synapticism.com"
3232
, theme-description: "A minimally viable theme made with the WordPress/Gulp starter kit"
33-
, theme-version: "0.2.0"
33+
, theme-version: "0.2.1"
3434
, theme-license: "GPLv3"
3535
, theme-license-uri: "http://www.gnu.org/licenses/gpl.txt"
3636
, theme-tags: (light, responsive-layout, right-sidebar, starter-theme, two-columns, translation-ready, white)

0 commit comments

Comments
 (0)