Skip to content

Commit

Permalink
Merge pull request #511 from spencermountain/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
spencermountain committed Dec 31, 2022
2 parents e40e5c4 + 6d7d7de commit c37ba13
Show file tree
Hide file tree
Showing 21 changed files with 410 additions and 241 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-and-test.yml
Expand Up @@ -8,7 +8,7 @@ jobs:

strategy:
matrix:
node-version: [12.x, 15.x, 16.x]
node-version: [12.x, 16.x, 18.x]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Expand Up @@ -15,7 +15,7 @@ jobs:

- uses: actions/setup-node@v1
with:
node-version: 12.x
node-version: 16.x

- name: cache dependencies
uses: actions/cache@v1
Expand Down
4 changes: 2 additions & 2 deletions builds/wtf_wikipedia-client.min.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions builds/wtf_wikipedia-client.mjs

Large diffs are not rendered by default.

86 changes: 57 additions & 29 deletions builds/wtf_wikipedia.cjs
@@ -1,4 +1,4 @@
/*! wtf_wikipedia 10.0.5 MIT */
/*! wtf_wikipedia 10.1.0 MIT */
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('isomorphic-unfetch')) :
typeof define === 'function' && define.amd ? define(['isomorphic-unfetch'], factory) :
Expand Down Expand Up @@ -1533,8 +1533,8 @@
nkcells: w + 'nkcells.info/index.php?title=$1',
nara: 'catalog.archives.gov/id/$1',
nosmoke: 'no-smok.net/nsmk/$1',
nost: 'nostalgia.' + wp,
nostalgia: 'nostalgia.' + wp,
nost: 'nostalgia' + wp,
nostalgia: 'nostalgia' + wp,
oeis: 'oeis.org/$1',
oldwikisource: 'wikisource.org/wiki/$1',
olpc: 'wiki.laptop.org/go/$1',
Expand Down Expand Up @@ -1615,10 +1615,10 @@
tabwiki: w + 'tabwiki.com/index.php/$1',
tclerswiki: 'wiki.tcl.tk/$1',
technorati: w + 'technorati.com/search/$1',
tenwiki: 'ten.' + wp,
testwiki: 'test.' + wp,
tenwiki: 'ten' + wp,
testwiki: 'test' + wp,
testwikidata: 'test.wikidata.org/wiki/$1',
test2wiki: 'test2.' + wp,
test2wiki: 'test2' + wp,
tfwiki: 'tfwiki.net/wiki/$1',
thelemapedia: w + 'thelemapedia.org/index.php/$1',
theopedia: w + 'theopedia.com/$1',
Expand Down Expand Up @@ -1651,7 +1651,7 @@
voipinfo: w + 'voip-info.org/wiki/view/$1',
votewiki: 'vote' + wm,
werelate: w + 'werelate.org/wiki/$1',
wg: 'wg-en.' + wp,
wg: 'wg-en' + wp,
wikia: w + 'wikia.com/wiki/w:c:$1',
wikiasite: w + 'wikia.com/wiki/w:c:$1',
wikiapiary: 'wikiapiary.com/wiki/$1',
Expand All @@ -1675,7 +1675,7 @@
wikinvest: 'meta.wikimedia.org/wiki/Interwiki_map/discontinued#Wikinvest',
wikiotics: 'wikiotics.org/$1',
wikipapers: 'wikipapers.referata.com/wiki/$1',
wikipedia: 'en.' + wp,
wikipedia: 'en' + wp,
wikipediawikipedia: 'en.wikipedia.org/wiki/Wikipedia:$1',
wikiquote: 'en.wikiquote.org/wiki/$1',
wikisophia: 'wikisophia.org/index.php?title=$1',
Expand Down Expand Up @@ -1776,23 +1776,23 @@
zwiki: w + 'zwiki.org/$1',
m: 'meta' + wm,
meta: 'meta' + wm,
sep11: 'sep11.' + wp,
sep11: 'sep11' + wp,
d: w + 'wikidata.org/wiki/$1',
minnan: 'zh-min-nan.' + wp,
nb: 'no.' + wp,
'zh-cfr': 'zh-min-nan.' + wp,
'zh-cn': 'zh.' + wp,
'zh-tw': 'zh.' + wp,
nan: 'zh-min-nan.' + wp,
vro: 'fiu-vro.' + wp,
cmn: 'zh.' + wp,
lzh: 'zh-classical.' + wp,
rup: 'roa-rup.' + wp,
gsw: 'als.' + wp,
'be-tarask': 'be-x-old.' + wp,
sgs: 'bat-smg.' + wp,
egl: 'eml.' + wp,
w: 'en.' + wp,
minnan: 'zh-min-nan' + wp,
nb: 'no' + wp,
'zh-cfr': 'zh-min-nan' + wp,
'zh-cn': 'zh' + wp,
'zh-tw': 'zh' + wp,
nan: 'zh-min-nan' + wp,
vro: 'fiu-vro' + wp,
cmn: 'zh' + wp,
lzh: 'zh-classical' + wp,
rup: 'roa-rup' + wp,
gsw: 'als' + wp,
'be-tarask': 'be-x-old' + wp,
sgs: 'bat-smg' + wp,
egl: 'eml' + wp,
w: 'en' + wp,
wikt: 'en.wiktionary.org/wiki/$1',
q: 'en.wikiquote.org/wiki/$1',
b: 'en.wikibooks.org/wiki/$1',
Expand Down Expand Up @@ -1840,7 +1840,7 @@
};

