Changeset 1836044
- Timestamp:
- 03/08/2018 08:52:27 AM (7 years ago)
- Location:
- writing-on-github/trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
writing-on-github/trunk/lib/controller.php
r1719790 r1836044 58 58 return $this->app->response()->error( new WP_Error( 59 59 'invalid_headers', 60 __( 'Failed to validate webhook event.', 'writing-on-github' ) 60 sprintf( 'Failed to validate webhook event: %s.', 61 $this->app->request()->webhook_event() ) 61 62 ) ); 62 63 } 63 64 $payload = $this->app->request()->payload(); 64 65 65 if ( ! $payload->should_import() ) { 66 return $this->app->response()->error( new WP_Error( 67 'invalid_payload', 68 sprintf( 69 __( "%s won't be imported.", 'writing-on-github' ), 70 strtolower( $payload->get_commit_id() ) ? : '[Missing Commit ID]' 71 ) 72 ) ); 66 $error = $payload->should_import(); 67 if ( is_wp_error( $error ) ) { 68 /* @var WP_Error $error */ 69 return $this->app->response()->error( $error ); 73 70 } 74 71 -
writing-on-github/trunk/lib/import.php
r1719790 r1836044 302 302 if ( array_key_exists( 'ID', $meta ) ) { 303 303 $id = $args['ID'] = $meta['ID']; 304 $blob->set_id( $id);304 $blob->set_id( $id ); 305 305 unset( $meta['ID'] ); 306 } 307 308 if ( array_key_exists( 'post_date', $meta ) ) { 309 if ( empty( $meta['post_date'] ) ) { 310 $meta['post_date'] = current_time( 'mysql' ); 311 } 312 313 $args['post_date'] = $meta['post_date']; 314 unset( $meta['post_date'] ); 306 315 } 307 316 } -
writing-on-github/trunk/lib/payload.php
r1713007 r1836044 38 38 * Returns whether payload should be imported. 39 39 * 40 * @return bool40 * @return true|WP_Error 41 41 */ 42 42 public function should_import() { 43 43 // @todo how do we get this without importing the whole api object just for this? 44 44 if ( strtolower( $this->data->repository->full_name ) !== strtolower( $this->app->api()->fetch()->repository() ) ) { 45 return false; 45 return new WP_Error( 46 'incorrect_repository', 47 sprintf( 'Incorrect repository, %s -> %s .', 48 $this->data->repository->full_name, 49 $this->app->api()->fetch()->repository() 50 ) 51 ); 46 52 } 47 53 … … 53 59 54 60 if ( $branch !== $payload_branch ) { 55 return false; 61 return new WP_Error( 62 'incorrect_branch', 63 sprintf( 'Incorrect branch, %s -> %s .', 64 $payload_branch, 65 $branch 66 ) 67 ); 56 68 } 57 69 … … 64 76 65 77 if ( $tag === substr( $this->message(), -1 * strlen( $tag ) ) ) { 66 return false; 78 return new WP_Error( 79 'skip_import', 80 'Skip import on auto export post.' 81 ); 67 82 } 68 83 69 84 if ( ! $this->get_commit_id() ) { 70 return false; 85 return new WP_Error( 86 'invalid_payload', 87 "[Missing Commit ID] won't be imported." 88 ); 71 89 } 72 90 -
writing-on-github/trunk/lib/request.php
r1713007 r1836044 68 68 */ 69 69 public function is_ping() { 70 $headers = $this->headers(); 71 72 $event = $headers['X-Github-Event']; 73 return 'ping' == $event; 70 return 'ping' == $this->webhook_event(); 74 71 } 75 72 … … 79 76 */ 80 77 public function is_push() { 78 return 'push' == $this->webhook_event(); 79 } 80 81 /** 82 * Return X-Github-Event in headers. 83 * @return string 84 */ 85 public function webhook_event() { 81 86 $headers = $this->headers(); 82 83 $event = $headers['X-Github-Event']; 84 return 'push' == $event; 87 return $headers['X-Github-Event']; 85 88 } 86 89 -
writing-on-github/trunk/readme.txt
r1719790 r1836044 6 6 Donate link: https://www.paypal.me/litefeel 7 7 Requires at least: 3.9 8 Tested up to: 4. 8.19 Stable tag: 1. 78 Tested up to: 4.9.4 9 Stable tag: 1.8 10 10 License: GPLv2 11 11 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 101 101 post_title: 'Post Title' 102 102 post_name: 'this is post name' 103 post_date: '2018-03-07 15:21:26' 103 104 layout: post_type_probably_post 104 105 published: true_or_false … … 135 136 == Changelog == 136 137 138 = 1.8 = 139 140 * Apply post_date from github 141 * Friendly error message when validate webhook event 142 * Friendly error message when can not import 143 137 144 = 1.7 = 138 145 … … 198 205 [1.6.1]: https://github.com/litefeel/writing-on-github/releases/tag/1.6.1 199 206 [1.7]: https://github.com/litefeel/writing-on-github/releases/tag/1.7 207 [1.8]: https://github.com/litefeel/writing-on-github/releases/tag/1.8 -
writing-on-github/trunk/vendor/autoload.php
r1719790 r1836044 5 5 require_once __DIR__ . '/composer/autoload_real.php'; 6 6 7 return ComposerAutoloaderInit dceed942811feb8a045169f778363db6::getLoader();7 return ComposerAutoloaderInit4cd77128cdef6e0cbb9a7016878f8015::getLoader(); -
writing-on-github/trunk/vendor/composer/ClassLoader.php
r1713007 r1836044 380 380 $search = $subPath.'\\'; 381 381 if (isset($this->prefixDirsPsr4[$search])) { 382 $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); 382 383 foreach ($this->prefixDirsPsr4[$search] as $dir) { 383 $length = $this->prefixLengthsPsr4[$first][$search]; 384 if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) { 384 if (file_exists($file = $dir . $pathEnd)) { 385 385 return $file; 386 386 } -
writing-on-github/trunk/vendor/composer/autoload_real.php
r1719790 r1836044 3 3 // autoload_real.php @generated by Composer 4 4 5 class ComposerAutoloaderInit dceed942811feb8a045169f778363db65 class ComposerAutoloaderInit4cd77128cdef6e0cbb9a7016878f8015 6 6 { 7 7 private static $loader; … … 20 20 } 21 21 22 spl_autoload_register(array('ComposerAutoloaderInit dceed942811feb8a045169f778363db6', 'loadClassLoader'), true, true);22 spl_autoload_register(array('ComposerAutoloaderInit4cd77128cdef6e0cbb9a7016878f8015', 'loadClassLoader'), true, true); 23 23 self::$loader = $loader = new \Composer\Autoload\ClassLoader(); 24 spl_autoload_unregister(array('ComposerAutoloaderInit dceed942811feb8a045169f778363db6', 'loadClassLoader'));24 spl_autoload_unregister(array('ComposerAutoloaderInit4cd77128cdef6e0cbb9a7016878f8015', 'loadClassLoader')); 25 25 26 26 $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); … … 28 28 require_once __DIR__ . '/autoload_static.php'; 29 29 30 call_user_func(\Composer\Autoload\ComposerStaticInit dceed942811feb8a045169f778363db6::getInitializer($loader));30 call_user_func(\Composer\Autoload\ComposerStaticInit4cd77128cdef6e0cbb9a7016878f8015::getInitializer($loader)); 31 31 } else { 32 32 $map = require __DIR__ . '/autoload_namespaces.php'; … … 49 49 50 50 if ($useStaticLoader) { 51 $includeFiles = Composer\Autoload\ComposerStaticInit dceed942811feb8a045169f778363db6::$files;51 $includeFiles = Composer\Autoload\ComposerStaticInit4cd77128cdef6e0cbb9a7016878f8015::$files; 52 52 } else { 53 53 $includeFiles = require __DIR__ . '/autoload_files.php'; 54 54 } 55 55 foreach ($includeFiles as $fileIdentifier => $file) { 56 composerRequire dceed942811feb8a045169f778363db6($fileIdentifier, $file);56 composerRequire4cd77128cdef6e0cbb9a7016878f8015($fileIdentifier, $file); 57 57 } 58 58 … … 61 61 } 62 62 63 function composerRequire dceed942811feb8a045169f778363db6($fileIdentifier, $file)63 function composerRequire4cd77128cdef6e0cbb9a7016878f8015($fileIdentifier, $file) 64 64 { 65 65 if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { -
writing-on-github/trunk/vendor/composer/autoload_static.php
r1719790 r1836044 5 5 namespace Composer\Autoload; 6 6 7 class ComposerStaticInit dceed942811feb8a045169f778363db67 class ComposerStaticInit4cd77128cdef6e0cbb9a7016878f8015 8 8 { 9 9 public static $files = array ( … … 35 35 { 36 36 return \Closure::bind(function () use ($loader) { 37 $loader->classMap = ComposerStaticInit dceed942811feb8a045169f778363db6::$classMap;37 $loader->classMap = ComposerStaticInit4cd77128cdef6e0cbb9a7016878f8015::$classMap; 38 38 39 39 }, null, ClassLoader::class); -
writing-on-github/trunk/writing-on-github.php
r1719790 r1836044 4 4 * Plugin URI: https://github.com/litefeel/writing-on-github 5 5 * Description: A WordPress plugin to allow you writing on GitHub (or Jekyll site). 6 * Version: 1. 76 * Version: 1.8 7 7 * Author: litefeel 8 8 * Author URI: https://www.litefeel.com
Note: See TracChangeset
for help on using the changeset viewer.