-
Notifications
You must be signed in to change notification settings - Fork 129
Home
Application of wtf_wikipedia
can be used in the following context:
- fetch and parse one or more Wikipedia or Wikiversity articles and provide the results e.g. in an aggregated form (e.g. Wikibook in PDF format rendered on the client side). Rendering on the client side is helpful to reduce the workload and costs on the servers of the Wiki Foundation.
- process the content and extract specific content elements for further analysis,
- Wikipedia pages contain content to specific geolocations. Together with Augmented Reality packages, like Location based AR.js an article in Wikipedia about the Forum Romanum in Rome Italy can be comibined with 3D models of the Forum Romanum and learning resources can be assigned to real geolocation of the Forum Romanum in Rome. To do this the content about the Forum Romanum must be parsed from Wikipedia and geolocation (see top right on Wikipedia article ) must be extract to location the digital 3D model and the Wikipedia article to correct geolocation
The example and use-case about shows basic principle to provide Open Educational Resources to specific geolocation. The requirements and constraints analysis for such a use case will help to understand, how wtf_wikipedia
will you to implement such OER learning resources.
- Wikiversity Article with Mathematical Expression
-
Export Format RevealJS Presentation - currently static export with PanDocElectron - can be generated on the fly with
wtf_wikipedia
with RevealJS export format. - Wiki2Reveal as online demo to create dynamically from Wiki source text a reveal presentation.
If you just want the source text of an MediaWiki article, call the API in the browser. The following example just downloads an article about Toronto from the english Wikipedia and the learning resource about Water from english Wikiversity.
var wtf = require('wtf_wikipedia');
//call the API and process the markup 'pWikiSource' in the callback function of the API
wtf.fetch('Toronto', 'en', function(err, doc) {
// do something with parsed document in doc returned by the callback function
console.log("JSON: doc="+JSON.stringify(doc,null,2))
});
You can fetch article e.g. from Wikiversity from the url: https:// en.wikiversity.org/wiki/Water with the following javascript code
wtf.fetch('Water', 'enwikiversity', function(pError, pDoc) {
// do something with parsed document in doc
// returned by the callback function
if (pError) {
console.error("ERROR: "+pError)
} else {
console.log("JSON: doc="+JSON.stringify(pDoc,null,2))
}
});
Remark: To distinguish local variables from parameters of functions a preceeding p
can used to indicate that (e.g. pWikiSource
). This denomination of parameters variables is just a support for reading the code without any impact on the Javascript interpretation of code.
You can retrieve the Wiki markdown from different MediaWiki products of the WikiFoundation. The domain name includes the Wiki product (e.g. Wikipedia or Wikiversity) and a language. The WikiID encoded the language and the domain determines the API that is called for fetching the source Wiki. The following WikiIDs are referring to the following domain name.
-
en
: https://en.wikipedia.org -
enwiki
: https://en.wikipedia.org -
enwikipedia
: https://en.wikipedia.org -
enwikibooks
: https://en.wikibooks.org', -
enwikinews
: https://en.wikinews.org', -
enwikiquote
: https://en.wikiquote.org', -
enwikisource
: https://en.wikisource.org', -
enwikiversity
: https://en.wikiversity.org', -
enwikivoyage
: https://en.wikivoyage.org'
If you use just the language identifier en
then wtf_wikipedia
assumes that the wiki is Wikipedia
. The same is applied if you just use enwiki
. Due to the fact that the Wiki Foundation has severval MediaWikis with a different content scope, also enwiki
is mapped to the english Wikipedia.
var wtf = require('wtf_wikipedia');
// Fetch the article about '3D Modelling' in english Wikiversity from the domain https://en.wikiversity.org
// call the API and process the markup 'pWikiSource' in the callback function of the API
wtf.fecth('3D Modelling', 'enwikiversity', function(pWikiSource) {
// do something with wiki markup return by the callback function in the parameter pWikiSource (String)
});
If you want to fetch Wiki markdown with a different language (e.g. german Wikiversity) use the appropriate language ID (e.g. de
for german).
-
de
: https://de.wikipedia.org -
dewiki
: https://de.wikipedia.org -
dewikipedia
: https://de.wikipedia.org -
dewikibooks
: https://de.wikibooks.org', -
dewikinews
: https://de.wikinews.org', -
dewikiquote
: https://de.wikiquote.org', -
dewikisource
: https://de.wikisource.org', -
dewikiversity
: https://de.wikiversity.org', -
dewikivoyage
: https://de.wikivoyage.org'
In previous versions of wtf_wikipedia
the wiki identifier (wikiid
) used for Wikipedia
the domain specification wiki
. To be consistent with wiki product specification part in the domain name wikipedia
the following wiki IDs are added to list of Wiki ID mapping (defined in the file /src/data/site_map.js
as hash).
-
enwikipedia
: https://en.wikipedia.org -
dewikipedia
: https://de.wikipedia.org
The additional entries for a consistent WikiID mapping are added with a regular expression (Perl-like)
If you can set up you own Media Wiki or want to fetch from an other Media Wiki which was not hosted by the Wiki Foundation, then you have to pass the wikiURL as options to wtf.fetch
let options = {
wikiUrl: 'https://dota2.gamepedia.com/api.php'
}
wtf.fetch('Abaddon', 'dota2', options).then(function(doc) {
console.log(doc.json())
})
Added to Wiki according to discussion in issues.
- Parsing Concepts are based on Parsoid - https://www.mediawiki.org/wiki/Parsoid
- Output: Based on concepts of the swiss-army knife of
document conversion
developed by John MacFarlane PanDoc - https://www.pandoc.org