Changeset 1947892
- Timestamp:
- 09/27/2018 08:35:08 AM (8 years ago)
- Location:
- nerd-wp
- Files:
-
- 11 edited
- 17 copied
-
tags/1.1.0 (copied) (copied from nerd-wp/trunk)
-
tags/1.1.0/.editorconfig (copied) (copied from nerd-wp/trunk/.editorconfig)
-
tags/1.1.0/.travis.yml (copied) (copied from nerd-wp/trunk/.travis.yml)
-
tags/1.1.0/AUTHORS (copied) (copied from nerd-wp/trunk/AUTHORS)
-
tags/1.1.0/CHANGELOG.md (copied) (copied from nerd-wp/trunk/CHANGELOG.md) (1 diff)
-
tags/1.1.0/LICENSE.txt (copied) (copied from nerd-wp/trunk/LICENSE.txt)
-
tags/1.1.0/README.txt (copied) (copied from nerd-wp/trunk/README.txt) (2 diffs)
-
tags/1.1.0/admin (copied) (copied from nerd-wp/trunk/admin)
-
tags/1.1.0/bin (copied) (copied from nerd-wp/trunk/bin)
-
tags/1.1.0/includes (copied) (copied from nerd-wp/trunk/includes)
-
tags/1.1.0/includes/class-nerd-wp.php (modified) (2 diffs)
-
tags/1.1.0/libraries (copied) (copied from nerd-wp/trunk/libraries)
-
tags/1.1.0/nerd-wp.php (copied) (copied from nerd-wp/trunk/nerd-wp.php) (1 diff)
-
tags/1.1.0/phpcs.xml.dist (copied) (copied from nerd-wp/trunk/phpcs.xml.dist)
-
tags/1.1.0/phpunit.xml.dist (copied) (copied from nerd-wp/trunk/phpunit.xml.dist)
-
tags/1.1.0/public (copied) (copied from nerd-wp/trunk/public)
-
tags/1.1.0/public/class-nerd-wp-public.php (modified) (2 diffs)
-
tags/1.1.0/public/class-nerd-wp-widget.php (modified) (3 diffs)
-
tags/1.1.0/public/js/nerd-wp-public.js (modified) (2 diffs)
-
tags/1.1.0/tests (copied) (copied from nerd-wp/trunk/tests)
-
tags/1.1.0/uninstall.php (copied) (copied from nerd-wp/trunk/uninstall.php)
-
trunk/CHANGELOG.md (modified) (1 diff)
-
trunk/README.txt (modified) (2 diffs)
-
trunk/includes/class-nerd-wp.php (modified) (2 diffs)
-
trunk/nerd-wp.php (modified) (1 diff)
-
trunk/public/class-nerd-wp-public.php (modified) (2 diffs)
-
trunk/public/class-nerd-wp-widget.php (modified) (3 diffs)
-
trunk/public/js/nerd-wp-public.js (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
nerd-wp/tags/1.1.0/CHANGELOG.md
r1925226 r1947892 7 7 ## Unreleased 8 8 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 10 14 ### Added 11 - 15 - First version of the NERD WP plugin -
nerd-wp/tags/1.1.0/README.txt
r1925256 r1947892 6 6 Tested up to: 4.9.1 7 7 Requires PHP: 5.6.35 8 Stable tag: 1. 0.08 Stable tag: 1.1.0 9 9 License: Apache License - 2.0 10 10 License URI: http://www.apache.org/licenses/LICENSE-2.0 … … 15 15 16 16 [NERD](https://github.com/kermitt2/entity-fishing) is an application that allows to recognize and disambiguate named entities. 17 This plugin allows integration of th iswith Wordpress. Each post can be run through NERD and will automatically create tags for it.17 This plugin allows integration of the NERD service with Wordpress. Each post can be run through NERD and will automatically create tags for it. 18 18 Those tags, in return are used to propose extra information coming from Wikipedia and Wikidata. 19 19 -
nerd-wp/tags/1.1.0/includes/class-nerd-wp.php
r1925226 r1947892 65 65 $this->version = NERD_WP_VERSION; 66 66 } else { 67 $this->version = '1. 0.0';67 $this->version = '1.1.0'; 68 68 } 69 69 $this->plugin_name = 'nerd-wp'; … … 173 173 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); 174 174 $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' ); 181 177 } 182 178 /** -
nerd-wp/tags/1.1.0/nerd-wp.php
r1925226 r1947892 17 17 * Plugin URI: https://github.com/dariah-eric/nerd-wp 18 18 * 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.019 * Version: 1.1.0 20 20 * Author: Yoann 21 21 * Author URI: https://www.dariah.eu -
nerd-wp/tags/1.1.0/public/class-nerd-wp-public.php
r1925226 r1947892 12 12 * @author Yoann Moranville <yoann.moranville@dariah.eu> 13 13 */ 14 use GuzzleHttp\Exception\RequestException; 14 15 class Nerd_Wp_Public { 15 16 /** … … 84 85 85 86 } 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 } 86 121 } -
nerd-wp/tags/1.1.0/public/class-nerd-wp-widget.php
r1925226 r1947892 2 2 3 3 class Nerd_Wp_Widget extends WP_Widget { 4 /**5 * The ID of this plugin.6 *7 * @since 1.0.08 * @access private9 * @var string $plugin_name The ID of this plugin.10 */11 private $plugin_name;12 4 13 function __construct( $plugin_name ) { 14 $this->plugin_name = $plugin_name; 5 function __construct() { 15 6 parent::__construct( 'nerd_wp_widget', __( 'NERD WP Widget', 'nerd_wp_domain' ), array( 16 7 'description' => __( 'NERD WP Widget', 'nerd_wp_domain' ) … … 55 46 } 56 47 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>'; 69 53 echo $args['after_widget']; 70 54 } … … 81 65 } 82 66 83 function nerd_wp_widget( \WP_Widget $widget) {84 register_widget( $ widget);67 function nerd_wp_widget() { 68 register_widget( $this ); 85 69 } 86 70 } -
nerd-wp/tags/1.1.0/public/js/nerd-wp-public.js
r1925226 r1947892 1 function hoverEntity( nerd_url) {1 function hoverEntity() { 2 2 jQuery(".nerd_tags").each(function(index, value) { 3 3 var wiki_ids = jQuery(this).attr('id'); … … 19 19 jQuery.ajax({ 20 20 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'), 22 22 success: function(result) { 23 viewEntity( result, wikipedia_id, this_element);23 viewEntity(jQuery.parseJSON(result), wikipedia_id, this_element); 24 24 }, 25 25 complete: function() { -
nerd-wp/trunk/CHANGELOG.md
r1925226 r1947892 7 7 ## Unreleased 8 8 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 10 14 ### Added 11 - 15 - First version of the NERD WP plugin -
nerd-wp/trunk/README.txt
r1925256 r1947892 6 6 Tested up to: 4.9.1 7 7 Requires PHP: 5.6.35 8 Stable tag: 1. 0.08 Stable tag: 1.1.0 9 9 License: Apache License - 2.0 10 10 License URI: http://www.apache.org/licenses/LICENSE-2.0 … … 15 15 16 16 [NERD](https://github.com/kermitt2/entity-fishing) is an application that allows to recognize and disambiguate named entities. 17 This plugin allows integration of th iswith Wordpress. Each post can be run through NERD and will automatically create tags for it.17 This plugin allows integration of the NERD service with Wordpress. Each post can be run through NERD and will automatically create tags for it. 18 18 Those tags, in return are used to propose extra information coming from Wikipedia and Wikidata. 19 19 -
nerd-wp/trunk/includes/class-nerd-wp.php
r1925226 r1947892 65 65 $this->version = NERD_WP_VERSION; 66 66 } else { 67 $this->version = '1. 0.0';67 $this->version = '1.1.0'; 68 68 } 69 69 $this->plugin_name = 'nerd-wp'; … … 173 173 $this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' ); 174 174 $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' ); 181 177 } 182 178 /** -
nerd-wp/trunk/nerd-wp.php
r1925226 r1947892 17 17 * Plugin URI: https://github.com/dariah-eric/nerd-wp 18 18 * 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.019 * Version: 1.1.0 20 20 * Author: Yoann 21 21 * Author URI: https://www.dariah.eu -
nerd-wp/trunk/public/class-nerd-wp-public.php
r1925226 r1947892 12 12 * @author Yoann Moranville <yoann.moranville@dariah.eu> 13 13 */ 14 use GuzzleHttp\Exception\RequestException; 14 15 class Nerd_Wp_Public { 15 16 /** … … 84 85 85 86 } 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 } 86 121 } -
nerd-wp/trunk/public/class-nerd-wp-widget.php
r1925226 r1947892 2 2 3 3 class Nerd_Wp_Widget extends WP_Widget { 4 /**5 * The ID of this plugin.6 *7 * @since 1.0.08 * @access private9 * @var string $plugin_name The ID of this plugin.10 */11 private $plugin_name;12 4 13 function __construct( $plugin_name ) { 14 $this->plugin_name = $plugin_name; 5 function __construct() { 15 6 parent::__construct( 'nerd_wp_widget', __( 'NERD WP Widget', 'nerd_wp_domain' ), array( 16 7 'description' => __( 'NERD WP Widget', 'nerd_wp_domain' ) … … 55 46 } 56 47 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>'; 69 53 echo $args['after_widget']; 70 54 } … … 81 65 } 82 66 83 function nerd_wp_widget( \WP_Widget $widget) {84 register_widget( $ widget);67 function nerd_wp_widget() { 68 register_widget( $this ); 85 69 } 86 70 } -
nerd-wp/trunk/public/js/nerd-wp-public.js
r1925226 r1947892 1 function hoverEntity( nerd_url) {1 function hoverEntity() { 2 2 jQuery(".nerd_tags").each(function(index, value) { 3 3 var wiki_ids = jQuery(this).attr('id'); … … 19 19 jQuery.ajax({ 20 20 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'), 22 22 success: function(result) { 23 viewEntity( result, wikipedia_id, this_element);23 viewEntity(jQuery.parseJSON(result), wikipedia_id, this_element); 24 24 }, 25 25 complete: function() {
Note: See TracChangeset
for help on using the changeset viewer.