PubNight Extensions
From PubNight
Contents
The complete and utter guide to Pub Night Wiki Extensions
PNC Wiki Extensions can be grouped into two main categories:
- Formatting
- Data
Formatting
dateform
A simple little extension that formats dates for you.
<dateform dateformat=full>12/12/2005</dateform> produces " Monday 12th December 2005 "
If a partial date is provided then the output changes in a rather clever way
<dateform dateformat=full>00/12/2005</dateform> produces " sometime in December 2005 "
<dateform dateformat=full>00/00/2005</dateform> produces " sometime in 2005 "
<dateform>00/12/2005</dateform> produces " 12/2005 "
<dateform>00/00/2005</dateform> produces " 2005 "
See nicedate for a shorter fixed format version
left, centre, right, justify
These simply align the text between the open and close tags
Data
The Pub Night Wiki uses a lot of formatted data to build consistent looking pages. The Wiki way of using cascading templates was, to put it mildly, horrendous so we coded our own extensions.
PNDATA
This is the main Pub Night Data extension and takes several parameters:
- DG
- field
- formatting options
Digraphs
The Digraph is the Key to accessing Pub Night data. Each pub has its own unique Digraph and by using this you can access the data held for each pub - for example dg=AE would return information associated with the Pub Data page AE.
Multiple digraphs can be entered and data will be returned for each digraph in turn, so dg=MB,AE,3K will return the selected fields for those three pubs.
You can also specify dg=* which returns ALL digraphs from the PNPD namespace.
Fields
Each Pub Data page contains several fields (see PNPD:Data Fields for details on the current set of fields.)
Specifying a field returns the data associated with that field for the supplied digraph. So dg=AE field=address will return the address for the pub identified by the digraph AE.
Multiple fields can be specified. Fields will be returned in the order specified so field=who,beers,lastvisit will put those fields out with NO spaces (See the notes on formatting ).
There is also special field called user_content. This tells the extension to return the text between the start and end tags as part of the output. This allows you to control where in the formatted page the user generated stuff goes See Mabels Tavern, St Pancras for an example of this
If you specify NO fields apart from the digraph then the following fields are automatically returned: header, user_content, footer
Formatting
Some of the Pub Data fields support different styles of formatting. The fields that support formatting options are:
- lastvisit
- rating
- beer_rating.
Each of these fields has its own keyword associated with it :
The lastvisit field (and by extrapolation the DATEFORM extension) uses dateformat to control how its output is displayed.
The rating and beer_ratings use ratingformat and beerratingformat accordingly which take a descriptive word. Not supplying the parameter makes them return the number value. The descriptive words that can be used by these two rating fields are defined on PNPD:Rating Words which contains sets of words to be used as ratings descriptions. There are currently two sorts of ratings - beer ratings which comprise of 6 words (numerically 0-5) and pub ratings which comprise of 11 words (numerically 0-10). Simply add a new line with a unique "keyword" and then those rating words will be available for use. If the rating field in the DG page is empty then N/A is returned, if its NOT numeric then the contents of the field are returned
Additional Parameters
There is a formatting parameter which is associated with multiple DG and multiple data fields. The parameter is style and it can either be table, space or line.
If its table then each field appears in a td section within a table row with one row for each DG specified. The column headers are specified in the space between the start and end tags.
If it is space then each field is put out with a space separating them. If there are mulitple DGs then each set of fields appears on a new line. If it is line then each field is put out a new line.
There is also a new parameter associated with the DG field. This is the edit parameter and can be yes or no. This makes the DG an click to edit style link.
So lets roll up all these features into an example:
<pndata dg=CN,AE field=page,dg,notes,lastvisit,rating,beer_rating style=table dateformat=full edit=yes ratingformat=formal beerratingformat=camra > Name,[[PDDG]],Notes,Last PNC Visit,Rating,Beer Rating</pndata>
This retrieves the pub name as a Wiki clickable link to the name page for the pub. This allows us to have multiple pubs of the same name but linking back to differen name pages, the DiGraph, the notes, the last visit date, the pub rating and the beer rating fields (field=page,dg,notes,lastvisit,rating,beer_rating) for the PNPD data pages for CN and AE (dg=CN,AE ) .
It places these field items into a table (style=table) with the following column headers : Name,[[PDDG]],Notes,Last PNC Visit,Rating,Beer Rating (Note that the PDDG column header is a Wiki Link) and populates it with the data.
The Digraphs for the Pubs are represented as click to edit links (because we specified edit=yes) to the associated PNPD namespace pages.
The last visit date is formatted using the full styling, The pub rating is described using the formal wordings and the beer is rated using the camra ratings.
And this is what it looks like:
Name | PDDG | Notes | Last PNC Visit | Rating | Beer Rating |
Cheltenham Motor Club | CN | Orginally The Crown, and accesible via Crown Passage from the London Rd. Winner of CAMRA SW Club of the Year 2006, 2007, 2008 through to 2012 and was CAMRA National Club of the Year in 2013, 2017 and 2020 - a testament to the effort put in by Neil behind the bar (and in the cellar). Was Branch Club of the Year 2019 and was Regional Club of the year 2018 | Wednesday 8th January 2020 | ||
The Adam and Eve | AE | Long standing Local for several members of Pub Night | Tuesday 7th January 2014 |
PNQUERY
This allows very basic querying of pubnight data fields
The extension takes the same parameters as the pndata extension but adds "what" and "where" to it. The what field contains what you want to search for. If you want to search for a phrase then enclose it in quotes - so to search for Hook Norton you would put "Hook Norton". The where field contains the pndata field that you want to search in.
NOTES
- Basic OR logic has been implemented so it is possible to search for more than one term BUT only in 1 data field.
Some examples:
Return a list of pubs that list "Hook Norton" as a brewer. This could be used on each breweries page to show which pubs are selling their beers.
<pnquery field=page,dg,rating,beers,beer_rating what="Hook Norton" where=brewery style=table> Pub Name,Digraph,Rating,Beers, Beer Rating </pnquery>
Pub Name | Digraph | Rating | Beers | Beer Rating |
Fleece Inn, Bretforton | FIB | N/A | Shepherds Delight and Hooky Bitter | N/A |
Falcon, Thame | FNT | N/A | Hooky Bitter, Steaming On and Twelve Days | N/A |
The Green Dragon, Cockleford | GDC | N/A | Butcombe Traditional Bitter, Hookey Bitter and Directors | N/A |
The Kings Head, Bledington | KI | N/A | Cotswold Way, Hook Norton Bitter and Slaters | N/A |
Tunnel House, Coates | TU | N/A | Hookey Bitter, Budding and Uley Bitter | N/A |
White Hart, Fyfield | WHF | N/A | Black Swan, Life Of Riley, Old Hooky and Doom Bar | N/A |
Return a list of pubs that list "Old Hooky" as a beer
<pnquery field=page,dg,rating,beers,beer_rating what="Old Hooky" where=beers style=table> Pub Name,Digraph,Rating,Beers, Beer Rating </pnquery>
Pub Name | Digraph | Rating | Beers | Beer Rating |
White Hart, Fyfield | WHF | N/A | Black Swan, Life Of Riley, Old Hooky and Doom Bar | N/A |
Returns a list of pubs that have Steve listed as a who attended
<pnquery field=page,dg,rating,beers,beer_rating what=steve where=who style=table> Pub Name,Digraph,Rating,Beers, Beer Rating </pnquery>
Returns a list of pubs that have a beer rating of 3,4 or 5
<pnquery field=page,dg,rating,beers,beer_rating what=3,4,5 where=beer_rating style=table edit=yes> Pub Name,Digraph,Rating,Beers, Beer Rating </pnquery>
Returns a list of pubs that have Steve OR nick listed as a who attended
<pnquery field=page,dg,rating,beers,beer_rating what=steve,nick where=who style=table> Pub Name,Digraph,Rating,Beers, Beer Rating </pnquery>
Returns a list of pubs that have Bath Road in their address
<pnquery field=page,dg,rating,beers,beer_rating what="Bath Road" where=address style=table> Pub Name,Digraph,Rating,Beers, Beer Rating </pnquery>
Pub Name | Digraph | Rating | Beers | Beer Rating | address |
Exmouth Arms | EX | N/A | N/A | Bath Road Cheltenham Gloucestershire GL53 7LX | |
Five Alls | FA | N/A | Bath Road Cheltenham Gloucestershire GL53 7ND |
GOOGLEMAP
This displays a googlemap when you use this tag. There can be multiple googlemaps per page as long as each map/dataset is identified using the mapid tag.
<googlemap lat="latitude" lon="longitude"></googlemap>
Legal attributes are:
- width. Defaults to 300
- height. Defaults to 300
- lat (the center latitude on the map)
- lon (the center longitude on the map)
- zoom (the zoom level; 0 is the furthest away, 17 is the closest in). Defaults to 12
- type (legal values are normal (or, equivalently, map), hybrid, and satellite. Defaults to map
- controls (small creates +/- zoom buttons, medium has zoom buttons and pan buttons, and large has pan buttons with a sliding scale for zoom). Defaults to medium
- gmarker. This can be text,link or number or icon. Text puts the pub name out, link puts a clicky link, number puts out a number by the side of the marker, icon puts out a numbered icon (1-99)
- edit. If this is set (=yes) then the markers become draggable.. When you let go a pop up appears with the new Lat and Lon of the marker. You can then cut and paste these and use them to update the lat and lon in the pub data page!
Of course this only displays a map - it does not actually put anything on it. To add markers to the map you need to use the pndata tag with the addmarker field.
PNBREWERY
This tag brings back a link to an external web page with link text for a specified brewery
For example
<pnbrewery>arkells</pnbrewery>
Returns a link to the Arkell Brewery home page:
PNBEER
This tag brings back a link to an external web page with link text for a specified brewery.
For example
<pnbeer>purity pure ubu</pnbeer>
Returns a link to the web page for Purity Pure UBU
Shortened Tags
Obviously the PNC wiki extensions allow lots of complicated and clever things. But in a large number of cases we only want to do something simple so several shortened tags have been implemented:
NOTE: Since the Introduction of Wiki 1.6.6 some of these short versions can have odd effects. If in doubt please use the full length versions.
- nicedate
- pnlink
- pngmap
- addmarker
All shortened tags have the digraph placed between the open and close tags
nicedate
This is a shortened form of the dateform extension - it always returns the date in "full" format. So <nicedate>01/04/2006</nicedate> returns Saturday 1st April 2006 .
pnlink
This is a shortened form of the pndata extension - it returns the name of the pub as a WIKI link to the page associated with it. So <pnlink>AE</pnlink> returns The Adam and Eve
pngmap
This is a shortened version of the pndata googlemap extension - it returns a googlemap centered on the pub (assuming the lat and lon data field are populated). Clicking on the marker pin brings up a bubble with a clickable wiki link to the pub page. This shortened version also supports the gmarker keyword.
So <pngmap gmarker=text>AE</pngmap> would return.
The Adam and Eve
8 Townsend St
Cheltenham
GL51 9HD
addmarker
This is a shortened version of the pndata addmarker extension - it places a marker on the map (specified using the optional mapid field).
So if we create a mpa using pngmap centered on The Adam and Eve and then add a marker for the New Penny
<pngmap gmarker=text mapid=2>AE</pngmap>
The Adam and Eve
8 Townsend St
Cheltenham
GL51 9HD
thumb
This is a shortened version of the pndata thumb extension. It displays a thumbnail of the image for the specified digraph
So <thumb>PL</thumb> would produce:
picture
This is a shortened version of the pndata picture extension. It displays the image for the specified digraph nicely framed with the caption text beneath it
So
<picture>PL</picture> would produce: