add Cookbook page
|
NZ DoC
Summary: Use DoC API to retrieve campsites, huts, and tracks information to display in PmWiki
Version: 2020-06-10
Prerequisites: PmWiki 2.2.130 (PHP 7.4 compatible)
Status: Production
Questions answered by this recipe
How do I display information from Te Papa AtawhaiNew Zealand's Department of Conservation on campsites, huts, and tracks information on a PmWiki page?
Description
This recipe generates the markup for the display of Department of Conservation information
The recipe uses the DoC API to retrieve campsites, huts, and tracks information to display in a PmWiki wiki.
Installation
Usage
Place the directive, as described below, in your PmWiki page.
The recipe provides a page variable {$NZDoCVersion} which contains the current version, and page variable $NZDoC for a (:if enabled NZDoC:) recipe installation check.
DoC regions
You have to ask to find these out, they are not provided in DoC's information about the API
CODE | REGION |
NZ-NTL | Northland |
NZ-AUK | Auckland |
NZ-WKO | Waikato |
DOC-COR | Coromandel |
NZ-BOP | Bay of Plenty |
NZ-GIS | East Coast |
NZ-TKI | Taranaki |
NZ-MWT | Manawatu/Whanganui |
DOC-CNI | Central North Island |
NZ-HKB | Hawke's Bay |
NZ-WGN | Wellington/Kapiti |
DOC-WPA | Wairarapa |
NZ-CIT | Chatham Islands |
NZ-NSN | Nelson/Tasman |
NZ-MBH | Marlborough |
NZ-WTC | West Coast |
NZ-CAN | Canterbury |
NZ-OTA | Otago |
NZ-STL | Southland |
DOC-FIL | Fiordland |
Configuration
(:nzdoc '''type'''=''type''
'''content'''=''detail''
'''id'''=''identifier''
'''height'''=''pixels'' '''width'''=''pixels''
'''float'''=''left|right'' '''clear'''=''both|right|left'':)
'''h'''=''level''
type= -- hut, track, campsite
content= -- alert, detail, region, all, dump, check, list
id= -- id for hut, track, campsite, or region
clear= -- clear image to left, right, or both
h= -- heading level, must be 3 or greater
Parameters are case-insensitive.
config.php settings
You can change the following in config.php . For example
$NZDoCAPIKey = 10; # key obtained from DoC API website
$NZDoCDebug = true; # results may vary
Styling output
Style the output using CSS. Add the css to local.css .
To assist the following classes are applied
- output is encapsulated by
<div class='nzdoc':>
- tables are defined with
<table class='nzdocdata'>
- the following classes are used for data:
nzdocalert , inspect the html output for other classes
DoC API notes
The DoC API offering the following resources:
v2-huts [ Base URL: api.doc.govt.nz/v2 ]
/huts
[{assetId, name, status, region, lat, lon}]
/huts/alerts
[{assetId, name, alerts[{displayDate, heading, detail}]}]
Notes: detail has html formatting; displayDate is duplicated in text; ''Bug: URLS are not fully qualified;
/huts/{id}/alerts
[{assetId, name, alerts[{displayDate, heading, detail}]}]
/huts/{id}/detail
{assetId, name, locationString, numberOfBunks, facilities[], hutCategory, proximityToRoadEnd, bookable, introduction, introductionThumbnail, staticLink, region, place, status, lat, lon}
Notes: bookable is a boolean
v2-campsites [ Base URL: api.doc.govt.nz/v2 ]
/campsites
[{assetId, name, status, region, lat, lon}]
/campsites/alerts
[{assetId, name, alerts[{displayDate, heading, detail}]}]
/campsites/{id}/alerts
[{assetId, name, alerts[{displayDate, heading, detail}]}]
Notes: detail has html formatting; displayDate is duplicated in text; Bug: URLS are not fully qualified;
/campsites/{id}/detail
{assetId, name, locationString, introduction, introductionThumbnail, landscape[], campsiteCategory, access[]; facilities[], activities[], dogsAllowed, numberOfPoweredSites, numberOfUnpoweredSites, bookable, staticLink, region, place, status, lat, lon
Notes: bookable is a boolean
v1-tracks [ Base URL: api.doc.govt.nz/v1 ]
/tracks
/tracks/alerts
/tracks/region/{regionId}
/tracks/{id}/alerts
/tracks/{id}/detail
DoC API quirks
Some facilities shown on DoCs website are not available, e.g. Lodges.
Change log / Release notes
2020-06-10 Initial version
See also
Contributors
Special thanks to Gavin Harriss for the use of NZ Topo Map
Comments
See discussion at NZDoC-Talk?
|