All Projects → wikimedia → wikipedia-preview

wikimedia / wikipedia-preview

Licence: MIT license
wikimedia.github.io/wikipedia-preview/main

Programming Languages

javascript
184084 projects - #8 most used programming language
Less
1899 projects

Labels

Projects that are alternatives of or similar to wikipedia-preview

Taizen
curses based mediawiki browser
Stars: ✭ 249 (+492.86%)
Mutual labels:  wikipedia
wikipedia-reference-scraper
Wikipedia API wrapper for references
Stars: ✭ 34 (-19.05%)
Mutual labels:  wikipedia
on-this-day
App that serves and displays events, births and deaths that occurred during the queried day of history, scraped from Wikipedia
Stars: ✭ 12 (-71.43%)
Mutual labels:  wikipedia
Alfred Searchio
Alfred workflow to auto-suggest search results from multiple search engines and languages.
Stars: ✭ 250 (+495.24%)
Mutual labels:  wikipedia
cassandra-GLAM-tools
Support GLAMs in monitoring and evaluating their cooperation with Wikimedia projects
Stars: ✭ 17 (-59.52%)
Mutual labels:  wikipedia
Wikifeedia
☔ Wikipedia turned into a newsfeed
Stars: ✭ 43 (+2.38%)
Mutual labels:  wikipedia
Mwclient
Python client library to interface with the MediaWiki API
Stars: ✭ 221 (+426.19%)
Mutual labels:  wikipedia
wistalk
Wistalk : Analyze Wikipedia User's Activity
Stars: ✭ 19 (-54.76%)
Mutual labels:  wikipedia
go-wikidata
Wikidata API bindings in go.
Stars: ✭ 27 (-35.71%)
Mutual labels:  wikipedia
helpmebot
Helpmebot
Stars: ✭ 16 (-61.9%)
Mutual labels:  wikipedia
discord-wiki-bot
Wiki-Bot is a bot with the purpose to easily search for and link to wiki pages. Wiki-Bot shows short descriptions and additional info about the pages and is able to resolve redirects and follow interwiki links.
Stars: ✭ 69 (+64.29%)
Mutual labels:  wikipedia
HealthApp
A desktop application to fetch Wikipedia,Google,Disease results and save them as text file,in database.Have a Section to search details about doctors in location
Stars: ✭ 23 (-45.24%)
Mutual labels:  wikipedia
wikirepo
Python based Wikidata framework for easy dataframe extraction
Stars: ✭ 33 (-21.43%)
Mutual labels:  wikipedia
Alfred Web Search Suggest
Alfred search suggest workflow for various popular websites.
Stars: ✭ 249 (+492.86%)
Mutual labels:  wikipedia
tech-seo-crawler
Build a small, 3 domain internet using Github pages and Wikipedia and construct a crawler to crawl, render, and index.
Stars: ✭ 57 (+35.71%)
Mutual labels:  wikipedia
Wikipedia Api
Python wrapper for Wikipedia
Stars: ✭ 227 (+440.48%)
Mutual labels:  wikipedia
pw
Best websites a Programmer should visit
Stars: ✭ 27 (-35.71%)
Mutual labels:  wikipedia
wikibot
A 🤖 which provides features from Wikipedia like summary, title searches, location API etc.
Stars: ✭ 25 (-40.48%)
Mutual labels:  wikipedia
Spell4Wiki
Spell4Wiki is a mobile application to record and upload audio for Wiktionary words to Wikimedia commons. Also act as a Wiki-Dictionary.
Stars: ✭ 17 (-59.52%)
Mutual labels:  wikipedia
wikibot
Some MediaWiki bot examples including wikipedia, wikidata using MediaWiki module of CeJS library. 採用 CeJS MediaWiki 自動化作業用程式庫來製作 MediaWiki (維基百科/維基數據) 機器人的範例。
Stars: ✭ 26 (-38.1%)
Mutual labels:  wikipedia

CI

Wikipedia Preview

