Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
startah
- Loading branch information
Joel Salisbury
committed
Jun 29, 2016
0 parents
commit d79f04d
Showing
165 changed files
with
6,395 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bower_components | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
/** | ||
* The template for displaying 404 pages (Not Found) | ||
* | ||
* Methods for TimberHelper can be found in the /functions sub-directory | ||
* | ||
* @package WordPress | ||
* @subpackage Timber | ||
* @since Timber 0.1 | ||
*/ | ||
|
||
$context = Timber::get_context(); | ||
Timber::render( '404.twig', $context ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
# DMD's Web Development Guidelines | ||
|
||
*Note to the reader: This document is a work in progress.* | ||
|
||
## Development | ||
|
||
### Local environment | ||
|
||
This assumes the following global installs: | ||
|
||
- [npm](https://docs.npmjs.com/getting-started/installing-node) | ||
- [bower](http://bower.io/) | ||
- [sass](http://sass-lang.com/) | ||
- [gulp](http://gulpjs.com/) | ||
|
||
To install dependencies, fork our starter repo (or clone the existing project repo) and run the following in your project directory: | ||
|
||
$ npm install | ||
$ bower install jquery | ||
|
||
Then run the following command: | ||
|
||
$ gulp | ||
|
||
...which should: | ||
- Watch files for changes as you dev | ||
- Compile your SCSS to CSS | ||
- Concatenate and minify your JS and CSS | ||
- Update your live browser view via browsersync | ||
|
||
|
||
### Versioning | ||
|
||
Work with a "stable master" philosophy, meaning that the `master` branch is the production deploy. All work should be completed on the `develop` branch and pushed to master before deploying to production. More information can be found [here](http://nvie.com/posts/a-successful-git-branching-model/). | ||
|
||
|
||
## CSS | ||
|
||
DMD hopes to impart a "mobile-first" philosophy, utilizing only `min-width` media queries. This means that the majority of application styling will be in `base/_global.scss`. Variable names should be camel cased. All the files to be included (along with a reset) in `src/scss/app.scss`. The scss structure looks like: | ||
|
||
# Generic set up | ||
app.scss | ||
/base | ||
_variables.scss | ||
_mixins.scss | ||
_normalize.scss | ||
_global.scss | ||
_utilities.scss | ||
|
||
# Additional scss files | ||
/screens | ||
tablet.scss | ||
tabletLarge.scss | ||
desktop.scss | ||
|
||
|
||
CSS Guidelines are adapted from [BEM](http://getbem.com/naming/) using the "Block Element Modifier" semantic CSS naming convention Avoid overqualified selectors. The format is as follows: | ||
|
||
.<block>[--modifierName|__elementName] | ||
|
||
### Block | ||
*Encapsulates a standalone entity that is meaningful on its own. While blocks can be nested and interact with each other, semantically they remain equal; there is no precedence or hierarchy. Holistic entities without DOM representation (such as controllers or models) can be blocks as well.* | ||
|
||
Syntax: `.nav` | ||
|
||
<nav class="nav"></nav> | ||
|
||
|
||
### Block__element | ||
|
||
Syntax: `.nav__item` | ||
|
||
Parts of a block and have no standalone meaning. Any element is semantically tied to its block. | ||
<nav class="nav"> | ||
<ul class="nav__list"> | ||
<li class="nav__item"><a class="nav__link" href="#">Link</a></li> | ||
</ul> | ||
</nav> | ||
|
||
### componentName--modifierName | ||
|
||
Syntax: `.nav__item--last` | ||
|
||
<nav class="nav"> | ||
<ul class="nav__list"> | ||
<li class="nav__item"><a class="nav__link" href="#">Link</a></li> | ||
<li class="nav__item nav__item-last"><a class="nav__link" href="#">Link</a></li> | ||
</ul> | ||
</nav> | ||
|
||
|
||
We use SCSS as our preprocessor, mostly for variables and mixins. Do not nest selectors as this can quickly become difficult to read. | ||
|
||
### Utility classes | ||
|
||
Syntax: `.u-<utilityName>` | ||
|
||
It is recommended to create utility selectors as necessary, these should be prefixed with `u-` and should be universal. These selectors should not be modified from their initial definition. If you need to use more than one utility selector in a given element, create a new `componentName` selector. | ||
|
||
.u-textCenter | ||
.u-bgColorRed | ||
|
||
|
||
### Format | ||
|
||
Define the css selectors with an opening curly on the first line. All declarations must be indented 2 spaces on the following lines, one declaration per line, in alphabetical order. Single declaration selectors can remain on one line. All indentation should be 2 character spaces. Use 'single quotes' over "double quotes" where applicable. | ||
|
||
/* Multi declaration selector */ | ||
.row { | ||
float:left; | ||
position: relative; | ||
width: 100%; | ||
} | ||
|
||
/* Single declaration selector */ | ||
.row--even { background: $altWhite; } | ||
.row--active { background: $blue; } | ||
|
||
.u-alignLeft { float:left; } | ||
|
||
`js-` selectors should never be styled and only be used for event interactions. | ||
|
||
|
||
## HTML | ||
|
||
Use semantic HTML5 Markup. Never use an ID unless necessary. See [CSS](#css) section for information about class naming. | ||
|
||
## Javascript | ||
|
||
Use jQuery. All files should be located in `src/js`. Try to keep all Javascript lines to a maximum of 80 characters. This can be unavoidable in some cases, so if you must break 80 characters, do not exceed 120. All events should be called using `js-` prefixed selector. | ||
|
||
### Commenting | ||
|
||
Use `/*! COMMENT */` as a comment block. Use multiline comments over single line comments. | ||
|
||
### Format | ||
|
||
Each JS file should use jQuery and be wrapped with an IIFE. Each method should be documented with a few words or sentence about what the interaction is doing. Indentation should be 2 character spaces. Use single quotes over double quotes. | ||
|
||
;(function(window, $) { | ||
|
||
/*! | ||
* Document ready | ||
*/ | ||
$(function() { | ||
|
||
/*! | ||
* Toggle mobile nav | ||
*/ | ||
$('.js-toggleNav').on('click', function(e) { | ||
e.preventDefault(); | ||
$('body').toggleClass('is-showingMobileNav'); | ||
}); | ||
|
||
// ... | ||
}); | ||
})(window, jQuery); | ||
|
||
### Custom classes | ||
|
||
When creating custom classes, use a separate file with the class created using prototypical inheritance. Private variables should be appended with `_` as opposed to prefixing. Comments should be able to be read by jsdoc use multiline, `/** COMMENT */`. Comments that begin with `/*!` are ignored by jsdoc. | ||
|
||
;(function(window, $){ | ||
|
||
/** | ||
* A Custom Class | ||
* | ||
* @param {String=} options - description. | ||
* @constructor | ||
*/ | ||
function CustomClass(title) { | ||
this.title_ = title || 'Title'; | ||
}; | ||
|
||
/** | ||
* Gets the title | ||
* | ||
* @memberof CustomClass | ||
* @returns {String} | ||
*/ | ||
CustomClass.prototype.getTitle = function() { | ||
var self = this; | ||
return self.title_; | ||
}; | ||
|
||
/** | ||
* Bind to window | ||
*/ | ||
window.CustomClass = CustomClass; | ||
|
||
})(window, jQuery); | ||
|
||
Usage in main application file. | ||
|
||
;(function(window, $, CustomClass) { | ||
|
||
var item = new CustomClass(); | ||
console.log(item.getTitle()); // Title | ||
|
||
})(window, $, CustomClass); | ||
|
||
## Questions | ||
|
||
If there are any questions please chat / email / hangout / call [joel@uconn.edu](mailto:joel@uconn.edu) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
/** | ||
* The template for displaying Archive pages. | ||
* | ||
* Used to display archive-type pages if nothing more specific matches a query. | ||
* For example, puts together date-based pages if no date.php file exists. | ||
* | ||
* Learn more: http://codex.wordpress.org/Template_Hierarchy | ||
* | ||
* Methods for TimberHelper can be found in the /lib sub-directory | ||
* | ||
* @package WordPress | ||
* @subpackage Timber | ||
* @since Timber 0.2 | ||
*/ | ||
|
||
$templates = array( 'archive.twig', 'index.twig' ); | ||
|
||
$data = Timber::get_context(); | ||
|
||
$data['title'] = 'Archive'; | ||
if ( is_day() ) { | ||
$data['title'] = 'Archive: '.get_the_date( 'D M Y' ); | ||
} else if ( is_month() ) { | ||
$data['title'] = 'Archive: '.get_the_date( 'M Y' ); | ||
} else if ( is_year() ) { | ||
$data['title'] = 'Archive: '.get_the_date( 'Y' ); | ||
} else if ( is_tag() ) { | ||
$data['title'] = single_tag_title( '', false ); | ||
} else if ( is_category() ) { | ||
$data['title'] = single_cat_title( '', false ); | ||
array_unshift( $templates, 'archive-' . get_query_var( 'cat' ) . '.twig' ); | ||
} else if ( is_post_type_archive() ) { | ||
$data['title'] = post_type_archive_title( '', false ); | ||
array_unshift( $templates, 'archive-' . get_post_type() . '.twig' ); | ||
} | ||
|
||
$data['posts'] = Timber::get_posts(); | ||
|
||
Timber::render( $templates, $data ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
/** | ||
* The template for displaying Author Archive pages | ||
* | ||
* Methods for TimberHelper can be found in the /lib sub-directory | ||
* | ||
* @package WordPress | ||
* @subpackage Timber | ||
* @since Timber 0.1 | ||
*/ | ||
global $wp_query; | ||
|
||
$data = Timber::get_context(); | ||
$data['posts'] = Timber::get_posts(); | ||
if ( isset( $wp_query->query_vars['author'] ) ) { | ||
$author = new TimberUser( $wp_query->query_vars['author'] ); | ||
$data['author'] = $author; | ||
$data['title'] = 'Author Archives: ' . $author->name(); | ||
} | ||
Timber::render( array( 'author.twig', 'archive.twig' ), $data ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
#!/usr/bin/env bash | ||
|
||
if [ $# -lt 3 ]; then | ||
echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version]" | ||
exit 1 | ||
fi | ||
|
||
DB_NAME=$1 | ||
DB_USER=$2 | ||
DB_PASS=$3 | ||
DB_HOST=${4-localhost} | ||
WP_VERSION=${5-latest} | ||
|
||
WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib} | ||
WP_CORE_DIR=${WP_CORE_DIR-/tmp/wordpress/} | ||
|
||
download() { | ||
if [ `which curl` ]; then | ||
curl -s "$1" > "$2"; | ||
elif [ `which wget` ]; then | ||
wget -nv -O "$2" "$1" | ||
fi | ||
} | ||
|
||
if [[ $WP_VERSION =~ [0-9]+\.[0-9]+(\.[0-9]+)? ]]; then | ||
WP_TESTS_TAG="tags/$WP_VERSION" | ||
else | ||
# http serves a single offer, whereas https serves multiple. we only want one | ||
download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json | ||
grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json | ||
LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//') | ||
if [[ -z "$LATEST_VERSION" ]]; then | ||
echo "Latest WordPress version could not be found" | ||
exit 1 | ||
fi | ||
WP_TESTS_TAG="tags/$LATEST_VERSION" | ||
fi | ||
|
||
set -ex | ||
|
||
install_wp() { | ||
|
||
if [ -d $WP_CORE_DIR ]; then | ||
return; | ||
fi | ||
|
||
mkdir -p $WP_CORE_DIR | ||
|
||
if [ $WP_VERSION == 'latest' ]; then | ||
local ARCHIVE_NAME='latest' | ||
else | ||
local ARCHIVE_NAME="wordpress-$WP_VERSION" | ||
fi | ||
|
||
download https://wordpress.org/${ARCHIVE_NAME}.tar.gz /tmp/wordpress.tar.gz | ||
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR | ||
|
||
download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php | ||
} | ||
|
||
install_test_suite() { | ||
# portable in-place argument for both GNU sed and Mac OSX sed | ||
if [[ $(uname -s) == 'Darwin' ]]; then | ||
local ioption='-i .bak' | ||
else | ||
local ioption='-i' | ||
fi | ||
|
||
# set up testing suite if it doesn't yet exist | ||
if [ ! -d $WP_TESTS_DIR ]; then | ||
# set up testing suite | ||
mkdir -p $WP_TESTS_DIR | ||
svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes | ||
fi | ||
|
||
cd $WP_TESTS_DIR | ||
|
||
if [ ! -f wp-tests-config.php ]; then | ||
download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php | ||
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR':" "$WP_TESTS_DIR"/wp-tests-config.php | ||
sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php | ||
sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php | ||
sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php | ||
sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php | ||
fi | ||
|
||
} | ||
|
||
install_db() { | ||
# parse DB_HOST for port or socket references | ||
local PARTS=(${DB_HOST//\:/ }) | ||
local DB_HOSTNAME=${PARTS[0]}; | ||
local DB_SOCK_OR_PORT=${PARTS[1]}; | ||
local EXTRA="" | ||
|
||
if ! [ -z $DB_HOSTNAME ] ; then | ||
if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then | ||
EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp" | ||
elif ! [ -z $DB_SOCK_OR_PORT ] ; then | ||
EXTRA=" --socket=$DB_SOCK_OR_PORT" | ||
elif ! [ -z $DB_HOSTNAME ] ; then | ||
EXTRA=" --host=$DB_HOSTNAME --protocol=tcp" | ||
fi | ||
fi | ||
|
||
# create database | ||
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA | ||
} | ||
|
||
install_wp | ||
install_test_suite | ||
install_db |
Oops, something went wrong.