Plugin Directory

Changeset 1836044


Ignore:
Timestamp:
03/08/2018 08:52:27 AM (7 years ago)
Author:
litefeel
Message:

auto deploy from deploy2wp:https://github.com/litefeel/deploy2wp

Location:
writing-on-github/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • writing-on-github/trunk/lib/controller.php

    r1719790 r1836044  
    5858            return $this->app->response()->error( new WP_Error(
    5959                '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() )
    6162            ) );
    6263        }
    6364        $payload = $this->app->request()->payload();
    6465
    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 );
    7370        }
    7471
  • writing-on-github/trunk/lib/import.php

    r1719790 r1836044  
    302302            if ( array_key_exists( 'ID', $meta ) ) {
    303303                $id = $args['ID'] = $meta['ID'];
    304                 $blob->set_id($id);
     304                $blob->set_id( $id );
    305305                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'] );
    306315            }
    307316        }
  • writing-on-github/trunk/lib/payload.php

    r1713007 r1836044  
    3838     * Returns whether payload should be imported.
    3939     *
    40      * @return bool
     40     * @return true|WP_Error
    4141     */
    4242    public function should_import() {
    4343        // @todo how do we get this without importing the whole api object just for this?
    4444        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            );
    4652        }
    4753
     
    5359
    5460        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            );
    5668        }
    5769
     
    6476
    6577        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            );
    6782        }
    6883
    6984        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            );
    7189        }
    7290
  • writing-on-github/trunk/lib/request.php

    r1713007 r1836044  
    6868     */
    6969    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();
    7471    }
    7572
     
    7976     */
    8077    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() {
    8186        $headers = $this->headers();
    82 
    83         $event = $headers['X-Github-Event'];
    84         return 'push' == $event;
     87        return $headers['X-Github-Event'];
    8588    }
    8689
  • writing-on-github/trunk/readme.txt

    r1719790 r1836044  
    66Donate link: https://www.paypal.me/litefeel 
    77Requires at least: 3.9 
    8 Tested up to: 4.8.1 
    9 Stable tag: 1.7 
     8Tested up to: 4.9.4 
     9Stable tag: 1.8 
    1010License: GPLv2 
    1111License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    101101    post_title: 'Post Title'
    102102    post_name: 'this is post name'
     103    post_date: '2018-03-07 15:21:26'
    103104    layout: post_type_probably_post
    104105    published: true_or_false
     
    135136== Changelog ==
    136137
     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
    137144= 1.7 =
    138145
     
    198205  [1.6.1]: https://github.com/litefeel/writing-on-github/releases/tag/1.6.1
    199206  [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  
    55require_once __DIR__ . '/composer/autoload_real.php';
    66
    7 return ComposerAutoloaderInitdceed942811feb8a045169f778363db6::getLoader();
     7return ComposerAutoloaderInit4cd77128cdef6e0cbb9a7016878f8015::getLoader();
  • writing-on-github/trunk/vendor/composer/ClassLoader.php

    r1713007 r1836044  
    380380                $search = $subPath.'\\';
    381381                if (isset($this->prefixDirsPsr4[$search])) {
     382                    $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
    382383                    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)) {
    385385                            return $file;
    386386                        }
  • writing-on-github/trunk/vendor/composer/autoload_real.php

    r1719790 r1836044  
    33// autoload_real.php @generated by Composer
    44
    5 class ComposerAutoloaderInitdceed942811feb8a045169f778363db6
     5class ComposerAutoloaderInit4cd77128cdef6e0cbb9a7016878f8015
    66{
    77    private static $loader;
     
    2020        }
    2121
    22         spl_autoload_register(array('ComposerAutoloaderInitdceed942811feb8a045169f778363db6', 'loadClassLoader'), true, true);
     22        spl_autoload_register(array('ComposerAutoloaderInit4cd77128cdef6e0cbb9a7016878f8015', 'loadClassLoader'), true, true);
    2323        self::$loader = $loader = new \Composer\Autoload\ClassLoader();
    24         spl_autoload_unregister(array('ComposerAutoloaderInitdceed942811feb8a045169f778363db6', 'loadClassLoader'));
     24        spl_autoload_unregister(array('ComposerAutoloaderInit4cd77128cdef6e0cbb9a7016878f8015', 'loadClassLoader'));
    2525
    2626        $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
     
    2828            require_once __DIR__ . '/autoload_static.php';
    2929
    30             call_user_func(\Composer\Autoload\ComposerStaticInitdceed942811feb8a045169f778363db6::getInitializer($loader));
     30            call_user_func(\Composer\Autoload\ComposerStaticInit4cd77128cdef6e0cbb9a7016878f8015::getInitializer($loader));
    3131        } else {
    3232            $map = require __DIR__ . '/autoload_namespaces.php';
     
    4949
    5050        if ($useStaticLoader) {
    51             $includeFiles = Composer\Autoload\ComposerStaticInitdceed942811feb8a045169f778363db6::$files;
     51            $includeFiles = Composer\Autoload\ComposerStaticInit4cd77128cdef6e0cbb9a7016878f8015::$files;
    5252        } else {
    5353            $includeFiles = require __DIR__ . '/autoload_files.php';
    5454        }
    5555        foreach ($includeFiles as $fileIdentifier => $file) {
    56             composerRequiredceed942811feb8a045169f778363db6($fileIdentifier, $file);
     56            composerRequire4cd77128cdef6e0cbb9a7016878f8015($fileIdentifier, $file);
    5757        }
    5858
     
    6161}
    6262
    63 function composerRequiredceed942811feb8a045169f778363db6($fileIdentifier, $file)
     63function composerRequire4cd77128cdef6e0cbb9a7016878f8015($fileIdentifier, $file)
    6464{
    6565    if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
  • writing-on-github/trunk/vendor/composer/autoload_static.php

    r1719790 r1836044  
    55namespace Composer\Autoload;
    66
    7 class ComposerStaticInitdceed942811feb8a045169f778363db6
     7class ComposerStaticInit4cd77128cdef6e0cbb9a7016878f8015
    88{
    99    public static $files = array (
     
    3535    {
    3636        return \Closure::bind(function () use ($loader) {
    37             $loader->classMap = ComposerStaticInitdceed942811feb8a045169f778363db6::$classMap;
     37            $loader->classMap = ComposerStaticInit4cd77128cdef6e0cbb9a7016878f8015::$classMap;
    3838
    3939        }, null, ClassLoader::class);
  • writing-on-github/trunk/writing-on-github.php

    r1719790 r1836044  
    44 * Plugin URI: https://github.com/litefeel/writing-on-github
    55 * Description: A WordPress plugin to allow you writing on GitHub (or Jekyll site).
    6  * Version: 1.7
     6 * Version: 1.8
    77 * Author:  litefeel
    88 * Author URI: https://www.litefeel.com
Note: See TracChangeset for help on using the changeset viewer.