Skip to content

Commit

Permalink
cleanup babel lib
Browse files Browse the repository at this point in the history
  • Loading branch information
spencermountain committed Mar 31, 2022
1 parent c53bca4 commit 4764de1
Show file tree
Hide file tree
Showing 31 changed files with 16,478 additions and 29,771 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
**/node_modules/
node_modules/
**/builds/
*.test.js
5 changes: 4 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
"browser": true,
"node": true
},
"globals": {
"URL": "writable"
},
"parserOptions": {
"ecmaVersion": 2018,
"ecmaVersion": 2020,
"sourceType": "module",
"ecmaFeatures": {}
},
Expand Down
150 changes: 69 additions & 81 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,28 +53,14 @@
<br/>
<img height="30px" src="https://user-images.githubusercontent.com/399657/68221862-17ceb980-ffb8-11e9-87d4-7b30b6488f16.png"/>
we put our information in places we can't take it out.
<br/>
information in wikipedia can't <i>be used</i>
</div>

<!-- spacer -->
<img height="15px" src="https://user-images.githubusercontent.com/399657/68221862-17ceb980-ffb8-11e9-87d4-7b30b6488f16.png"/>
<div align="center">
<div >and it's not just wikipedia</div>
it's
<ul >
<li>dj set-lists</li>
<li>mathematical proofs</li>
<li>e-sports rankings</li>
<li>dictionary information</li>
</ul>
</div>

<!-- spacer -->
<img height="50px" src="https://user-images.githubusercontent.com/399657/68221862-17ceb980-ffb8-11e9-87d4-7b30b6488f16.png"/>

```js
const wtf = require('wtf_wikipedia')
import wtf from 'wtf_wikipedia' // or require('wtf_wikipedia')

wtf.fetch('Toronto Raptors').then((doc) => {
let coach = doc.infobox().get('coach')
Expand Down Expand Up @@ -164,10 +150,10 @@ run it on the client-side:
</script>
```

or in Deno/typescript/webpack:
or the server-side:

```js
import wtf from 'https://unpkg.com/wtf_wikipedia'
import wtf from 'wtf_wikipedia'
```

<!-- spacer -->
Expand Down Expand Up @@ -197,66 +183,6 @@ npm install -g dumpster-dive
<img height="50px" src="https://user-images.githubusercontent.com/399657/68221824-09809d80-ffb8-11e9-9ef0-6ed3574b0ce8.png"/>
</div>

## Tutorials

