Skip to content

Instantly share code, notes, and snippets.

View n8finch's full-sized avatar

Nate Finch n8finch

View GitHub Profile
@n8finch
n8finch / 0_reuse_code.js
Created June 25, 2014 07:54
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@n8finch
n8finch / Random Quote-to-Tweet Machine.markdown
Created December 13, 2015 11:06
Random Quote-to-Tweet Machine
@n8finch
n8finch / controller-example.php
Created August 29, 2016 15:35
Add a controller in the Angular view to work with
//*Add a controller in the Angular view to work with
add_action('genesis_loop', __NAMESPACE__ . '\do_ng_view_content');
function do_ng_view_content() {
$output = '<div ng-controller="example">'.
'<h2>Recent Posts</h2>'.
'{{posts}}'.
'</div>';
echo $output;
}
@n8finch
n8finch / angular-basic-http.js
Created August 29, 2016 15:37
angular-basic-http.js
(function (angular) {
'use strict';
angular.module('myApp', [])
.controller('example', ['$scope', '$http', function ($scope, $http) {
$http({
url: 'https://n8finch.dev/wp-json/wp/v2/posts',
cache: true
}).success(function (res) {
$scope.posts = res;
@n8finch
n8finch / adding-filter-to-rendered-posts.js
Created August 29, 2016 15:38
adding-filter-to-rendered-posts.js
(function (angular) {
'use strict';
angular.module('myApp', [])
.controller('example', ['$scope', '$http', function ($scope, $http) {
$http({
url: 'https://n8finch.dev/wp-json/wp/v2/posts',
cache: true
}).success(function (res) {
$scope.posts = res;
@n8finch
n8finch / update-the-angular-view.php
Last active August 29, 2016 15:43
update-the-angular-view.php
//*Add a controller in the Angular view to work with
add_action('genesis_loop', __NAMESPACE__ . '\do_ng_view_content');
function do_ng_view_content() {
$output = '<div ng-controller="example">'.
'<h2>Recent Posts:</h2>'.
'<div class="posts-list" ng-repeat="post in posts">'.
'<div class="single-post">'.
'<h2>{{post.title.rendered}}</h2>'.
'<p>Posted by Name on {{post.date | date:\'longDate\'}}</p>'.
'<img src="http://placekitten.com/g/200/300"/>'.
@n8finch
n8finch / custom-wp-rest-api-routes.php
Created August 29, 2016 15:44
custom-wp-rest-api-routes.php
//* =================================================
//* Mostly from Mor10's Lynda course
//* Add various fields to the WP REST API JSON output
//* https://www.lynda.com/WordPress-tutorials/WordPress-REST-API-WP-API-First-Look/383783-2.html
function register_new_restapi_fields() {
// Add Author Name
register_api_field( 'post',
'author_name',
array(
@n8finch
n8finch / genesis-angular-app-index.html
Created August 29, 2016 15:46
genesis-angular-app-index.html
<div ng-controller="Posts" ng-repeat="post in posts">
<article class="single-post post type-post status-publish format-standard has-post-thumbnail entry">
<header class="entry-header">
<h2 class="entry-title">{{post.title.rendered}}</h2>
<p class="entry-meta">Posted by {{post.author_name}} on {{post.date | date:'longDate'}}</p>
</header>
<img class="attachment-post-image size-post-image wp-post-image" ng-src="{{post.featured_image_src}}"/>
<div class="entry-content">
<p ng-bind-html="post.excerpt.rendered | to_trusted"></p>
<p><a href="#/post/{{post.slug}}">Read more...</a></p>
@n8finch
n8finch / add-new-custom-routes.php
Created August 29, 2016 15:51
add-new-custom-routes.php
//*Add a controller in the Angular view to work with
add_action('genesis_loop', __NAMESPACE__ . '\do_ng_view_content');
function do_ng_view_content() {
$output = '<div ng-controller="example">'.
'<div class="posts-list" ng-repeat="post in posts">'.
'<div class="single-post">'.
'<h2>{{post.title.rendered}}</h2>'.
'<p>Posted by {{post.author_name}} on {{post.date | date:\'longDate\'}}</p>'.
'<img ng-src="{{post.featured_image_src}}"/>'.
'<a href="{{post.slug}}">Read more...</a>'.
genesis-angular-gulp
|__assets
|__js
|__app.js (our Angular app)
|__templates
|__app-index.html (our main list of posts from Part 2)
|__page.html (our page view for Pages)
|__single.html (our single view for individual Posts)