Extension:GoogleKnowledgeGraph

Category:Extensions without an imageCategory:Extensions without a compatibility policyCategory:MIT licensed extensions
MediaWiki extensions manual
GoogleKnowledgeGraph
Release status: betaCategory:Beta status extensions
Implementation Tag Category:Tag extensions, API Category:API extensions
Description The GoogleKnowledgeGraph extension automatically gets short summary from Google Knowledge Graph and adds it to a tooltip.
Author(s) Urfiner (Nikolai Kochkin)
Latest version 0.1.0
MediaWiki 1.43Category:Extensions with manual MediaWiki version
License MIT License
Download Category:Extensions in GitHub version control
Category:All extensionsCategory:Extensions not in ExtensionJson

The GoogleKnowledgeGraph extension automatically gets short summary from Google Knowledge Graph and adds it to a tooltip.

The extension developed to help newcommers understand how to create a simple extension with frontend/backend (parser+api). The code of the extension is well-commented to make it easy to understand.

Production usage of the extension is not recommended.

Usage

Put something like that on your page:

<GoogleKnowledgeGraph query="Mario"/>

And save the page. After that hover cursor on the word "Mario" and see:

Production usage disclamer

The extension is not recommended for production usage:

  1. Google Knowledge Graph provides only 100 000 requests for free per day.
    1. For small wikis it is more than enough but on big ones the limit will be depleted quite soon.
    2. Howewer, adding long-living cache may significantly improve the situation if for some reason you still want to use it in prod. There is a comment in code how a simple caching can be added.
  2. It is not a big issue for English but Google Knowledge Graph supports search terms in Nominative case only.
    1. In the future we can add something like that (synthax is not supported yet): <GoogleKnowledgeGraph query="Mario">visible text</GoogleKnowledgeGraph>.

Installation and configuration

The extension tested on MediaWiki 1.35. Probably it will work on 1.29+ (the used hooks are quite old).

To install the extension:

  1. Clone the repository to your extensions/ subfolder: git clone https://github.com/Griboedow/GoogleKnowledgeGraph.git
  2. Load the extension in your LocalSettings.php: wfLoadExtension( 'GoogleKnowledgeGraph' );
  3. Configure API key:
    1. Get Google API token here
    2. In LocalSettings.php set your key: $wgGoogleApiToken = 'your-google-token';
  4. Setup language:$wgGoogleApiLanguage = 'en';

Done!

Category:Extensions that are just for fun Category:Extension examples Category:Simple extensions
Category:API extensions Category:All extensions Category:Beta status extensions Category:Extension examples Category:Extensions in GitHub version control Category:Extensions not in ExtensionJson Category:Extensions that are just for fun Category:Extensions with manual MediaWiki version Category:Extensions without a compatibility policy Category:Extensions without an image Category:MIT licensed extensions Category:OutputPageParserOutput extensions Category:ParserFirstCallInit extensions Category:Simple extensions Category:Tag extensions