Offline content generator/metabook.json

From MediaWiki.org
Jump to navigation Jump to search

The metabook.json is a file part of the bundle and gathers the collection/book metadatas.

Specification[edit]

The metabook.json file is composed of several different object types, each of which shares a field named type which can be used to distinguish them. The top level object is a Collection.

Collection[edit]

A collection object contains the specification for the entire render and contains the following fields:

type 
"collection"
version 
1
items 
an array of Chapter or Article objects.
license
an array of License objects.
title
the overall title for the collection
subtitle
overall subtitle for the collection
summary
summary text for the collection (currently unused)
toc
(optional) a boolean indicating whether a table of contents will be generated for this collection. If this option is missing, a table of contents will be generated iff items contains at least one Chapter object.
columns
(optional) a number indicating whether this collection should be rendered in one column or two column layout. The default is 2.
lang
(optional) a BCP47 language tag (ie, a valid value for an HTML lang attribute) giving the language of the collection as a whole. This is used for page numbers, chapter headings, etc. If this option is missing, the default language of the wiki containing the first article is used.
wikis
an array of WikiConf objects, giving the wiki configurations referenced by the items

Chapter[edit]

A chapter object groups articles in a collection. It contains the following fields:

type 
"chapter"
title 
the title of this chapter
columns
(optional) a number indicating whether this collection should be rendered in one column or two column layout.
items 
an array of Article objects contained within this chapter.

Article[edit]

An article object represents a single wikipedia article within a collection or chapter. It contains the following fields:

type 
"article"
title
the title of the article, in human-readable form (spaces, initial lowercase where appropriate, etc)
wiki
an index within the Collection's wikis array, giving the WikiConf for the wiki containing this article
revision
(optional) the revision ID of the article. If missing, the latest version will be rendered.

The following fields are filled in by the bundler process, but are not required as input to the bundler.

revision
if the article revision is missing, it will be added
timestamp
the timestamp corresponding to the given revision

The following fields are present for legacy compatibility, but are presently unused:

currentVersion
1
content_type
"text/x-wiki"
latest
the most recent revision of the article. Hard coded to match the revision field so that we don't spoil caching.
url
the canonical URL for the article. (This can be derived from the WikiConf and siteinfo in the bundle.)

License[edit]

A license object presumably represents the default license for a wiki or collection. It is currently unused.

type
"license"

WikiConf[edit]

A wikiconf object gives the configuration of one of the wikis from which articles and images will be taken. It contains the following fields:

