├── .distignore ├── .editorconfig ├── .gitignore ├── .travis.yml ├── Gruntfile.js ├── README.md ├── bin └── install-wp-tests.sh ├── blocks ├── github-gist.php └── github-gist │ ├── editor.css │ └── index.js ├── github-gist-gutenberg-block.php ├── languages └── github-gist-gutenberg-block.pot ├── package-lock.json ├── package.json ├── phpcs.xml.dist ├── phpunit.xml.dist ├── readme.txt └── tests ├── bootstrap.php └── test-sample.php /.distignore: -------------------------------------------------------------------------------- 1 | # A set of files you probably don't want in your WordPress.org distribution 2 | .distignore 3 | .editorconfig 4 | .git 5 | .gitignore 6 | .gitlab-ci.yml 7 | .travis.yml 8 | .DS_Store 9 | Thumbs.db 10 | behat.yml 11 | bin 12 | circle.yml 13 | composer.json 14 | composer.lock 15 | Gruntfile.js 16 | package.json 17 | package-lock.json 18 | phpunit.xml 19 | phpunit.xml.dist 20 | multisite.xml 21 | multisite.xml.dist 22 | phpcs.xml 23 | phpcs.xml.dist 24 | README.md 25 | wp-cli.local.yml 26 | yarn.lock 27 | tests 28 | vendor 29 | node_modules 30 | *.sql 31 | *.tar.gz 32 | *.zip 33 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # This file is for unifying the coding style for different editors and IDEs 2 | # editorconfig.org 3 | 4 | # WordPress Coding Standards 5 | # https://make.wordpress.org/core/handbook/coding-standards/ 6 | 7 | root = true 8 | 9 | [*] 10 | charset = utf-8 11 | end_of_line = lf 12 | insert_final_newline = true 13 | trim_trailing_whitespace = true 14 | indent_style = tab 15 | indent_size = 4 16 | 17 | [{.jshintrc,*.json,*.yml}] 18 | indent_style = space 19 | indent_size = 2 20 | 21 | [{*.txt,wp-config-sample.php}] 22 | end_of_line = crlf 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | phpcs.xml 3 | phpunit.xml 4 | Thumbs.db 5 | wp-cli.local.yml 6 | node_modules/ 7 | *.sql 8 | *.tar.gz 9 | *.zip 10 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | dist: trusty 3 | 4 | language: php 5 | 6 | notifications: 7 | email: 8 | on_success: never 9 | on_failure: change 10 | 11 | branches: 12 | only: 13 | - master 14 | 15 | cache: 16 | directories: 17 | - $HOME/.composer/cache 18 | 19 | matrix: 20 | include: 21 | - php: 7.1 22 | env: WP_VERSION=latest 23 | - php: 7.0 24 | env: WP_VERSION=latest 25 | - php: 5.6 26 | env: WP_VERSION=4.4 27 | - php: 5.6 28 | env: WP_VERSION=latest 29 | - php: 5.6 30 | env: WP_VERSION=trunk 31 | - php: 5.6 32 | env: WP_TRAVISCI=phpcs 33 | - php: 5.3 34 | env: WP_VERSION=latest 35 | dist: precise 36 | 37 | before_script: 38 | - export PATH="$HOME/.composer/vendor/bin:$PATH" 39 | - | 40 | if [ -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini ]; then 41 | phpenv config-rm xdebug.ini 42 | else 43 | echo "xdebug.ini does not exist" 44 | fi 45 | - | 46 | if [[ ! -z "$WP_VERSION" ]] ; then 47 | bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION 48 | composer global require "phpunit/phpunit=4.8.*|5.7.*" 49 | fi 50 | - | 51 | if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then 52 | composer global require wp-coding-standards/wpcs 53 | phpcs --config-set installed_paths $HOME/.composer/vendor/wp-coding-standards/wpcs 54 | fi 55 | 56 | script: 57 | - | 58 | if [[ ! -z "$WP_VERSION" ]] ; then 59 | phpunit 60 | WP_MULTISITE=1 phpunit 61 | fi 62 | - | 63 | if [[ "$WP_TRAVISCI" == "phpcs" ]] ; then 64 | phpcs 65 | fi 66 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function( grunt ) { 2 | 3 | 'use strict'; 4 | 5 | // Project configuration 6 | grunt.initConfig( { 7 | 8 | pkg: grunt.file.readJSON( 'package.json' ), 9 | 10 | addtextdomain: { 11 | options: { 12 | textdomain: 'github-gist-gutenberg-block', 13 | }, 14 | update_all_domains: { 15 | options: { 16 | updateDomains: true 17 | }, 18 | src: [ '*.php', '**/*.php', '!\.git/**/*', '!bin/**/*', '!node_modules/**/*', '!tests/**/*' ] 19 | } 20 | }, 21 | 22 | wp_readme_to_markdown: { 23 | your_target: { 24 | files: { 25 | 'README.md': 'readme.txt' 26 | } 27 | }, 28 | }, 29 | 30 | makepot: { 31 | target: { 32 | options: { 33 | domainPath: '/languages', 34 | exclude: [ '\.git/*', 'bin/*', 'node_modules/*', 'tests/*' ], 35 | mainFile: 'github-gist-gutenberg-block.php', 36 | potFilename: 'github-gist-gutenberg-block.pot', 37 | potHeaders: { 38 | poedit: true, 39 | 'x-poedit-keywordslist': true 40 | }, 41 | type: 'wp-plugin', 42 | updateTimestamp: true 43 | } 44 | } 45 | }, 46 | } ); 47 | 48 | grunt.loadNpmTasks( 'grunt-wp-i18n' ); 49 | grunt.loadNpmTasks( 'grunt-wp-readme-to-markdown' ); 50 | grunt.registerTask( 'default', [ 'i18n','readme' ] ); 51 | grunt.registerTask( 'i18n', ['addtextdomain', 'makepot'] ); 52 | grunt.registerTask( 'readme', ['wp_readme_to_markdown'] ); 53 | 54 | grunt.util.linefeed = '\n'; 55 | 56 | }; 57 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Gist Block by Pantheon # 2 | **Contributors:** getpantheon, danielbachhuber 3 | **Tags:** github gist, gutenberg 4 | **Requires at least:** 4.4 5 | **Tested up to:** 4.9.2 6 | **Stable tag:** 0.1.1 7 | **License:** GPLv2 or later 8 | **License URI:** https://www.gnu.org/licenses/gpl-2.0.html 9 | 10 | Include GitHub Gists in your Gutenberg posts without the hassle of shortcodes. 11 | 12 | ## Description ## 13 | This plugin was written as a code sample for the blog article [How To Convert Shortcodes To Gutenberg Blocks](https://pantheon.io/blog/how-convert-shortcode-gutenberg-block) in January 2018 and is not maintained. 14 | 15 | The Gist Block by Pantheon makes it possible to embed GitHub Gists in your Gutenberg posts. Simply add the "GitHub Gist" block, paste the URL to your Gist, and see it transform to a wonderful preview. 16 | 17 | Curious as to how blocks work? This is a great one to explore. Specifically, check out these implementation details: 18 | 19 | 1. Block UI is registered in `blocks/github-gist/index.js`. When the block is previewed in Gutenberg, custom code is used to generate the embed. 20 | 2. Fallback HTML content is what's actually stored in the post content. 21 | 3. A dynamic render callback is used to transform the block to GitHub's standard Gist embed code. 22 | 23 | Read "[How to Convert a Shortcode to a Gutenberg Block](https://pantheon.io/blog/how-convert-shortcode-gutenberg-block)" for a more detailed explanation of the plugin. 24 | 25 | Something we can clarify? [Check out the project on GitHub](https://github.com/pantheon-systems/github-gist-gutenberg-block/) for any questions, feedback, suggestions, or pull requests. 26 | 27 | ## Installation ## 28 | 29 | The Gist Block can be installed just like any other WordPress plugin! 30 | 31 | ## Changelog ## 32 | 33 | ### 0.1.1 (Mar. 22nd, 2018) ### 34 | * Uses new `wp.components` API included in Gutenberg 2.4. 35 | * Removes textdomain because it's not registered. 36 | 37 | ### 0.1.0 (Feb. 5th, 2018) ### 38 | * Initial release. 39 | -------------------------------------------------------------------------------- /bin/install-wp-tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if [ $# -lt 3 ]; then 4 | echo "usage: $0 [db-host] [wp-version] [skip-database-creation]" 5 | exit 1 6 | fi 7 | 8 | DB_NAME=$1 9 | DB_USER=$2 10 | DB_PASS=$3 11 | DB_HOST=${4-localhost} 12 | WP_VERSION=${5-latest} 13 | SKIP_DB_CREATE=${6-false} 14 | 15 | TMPDIR=${TMPDIR-/tmp} 16 | TMPDIR=$(echo $TMPDIR | sed -e "s/\/$//") 17 | WP_TESTS_DIR=${WP_TESTS_DIR-$TMPDIR/wordpress-tests-lib} 18 | WP_CORE_DIR=${WP_CORE_DIR-$TMPDIR/wordpress/} 19 | 20 | download() { 21 | if [ `which curl` ]; then 22 | curl -s "$1" > "$2"; 23 | elif [ `which wget` ]; then 24 | wget -nv -O "$2" "$1" 25 | fi 26 | } 27 | 28 | if [[ $WP_VERSION =~ ^[0-9]+\.[0-9]+$ ]]; then 29 | WP_TESTS_TAG="branches/$WP_VERSION" 30 | elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0-9]+ ]]; then 31 | if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then 32 | # version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x 33 | WP_TESTS_TAG="tags/${WP_VERSION%??}" 34 | else 35 | WP_TESTS_TAG="tags/$WP_VERSION" 36 | fi 37 | elif [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then 38 | WP_TESTS_TAG="trunk" 39 | else 40 | # http serves a single offer, whereas https serves multiple. we only want one 41 | download http://api.wordpress.org/core/version-check/1.7/ /tmp/wp-latest.json 42 | grep '[0-9]+\.[0-9]+(\.[0-9]+)?' /tmp/wp-latest.json 43 | LATEST_VERSION=$(grep -o '"version":"[^"]*' /tmp/wp-latest.json | sed 's/"version":"//') 44 | if [[ -z "$LATEST_VERSION" ]]; then 45 | echo "Latest WordPress version could not be found" 46 | exit 1 47 | fi 48 | WP_TESTS_TAG="tags/$LATEST_VERSION" 49 | fi 50 | 51 | set -ex 52 | 53 | install_wp() { 54 | 55 | if [ -d $WP_CORE_DIR ]; then 56 | return; 57 | fi 58 | 59 | mkdir -p $WP_CORE_DIR 60 | 61 | if [[ $WP_VERSION == 'nightly' || $WP_VERSION == 'trunk' ]]; then 62 | mkdir -p $TMPDIR/wordpress-nightly 63 | download https://wordpress.org/nightly-builds/wordpress-latest.zip $TMPDIR/wordpress-nightly/wordpress-nightly.zip 64 | unzip -q $TMPDIR/wordpress-nightly/wordpress-nightly.zip -d $TMPDIR/wordpress-nightly/ 65 | mv $TMPDIR/wordpress-nightly/wordpress/* $WP_CORE_DIR 66 | else 67 | if [ $WP_VERSION == 'latest' ]; then 68 | local ARCHIVE_NAME='latest' 69 | elif [[ $WP_VERSION =~ [0-9]+\.[0-9]+ ]]; then 70 | # https serves multiple offers, whereas http serves single. 71 | download https://api.wordpress.org/core/version-check/1.7/ $TMPDIR/wp-latest.json 72 | if [[ $WP_VERSION =~ [0-9]+\.[0-9]+\.[0] ]]; then 73 | # version x.x.0 means the first release of the major version, so strip off the .0 and download version x.x 74 | LATEST_VERSION=${WP_VERSION%??} 75 | else 76 | # otherwise, scan the releases and get the most up to date minor version of the major release 77 | local VERSION_ESCAPED=`echo $WP_VERSION | sed 's/\./\\\\./g'` 78 | LATEST_VERSION=$(grep -o '"version":"'$VERSION_ESCAPED'[^"]*' $TMPDIR/wp-latest.json | sed 's/"version":"//' | head -1) 79 | fi 80 | if [[ -z "$LATEST_VERSION" ]]; then 81 | local ARCHIVE_NAME="wordpress-$WP_VERSION" 82 | else 83 | local ARCHIVE_NAME="wordpress-$LATEST_VERSION" 84 | fi 85 | else 86 | local ARCHIVE_NAME="wordpress-$WP_VERSION" 87 | fi 88 | download https://wordpress.org/${ARCHIVE_NAME}.tar.gz $TMPDIR/wordpress.tar.gz 89 | tar --strip-components=1 -zxmf $TMPDIR/wordpress.tar.gz -C $WP_CORE_DIR 90 | fi 91 | 92 | download https://raw.github.com/markoheijnen/wp-mysqli/master/db.php $WP_CORE_DIR/wp-content/db.php 93 | } 94 | 95 | install_test_suite() { 96 | # portable in-place argument for both GNU sed and Mac OSX sed 97 | if [[ $(uname -s) == 'Darwin' ]]; then 98 | local ioption='-i .bak' 99 | else 100 | local ioption='-i' 101 | fi 102 | 103 | # set up testing suite if it doesn't yet exist 104 | if [ ! -d $WP_TESTS_DIR ]; then 105 | # set up testing suite 106 | mkdir -p $WP_TESTS_DIR 107 | svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/includes/ $WP_TESTS_DIR/includes 108 | svn co --quiet https://develop.svn.wordpress.org/${WP_TESTS_TAG}/tests/phpunit/data/ $WP_TESTS_DIR/data 109 | fi 110 | 111 | if [ ! -f wp-tests-config.php ]; then 112 | download https://develop.svn.wordpress.org/${WP_TESTS_TAG}/wp-tests-config-sample.php "$WP_TESTS_DIR"/wp-tests-config.php 113 | # remove all forward slashes in the end 114 | WP_CORE_DIR=$(echo $WP_CORE_DIR | sed "s:/\+$::") 115 | sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR/':" "$WP_TESTS_DIR"/wp-tests-config.php 116 | sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" "$WP_TESTS_DIR"/wp-tests-config.php 117 | sed $ioption "s/yourusernamehere/$DB_USER/" "$WP_TESTS_DIR"/wp-tests-config.php 118 | sed $ioption "s/yourpasswordhere/$DB_PASS/" "$WP_TESTS_DIR"/wp-tests-config.php 119 | sed $ioption "s|localhost|${DB_HOST}|" "$WP_TESTS_DIR"/wp-tests-config.php 120 | fi 121 | 122 | } 123 | 124 | install_db() { 125 | 126 | if [ ${SKIP_DB_CREATE} = "true" ]; then 127 | return 0 128 | fi 129 | 130 | # parse DB_HOST for port or socket references 131 | local PARTS=(${DB_HOST//\:/ }) 132 | local DB_HOSTNAME=${PARTS[0]}; 133 | local DB_SOCK_OR_PORT=${PARTS[1]}; 134 | local EXTRA="" 135 | 136 | if ! [ -z $DB_HOSTNAME ] ; then 137 | if [ $(echo $DB_SOCK_OR_PORT | grep -e '^[0-9]\{1,\}$') ]; then 138 | EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp" 139 | elif ! [ -z $DB_SOCK_OR_PORT ] ; then 140 | EXTRA=" --socket=$DB_SOCK_OR_PORT" 141 | elif ! [ -z $DB_HOSTNAME ] ; then 142 | EXTRA=" --host=$DB_HOSTNAME --protocol=tcp" 143 | fi 144 | fi 145 | 146 | # create database 147 | mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA 148 | } 149 | 150 | install_wp 151 | install_test_suite 152 | install_db 153 | -------------------------------------------------------------------------------- /blocks/github-gist.php: -------------------------------------------------------------------------------- 1 | '); 62 | stylesheet.attr('ref', 'stylesheet'); 63 | stylesheet.attr('href', data.stylesheet); 64 | stylesheet.attr('type', 'text/css'); 65 | div.append(stylesheet); 66 | div.append(data.div); 67 | } 68 | ); 69 | }, 10 ); 70 | retval.push( el( 'div', { id: id } ) ); 71 | } 72 | return retval; 73 | }, 74 | 75 | /** 76 | * Called when Gutenberg "saves" the block to post_content 77 | */ 78 | save: function( props ) { 79 | var url = props.attributes.url || ''; 80 | // If there's no URL, don't save any inline HTML. 81 | if ( ! url.length ) { 82 | return null; 83 | } 84 | // Include a fallback link for non-JS contexts 85 | // and for when the plugin is not activated. 86 | return el( 'a', { href: url }, __( 'View Gist on GitHub' ) ); 87 | } 88 | } ); 89 | } )( 90 | window.wp 91 | ); 92 | -------------------------------------------------------------------------------- /github-gist-gutenberg-block.php: -------------------------------------------------------------------------------- 1 | 'gggb_render_shortcode', 24 | ) ); 25 | } 26 | } 27 | add_action( 'init', 'gggb_init' ); 28 | 29 | /** 30 | * Render the GitHub Gist shortcode 31 | * 32 | * @param array $atts Shortcode attributes. 33 | */ 34 | function gggb_render_shortcode( $atts ) { 35 | if ( empty( $atts['url'] ) 36 | || 'gist.github.com' !== parse_url( $atts['url'], PHP_URL_HOST ) ) { 37 | return ''; 38 | } 39 | return sprintf( 40 | '', 41 | esc_url( rtrim( $atts['url'], '/' ) . '.js' ) 42 | ); 43 | } 44 | -------------------------------------------------------------------------------- /languages/github-gist-gutenberg-block.pot: -------------------------------------------------------------------------------- 1 | # Copyright (C) 2018 Pantheon 2 | # This file is distributed under the same license as the Gist Block by Pantheon package. 3 | msgid "" 4 | msgstr "" 5 | "Project-Id-Version: Gist Block by Pantheon 0.1.0\n" 6 | "Report-Msgid-Bugs-To: " 7 | "https://wordpress.org/support/plugin/github-gist-gutenberg-block\n" 8 | "POT-Creation-Date: 2018-02-05 23:28:07+00:00\n" 9 | "MIME-Version: 1.0\n" 10 | "Content-Type: text/plain; charset=utf-8\n" 11 | "Content-Transfer-Encoding: 8bit\n" 12 | "PO-Revision-Date: 2018-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "X-Generator: grunt-wp-i18n 0.5.4\n" 16 | "X-Poedit-KeywordsList: " 17 | "__;_e;_x:1,2c;_ex:1,2c;_n:1,2;_nx:1,2,4c;_n_noop:1,2;_nx_noop:1,2,3c;esc_" 18 | "attr__;esc_html__;esc_attr_e;esc_html_e;esc_attr_x:1,2c;esc_html_x:1,2c;\n" 19 | "Language: en\n" 20 | "Plural-Forms: nplurals=2; plural=(n != 1);\n" 21 | "X-Poedit-Country: United States\n" 22 | "X-Poedit-SourceCharset: UTF-8\n" 23 | "X-Poedit-Basepath: ../\n" 24 | "X-Poedit-SearchPath-0: .\n" 25 | "X-Poedit-Bookmarks: \n" 26 | "X-Textdomain-Support: yes\n" 27 | 28 | #. Plugin Name of the plugin/theme 29 | msgid "Gist Block by Pantheon" 30 | msgstr "" 31 | 32 | #. Description of the plugin/theme 33 | msgid "Render GitHub gists" 34 | msgstr "" 35 | 36 | #. Author of the plugin/theme 37 | msgid "Pantheon" 38 | msgstr "" 39 | 40 | #. Author URI of the plugin/theme 41 | msgid "https://pantheon.io" 42 | msgstr "" -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "github-gist-gutenberg-block", 3 | "version": "0.1.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "abbrev": { 8 | "version": "1.1.1", 9 | "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", 10 | "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==", 11 | "dev": true 12 | }, 13 | "argparse": { 14 | "version": "0.1.16", 15 | "resolved": "https://registry.npmjs.org/argparse/-/argparse-0.1.16.tgz", 16 | "integrity": "sha1-z9AeD7uj1srtBJ+9dY1A9lGW9Xw=", 17 | "dev": true, 18 | "requires": { 19 | "underscore": "1.7.0", 20 | "underscore.string": "2.4.0" 21 | }, 22 | "dependencies": { 23 | "underscore.string": { 24 | "version": "2.4.0", 25 | "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.4.0.tgz", 26 | "integrity": "sha1-jN2PusTi0uoefi6Al8QvRCKA+Fs=", 27 | "dev": true 28 | } 29 | } 30 | }, 31 | "async": { 32 | "version": "0.1.22", 33 | "resolved": "https://registry.npmjs.org/async/-/async-0.1.22.tgz", 34 | "integrity": "sha1-D8GqoIig4+8Ovi2IMbqw3PiEUGE=", 35 | "dev": true 36 | }, 37 | "coffee-script": { 38 | "version": "1.3.3", 39 | "resolved": "https://registry.npmjs.org/coffee-script/-/coffee-script-1.3.3.tgz", 40 | "integrity": "sha1-FQ1rTLUiiUNp7+1qIQHCC8f0pPQ=", 41 | "dev": true 42 | }, 43 | "colors": { 44 | "version": "0.6.2", 45 | "resolved": "https://registry.npmjs.org/colors/-/colors-0.6.2.tgz", 46 | "integrity": "sha1-JCP+ZnisDF2uiFLl0OW+CMmXq8w=", 47 | "dev": true 48 | }, 49 | "dateformat": { 50 | "version": "1.0.2-1.2.3", 51 | "resolved": "https://registry.npmjs.org/dateformat/-/dateformat-1.0.2-1.2.3.tgz", 52 | "integrity": "sha1-sCIMAt6YYXQztyhRz0fePfLNvuk=", 53 | "dev": true 54 | }, 55 | "encoding": { 56 | "version": "0.1.12", 57 | "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.12.tgz", 58 | "integrity": "sha1-U4tm8+5izRq1HsMjgp0flIDHS+s=", 59 | "dev": true, 60 | "requires": { 61 | "iconv-lite": "0.4.19" 62 | }, 63 | "dependencies": { 64 | "iconv-lite": { 65 | "version": "0.4.19", 66 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", 67 | "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==", 68 | "dev": true 69 | } 70 | } 71 | }, 72 | "esprima": { 73 | "version": "1.0.4", 74 | "resolved": "https://registry.npmjs.org/esprima/-/esprima-1.0.4.tgz", 75 | "integrity": "sha1-n1V+CPw7TSbs6d00+Pv0drYlha0=", 76 | "dev": true 77 | }, 78 | "eventemitter2": { 79 | "version": "0.4.14", 80 | "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-0.4.14.tgz", 81 | "integrity": "sha1-j2G3XN4BKy6esoTUVFWDtWQ7Yas=", 82 | "dev": true 83 | }, 84 | "exit": { 85 | "version": "0.1.2", 86 | "resolved": "https://registry.npmjs.org/exit/-/exit-0.1.2.tgz", 87 | "integrity": "sha1-BjJjj42HfMghB9MKD/8aF8uhzQw=", 88 | "dev": true 89 | }, 90 | "findup-sync": { 91 | "version": "0.1.3", 92 | "resolved": "https://registry.npmjs.org/findup-sync/-/findup-sync-0.1.3.tgz", 93 | "integrity": "sha1-fz56l7gjksZTvwZYm9hRkOk8NoM=", 94 | "dev": true, 95 | "requires": { 96 | "glob": "3.2.11", 97 | "lodash": "2.4.2" 98 | }, 99 | "dependencies": { 100 | "glob": { 101 | "version": "3.2.11", 102 | "resolved": "https://registry.npmjs.org/glob/-/glob-3.2.11.tgz", 103 | "integrity": "sha1-Spc/Y1uRkPcV0QmH1cAP0oFevj0=", 104 | "dev": true, 105 | "requires": { 106 | "inherits": "2.0.3", 107 | "minimatch": "0.3.0" 108 | } 109 | }, 110 | "lodash": { 111 | "version": "2.4.2", 112 | "resolved": "https://registry.npmjs.org/lodash/-/lodash-2.4.2.tgz", 113 | "integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4=", 114 | "dev": true 115 | }, 116 | "minimatch": { 117 | "version": "0.3.0", 118 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.3.0.tgz", 119 | "integrity": "sha1-J12O2qxPG7MyZHIInnlJyDlGmd0=", 120 | "dev": true, 121 | "requires": { 122 | "lru-cache": "2.7.3", 123 | "sigmund": "1.0.1" 124 | } 125 | } 126 | } 127 | }, 128 | "getobject": { 129 | "version": "0.1.0", 130 | "resolved": "https://registry.npmjs.org/getobject/-/getobject-0.1.0.tgz", 131 | "integrity": "sha1-BHpEl4n6Fg0Bj1SG7ZEyC27HiFw=", 132 | "dev": true 133 | }, 134 | "gettext-parser": { 135 | "version": "1.1.2", 136 | "resolved": "https://registry.npmjs.org/gettext-parser/-/gettext-parser-1.1.2.tgz", 137 | "integrity": "sha1-zw8MnJCJrtsO5RSZKRg+ncQ1hKc=", 138 | "dev": true, 139 | "requires": { 140 | "encoding": "0.1.12" 141 | } 142 | }, 143 | "glob": { 144 | "version": "3.1.21", 145 | "resolved": "https://registry.npmjs.org/glob/-/glob-3.1.21.tgz", 146 | "integrity": "sha1-0p4KBV3qUTj00H7UDomC6DwgZs0=", 147 | "dev": true, 148 | "requires": { 149 | "graceful-fs": "1.2.3", 150 | "inherits": "1.0.2", 151 | "minimatch": "0.2.14" 152 | }, 153 | "dependencies": { 154 | "inherits": { 155 | "version": "1.0.2", 156 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-1.0.2.tgz", 157 | "integrity": "sha1-ykMJ2t7mtUzAuNJH6NfHoJdb3Js=", 158 | "dev": true 159 | } 160 | } 161 | }, 162 | "graceful-fs": { 163 | "version": "1.2.3", 164 | "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-1.2.3.tgz", 165 | "integrity": "sha1-FaSAaldUfLLS2/J/QuiajDRRs2Q=", 166 | "dev": true 167 | }, 168 | "grunt": { 169 | "version": "0.4.5", 170 | "resolved": "https://registry.npmjs.org/grunt/-/grunt-0.4.5.tgz", 171 | "integrity": "sha1-VpN81RlDJK3/bSB2MYMqnWuk5/A=", 172 | "dev": true, 173 | "requires": { 174 | "async": "0.1.22", 175 | "coffee-script": "1.3.3", 176 | "colors": "0.6.2", 177 | "dateformat": "1.0.2-1.2.3", 178 | "eventemitter2": "0.4.14", 179 | "exit": "0.1.2", 180 | "findup-sync": "0.1.3", 181 | "getobject": "0.1.0", 182 | "glob": "3.1.21", 183 | "grunt-legacy-log": "0.1.3", 184 | "grunt-legacy-util": "0.2.0", 185 | "hooker": "0.2.3", 186 | "iconv-lite": "0.2.11", 187 | "js-yaml": "2.0.5", 188 | "lodash": "0.9.2", 189 | "minimatch": "0.2.14", 190 | "nopt": "1.0.10", 191 | "rimraf": "2.2.8", 192 | "underscore.string": "2.2.1", 193 | "which": "1.0.9" 194 | } 195 | }, 196 | "grunt-legacy-log": { 197 | "version": "0.1.3", 198 | "resolved": "https://registry.npmjs.org/grunt-legacy-log/-/grunt-legacy-log-0.1.3.tgz", 199 | "integrity": "sha1-7ClCboAwIa9ZAp+H0vnNczWgVTE=", 200 | "dev": true, 201 | "requires": { 202 | "colors": "0.6.2", 203 | "grunt-legacy-log-utils": "0.1.1", 204 | "hooker": "0.2.3", 205 | "lodash": "2.4.2", 206 | "underscore.string": "2.3.3" 207 | }, 208 | "dependencies": { 209 | "lodash": { 210 | "version": "2.4.2", 211 | "resolved": "https://registry.npmjs.org/lodash/-/lodash-2.4.2.tgz", 212 | "integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4=", 213 | "dev": true 214 | }, 215 | "underscore.string": { 216 | "version": "2.3.3", 217 | "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.3.3.tgz", 218 | "integrity": "sha1-ccCL9rQosRM/N+ePo6Icgvcymw0=", 219 | "dev": true 220 | } 221 | } 222 | }, 223 | "grunt-legacy-log-utils": { 224 | "version": "0.1.1", 225 | "resolved": "https://registry.npmjs.org/grunt-legacy-log-utils/-/grunt-legacy-log-utils-0.1.1.tgz", 226 | "integrity": "sha1-wHBrndkGThFvNvI/5OawSGcsD34=", 227 | "dev": true, 228 | "requires": { 229 | "colors": "0.6.2", 230 | "lodash": "2.4.2", 231 | "underscore.string": "2.3.3" 232 | }, 233 | "dependencies": { 234 | "lodash": { 235 | "version": "2.4.2", 236 | "resolved": "https://registry.npmjs.org/lodash/-/lodash-2.4.2.tgz", 237 | "integrity": "sha1-+t2DS5aDBz2hebPq5tnA0VBT9z4=", 238 | "dev": true 239 | }, 240 | "underscore.string": { 241 | "version": "2.3.3", 242 | "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.3.3.tgz", 243 | "integrity": "sha1-ccCL9rQosRM/N+ePo6Icgvcymw0=", 244 | "dev": true 245 | } 246 | } 247 | }, 248 | "grunt-legacy-util": { 249 | "version": "0.2.0", 250 | "resolved": "https://registry.npmjs.org/grunt-legacy-util/-/grunt-legacy-util-0.2.0.tgz", 251 | "integrity": "sha1-kzJIhNv343qf98Am3/RR2UqeVUs=", 252 | "dev": true, 253 | "requires": { 254 | "async": "0.1.22", 255 | "exit": "0.1.2", 256 | "getobject": "0.1.0", 257 | "hooker": "0.2.3", 258 | "lodash": "0.9.2", 259 | "underscore.string": "2.2.1", 260 | "which": "1.0.9" 261 | } 262 | }, 263 | "grunt-wp-i18n": { 264 | "version": "0.5.4", 265 | "resolved": "https://registry.npmjs.org/grunt-wp-i18n/-/grunt-wp-i18n-0.5.4.tgz", 266 | "integrity": "sha1-hynlrU9LIxJpch8xcWVNLGKVVJI=", 267 | "dev": true, 268 | "requires": { 269 | "async": "0.9.2", 270 | "gettext-parser": "1.1.2", 271 | "grunt": "0.4.5", 272 | "underscore": "1.8.3", 273 | "underscore.string": "3.0.3" 274 | }, 275 | "dependencies": { 276 | "async": { 277 | "version": "0.9.2", 278 | "resolved": "https://registry.npmjs.org/async/-/async-0.9.2.tgz", 279 | "integrity": "sha1-rqdNXmHB+JlhO/ZL2mbUx48v0X0=", 280 | "dev": true 281 | }, 282 | "underscore": { 283 | "version": "1.8.3", 284 | "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.8.3.tgz", 285 | "integrity": "sha1-Tz+1OxBuYJf8+ctBCfKl6b36UCI=", 286 | "dev": true 287 | }, 288 | "underscore.string": { 289 | "version": "3.0.3", 290 | "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-3.0.3.tgz", 291 | "integrity": "sha1-Rhe4waJQz25QZPu7Nj0PqWzxRVI=", 292 | "dev": true 293 | } 294 | } 295 | }, 296 | "grunt-wp-readme-to-markdown": { 297 | "version": "1.0.0", 298 | "resolved": "https://registry.npmjs.org/grunt-wp-readme-to-markdown/-/grunt-wp-readme-to-markdown-1.0.0.tgz", 299 | "integrity": "sha1-dJ/9gDtYTVC9ZOc6ehqRhz6djPs=", 300 | "dev": true 301 | }, 302 | "hooker": { 303 | "version": "0.2.3", 304 | "resolved": "https://registry.npmjs.org/hooker/-/hooker-0.2.3.tgz", 305 | "integrity": "sha1-uDT3I8xKJCqmWWNFnfbZhMXT2Vk=", 306 | "dev": true 307 | }, 308 | "iconv-lite": { 309 | "version": "0.2.11", 310 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.2.11.tgz", 311 | "integrity": "sha1-HOYKOleGSiktEyH/RgnKS7llrcg=", 312 | "dev": true 313 | }, 314 | "inherits": { 315 | "version": "2.0.3", 316 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", 317 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", 318 | "dev": true 319 | }, 320 | "js-yaml": { 321 | "version": "2.0.5", 322 | "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-2.0.5.tgz", 323 | "integrity": "sha1-olrmUJmZ6X3yeMZxnaEb0Gh3Q6g=", 324 | "dev": true, 325 | "requires": { 326 | "argparse": "0.1.16", 327 | "esprima": "1.0.4" 328 | } 329 | }, 330 | "lodash": { 331 | "version": "0.9.2", 332 | "resolved": "https://registry.npmjs.org/lodash/-/lodash-0.9.2.tgz", 333 | "integrity": "sha1-jzSZxSRdNG1oLlsNO0B2fgnxqSw=", 334 | "dev": true 335 | }, 336 | "lru-cache": { 337 | "version": "2.7.3", 338 | "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-2.7.3.tgz", 339 | "integrity": "sha1-bUUk6LlV+V1PW1iFHOId1y+06VI=", 340 | "dev": true 341 | }, 342 | "minimatch": { 343 | "version": "0.2.14", 344 | "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-0.2.14.tgz", 345 | "integrity": "sha1-x054BXT2PG+aCQ6Q775u9TpqdWo=", 346 | "dev": true, 347 | "requires": { 348 | "lru-cache": "2.7.3", 349 | "sigmund": "1.0.1" 350 | } 351 | }, 352 | "nopt": { 353 | "version": "1.0.10", 354 | "resolved": "https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz", 355 | "integrity": "sha1-bd0hvSoxQXuScn3Vhfim83YI6+4=", 356 | "dev": true, 357 | "requires": { 358 | "abbrev": "1.1.1" 359 | } 360 | }, 361 | "rimraf": { 362 | "version": "2.2.8", 363 | "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz", 364 | "integrity": "sha1-5Dm+Kq7jJzIZUnMPmaiSnk/FBYI=", 365 | "dev": true 366 | }, 367 | "sigmund": { 368 | "version": "1.0.1", 369 | "resolved": "https://registry.npmjs.org/sigmund/-/sigmund-1.0.1.tgz", 370 | "integrity": "sha1-P/IfGYytIXX587eBhT/ZTQ0ZtZA=", 371 | "dev": true 372 | }, 373 | "underscore": { 374 | "version": "1.7.0", 375 | "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.7.0.tgz", 376 | "integrity": "sha1-a7rwh3UA02vjTsqlhODbn+8DUgk=", 377 | "dev": true 378 | }, 379 | "underscore.string": { 380 | "version": "2.2.1", 381 | "resolved": "https://registry.npmjs.org/underscore.string/-/underscore.string-2.2.1.tgz", 382 | "integrity": "sha1-18D6KvXVoaZ/QlPa7pgTLnM/Dxk=", 383 | "dev": true 384 | }, 385 | "which": { 386 | "version": "1.0.9", 387 | "resolved": "https://registry.npmjs.org/which/-/which-1.0.9.tgz", 388 | "integrity": "sha1-RgwdoPgQED0DIam2M6+eV15kSG8=", 389 | "dev": true 390 | } 391 | } 392 | } 393 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "github-gist-gutenberg-block", 3 | "version": "0.1.0", 4 | "main": "Gruntfile.js", 5 | "author": "Pantheon", 6 | "devDependencies": { 7 | "grunt": "~0.4.5", 8 | "grunt-wp-i18n": "~0.5.0", 9 | "grunt-wp-readme-to-markdown": "~1.0.0" 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /phpcs.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | Generally-applicable sniffs for WordPress plugins 4 | 5 | 6 | 7 | 8 | 9 | 10 | . 11 | 12 | 13 | 14 | 15 | */node_modules/* 16 | */vendor/* 17 | 18 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | ./tests/ 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | === Gist Block by Pantheon === 2 | Contributors: getpantheon, danielbachhuber 3 | Tags: github gist, gutenberg 4 | Requires at least: 4.4 5 | Tested up to: 4.9.2 6 | Stable tag: 0.1.1 7 | License: GPLv2 or later 8 | License URI: https://www.gnu.org/licenses/gpl-2.0.html 9 | 10 | Include GitHub Gists in your Gutenberg posts without the hassle of shortcodes. 11 | 12 | == Description == 13 | 14 | The Gist Block by Pantheon makes it possible to embed GitHub Gists in your Gutenberg posts. Simply add the "GitHub Gist" block, paste the URL to your Gist, and see it transform to a wonderful preview. 15 | 16 | Curious as to how blocks work? This is a great one to explore. Specifically, check out these implementation details: 17 | 18 | 1. Block UI is registered in `blocks/github-gist/index.js`. When the block is previewed in Gutenberg, custom code is used to generate the embed. 19 | 2. Fallback HTML content is what's actually stored in the post content. 20 | 3. A dynamic render callback is used to transform the block to GitHub's standard Gist embed code. 21 | 22 | Read "[How to Convert a Shortcode to a Gutenberg Block](https://pantheon.io/blog/how-convert-shortcode-gutenberg-block)" for a more detailed explanation of the plugin. 23 | 24 | Something we can clarify? [Check out the project on GitHub](https://github.com/pantheon-systems/github-gist-gutenberg-block/) for any questions, feedback, suggestions, or pull requests. 25 | 26 | == Installation == 27 | 28 | The Gist Block can be installed just like any other WordPress plugin! 29 | 30 | == Changelog == 31 | 32 | = 0.1.1 (Mar. 22nd, 2018) = 33 | * Uses new `wp.components` API included in Gutenberg 2.4. 34 | * Removes textdomain because it's not registered. 35 | 36 | = 0.1.0 (Feb. 5th, 2018) = 37 | * Initial release. 38 | -------------------------------------------------------------------------------- /tests/bootstrap.php: -------------------------------------------------------------------------------- 1 | assertTrue( true ); 19 | } 20 | } 21 | --------------------------------------------------------------------------------