- [Gentle Introduction](https://observablehq.com/@spencermountain/wtf_wikipedia-tutorial?collection=@spencermountain/wtf_wikipedia) - Getting NBA Team data
- [Parsing tables](https://observablehq.com/@spencermountain/parsing-wikipedia-tables) - getting all Apollo Astronauts as JSON
- [Parsing Timezones](https://observablehq.com/@spencermountain/parsing-timezones-from-wikipedia)
- [MBL season schedules](https://observablehq.com/@spencermountain/wikipedia-baseball-table-parser?collection=@spencermountain/wtf_wikipedia)
- [Fetching a list of pages](https://observablehq.com/@spencermountain/parsing-a-list-of-wikipedia-articles)
- [Parsing COVID outbreak table](https://observablehq.com/@spencermountain/parsing-wikipedias-coronavirus-outbreak-data?collection=@spencermountain/wtf_wikipedia)

<!-- spacer -->
<img height="50px" src="https://user-images.githubusercontent.com/399657/68221862-17ceb980-ffb8-11e9-87d4-7b30b6488f16.png"/>
<div align="center">
<img height="50px" src="https://user-images.githubusercontent.com/399657/68221824-09809d80-ffb8-11e9-9ef0-6ed3574b0ce8.png"/>
</div>

## Plugins

these add all sorts of new functionality:

```js
wtf.extend(require('wtf-plugin-classify'))
await wtf.fetch('Toronto Raptors').classify()
// 'Organization/SportsTeam'

wtf.extend(require('wtf-plugin-summary'))
await wtf.fetch('Pulp Fiction').summary()
// 'a 1994 American crime film'

wtf.extend(require('wtf-plugin-person'))
await wtf.fetch('David Bowie').birthDate()
// {year:1947, date:8, month:1}

wtf.extend(require('wtf-plugin-i18n'))
await wtf.fetch('Ziggy Stardust', 'fr').infobox().json()
// {nom:{text:"Ziggy Stardust"}, oeuvre:{text:"The Rise and Fall of Ziggy Stardust"}}
```

| **Plugin** | |
| ---------------------------------------------------------- | --------------------------------------- |
| [classify](./plugins/classify) | person/place/thing |
| [summary](./plugins/summary) | short description text |
| [person](./plugins/person) | birth/death information |
| [api](./plugins/api) | fetch more data from the API |
| [i18n](./plugins/i18n) | improves multilingual template coverage |
| [wtf-mlb](https://github.com/spencermountain/wtf-mlb) | fetch baseball data |
| [wtf-nhl](https://github.com/spencermountain/wtf-nhl) | fetch hockey data |
| [nsfw](https://github.com/spencermountain/wtf-plugin-nsfw) | flag sexual/graphic/adult articles |
| [image](./plugins/image) | additional methods for `.images()` |
| [html](./plugins/html) | output html |
| [wikitext](./plugins/wikitext) | output wikitext |
| [markdown](./plugins/markdown) | output markdown |
| [latex](./plugins/latex) | output latex |

<div align="right">
<a href="https://observablehq.com/@spencermountain/wtf-wikipedia-plugins">plugin docs</a>
</div>
<div align="center">
<img height="50px" src="https://user-images.githubusercontent.com/399657/68221824-09809d80-ffb8-11e9-9ef0-6ed3574b0ce8.png"/>
</div>

### Ok first, 🛀

[Wikitext](https://en.wikipedia.org/wiki/Help:Wikitext) is no small thing.
Expand Down Expand Up @@ -332,7 +258,7 @@ This library has (_lovingly_) borrowed a lot of code and data from the parsoid p
<img height="50px" src="https://user-images.githubusercontent.com/399657/68221824-09809d80-ffb8-11e9-9ef0-6ed3574b0ce8.png"/>
</div>

## enough chat.
#### okay,

flip your wikitext into a Doc object

Expand Down Expand Up @@ -467,6 +393,69 @@ wtf.random().then((doc) => {

see [wtf-plugin-api](./plugins/api)



## Tutorials

- [Gentle Introduction](https://observablehq.com/@spencermountain/wtf_wikipedia-tutorial?collection=@spencermountain/wtf_wikipedia) - Getting NBA Team data
- [Parsing tables](https://observablehq.com/@spencermountain/parsing-wikipedia-tables) - getting all Apollo Astronauts as JSON
- [Parsing Timezones](https://observablehq.com/@spencermountain/parsing-timezones-from-wikipedia)
- [MBL season schedules](https://observablehq.com/@spencermountain/wikipedia-baseball-table-parser?collection=@spencermountain/wtf_wikipedia)
- [Fetching a list of pages](https://observablehq.com/@spencermountain/parsing-a-list-of-wikipedia-articles)
- [Parsing COVID outbreak table](https://observablehq.com/@spencermountain/parsing-wikipedias-coronavirus-outbreak-data?collection=@spencermountain/wtf_wikipedia)

<!-- spacer -->
<img height="50px" src="https://user-images.githubusercontent.com/399657/68221862-17ceb980-ffb8-11e9-87d4-7b30b6488f16.png"/>
<div align="center">
<img height="50px" src="https://user-images.githubusercontent.com/399657/68221824-09809d80-ffb8-11e9-9ef0-6ed3574b0ce8.png"/>
</div>

## Plugins

these add all sorts of new functionality:

```js
wtf.extend(require('wtf-plugin-classify'))
await wtf.fetch('Toronto Raptors').classify()
// 'Organization/SportsTeam'

wtf.extend(require('wtf-plugin-summary'))
await wtf.fetch('Pulp Fiction').summary()
// 'a 1994 American crime film'

wtf.extend(require('wtf-plugin-person'))
await wtf.fetch('David Bowie').birthDate()
// {year:1947, date:8, month:1}

wtf.extend(require('wtf-plugin-i18n'))
await wtf.fetch('Ziggy Stardust', 'fr').infobox().json()
// {nom:{text:"Ziggy Stardust"}, oeuvre:{text:"The Rise and Fall of Ziggy Stardust"}}
```

| **Plugin** | |
| ---------------------------------------------------------- | --------------------------------------- |
| [classify](./plugins/classify) | person/place/thing |
| [summary](./plugins/summary) | short description text |
| [person](./plugins/person) | birth/death information |
| [api](./plugins/api) | fetch more data from the API |
| [i18n](./plugins/i18n) | improves multilingual template coverage |
| [wtf-mlb](https://github.com/spencermountain/wtf-mlb) | fetch baseball data |
| [wtf-nhl](https://github.com/spencermountain/wtf-nhl) | fetch hockey data |
| [nsfw](https://github.com/spencermountain/wtf-plugin-nsfw) | flag sexual/graphic/adult articles |
| [image](./plugins/image) | additional methods for `.images()` |
| [html](./plugins/html) | output html |
| [wikitext](./plugins/wikitext) | output wikitext |
| [markdown](./plugins/markdown) | output markdown |
| [latex](./plugins/latex) | output latex |

<div align="right">
<a href="https://observablehq.com/@spencermountain/wtf-wikipedia-plugins">plugin docs</a>
</div>
<div align="center">
<img height="50px" src="https://user-images.githubusercontent.com/399657/68221824-09809d80-ffb8-11e9-9ef0-6ed3574b0ce8.png"/>
</div>


### Good practice:

The wikipedia api is [pretty welcoming](https://www.mediawiki.org/wiki/API:Etiquette#Request_limit) though recommends three things, if you're going to hit it heavily -
Expand Down Expand Up @@ -721,12 +710,11 @@ Please make a PR if you see something missing for your language.

this library ships seperate client-side and server-side builds, to preserve filesize.

- _[./wtf_wikipedia-client.js](./builds/wtf_wikipedia-client.js)_ - with sourcemap
- _[./wtf_wikipedia-client.mjs](./builds/wtf_wikipedia-client.mjs)_ - as es-module (or Deno)
- _[./wtf_wikipedia-client.min.js](./builds/wtf_wikipedia-client.min.js)_ - for production

- _[./wtf_wikipedia.js](./builds/wtf_wikipedia.js)_ - main node build
- _[./wtf_wikipedia.mjs](./builds/wtf_wikipedia.mjs)_ - esmodule node (deno/typescript)
- _[./wtf_wikipedia.cjs](./builds/wtf_wikipedia.js)_ - node commonjs build
- _[./wtf_wikipedia.mjs](./builds/wtf_wikipedia.mjs)_ - node/deno/typescript esm build

the browser version uses `fetch()` and the server version uses `require('https')`.

Expand Down
Loading

0 comments on commit 4764de1

Please sign in to comment.