Skip to content

Commit 1e875e0

Browse files
Merge pull request #571 from spencermountain/dev
Dev
2 parents e49e3c2 + 32d6737 commit 1e875e0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+4562
-630
lines changed

README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ run it on the client-side:
138138
```html
139139
<script src="https://unpkg.com/wtf_wikipedia"></script>
140140
<script>
141-
wtf.fetch('Radiohead', {'Api-User-Agent': 'Name your script here'}, function (err, doc) {
141+
wtf.fetch('Radiohead', { 'Api-User-Agent': 'Name your script here' }, function (err, doc) {
142142
let members = doc.infobox().get('current members')
143143
members.links().map((l) => l.page())
144144
//['Thom Yorke', 'Jonny Greenwood', 'Colin Greenwood'...]
@@ -276,7 +276,9 @@ wtf(txt)
276276

277277
```javascript
278278
let txt = `Whistling is featured in a number of television shows, such as [[Lassie (1954 TV series)|''Lassie'']], and the title theme for ''[[The X-Files]]''.`
279-
wtf(txt).links().map((l) => l.page())
279+
wtf(txt)
280+
.links()
281+
.map((l) => l.page())
280282
// [ 'Lassie (1954 TV series)', 'The X-Files' ]
281283
```
282284

@@ -285,7 +287,8 @@ wtf(txt).links().map((l) => l.page())
285287
returns nice plain-text of the article
286288

287289
```js
288-
let txt = "[[Greater_Boston|Boston]]'s [[Fenway_Park|baseball field]] has a {{convert|37|ft}} wall.<ref>{{cite web|blah}}</ref>"
290+
let txt =
291+
"[[Greater_Boston|Boston]]'s [[Fenway_Park|baseball field]] has a {{convert|37|ft}} wall.<ref>{{cite web|blah}}</ref>"
289292
wtf(txt).text()
290293
//"Boston's baseball field has a 37ft wall."
291294
```
@@ -395,7 +398,6 @@ wtf.random().then((doc) => {
395398

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

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

@@ -459,7 +461,6 @@ await wtf.fetch('Ziggy Stardust', 'fr').infobox().json()
459461
<img height="50px" src="https://user-images.githubusercontent.com/399657/68221824-09809d80-ffb8-11e9-9ef0-6ed3574b0ce8.png"/>
460462
</div>
461463

462-
463464
### Good practice:
464465

465466
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 -
@@ -497,6 +498,7 @@ wtf
497498
- **.isRedirect()** - if the page is just a redirect to another page
498499
- **.redirectTo()** - the page this redirects to
499500
- **.isDisambiguation()** - is this a placeholder page to direct you to one-of-many possible pages
501+
- **.isStub()** - if the page is flagged as incomplete
500502
- **.categories()** - return all categories of the document
501503
- **.sections()** - return a list of the Document's sections
502504
- **.paragraphs()** - return a list of Paragraphs, in all sections
@@ -512,6 +514,10 @@ wtf
512514
- **.text()** - plaintext, human-readable output for the page
513515
- **.json()** - a 'stringifyable' output of the page's main data
514516
- **.wikitext()** - original wiki markup
517+
- **.description()** - get/set the page's short description, if we have one.
518+
- **.pageImage()** - get/set the page's representative image, if we have one.
519+
- **.revisionID()** - get/set the latest edit id of the page, if we have it.
520+
- **.timestamp()** - get/set the time of the most recent edit of the page, if we have it.
515521

516522
### Section
517523

@@ -659,12 +665,12 @@ by default, if there's no parser for a template, it will be just ignored and gen
659665
However, it's possible to configure a fallback parser function to handle these templates:
660666

661667
```js
662-
wtf('some {{weird_template}} here', {
668+
wtf('some {{weird_template}} here', {
663669
templateFallbackFn: (tmpl, list, parse) => {
664670
let obj = parse(tmpl) //or do a custom regex
665671
list.push(obj)
666672
return '[unsupported template]' // or return null to ignore this template
667-
}
673+
},
668674
})
669675
```
670676

builds/wtf_wikipedia-client.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

builds/wtf_wikipedia-client.mjs

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)