-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
edcce1c
commit 8d83a9d
Showing
5 changed files
with
42 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Instructions for parsing OpenStreetMap's wiki at [https://wiki.openstreetmap.org](https://wiki.openstreetmap.org) | ||
|
||
|
||
```js | ||
wtf.extend(require('./plugin.js')) | ||
``` | ||
|
||
The OSM wiki api uses a custom path: | ||
```js | ||
wtf.fetch('https://wiki.openstreetmap.org/wiki/Tag:highway%3Dmotorway', { path: '/w/api.php' }).then((doc) => { | ||
console.log(doc.templates('ValueDescription')) | ||
}) | ||
``` | ||
|
||
Some of the data in the osm wiki, such as [Map_features](https://wiki.openstreetmap.org/wiki/Map_features) is generated dynamically through [{{Taglist}}](https://wiki.openstreetmap.org/wiki/Taginfo/Taglists), which means it cannot be retrieved. | ||
|
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const boxes = { | ||
KeyDescription: true, | ||
ValueDescription: true, | ||
Place: true, | ||
} | ||
|
||
const plugin = (models, templates, infoboxes) => { | ||
// add infoboxes | ||
Object.assign(infoboxes, boxes) | ||
// add templates | ||
templates.tag = (text, data) => { | ||
console.log(data) | ||
return | ||
} | ||
} | ||
module.exports = plugin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,18 @@ | ||
const wtf = require('./src/index') | ||
wtf.extend(require('./plugins/api/src')) | ||
|
||
const getBox = function (doc) { | ||
let box = doc.infobox('currency') //.json() | ||
let res = box.get(['iso_code', 'subunit_name_1', 'symbol']).map((s) => s.text()) | ||
return { | ||
title: doc.title(), | ||
iso: res[0], | ||
subUnit: res[1], | ||
symbol: res[2], | ||
const plugin = (models, templates) => { | ||
// add templates | ||
templates.tag = (text, data, c, d) => { | ||
console.log(d) | ||
return | ||
} | ||
} | ||
|
||
// const getAll = async function (tmpl) { | ||
// let pages = await wtf.getTemplatePages(tmpl) | ||
// let docs = await wtf.fetchList(pages) | ||
// return docs.map(getBox) | ||
// } | ||
// console.log(JSON.stringify(getAll('Template:Infobox currency'), null, 2)) | ||
wtf.extend(plugin) | ||
|
||
// wtf.fetch('Brunei dollar').then((doc) => { | ||
// console.log(getBox(doc)) | ||
// wtf.fetch('https://wiki.openstreetmap.org/wiki/Tag:highway%3Dmotorway', { path: '/w/api.php' }).then((doc) => { | ||
// // console.log(doc.templates('ValueDescription')) | ||
// }) | ||
|
||
// wtf.fetch('https://wiki.openstreetmap.org/wiki/Tag:highway%3Dmotorway', { path: '/w/api.php' }).then((doc) => { | ||
wtf.fetch('https://wiki.openstreetmap.org/wiki/Tag:highway%3Dmotorway').then((doc) => { | ||
console.log(doc.templates('ValueDescription')) | ||
}) | ||
wtf(`{{Tag|aerialway|subkey=occupancy}}`) |