const ignore_links =
/^:?(category|catégorie|kategorie|categoría|categoria|categorie|kategoria|تصنيف|image|file|fichier|datei|media):/i;
/^(category|catégorie|kategorie|categoría|categoria|categorie|kategoria|تصنيف|image|file|fichier|datei|media):/i;
const external_link = /\[(https?|news|ftp|mailto|gopher|irc)(:\/\/[^\]| ]{4,1500})([| ].*?)?\]/g;
const link_reg = /\[\[(.{0,1600}?)\]\]([a-z]+)?/gi; //allow dangling suffixes - "[[flanders]]s"

Expand Down Expand Up @@ -1913,6 +1913,10 @@
}
obj.page = obj.page;
}
// support [[:Category:Foo]] syntax
if (obj.text && obj.text.startsWith(':')) {
obj.text = obj.text.replace(/^:/, '');
}
links.push(obj);
return s
});
Expand Down Expand Up @@ -3661,6 +3665,7 @@
const isFile = new RegExp('(' + images.join('|') + '):', 'i');
let fileNames = `(${images.join('|')})`;
const file_reg = new RegExp(fileNames + ':(.+?)[\\||\\]]', 'iu');
const linkToFile = /^\[\[:/;

//style directives for Wikipedia:Extended_image_syntax
const imgLayouts = {
Expand All @@ -3686,6 +3691,9 @@
if (m === null || !m[2]) {
return null
}
if (linkToFile.test(img)) {
return null
}
let file = `${m[1]}:${m[2] || ''}`;
if (file) {
let obj = {
Expand Down Expand Up @@ -3727,8 +3735,8 @@
let img = oneImage(s, doc);
if (img) {
paragraph.images.push(img);
wiki = wiki.replace(s, '');
}
wiki = wiki.replace(s, '');
}
});
paragraph.wiki = wiki;
Expand Down Expand Up @@ -5849,6 +5857,26 @@
list.push(obj);
return ''
},
//https://en.wikipedia.org/wiki/Template:MedalCount
'medalcount': (tmpl, list) => {
let all = parser(tmpl).list || [];
let lines = [];
for (let i = 0; i < all.length; i += 4) {
lines.push({
name: all[i],
'1st': Number(all[i + 1]),
'2nd': Number(all[i + 2]),
'3rd': Number(all[i + 3]),
});
console.log(all[i]);
}
let obj = {
template: 'medalcount',
list: lines
};
list.push(obj);
return ''
}
};

let templates$4 = {
Expand Down Expand Up @@ -7687,7 +7715,7 @@
return
}
// is it an Infobox?
if (json.template === 'infobox' && json.subbox !== 'yes' && !obj.nested) {
if (json.template === 'infobox' && json.subbox !== 'yes') {
json.domain = domain; //infoboxes need this for images, i guess
json.data = json.data || {}; //validate it a little
res.infoboxes.push(new Infobox(json, obj.wiki));
Expand Down Expand Up @@ -8750,7 +8778,7 @@
return removeReferenceSection(sections)
};

const cat_reg = new RegExp('\\[\\[:?(' + _categories.join('|') + '):(.{2,178}?)]](w{0,10})', 'gi');
const cat_reg = new RegExp('\\[\\[(' + _categories.join('|') + '):(.{2,178}?)]](w{0,10})', 'gi');
const cat_remove_reg = new RegExp('^\\[\\[:?(' + _categories.join('|') + '):', 'gi');

const parse_categories = function (wiki) {
Expand Down Expand Up @@ -9437,7 +9465,7 @@
})
};

