1
0
mirror of https://github.com/ascribe/wp-theme synced 2024-12-22 09:13:38 +01:00

Working theme

This commit is contained in:
Sarah Etter 2015-09-16 18:17:28 -06:00
parent 9994b59a31
commit c429b69d2d
22 changed files with 401 additions and 187 deletions

50
.gitignore vendored
View File

@ -4,53 +4,3 @@ vendor
composer.lock
phpunit.xml
.idea
.ftppass
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion
*.iml
## Directory-based project format:
.idea/
# if you remove the above rule, at least ignore the following:
# User-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries
# Sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# .idea/uiDesigner.xml
# Gradle:
# .idea/gradle.xml
# .idea/libraries
# Mongo Explorer plugin:
# .idea/mongoSettings.xml
## File-based project format:
*.ipr
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties

View File

@ -5,15 +5,18 @@ module.exports = function( grunt ) {
pkg: grunt.file.readJSON( 'package.json' ),
concat: {
options: {
stripBanners: true
stripBanners: true,
banner: '/*! <%= pkg.title %> - v<%= pkg.version %>\n' +
' * <%= pkg.homepage %>\n' +
' * Copyright (c) <%= grunt.template.today("yyyy") %>;' +
' * Licensed GPLv2+' +
' */\n'
},
main: {
src: [
'assets/js/vendor/*/*.min.js',
'assets/js/vendor/*/*.js',
'assets/js/src/ascribeio.js'
'assets/js/src/ascribe.js'
],
dest: 'assets/js/ascribeio.js'
dest: 'assets/js/ascribe.js'
}
},
jshint: {
@ -26,9 +29,14 @@ module.exports = function( grunt ) {
uglify: {
all: {
files: {
'assets/js/ascribeio.min.js': ['assets/js/ascribeio.js']
'assets/js/ascribe.min.js': ['assets/js/ascribe.js']
},
options: {
banner: '/*! <%= pkg.title %> - v<%= pkg.version %>\n' +
' * <%= pkg.homepage %>\n' +
' * Copyright (c) <%= grunt.template.today("yyyy") %>;' +
' * Licensed GPLv2+' +
' */\n',
mangle: {
except: ['jQuery']
}
@ -36,16 +44,17 @@ module.exports = function( grunt ) {
}
},
less: {
all: {
options: {
sourceMap: false
},
files: {
'assets/css/ascribeio.css': 'assets/css/less/ascribeio.less'
}
}
},
sass: {
all: {
options: {
precision: 2,
sourceMap: true
},
files: {
'assets/css/ascribe.css': 'assets/css/sass/ascribe.scss'
}
}
},
postcss: {
@ -56,17 +65,24 @@ module.exports = function( grunt ) {
]
},
files: {
'assets/css/ascribeio.css': [ 'assets/css/ascribeio.css' ]
'assets/css/ascribe.css': [ 'assets/css/ascribe.css' ]
}
}
},
cssmin: {
options: {
banner: '/*! <%= pkg.title %> - v<%= pkg.version %>\n' +
' * <%=pkg.homepage %>\n' +
' * Copyright (c) <%= grunt.template.today("yyyy") %>;' +
' * Licensed GPLv2+' +
' */\n'
},
minify: {
expand: true,
cwd: 'assets/css/',
src: ['ascribeio.css'],
src: ['ascribe.css'],
dest: 'assets/css/',
ext: '.min.css'
@ -80,8 +96,8 @@ module.exports = function( grunt ) {
}
},
styles: {
files: ['assets/css/less/**/*.less'],
tasks: ['less', 'autoprefixer', 'cssmin'],
files: ['assets/css/sass/**/*.scss'],
tasks: ['sass', 'autoprefixer', 'cssmin'],
options: {
debounceDelay: 500
}
@ -94,65 +110,62 @@ module.exports = function( grunt ) {
}
}
},
'sftp-deploy': {
build: {
auth: {
host: 'server.territorial.ca',
port: 22,
authKey: 'key1'
},
cache: 'sftpCache.json',
src: '/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/',
dest: '/home/ascribe/public_html/wp-content/themes/ascribe/',
exclusions: ['/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/node_modules',
'/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/release',
'/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/vendor',
'/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/.git',
'/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/.idea',
'/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/**/.DS_Store'],
serverSep: '/',
concurrency: 4,
progress: true
},
css: {
auth: {
host: 'server.territorial.ca',
port: 22,
authKey: 'key1'
},
cache: 'sftpCache.json',
src: '/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/css/',
dest: '/home/ascribe/public_html/wp-content/themes/ascribe/assets/css',
serverSep: '/',
concurrency: 4,
progress: true
},
js: {
auth: {
host: 'server.territorial.ca',
port: 22,
authKey: 'key1'
},
cache: 'sftpCache.json',
src: '/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/js/',
dest: '/home/ascribe/public_html/wp-content/themes/ascribe/assets/js',
serverSep: '/',
concurrency: 4,
progress: true
},
controller: {
auth: {
host: 'server.territorial.ca',
port: 22,
authKey: 'key1'
},
src: '/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/controller/',
dest: '/home/ascribe/public_html/wp-content/themes/ascribe/controller/',
serverSep: '/',
concurrency: 4,
progress: true
}
}
clean: {
main: ['release/<%= pkg.version %>']
},
copy: {
// Copy the theme to a versioned release directory
main: {
src: [
'**',
'!**/.*',
'!**/readme.md',
'!node_modules/**',
'!vendor/**',
'!tests/**',
'!release/**',
'!assets/css/sass/**',
'!assets/css/src/**',
'!assets/js/src/**',
'!images/src/**',
'!bootstrap.php',
'!bower.json',
'!composer.json',
'!composer.lock',
'!Gruntfile.js',
'!package.json',
'!phpunit.xml',
'!phpunit.xml.dist'
],
dest: 'release/<%= pkg.version %>/'
}
},
compress: {
main: {
options: {
mode: 'zip',
archive: './release/wptheme.<%= pkg.version %>.zip'
},
expand: true,
cwd: 'release/<%= pkg.version %>/',
src: ['**/*'],
dest: 'wptheme/'
}
},
phpunit: {
classes: {
dir: 'tests/phpunit/'
},
options: {
bin: 'vendor/bin/phpunit',
bootstrap: 'bootstrap.php.dist',
colors: true,
testSuffix: 'Tests.php'
}
},
qunit: {
all: ['tests/qunit/**/*.html']
}
} );
// Load tasks
@ -160,13 +173,16 @@ module.exports = function( grunt ) {
// Register tasks
grunt.registerTask( 'css', ['less', 'postcss', 'cssmin', 'sftp-deploy:css'] );
grunt.registerTask( 'css', ['sass', 'postcss', 'cssmin'] );
grunt.registerTask( 'js', ['jshint', 'concat', 'uglify', 'sftp-deploy:js'] );
grunt.registerTask( 'controller', ['sftp-deploy:controller'] );
grunt.registerTask( 'js', ['jshint', 'concat', 'uglify'] );
grunt.registerTask( 'default', ['css', 'js', 'controller'] );
grunt.registerTask( 'default', ['css', 'js'] );
grunt.registerTask( 'build', ['default', 'clean', 'copy', 'compress'] );
grunt.registerTask( 'test', ['phpunit', 'qunit'] );
grunt.util.linefeed = '\n';
};

View File

@ -1,3 +0,0 @@
h1 {
color: blue;
}

View File

@ -1 +0,0 @@
h1{color:#00f}

View File

@ -1,3 +0,0 @@
h1 {
color: blue;
}

View File

@ -0,0 +1,7 @@
/**
* ascribe
* http://wordpress.org/themes
*
* Copyright (c) 2015 Territorial
* Licensed under the GPLv2+ license.
*/

View File

@ -1,5 +0,0 @@
( function( window, undefined ) {
'use strict';
} )( this );

View File

@ -1 +0,0 @@
!function(a,b){"use strict"}(this);

View File

@ -3,16 +3,16 @@ if ( ! defined( 'PROJECT' ) ) {
define( 'PROJECT', __DIR__ . '/includes/' );
}
if ( ! defined( 'TTL_DIR' ) ) {
define( 'TTL_DIR', __DIR__ . '/' );
if ( ! defined( 'WPTHEME_DIR' ) ) {
define( 'WPTHEME_DIR', __DIR__ . '/' );
}
// Place any additional bootstrapping requirements here for PHP Unit.
if ( ! defined( 'WP_LANG_DIR' ) ) {
define( 'WP_LANG_DIR', 'lang_dir' );
}
if ( ! defined( 'TTL_PATH' ) ) {
define( 'TTL_PATH', 'path' );
if ( ! defined( 'WPTHEME_PATH' ) ) {
define( 'WPTHEME_PATH', 'path' );
}
if ( ! file_exists( __DIR__ . '/vendor/autoload.php' ) ) {

View File

@ -1,5 +1,5 @@
{
"name": "ascribeio",
"name": "ascribe",
"version": "0.0.1",
"main": "/",
"license": "GPLv2+",

View File

@ -1,6 +1,6 @@
{
"name": "ascribeio",
"description": "ascribe theme by Territorial",
"name": "ascribe",
"description": "The best WordPress theme ever made!",
"version": "0.0.1",
"type": "wordpress-theme",
"keywords": [],

View File

@ -14,14 +14,14 @@
*/
// Useful global constants
define( 'TTL_VERSION', '0.1.0' );
define( 'TTL_URL', get_stylesheet_directory_uri() );
define( 'TTL_TEMPLATE_URL', get_template_directory_uri() );
define( 'TTL_PATH', get_template_directory() . '/' );
define( 'TTL_INC', TTL_PATH . 'includes/' );
define( 'WPTHEME_VERSION', '0.1.0' );
define( 'WPTHEME_URL', get_stylesheet_directory_uri() );
define( 'WPTHEME_TEMPLATE_URL', get_template_directory_uri() );
define( 'WPTHEME_PATH', get_template_directory() . '/' );
define( 'WPTHEME_INC', WPTHEME_PATH . 'includes/' );
// Include compartmentalized functions
require_once TTL_INC . 'functions/core.php';
require_once WPTHEME_INC . 'functions/core.php';
// Include lib classes

View File

@ -1,4 +1,5 @@
<?php
namespace TenUp\ascribe\Core;
/**
* Set up theme defaults and register supported WordPress features.
@ -34,7 +35,7 @@ function setup() {
* @return void.
*/
function i18n() {
load_theme_textdomain( 'ttl', TTL_PATH . '/languages' );
load_theme_textdomain( 'wptheme', WPTHEME_PATH . '/languages' );
}
/**
@ -50,10 +51,10 @@ function scripts( $debug = false ) {
$min = ( $debug || defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
wp_enqueue_script(
'ttl',
TTL_TEMPLATE_URL . "/assets/js/ascribeio{$min}.js",
'wptheme',
WPTHEME_TEMPLATE_URL . "/assets/js/ascribe{$min}.js",
array(),
TTL_VERSION,
WPTHEME_VERSION,
true
);
}
@ -71,10 +72,10 @@ function styles( $debug = false ) {
$min = ( $debug || defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
wp_enqueue_style(
'ttl',
TTL_URL . "/assets/css/ascribeio{$min}.css",
'wptheme',
WPTHEME_URL . "/assets/css/ascribe{$min}.css",
array(),
TTL_VERSION
WPTHEME_VERSION
);
}
@ -88,7 +89,7 @@ function styles( $debug = false ) {
* @return void.
*/
function header_meta() {
$humans = '<link type="text/plain" rel="author" href="' . TTL_TEMPLATE_URL . '/humans.txt" />';
$humans = '<link type="text/plain" rel="author" href="' . WPTHEME_TEMPLATE_URL . '/humans.txt" />';
echo apply_filters( 'ttl_humans', $humans );
echo apply_filters( 'wptheme_humans', $humans );
}

View File

@ -1,8 +1,8 @@
msgid ""
msgstr ""
"Project-Id-Version: ascribe\n"
"POT-Creation-Date: 2015-09-16T23:04:11.784Z\n"
"PO-Revision-Date: 2015-09-16T23:04:11.785Z\n"
"POT-Creation-Date: 2015-09-16T23:52:34.272Z\n"
"PO-Revision-Date: 2015-09-16T23:52:34.274Z\n"
"Last-Translator: 10up <info@10up.com>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"

View File

@ -1,7 +1,7 @@
{
"name": "ascribeio",
"name": "ascribe",
"title": "ascribe",
"description": "ascribe theme by Territorial",
"description": "The best WordPress theme ever made!",
"version": "0.0.1",
"homepage": "http://wordpress.org/themes",
"repository": {
@ -14,22 +14,20 @@
"url": "http://territorial.ca"
},
"devDependencies": {
"autoprefixer-core": "^5.2.1",
"grunt": "^0.4.5",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-compress": "^0.13.0",
"grunt-contrib-concat": "^0.5.1",
"grunt-contrib-copy": "^0.8.0",
"grunt-contrib-uglify": "^0.9.1",
"grunt-sass": "^1.0.0",
"autoprefixer-core": "^5.2.1",
"grunt-postcss": "^0.5.4",
"grunt-contrib-cssmin": "^0.12.3",
"grunt-contrib-jshint": "^0.11.2",
"grunt-contrib-less": "^1.0.1",
"grunt-contrib-qunit": "^0.7.0",
"grunt-contrib-uglify": "^0.9.1",
"grunt-contrib-watch": "^0.6.1",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-copy": "^0.8.0",
"grunt-contrib-compress": "^0.13.0",
"grunt-phpunit": "^0.3.6",
"grunt-postcss": "^0.5.4",
"grunt-sass": "^1.0.0",
"grunt-sftp-deploy": "^0.2.4",
"grunt-contrib-qunit": "^0.7.0",
"load-grunt-tasks": "^3.2.0",
"qunitjs": "~1.18.0"
},

View File

@ -1 +0,0 @@
{"/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/css//ascribeio.css":"2015-09-16T23:36:41.000Z","/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/css//ascribeio.min.css":"2015-09-16T23:36:41.000Z","/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/css//readme.md":"2015-09-16T23:04:11.000Z","/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/css//less/ascribeio.less":"2015-09-16T23:17:47.000Z","/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/js//ascribeio.js":"2015-09-16T23:36:44.000Z","/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/js//ascribeio.min.js":"2015-09-16T23:36:44.000Z","/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/js//src/ascribeio.js":"2015-09-16T23:04:11.000Z","/Users/sarahetter/Dropbox/_shared/sarahetter/ascribe/assets/js//vendor/readme.md":"2015-09-16T23:04:11.000Z"}

View File

@ -1,12 +1,12 @@
/**
* Theme Name: ascribe
* Theme URI: http://wordpress.org/themes
* Description: ascribe theme by Territorial
* Description: The best WordPress theme ever made!
* Author: Territorial
* Author URI: http://territorial.ca
* Version: 0.1.0
* Tags:
* Text Domain: ttl
* Text Domain: wptheme
*
* License: GPLv2+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html

View File

@ -0,0 +1,163 @@
<?php
namespace TenUp\ascribe\Core;
/**
* This is a very basic test case to get things started. You should probably rename this and make
* it work for your project. You can use all the tools provided by WP Mock and Mockery to create
* your tests. Coverage is calculated against your includes/ folder, so try to keep all of your
* functional code self contained in there.
*
* References:
* - http://phpunit.de/manual/current/en/index.html
* - https://github.com/padraic/mockery
* - https://github.com/10up/wp_mock
*/
use TenUp\ascribe as Base;
class Core_Tests extends Base\TestCase {
protected $testFiles = [
'functions/core.php'
];
/**
* Make sure all theme-specific constants are defined before we get started
*/
public function setUp() {
if ( ! defined( 'WPTHEME_TEMPLATE_URL' ) ) {
define( 'WPTHEME_TEMPLATE_URL', 'template_url' );
}
if ( ! defined( 'WPTHEME_VERSION' ) ) {
define( 'WPTHEME_VERSION', '0.0.1' );
}
if ( ! defined( 'WPTHEME_URL' ) ) {
define( 'WPTHEME_URL', 'url' );
}
parent::setUp();
}
/**
* Test setup method.
*/
public function test_setup() {
// Setup
\WP_Mock::expectActionAdded( 'after_setup_theme', 'TenUp\ascribe\Core\i18n' );
\WP_Mock::expectActionAdded( 'wp_head', 'TenUp\ascribe\Core\header_meta' );
\WP_Mock::expectActionAdded( 'wp_enqueue_scripts', 'TenUp\ascribe\Core\scripts' );
\WP_Mock::expectActionAdded( 'wp_enqueue_scripts', 'TenUp\ascribe\Core\styles' );
// Act
setup();
// Verify
$this->assertConditionsMet();
}
/**
* Test internationalization integration.
*/
public function test_i18n() {
// Setup
\WP_Mock::wpFunction( 'load_theme_textdomain', array(
'times' => 1,
'args' => array(
'wptheme',
WPTHEME_PATH . '/languages'
),
) );
// Act
i18n();
// Verify
$this->assertConditionsMet();
}
/**
* Test scripts enqueue.
*/
public function test_scripts() {
// Regular
\WP_Mock::wpFunction( 'wp_enqueue_script', array(
'times' => 1,
'args' => array(
'wptheme',
'template_url/assets/js/ascribe.min.js',
array(),
'0.0.1',
true,
),
) );
scripts();
$this->assertConditionsMet();
// Debug Mode
\WP_Mock::wpFunction( 'wp_enqueue_script', array(
'times' => 1,
'args' => array(
'wptheme',
'template_url/assets/js/ascribe.js',
array(),
'0.0.1',
true,
),
) );
scripts( true );
$this->assertConditionsMet();
}
/**
* Test style enqueue.
*/
public function test_styles() {
// Regular
\WP_Mock::wpFunction( 'wp_enqueue_style', array(
'times' => 1,
'args' => array(
'wptheme',
'url/assets/css/ascribe.min.css',
array(),
'0.0.1',
),
) );
styles();
$this->assertConditionsMet();
// Debug Mode
\WP_Mock::wpFunction( 'wp_enqueue_style', array(
'times' => 1,
'args' => array(
'wptheme',
'url/assets/css/ascribe.css',
array(),
'0.0.1',
),
) );
styles( true );
$this->assertConditionsMet();
}
/**
* Test header meta injection
*/
public function test_header_meta() {
// Setup
$meta = '<link type="text/plain" rel="author" href="template_url/humans.txt" />';
\WP_Mock::onFilter( 'wptheme_humans' )->with( $meta )->reply( $meta );
// Act
ob_start();
header_meta();
$result = ob_get_clean();
// Verify
$this->assertConditionsMet();
$this->assertEquals( $meta, $result );
}
}

View File

@ -0,0 +1,75 @@
<?php
namespace TenUp\ascribe;
use PHPUnit_Framework_TestResult;
use Text_Template;
use WP_Mock;
use WP_Mock\Tools\TestCase as BaseTestCase;
class TestCase extends BaseTestCase {
public function run( PHPUnit_Framework_TestResult $result = null ) {
$this->setPreserveGlobalState( false );
return parent::run( $result );
}
protected $testFiles = array();
public function setUp() {
if ( ! empty( $this->testFiles ) ) {
foreach ( $this->testFiles as $file ) {
if ( file_exists( PROJECT . $file ) ) {
require_once( PROJECT . $file );
}
}
}
parent::setUp();
}
public function assertActionsCalled() {
$actions_not_added = $expected_actions = 0;
try {
WP_Mock::assertActionsCalled();
} catch ( \Exception $e ) {
$actions_not_added = 1;
$expected_actions = $e->getMessage();
}
$this->assertEmpty( $actions_not_added, $expected_actions );
}
public function ns( $function ) {
if ( ! is_string( $function ) || false !== strpos( $function, '\\' ) ) {
return $function;
}
$thisClassName = trim( get_class( $this ), '\\' );
if ( ! strpos( $thisClassName, '\\' ) ) {
return $function;
}
// $thisNamespace is constructed by exploding the current class name on
// namespace separators, running array_slice on that array starting at 0
// and ending one element from the end (chops the class name off) and
// imploding that using namespace separators as the glue.
$thisNamespace = implode( '\\', array_slice( explode( '\\', $thisClassName ), 0, - 1 ) );
return "$thisNamespace\\$function";
}
/**
* Define constants after requires/includes
*
* See http://kpayne.me/2012/07/02/phpunit-process-isolation-and-constant-already-defined/
* for more details
*
* @param \Text_Template $template
*/
public function prepareTemplate( \Text_Template $template ) {
$template->setVar( [
'globals' => '$GLOBALS[\'__PHPUNIT_BOOTSTRAP\'] = \'' . $GLOBALS['__PHPUNIT_BOOTSTRAP'] . '\';',
] );
parent::prepareTemplate( $template );
}
}

14
tests/qunit/ascribe.html Normal file
View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>QUnit Example</title>
<link rel="stylesheet" href="../../node_modules/qunitjs/qunit/qunit.css">
</head>
<body>
<div id="qunit"></div>
<div id="qunit-fixture"></div>
<script src="../../node_modules/qunitjs/qunit/qunit.js"></script>
<script src="tests/ascribe.js"></script>
</body>
</html>

View File

@ -0,0 +1,4 @@
// Qunit Tests
test( "hello test", function() {
ok( 1 == "1", "Passed!" );
});