Wikipedia Preview is a JavaScript component that allows you to provide context from Wikipedia about words or phrases on any website. It lets you show a popup card with a short summary from Wikipedia when a reader hovers over a link.

Tasks and issues are tracked on Phabricator.

Desktop Mobile
Chat Chat

Storybook: https://wikimedia.github.io/wikipedia-preview/main/storybook

Compatibility

Browsers Versions
Chrome, Firefox, Opera, Edge Current and previous version
Internet Explorer 11+
Safari 5.1+
iOS 6.1+
Android 4.1+

Features

  • Works with any link that has an article on Wikipedia
  • Supports LTR and RTL languages
  • Works for articles with or without a lead image

Getting Started

Integrating Wikipedia Preview to your site consists of a three-step process:

  1. Loading wikipedia-preview.js (as a standalone script, WordPress plugin, or an npm dependency)
  2. Invoking wikipediaPreview.init( <options> )
  3. Annotating articles accordingly

You can read more about each step below. Once Wikipedia Preview is set up correctly, you should see the version information being logged in your JS console. You can also invoke wikipediaPreview.version() from your JS console to view version information at any time.

WordPress Plugin

A WordPress plugin providing a thin wrapper around Wikipedia Preview to simplify its integration and usage within WordPress is available on GitHub and WordPress.org.

Standalone Script

<script src="wikipedia-preview.production.js"></script>
<script type="text/javascript">
  wikipediaPreview.init()
</script>

You can serve the file yourself or include it from unpkg.

NPM

$ npm install wikipedia-preview --save
const wikipediaPreview = require('wikipedia-preview')
wikipediaPreview.init()

Options of the init function

The init function accepts the following options:

Name Type Default Description
root DOM Element document Where to look for elements that should have the popup
selector string '[data-wikipedia-preview]' How nodes that should have the popup are identified
lang string 'en' Default Wikipedia language
popupContainer DOM Element document.body Where to put the popup in the DOM
detectLinks Boolean false Allow Wikipedia hyperlinks to have the popup
events Object {} Custom event handlers: { onShow: <fn>, onWikiRead: <fn> }
debug Boolean false Shows the debug message when init() is called

Example (custom selector)

<p class="content">
	You can learn about <span class="wiki">Chat</span> and <span class="wiki">Chien</span> from Wikipedia.
</p>
<div class="popup-container"></div>
wikipediaPreview.init({
	root: document.querySelector('.content'),
	selector: '.wiki',
	popupContainer: '.popup-container',
	lang: 'fr'
});

Example (detect Wikipedia links)

<p class="content">
	You can learn about <a href="https://en.wikipedia.org/wiki/Chat">Chat</a> and <a href="https://en.wikipedia.org/wiki/Chien">Chien</a> from Wikipedia.
</p>
wikipediaPreview.init({
	detectLinks: true
});

Example (custom event handlers)

wikipediaPreview.init({
	events: {
		onShow: function(title, lang, type) {
			// call custom instrumentation here
		},
		onWikiRead: function(title, lang) {
			// call custom instrumentation here
		}
	}
});

Attributes

data-wikipedia-preview

To indicate that a word or expression should bring up the article preview popup, mark it with the data-wikipedia-preview attribute (or anything else as long as you're using the selector option described above).

data-wp-title

When the article title is not the same as the node's textContent property, use the data-wp-title attribute to specify the article title.

data-wp-lang

To use a language different than the language specified in the options, use the data-wp-lang attribute.

.wmf-wp-with-preview

To use the default trigger link styling:

  • Add the following link to the page header:
<link href="wikipedia-preview.css" rel="stylesheet">
  • Add the class wmf-wp-with-preview to the node

If you prefer to style them in a way that makes more sense for your context, simply don't include the wikipediaPreview.css link in the header and add your own class to the node. Both of these are valid ways:

[data-wikipedia-preview] {
	background-color: yellow;
}
.my-own-css-style {
	background-color: yellow;
}

Acknowledgements/Contributors

This is heavily inspired by jquery.wikilookup and Page Previews.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].