Plugin Directory

Changeset 1947892


Ignore:
Timestamp:
09/27/2018 08:35:08 AM (8 years ago)
Author:
yoannspace
Message:

->1.1.0 release

Location:
nerd-wp
Files:
11 edited
17 copied

Legend:

Unmodified
Added
Removed
  • nerd-wp/tags/1.1.0/CHANGELOG.md

    r1925226 r1947892  
    77## Unreleased
    88
    9 ## [1.0.0] - YYYY-MM-DD
     9## [1.1.0] - 2018-09-27
     10### Changed
     11- Ajax queries to NERD are not done via JS anymore but via the PHP code [See Issue](https://github.com/DARIAH-ERIC/nerd-wp/issues/1)
     12
     13## [1.0.0] - 2018-08-15
    1014### Added
    11 -
     15- First version of the NERD WP plugin
  • nerd-wp/tags/1.1.0/README.txt

    r1925256 r1947892  
    66Tested up to: 4.9.1
    77Requires PHP: 5.6.35
    8 Stable tag: 1.0.0
     8Stable tag: 1.1.0
    99License: Apache License - 2.0
    1010License URI: http://www.apache.org/licenses/LICENSE-2.0
     
    1515
    1616[NERD](https://github.com/kermitt2/entity-fishing) is an application that allows to recognize and disambiguate named entities.
    17 This plugin allows integration of this with Wordpress. Each post can be run through NERD and will automatically create tags for it.
     17This plugin allows integration of the NERD service with Wordpress. Each post can be run through NERD and will automatically create tags for it.
    1818Those tags, in return are used to propose extra information coming from Wikipedia and Wikidata.
    1919
  • nerd-wp/tags/1.1.0/includes/class-nerd-wp.php

    r1925226 r1947892  
    6565            $this->version = NERD_WP_VERSION;
    6666        } else {
    67             $this->version = '1.0.0';
     67            $this->version = '1.1.0';
    6868        }
    6969        $this->plugin_name = 'nerd-wp';
     
    173173        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
    174174        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
    175 
    176 //      $this->loader->add_action( 'widgets_init', new Nerd_Wp_Widget( $this-> plugin_name ), 'nerd_wp_widget' );
    177         $this->loader->add_action_callable( 'widgets_init', function() {
    178             $widget = new Nerd_Wp_Widget( $this->get_plugin_name() );
    179             $widget->nerd_wp_widget( $widget );
    180         } );
     175        $this->loader->add_action( 'init', $plugin_public, 'access_nerd_kb' );
     176        $this->loader->add_action( 'widgets_init', new Nerd_Wp_Widget(), 'nerd_wp_widget' );
    181177    }
    182178    /**
  • nerd-wp/tags/1.1.0/nerd-wp.php

    r1925226 r1947892  
    1717 * Plugin URI:        https://github.com/dariah-eric/nerd-wp
    1818 * Description:       NERD (Named Entity Recognition and Disambiguation: https://github.com/kermitt2/entity-fishing) is an application that allows to recognize and disambiguate named entities. This plugin allows integration of this with Wordpress.
    19  * Version:           1.0.0
     19 * Version:           1.1.0
    2020 * Author:            Yoann
    2121 * Author URI:        https://www.dariah.eu
  • nerd-wp/tags/1.1.0/public/class-nerd-wp-public.php

    r1925226 r1947892  
    1212 * @author     Yoann Moranville <yoann.moranville@dariah.eu>
    1313 */
     14use GuzzleHttp\Exception\RequestException;
    1415class Nerd_Wp_Public {
    1516    /**
     
    8485
    8586    }
     87
     88    public function access_nerd_kb() {
     89        $url = '/nerd_kb_service/?url=';
     90        if ( substr( $_SERVER['REQUEST_URI'], 0, strlen( $url ) ) === $url ) {
     91            $nerd_query = substr( $_SERVER['REQUEST_URI'], strlen( $url ) );
     92
     93            $options = get_option( $this->plugin_name );
     94            $url_nerd_instance = $options['url_nerd_instance'];
     95            if( $url_nerd_instance ) {;
     96                if ( substr( $url_nerd_instance, - 1 ) != '/' ) { // In case the URL provided does not contain a ending slash, add it
     97                    $url_nerd_instance = $url_nerd_instance . "/";
     98                }
     99                $access_url = $url_nerd_instance . urldecode( $nerd_query );
     100
     101                $client = new GuzzleHttp\Client();
     102                try {
     103                    $response = $client->request( 'GET', $access_url );
     104                    if( $response->getStatusCode() != 200 ) {
     105                        error_log( "Reason: " . $response->getReasonPhrase() );
     106                    }
     107
     108                } catch ( RequestException $e ) {
     109                    if ( $e->hasResponse() ) {
     110                        error_log( $e->getMessage() );
     111                        error_log( $e->getResponse()->getBody()->getContents() );
     112                    }
     113                } catch ( \GuzzleHttp\Exception\GuzzleException $e ) {
     114                    error_log( $e->getMessage() );
     115                }
     116                wp_send_json( $response->getBody()->getContents() );
     117            }
     118        }
     119        return "";
     120    }
    86121}
  • nerd-wp/tags/1.1.0/public/class-nerd-wp-widget.php

    r1925226 r1947892  
    22
    33class Nerd_Wp_Widget extends WP_Widget {
    4     /**
    5      * The ID of this plugin.
    6      *
    7      * @since    1.0.0
    8      * @access   private
    9      * @var      string    $plugin_name    The ID of this plugin.
    10      */
    11     private $plugin_name;
    124
    13     function __construct( $plugin_name ) {
    14         $this->plugin_name = $plugin_name;
     5    function __construct() {
    156        parent::__construct( 'nerd_wp_widget', __( 'NERD WP Widget', 'nerd_wp_domain' ), array(
    167            'description' => __( 'NERD WP Widget', 'nerd_wp_domain' )
     
    5546            }
    5647            if( $used_tags > 0 ) {
    57                 $options = get_option( $this->plugin_name );
    58                 $url_nerd_instance = $options['url_nerd_instance'];
    59                 if( $url_nerd_instance ) {
    60                     if ( substr( $url_nerd_instance, - 1 ) != '/' ) { // In case the URL provided does not contain a ending slash, add it
    61                         $url_nerd_instance = $url_nerd_instance . "/";
    62                     }
    63                     echo '<script type="text/javascript">
    64                             jQuery(document).ready(function($){
    65                                 hoverEntity("' . $url_nerd_instance . '");
    66                             });
    67                           </script>';
    68                 }
     48                echo '<script type="text/javascript">
     49                        jQuery(document).ready(function($){
     50                            hoverEntity();
     51                        });
     52                      </script>';
    6953                echo $args['after_widget'];
    7054            }
     
    8165    }
    8266
    83     function nerd_wp_widget( \WP_Widget $widget) {
    84         register_widget( $widget );
     67    function nerd_wp_widget() {
     68        register_widget( $this );
    8569    }
    8670}
  • nerd-wp/tags/1.1.0/public/js/nerd-wp-public.js

    r1925226 r1947892  
    1 function hoverEntity(nerd_url) {
     1function hoverEntity() {
    22    jQuery(".nerd_tags").each(function(index, value) {
    33        var wiki_ids = jQuery(this).attr('id');
     
    1919                jQuery.ajax({
    2020                    type: 'GET',
    21                     url: nerd_url + 'service/kb/concept/' + wikipedia_id.split(":")[1] + '?lang=en',
     21                    url: '/nerd_kb_service/?url=' + encodeURIComponent('service/kb/concept/' + wikipedia_id.split(":")[1] + '?lang=en'),
    2222                    success: function(result) {
    23                         viewEntity(result, wikipedia_id, this_element);
     23                        viewEntity(jQuery.parseJSON(result), wikipedia_id, this_element);
    2424                    },
    2525                    complete: function() {
  • nerd-wp/trunk/CHANGELOG.md

    r1925226 r1947892  
    77## Unreleased
    88
    9 ## [1.0.0] - YYYY-MM-DD
     9## [1.1.0] - 2018-09-27
     10### Changed
     11- Ajax queries to NERD are not done via JS anymore but via the PHP code [See Issue](https://github.com/DARIAH-ERIC/nerd-wp/issues/1)
     12
     13## [1.0.0] - 2018-08-15
    1014### Added
    11 -
     15- First version of the NERD WP plugin
  • nerd-wp/trunk/README.txt

    r1925256 r1947892  
    66Tested up to: 4.9.1
    77Requires PHP: 5.6.35
    8 Stable tag: 1.0.0
     8Stable tag: 1.1.0
    99License: Apache License - 2.0
    1010License URI: http://www.apache.org/licenses/LICENSE-2.0
     
    1515
    1616[NERD](https://github.com/kermitt2/entity-fishing) is an application that allows to recognize and disambiguate named entities.
    17 This plugin allows integration of this with Wordpress. Each post can be run through NERD and will automatically create tags for it.
     17This plugin allows integration of the NERD service with Wordpress. Each post can be run through NERD and will automatically create tags for it.
    1818Those tags, in return are used to propose extra information coming from Wikipedia and Wikidata.
    1919
  • nerd-wp/trunk/includes/class-nerd-wp.php

    r1925226 r1947892  
    6565            $this->version = NERD_WP_VERSION;
    6666        } else {
    67             $this->version = '1.0.0';
     67            $this->version = '1.1.0';
    6868        }
    6969        $this->plugin_name = 'nerd-wp';
     
    173173        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
    174174        $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
    175 
    176 //      $this->loader->add_action( 'widgets_init', new Nerd_Wp_Widget( $this-> plugin_name ), 'nerd_wp_widget' );
    177         $this->loader->add_action_callable( 'widgets_init', function() {
    178             $widget = new Nerd_Wp_Widget( $this->get_plugin_name() );
    179             $widget->nerd_wp_widget( $widget );
    180         } );
     175        $this->loader->add_action( 'init', $plugin_public, 'access_nerd_kb' );
     176        $this->loader->add_action( 'widgets_init', new Nerd_Wp_Widget(), 'nerd_wp_widget' );
    181177    }
    182178    /**
  • nerd-wp/trunk/nerd-wp.php

    r1925226 r1947892  
    1717 * Plugin URI:        https://github.com/dariah-eric/nerd-wp
    1818 * Description:       NERD (Named Entity Recognition and Disambiguation: https://github.com/kermitt2/entity-fishing) is an application that allows to recognize and disambiguate named entities. This plugin allows integration of this with Wordpress.
    19  * Version:           1.0.0
     19 * Version:           1.1.0
    2020 * Author:            Yoann
    2121 * Author URI:        https://www.dariah.eu
  • nerd-wp/trunk/public/class-nerd-wp-public.php

    r1925226 r1947892  
    1212 * @author     Yoann Moranville <yoann.moranville@dariah.eu>
    1313 */
     14use GuzzleHttp\Exception\RequestException;
    1415class Nerd_Wp_Public {
    1516    /**
     
    8485
    8586    }
     87
     88    public function access_nerd_kb() {
     89        $url = '/nerd_kb_service/?url=';
     90        if ( substr( $_SERVER['REQUEST_URI'], 0, strlen( $url ) ) === $url ) {
     91            $nerd_query = substr( $_SERVER['REQUEST_URI'], strlen( $url ) );
     92
     93            $options = get_option( $this->plugin_name );
     94            $url_nerd_instance = $options['url_nerd_instance'];
     95            if( $url_nerd_instance ) {;
     96                if ( substr( $url_nerd_instance, - 1 ) != '/' ) { // In case the URL provided does not contain a ending slash, add it
     97                    $url_nerd_instance = $url_nerd_instance . "/";
     98                }
     99                $access_url = $url_nerd_instance . urldecode( $nerd_query );
     100
     101                $client = new GuzzleHttp\Client();
     102                try {
     103                    $response = $client->request( 'GET', $access_url );
     104                    if( $response->getStatusCode() != 200 ) {
     105                        error_log( "Reason: " . $response->getReasonPhrase() );
     106                    }
     107
     108                } catch ( RequestException $e ) {
     109                    if ( $e->hasResponse() ) {
     110                        error_log( $e->getMessage() );
     111                        error_log( $e->getResponse()->getBody()->getContents() );
     112                    }
     113                } catch ( \GuzzleHttp\Exception\GuzzleException $e ) {
     114                    error_log( $e->getMessage() );
     115                }
     116                wp_send_json( $response->getBody()->getContents() );
     117            }
     118        }
     119        return "";
     120    }
    86121}
  • nerd-wp/trunk/public/class-nerd-wp-widget.php

    r1925226 r1947892  
    22
    33class Nerd_Wp_Widget extends WP_Widget {
    4     /**
    5      * The ID of this plugin.
    6      *
    7      * @since    1.0.0
    8      * @access   private
    9      * @var      string    $plugin_name    The ID of this plugin.
    10      */
    11     private $plugin_name;
    124
    13     function __construct( $plugin_name ) {
    14         $this->plugin_name = $plugin_name;
     5    function __construct() {
    156        parent::__construct( 'nerd_wp_widget', __( 'NERD WP Widget', 'nerd_wp_domain' ), array(
    167            'description' => __( 'NERD WP Widget', 'nerd_wp_domain' )
     
    5546            }
    5647            if( $used_tags > 0 ) {
    57                 $options = get_option( $this->plugin_name );
    58                 $url_nerd_instance = $options['url_nerd_instance'];
    59                 if( $url_nerd_instance ) {
    60                     if ( substr( $url_nerd_instance, - 1 ) != '/' ) { // In case the URL provided does not contain a ending slash, add it
    61                         $url_nerd_instance = $url_nerd_instance . "/";
    62                     }
    63                     echo '<script type="text/javascript">
    64                             jQuery(document).ready(function($){
    65                                 hoverEntity("' . $url_nerd_instance . '");
    66                             });
    67                           </script>';
    68                 }
     48                echo '<script type="text/javascript">
     49                        jQuery(document).ready(function($){
     50                            hoverEntity();
     51                        });
     52                      </script>';
    6953                echo $args['after_widget'];
    7054            }
     
    8165    }
    8266
    83     function nerd_wp_widget( \WP_Widget $widget) {
    84         register_widget( $widget );
     67    function nerd_wp_widget() {
     68        register_widget( $this );
    8569    }
    8670}
  • nerd-wp/trunk/public/js/nerd-wp-public.js

    r1925226 r1947892  
    1 function hoverEntity(nerd_url) {
     1function hoverEntity() {
    22    jQuery(".nerd_tags").each(function(index, value) {
    33        var wiki_ids = jQuery(this).attr('id');
     
    1919                jQuery.ajax({
    2020                    type: 'GET',
    21                     url: nerd_url + 'service/kb/concept/' + wikipedia_id.split(":")[1] + '?lang=en',
     21                    url: '/nerd_kb_service/?url=' + encodeURIComponent('service/kb/concept/' + wikipedia_id.split(":")[1] + '?lang=en'),
    2222                    success: function(result) {
    23                         viewEntity(result, wikipedia_id, this_element);
     23                        viewEntity(jQuery.parseJSON(result), wikipedia_id, this_element);
    2424                    },
    2525                    complete: function() {
Note: See TracChangeset for help on using the changeset viewer.