type 
"wikiconf"
baseurl
the $wgScriptDirUrl for the wiki, from which we can obtain the API endpoints.
script_extension
the $wgScriptExtension for the wiki
imagesize
the maximum image width (in pixels) to use when rendering images from this wiki
parsoid
a parsoid endpoint to use for parsing content from this wiki. Should correspond to $wgVirtualRestConfig['modules']['parsoid']['url'] 
prefix
a prefix to use when formulating parsoid queries. Should correspond to $wgVirtualRestConfig['modules']['parsoid']['prefix']  (and, in general, to general.wikiid in the wiki's siteinfo).
filerepos
an array of FileRepo objects giving the configuration of local and foreign file repositories for this wiki.

The following fields are present for legacy compatibility, but are presently unused:

keep_tmpfiles
false
format
"nuwiki"
status_file
output

FileRepo[edit]

A filerepo object gives the configuration of a foreign or local file repository used by a wiki. The name, displayname, and local fields correspond to those in the output of a action=query&meta=filerepoinfo query on the wiki. It contains the following fields:

type 
"filerepo"
name 
a short name for the repo, typically "local" or "shared". Corresponds to the imagerepository field in the image metadata.
wiki 
an index into the Collection's wikis field giving the wiki configuration of this file repository. For local repos, this will give the index of the containing WikiConf.

The following fields are present but currently unused:

displayname
A human-readable name for this file repository
rootUrl
local 
a boolean reflecting whether this file repository is within the containing WikiConf
scriptDirUrl
the $wgScriptDirUrl of the repository (this can be obtained from the WikiConf referenced by the wiki field of the FileRepo.
rootUrl
a path which could be used to construct a direct URL for a file in the repository

Examples[edit]

Single article[edit]

{
   "type":"collection",
   "title":"",
   "subtitle":"",
   "summary":"",
   "version":1,
   "items":[
      {
         "type":"article",
         "title":"Taoism",
         "wiki":0,
         "revision":"4585542"
         "content_type":"text/x-wiki",
         "url":"http://simple.wikipedia.org/wiki/Taoism",
      }
   ],
   "licenses":[
      {
         "type":"license",
         "name":"License",
         "mw_rights_icon":"",
         "mw_rights_page":"",
         "mw_rights_text":"",
         "mw_rights_url":""
      }
   ],
   "wikis":[
      {
         "type":"wikiconf",
         "baseurl":"http://simple.wikipedia.org/w",
         "imagesize":1200,
         "keep_tmpfiles":false,
         "script_extension":".php",
         "format":"nuwiki",
         "parsoid":"http://parsoid-lb.eqiad.wikimedia.org/",
         "prefix":"simplewiki",
         "filerepos":[
            {
               "type": "filerepo",
               "name":"shared",
               "displayname":"Wikimedia Commons",
               "rootUrl":"//upload.wikimedia.org/wikipedia/commons",
               "local":false,
               "apiUrl":"http://commons.wikimedia.org/w/api.php",
               "wiki":1
            },
            {
               "type": "filerepo",
               "name":"local",
               "displayname":null,
               "rootUrl":"//upload.wikimedia.org/wikipedia/simple",
               "local":true,
               "wiki":0
            }
         ]
      },
      {
         "type":"wikiconf",
         "baseurl":"http://commons.wikimedia.org/w/api.php",
         "imagesize":1200,
         "keep_tmpfiles":false,
         "script_extension":".php",
         "format":"nuwiki",
         "parsoid":"http://parsoid-lb.eqiad.wikimedia.org/",
         "prefix":"commonswiki",
         "filerepos":[
            {
               "type": "filerepo",
               "name":"local",
               "displayname":null,
               "rootUrl":"//upload.wikimedia.org/wikipedia/commons",
               "local":true,
               "wiki":1
            }
         ]
      }
   ]
}

Collection including multiple articles[edit]

{
   "type":"collection",
   "title":"1933 Atlantic hurricane season",
   "subtitle":"",
   "summary":"",
   "version":1,
   "items":[
      {
         "type":"chapter",
         "title":"Introduction",
         "items":[
            {
               "type":"article",
               "title":"1933 Atlantic hurricane season",
               "wiki":0,
               "revision":"579329188",
               "content_type":"text/x-wiki",
               "currentVersion":1,
               "latest":579329188,
               "timestamp":"1383073948",
               "url":"http://en.wikipedia.org/wiki/1933_Atlantic_hurricane_season"
            }
         ]
      },
      {
         "title":"Storms",
         "type":"chapter",
         "items":[
            {
               "type":"article",
               "title":"1933 Trinidad hurricane",
               "wiki":0,
               "revision":"550867472",
               "content_type":"text/x-wiki",
               "currentVersion":1,
               "latest":550867472,
               "timestamp":"1366230514",
               "url":"http://en.wikipedia.org/wiki/1933_Trinidad_hurricane"
            },
            {
               "type":"article",
               "title":"1933 Texas tropical storm",
               "wiki":0,
               "revision":"572402424",
               "content_type":"text/x-wiki",
               "currentVersion":1,
               "latest":572402424,
               "timestamp":"1378848251",
               "url":"http://en.wikipedia.org/wiki/1933_Texas_tropical_storm"
            },
            {
               "type":"article",
               "title":"1933 Chesapeake–Potomac hurricane",
               "wiki":0,
               "revision":"579390421",
               "content_type":"text/x-wiki",
               "currentVersion":1,
               "latest":579390421,
               "timestamp":"1383099157",
               "url":"http://en.wikipedia.org/wiki/1933_Chesapeake%E2%80%93Potomac_hurricane"
            },
            {
               "type":"article",
               "title":"1933 Cuba–Brownsville hurricane",
               "wiki":0,
               "revision":"572402369",
               "content_type":"text/x-wiki",
               "currentVersion":1,
               "latest":572402369,
               "timestamp":"1378848216",
               "url":"http://en.wikipedia.org/wiki/1933_Cuba%E2%80%93Brownsville_hurricane"
            },
            {
               "type":"article",
               "title":"1933 Treasure Coast hurricane",
               "wiki":0,
               "revision":"575674769",
               "content_type":"text/x-wiki",
               "currentVersion":1,
               "latest":575674769,
               "timestamp":"1380856363",
               "url":"http://en.wikipedia.org/wiki/1933_Treasure_Coast_hurricane"
            },
            {
               "type":"article",
               "title":"1933 Outer Banks hurricane",
               "wiki":0,
               "revision":"576090149",
               "content_type":"text/x-wiki",
               "currentVersion":1,
               "latest":576090149,
               "timestamp":"1381119599",
               "url":"http://en.wikipedia.org/wiki/1933_Outer_Banks_hurricane"
            },
            {
               "type":"article",
               "title":"1933 Tampico hurricane",
               "wiki":0,
               "revision":"567480201",
               "content_type":"text/x-wiki",
               "currentVersion":1,
               "latest":567480201,
               "timestamp":"1375840931",
               "url":"http://en.wikipedia.org/wiki/1933_Tampico_hurricane"
            },
            {
               "type":"article",
               "title":"1933 Cuba–Bahamas hurricane",
               "wiki":0,
               "revision":"578977949",
               "content_type":"text/x-wiki",
               "currentVersion":1,
               "latest":578977949,
               "timestamp":"1382894555",
               "url":"http://en.wikipedia.org/wiki/1933_Cuba%E2%80%93Bahamas_hurricane"
            }
         ]
      }
   ],
   "licenses":[
      {
         "type":"license",
         "name":"License",
         "mw_rights_icon":"//creativecommons.org/images/public/somerights20.png",
         "mw_rights_text":"Creative Commons Attribution-Share Alike 3.0",
         "mw_rights_url":"//creativecommons.org/licenses/by-sa/3.0/"
      }
   ],
   "wikis":[
      {
         "type":"wikiconf",
         "baseurl":"http://en.wikipedia.org/w",
         "imagesize":1200,
         "keep_tmpfiles":false,
         "output":"/home/anomie/test.zip",
         "script_extension":".php",
         "status_file":"/home/anomie/statusfile",
         "parsoid":"http://parsoid-lb.eqiad.wikimedia.org/",
         "prefix":"enwiki",
         "filerepos":[
            {
               "type":"filerepo",
               "name":"shared",
               "displayname":"Wikimedia Commons",
               "rootUrl":"//upload.wikimedia.org/wikipedia/commons",
               "local":false,
               "apiUrl":"http://commons.wikimedia.org/w/api.php",
               "wiki":1
            },
            {
               "type":"filerepo",
               "name":"local",
               "displayname":null,
               "rootUrl":"//upload.wikimedia.org/wikipedia/en",
               "local":true,
               "wiki":0
            }
         ]
      },
      {
         "type":"wikiconf",
         "baseurl":"http://commons.wikimedia.org/w/api.php",
         "imagesize":1200,
         "keep_tmpfiles":false,
         "script_extension":".php",
         "format":"nuwiki",
         "parsoid":"http://parsoid-lb.eqiad.wikimedia.org/",
         "prefix":"commonswiki",
         "filerepos":[
            {
               "type":"filerepo",
               "name":"local",
               "displayname":null,
               "rootUrl":"//upload.wikimedia.org/wikipedia/commons",
               "local":true,
               "wiki":1
            }
         ]
      }
   ]
}