var version = '10.0.5';
var version = '10.1.0';

/**
* use the native client-side fetch function
Expand Down
86 changes: 57 additions & 29 deletions builds/wtf_wikipedia.mjs
@@ -1,4 +1,4 @@
/*! wtf_wikipedia 10.0.5 MIT */
/*! wtf_wikipedia 10.1.0 MIT */
import unfetch from 'isomorphic-unfetch';

/**
Expand Down Expand Up @@ -1525,8 +1525,8 @@ var wikis = {
nkcells: w + 'nkcells.info/index.php?title=$1',
nara: 'catalog.archives.gov/id/$1',
nosmoke: 'no-smok.net/nsmk/$1',
nost: 'nostalgia.' + wp,
nostalgia: 'nostalgia.' + wp,
nost: 'nostalgia' + wp,
nostalgia: 'nostalgia' + wp,
oeis: 'oeis.org/$1',
oldwikisource: 'wikisource.org/wiki/$1',
olpc: 'wiki.laptop.org/go/$1',
Expand Down Expand Up @@ -1607,10 +1607,10 @@ var wikis = {
tabwiki: w + 'tabwiki.com/index.php/$1',
tclerswiki: 'wiki.tcl.tk/$1',
technorati: w + 'technorati.com/search/$1',
tenwiki: 'ten.' + wp,
testwiki: 'test.' + wp,
tenwiki: 'ten' + wp,
testwiki: 'test' + wp,
testwikidata: 'test.wikidata.org/wiki/$1',
test2wiki: 'test2.' + wp,
test2wiki: 'test2' + wp,
tfwiki: 'tfwiki.net/wiki/$1',
thelemapedia: w + 'thelemapedia.org/index.php/$1',
theopedia: w + 'theopedia.com/$1',
Expand Down Expand Up @@ -1643,7 +1643,7 @@ var wikis = {
voipinfo: w + 'voip-info.org/wiki/view/$1',
votewiki: 'vote' + wm,
werelate: w + 'werelate.org/wiki/$1',
wg: 'wg-en.' + wp,
wg: 'wg-en' + wp,
wikia: w + 'wikia.com/wiki/w:c:$1',
wikiasite: w + 'wikia.com/wiki/w:c:$1',
wikiapiary: 'wikiapiary.com/wiki/$1',
Expand All @@ -1667,7 +1667,7 @@ var wikis = {
wikinvest: 'meta.wikimedia.org/wiki/Interwiki_map/discontinued#Wikinvest',
wikiotics: 'wikiotics.org/$1',
wikipapers: 'wikipapers.referata.com/wiki/$1',
wikipedia: 'en.' + wp,
wikipedia: 'en' + wp,
wikipediawikipedia: 'en.wikipedia.org/wiki/Wikipedia:$1',
wikiquote: 'en.wikiquote.org/wiki/$1',
wikisophia: 'wikisophia.org/index.php?title=$1',
Expand Down Expand Up @@ -1768,23 +1768,23 @@ var wikis = {
zwiki: w + 'zwiki.org/$1',
m: 'meta' + wm,
meta: 'meta' + wm,
sep11: 'sep11.' + wp,
sep11: 'sep11' + wp,
d: w + 'wikidata.org/wiki/$1',
minnan: 'zh-min-nan.' + wp,
nb: 'no.' + wp,
'zh-cfr': 'zh-min-nan.' + wp,
'zh-cn': 'zh.' + wp,
'zh-tw': 'zh.' + wp,
nan: 'zh-min-nan.' + wp,
vro: 'fiu-vro.' + wp,
cmn: 'zh.' + wp,
lzh: 'zh-classical.' + wp,
rup: 'roa-rup.' + wp,
gsw: 'als.' + wp,
'be-tarask': 'be-x-old.' + wp,
sgs: 'bat-smg.' + wp,
egl: 'eml.' + wp,
w: 'en.' + wp,
minnan: 'zh-min-nan' + wp,
nb: 'no' + wp,
'zh-cfr': 'zh-min-nan' + wp,
'zh-cn': 'zh' + wp,
'zh-tw': 'zh' + wp,
nan: 'zh-min-nan' + wp,
vro: 'fiu-vro' + wp,
cmn: 'zh' + wp,
lzh: 'zh-classical' + wp,
rup: 'roa-rup' + wp,
gsw: 'als' + wp,
'be-tarask': 'be-x-old' + wp,
sgs: 'bat-smg' + wp,
egl: 'eml' + wp,
w: 'en' + wp,
wikt: 'en.wiktionary.org/wiki/$1',
q: 'en.wikiquote.org/wiki/$1',
b: 'en.wikibooks.org/wiki/$1',
Expand Down Expand Up @@ -1832,7 +1832,7 @@ const parseInterwiki = function (obj) {
};

const ignore_links =
/^:?(category|catégorie|kategorie|categoría|categoria|categorie|kategoria|تصنيف|image|file|fichier|datei|media):/i;
/^(category|catégorie|kategorie|categoría|categoria|categorie|kategoria|تصنيف|image|file|fichier|datei|media):/i;
const external_link = /\[(https?|news|ftp|mailto|gopher|irc)(:\/\/[^\]| ]{4,1500})([| ].*?)?\]/g;
const link_reg = /\[\[(.{0,1600}?)\]\]([a-z]+)?/gi; //allow dangling suffixes - "[[flanders]]s"

Expand Down Expand Up @@ -1905,6 +1905,10 @@ const internal_links = function (links, str) {
}
obj.page = obj.page;
}
// support [[:Category:Foo]] syntax
if (obj.text && obj.text.startsWith(':')) {
obj.text = obj.text.replace(/^:/, '');
}
links.push(obj);
return s
});
Expand Down Expand Up @@ -3653,6 +3657,7 @@ function nested_find(text) {
const isFile = new RegExp('(' + images.join('|') + '):', 'i');
let fileNames = `(${images.join('|')})`;
const file_reg = new RegExp(fileNames + ':(.+?)[\\||\\]]', 'iu');
const linkToFile = /^\[\[:/;

//style directives for Wikipedia:Extended_image_syntax
const imgLayouts = {
Expand All @@ -3678,6 +3683,9 @@ const oneImage = function (img, doc) {
if (m === null || !m[2]) {
return null
}
if (linkToFile.test(img)) {
return null
}
let file = `${m[1]}:${m[2] || ''}`;
if (file) {
let obj = {
Expand Down Expand Up @@ -3719,8 +3727,8 @@ const parseImages = function (paragraph, doc) {
let img = oneImage(s, doc);
if (img) {
paragraph.images.push(img);
wiki = wiki.replace(s, '');
}
wiki = wiki.replace(s, '');
}
});
paragraph.wiki = wiki;
Expand Down Expand Up @@ -5841,6 +5849,26 @@ var fns = {
list.push(obj);
return ''
},
//https://en.wikipedia.org/wiki/Template:MedalCount
'medalcount': (tmpl, list) => {
let all = parser(tmpl).list || [];
let lines = [];
for (let i = 0; i < all.length; i += 4) {
lines.push({
name: all[i],
'1st': Number(all[i + 1]),
'2nd': Number(all[i + 2]),
'3rd': Number(all[i + 3]),
});
console.log(all[i]);
}
let obj = {
template: 'medalcount',
list: lines
};
list.push(obj);
return ''
}
};

let templates$4 = {
Expand Down Expand Up @@ -7679,7 +7707,7 @@ const sortOut = function (list, domain) {
return
}
// is it an Infobox?
if (json.template === 'infobox' && json.subbox !== 'yes' && !obj.nested) {
if (json.template === 'infobox' && json.subbox !== 'yes') {
json.domain = domain; //infoboxes need this for images, i guess
json.data = json.data || {}; //validate it a little
res.infoboxes.push(new Infobox(json, obj.wiki));
Expand Down Expand Up @@ -8742,7 +8770,7 @@ const parseSections = function (doc) {
return removeReferenceSection(sections)
};

const cat_reg = new RegExp('\\[\\[:?(' + _categories.join('|') + '):(.{2,178}?)]](w{0,10})', 'gi');
const cat_reg = new RegExp('\\[\\[(' + _categories.join('|') + '):(.{2,178}?)]](w{0,10})', 'gi');
const cat_remove_reg = new RegExp('^\\[\\[:?(' + _categories.join('|') + '):', 'gi');

const parse_categories = function (wiki) {
Expand Down Expand Up @@ -9429,7 +9457,7 @@ const fetch = function (title, options, callback) {
})
};

var version = '10.0.5';
var version = '10.1.0';

/**
* use the native client-side fetch function
Expand Down

0 comments on commit c37ba13

Please sign in to comment.