JSON Export of Wiki Keys (Key Start, Switch, Image Switch etc.)

From Biowikifarm Metawiki
Revision as of 12:00, 3 July 2013 by Andreas Plank (Talk | contribs) (content[…])

Jump to: navigation, search

Used templates

For most recent documentation of template parameters see on German project page Offene-Naturführer (documentation in English):

Error messages

Note that objects can have "error":"error message" if there is any error worth reporting. Objects that can contain errors:

  • media.error
  • metadata.error

JSON

Legend:
[ ]   → array
{ }   → object
"":"" → pair (key : value)
  "type": "decisiontree | html | switch | imageswitch" → vertical bar | means “or”. Values can be either: decisiontree, html, switch or imageswitch

content[…]

content [ {…}, {…} ]
  Definition: Unbounded sequence of objects.
  Elements:
    type: type of content
           ├ "decisiontree" representation of a key (Key Start)
           ├ "switch"       representation of Switch"imageswitch"  representation of ImageSwitch"glossary"     representation of a glossary page[1]"html"         representation of a Wiki page[2]
                            a) a context page (=Wiki page without keys)
                            b) a Wiki page, different kind of pages: a result page, taxon page
    fragment_id: fragment identifier of the key (id attribute of a HTML tag; optional; set in most cases, but: content.type:"html" has no fragment_id)
    id:   (plain text) unique identifier with the possible values:
           ├ "wiki_page_title_decisiontree" ┬→ suffix _decisiontree is a decisiontree or switch or imageswitch
           ├ "wiki_page_title_decisiontree_fragment-id"[3]
           ├ "wiki_page_title_glossary" ────┬→ suffix _glossary is a glossary page
           ├ "wiki_page_title_glossary_fragment-id"[3]
           ├ "wiki_page_title_wikipage" ────┬→ suffix _wikipage is a context page (=wiki page mixed with keys) or a result page
           └ "wiki_page_title_wikipage_fragment-id"[3]

    metadata: {"":"", "":""}
    ├ title:           the title of the key, presented as a heading above the key
    ├ audience:        optional, the intended audience: 12 yr old school children, 6th grade, university students, general public, experts, etc.
    ├ geoscope:        optional, geographic scope
    ├ source:          optional, published source citation, if key itself was previously published. If key was newly developed, based on multiple publications, these should normally not be cited here.
    ├ contributor:     optional, a list of later co-authors or editors who contributed significantly to the improvement of the key. This includes contributors adding images. (is deprecated "edited_by")
    ├ creator:         the main creator(s) of a key, i.e. the ones to be cited as primary authors in the title line.
    ├ description:     optional, full text description, elaborating information not yet captured in title, geoscope, audience etc.
    ├ status:          optional, progress and status, e.g. "incomplete", "finished"
    ├ language:        optional?, abbreviated language code
    ├ collaboration_limited_to: a list of names, to which the collaboration shall be limited. Empty means: "collaboration: open" should be shown.
    ├ initiated_by:    optional, initiator(s) of a key project, who does not wish to be cited as primary author
    ├ general_review_by: optional, persons that have acted as reviewers and quality control editors
    ├ nomreview_by:    optional, nomenclatural review
    ├ expert_review_by: optional, review by a taxonomic expert of the group.
    ├ icon_url:        a non-default icon / pictogram representing the key in lists, overviews etc. (e.g. floating left or right), default icon is a sized version of http://species-id.net/openmedia/File:Determination_logo_2_question.svg (40x40px?)
    ├ publicity:       optional, advertise for an association, e.g. the German Deutscher Jugendbund für Naturbeobachtung or the author’s web page
    ├ recommendation_group: provide a recommendation for the end user (categorisation)
    ├ taxon_name:      optional
    ├ common_names:    optional
    ├ parent_key_id:   optional, refers to content.id (parent_key_id or parent_key_url, not both)
    ├ parent_key_url:  optional, external url (parent_key_id or parent_key_url, not both)
    ├ parent_key_text: optional, display text for the link to the parent key
    ├ parent_taxon:    optional, the next higher taxonomic level
    ·
    ├ error:           optional, if there is any error worth reporting
    ├ modified:        get the last touched timestamp (ISO 8601 format with no timezone: 1986-02-09T20:00:00Z)
    ├ created:         oldest revision timestamp of this page (ISO 8601 format with no timezone: 1986-02-09T20:00:00Z)
    ├ source_url:      URL of the page / key
    └ page_context_id: optional, id to extra page content (that means the key is embedded by page content, i.e. it has a page context, e.g. references, notes, introduction, non-key-text etc. surrounding the key)
  Example:
   {
       "metadata": {…},
       "content": [
           {
               "type": "html",
               "html": "",
               "fragment_id": "",
               "id": "page_title_wikipage"
           },
           {
               "metadata": {…},
               "type": "decsiontree",
               "fragment_id": "",
               "decision": [{…},{…}]
           },
           {
               "metadata": {…},
               "type": "switch",
               "fragment_id": "",
               "decision": [{…},{…}]
           },
           {
               "metadata": {…},
               "type": "imageswitch",
               "fragment_id": "",
               "decision": [{…},{…}]
           }
       ]
   }

content[…].decision[…]

decision: [ {…}, {…} ]
  Definition: Bounded sequence of objects and representation of content.type "decisiontree", "switch" or "imageswitch" (sequence order is that order on the original Wiki page).
  Elements:
    id: (plain text) unique identifier with the possible values:
                 ├ "wiki_page_title_decision" (=first decision)
                 ├ "wiki_page_title_decision_fragment-id" (=first decision of a key on a Wiki page having a non-default fragment-id, i.e. multiple keys on a page)
                 ├ "wiki_page_title_decision_decision-code" (=any decision but not the first )
                 └ "wiki_page_title_decision_fragment-id_decision-code" (=any decision but not the first )
    nid:         (integer) numeric record identifier
    code:        (plain text) code of the decision e.g.:
                 1 for 1*, 1'', 1 a OR
                 A for A 1, A*
                 (“A” or “1” but not “1a”)
    subheading:  (html) subheading to all alternatives[4]
    remarks:     (html)
    statements_intro_text:  (html) intro text or preceding text to all alternative statements[5]
    alternative: [ {…}, {…} ] → see decision[…].alternative[…]
    ├ result:   {…} → see decision[…].alternative[…]
    ├ media:    {…} → see decision[…].alternative[…]
    ├ "":"",
    └ "":""
  Example: see below

content[…].decision[…].alternative[…]

alternative: [ {…}, {…} ]
  Definition: Unbounded sequence of objects describing alternatives of a decision.
  Elements:
    id: (plain text) unique identifier with the possible values:
                  ├ "wiki_page_title_decision_decision-code_alternative-index"
                  └ "wiki_page_title_decision_fragment-id_decision-code_alternative-index"
    nid:          (integer) numeric record identifier
    code:         (plain text) code of the alternative e.g.:
                  ** OR a OR - OR empty, e.g. * for 2* or A*, '' for 2'', a for 2 a  
    next_code:    (plain text) next content[].decision[].code
    statement:    (html) statement of this decision
    remarks:      (html)
    description:  (html)
    occurrence:   (html)
    
    result: {"":"", "":""}
    ├ next_id:         (optional plain text) allows determination step by step. If it is empty, then determiantion stops and a result should be present
    │                  referring to content[].id or content[].decision.id[6]
    ├ text:            (html) text of result[7]
    ├ ref:             (plain text; ref OR url not both) wiki_page_name#optional-fragment-id[8]
    ├ url:             (plain text; ref OR url not both) external URL
    ├ scientific_name: (plain text | html)
    ├ synonyms:        (, list as plain text | html)
    ├ common_names:    (, list as plain text)
    └ qualifier:       (plain text | html) result qualifier, e.g. “male” or “incl. Agenus, Bgenus”

    collapsed_media_footer: (html) footer text to all collapsed images / media
    media: [{"":"", "":""}, {"":"", "":""}]
    ├ type: media type can have the following values
    │        ├ "primary"       media/images always visible 
    │        ├ "large_primary" media/images always visible but with large size
    │        └ "collapsed"     hidden or collapsible media/images
    ├ caption:         (html)
    ├ label:           (plain text) figure label
    ├ url_420px:       URL to 420px sized media
    ├ url_1000px:      URL to 1000px sized media
    ├ custom_height:   a specific height is used
    ├ custom_width:    a specific width is used
    ├ custom_url:      URL to the specified sized media
    ├ url_maxres:      URL of media with highest resolution
    ├ mimetype:        mime type of this media file
    ├ error:           any error that occurs during export that is worth reporting
    └ meta_url:        URL of meta data page

Elaboration of the decision object used above:

 1 {
 2     "metadata": { "":"", "":"" },
 3     "content": [
 4         {
 5             "type": "html",
 6             "html": "(html) the first content element of type 'html' contains usually the wiki page stripped off any keys in the page. Keys are stored in content[].decision",
 7             "fragment_id": "",
 8             "id": "(unique) content-id"
 9         },
10         {
11             "metadata": {
12                 "audience": "(plain text , list)",
13                 "edited_by": "(plain text , list) of authors",
14                 "geoscope": "(plain text , list)",
15                 "icon_url": "icon-url",
16                 "source": "(html) source(s) of the key",
17                 "status": "(html) working status",
18                 "title": "(html) title text",
19                 "source_url": "URL of the key (only), can have a fragemnt identifier #thekey-something",
20                 "page_context_id": "identifier to a content.id, i.e. the embedding (outer) wiki page"
21             },
22             "type": "decisiontree | html | switch | imageswitch",
23             "fragment_id": "(HTML id attribute) fragment identifier of the key",
24             "decision": [
25                 {
26                     "id": "(unique) decision-id",
27                     "code": "1",
28                     "subheading": "subheading to all alternatives",
29                     "statements_intro_text": "intro text to all alternative statements",
30                     "alternative": [
31                         {
32                             "id": "(unique) alternative-id",
33                             "code": "a",
34                             "next_code": "(next decision[].code) 2",
35                             "statement": "(html) statement of this decision alternative",
36                             "remarks": "(html)",
37                             "description": "(html) detailed description",
38                             "occurrence": "(html)",
39                             "result": [
40                                 {
41                                     "next_id": "next step of determination, i.e. next_id to either content.decision.id or content.id",
42                                     "text": "(html) text of result",
43                                     "ref": "local page (ref or url, not both)",
44                                     "url": "external page (ref or url, not both)",
45                                     "scientific_name": "(plain text | html)",
46                                     "synonyms": "(plain text as , list)",
47                                     "common_names": "(plain text as , list)",
48                                     "qualifier": "(plain text | html) result qualifier, e.g. “male”"
49                                 }
50                             ],
51                             "collapsed_media_footer": "(html) footer text to all collapsed images / media",
52                             "media": [
53                                 {
54                                     "type": "primary | large_primary | collapsed",
55                                     "mimetype": "image/jpeg",
56                                     "caption": "(html)",
57                                     "label": "(plain text) figure label",
58                                     "url_420px": "http:\/\/species-id.net\/o\/media\/b\/b5\/Paul_Williams_BumblebeeID_tail_yellow-white.jpg",
59                                     "url_1000px": "http:\/\/species-id.net\/o\/media\/b\/b5\/Paul_Williams_BumblebeeID_tail_yellow-white.jpg",
60                                     "custom_height": "121px",
61                                     "custom_width": "43px",
62                                     "custom_url": "http:\/\/species-id.net\/o\/media\/b\/b5\/Paul_Williams_BumblebeeID_tail_yellow-white.jpg",
63                                     "url_maxres": "http:\/\/species-id.net\/o\/media\/b\/b5\/Paul_Williams_BumblebeeID_tail_yellow-white.jpg",
64                                     "meta_url": "http:\/\/species-id.net\/openmedia\/File:Paul_Williams_BumblebeeID_tail_yellow-white.jpg"
65                                 }
66                             ]
67                         },
68                         {  NEXT_ALTERNATIVE  },
69                         {  NEXT_ALTERNATIVE  }
70                     ]
71                 },
72                 {  NEXT_DECISION  },
73                 {  NEXT_DECISION  }
74             ]
75         },
76         {  NEXT_CONTENT  },
77         {  NEXT_CONTENT  }
78     ]
79 }

id, next_id, nid

id 
all ids are unique text-string IDs in the JSON document (=candidate key). The following ids are defined
content[…].id
content[…].decision[…].id
content[…].decision[…].alternative[…].id
next_id 
referring to content[…].id or content[…].decision[…].id
The id of the next_id may be a decision in the same content object, or a decision in another content object.
page_context_id 
content[…].metadata.page_context_id referring to a content[…].id of a key’s context page (a key can be embedded in a page and may have a context content)
nid 
(unused for now) numerical (unique and constant) record id[9]
 1 {
 2   "metadata":{"":"", "":""},
 3   "content":[
 4     {
 5       "id":"(optional: mandatory only for type=html)"
 6     },
 7     {
 8       "decision":[
 9         "id":"(mandatory)",
10         "alternative":[
11           "id":"(mandatory)",
12           "result":{
13             "next_id":"(optional) referring to content[].id or content[].decision.id"
14           }
15         ]
16       ]
17     }
18   ]
19 }

Determination walk through

Going step by step through a key[10] is accomplished by:

  • using content[…].decision[…].alternative[…].result.next_id

The next_id refers to

  • content[].id or
  • content[].decision[].id

All id strings in the JSON document are unique. Those identifiers can be maintained to be constant after key changes only if decisions are just appended, they don't keep constant if decision sequences are interchanged.

If next_id is empty, then there can be further references:

Cross links

There can be cross links between key statements and a wiki page that is the context page of that key, i.e. the key or multiple keys are embedded in a Wiki page. Cross links are be referred to as follows (it may change if there is a better solution). Note that all href attributes should be rawurlencoded.

Ordinary local cross links: It links to the content.id of that wiki page and CSS class pagecontext is added:

<a href="#local-id">…</a> is changed to
<a href="wiki_page_name_wikipage#local-id" class="wikipage localref">…</a>

pointing to

  1. a content.type:"html"
    with content.id:"wiki_page_name_wikipage"
  2. #local-id points to an HTML tag id of that object content.html

Glossary cross links: It links to the content.id of that glossary wiki page and CSS class glossary is added:

<span class="cluetip other-classes"><a href="glossary_page_name">…</a></span> is changed to
<span class="cluetip other-classes"><a href="glossary_page_name_glossary" class="glossary localref">…</a></span>

pointing to

  1. a content.type:"glossary"
    with content.id:"glossary_page_name_glossary"
  2. optionally a #local-id to an HTML tag id of that content.html may be present for the use of CSS pseudo selector :target

Key cross links: provide a pointer to a numbered decision.code of a single access key (originally template:Lead Link used for template:Lead). They point to content.decision.id not to content.decision.alternative.id:

  1. <span class="leadontext"><a href="#Lkey_5">…</a></span>
  2. <span class="leadontext"><a href="#LmySpecialKey_5">…</a></span>

is changed to

  1. <span class="leadontext"><a href="wiki_page_name_decision_5" class="decision localref">…</a></span>
    pointing to content.decision.id:"wiki_page_name_decision_5"
  2. <span class="leadontext"><a href="wiki_page_name_decision_mySpecialKey_5" class="decision localref">…</a></span>
    pointing to content.decision.id:"wiki_page_name_decision_mySpecialKey_5"

Annotations

  1. a link pointing to a glossary has CSS class a.glossary.localref <span class="cluetip"><a class="glossary localref">…</a></span>
  2. a link pointing to a Wiki page has CSS class a.wikipage.localref <a class="wikipage localref">…</a>
  3. 3.0 3.1 3.2 Internal note: fragment-id is appended only when a non-standard id of a template parameter was set. Defaults are "key" ({{Key Strat}}), "switch" ({{Switch}}), "imageswitch" ({{ImageSwitch}})
  4. subheading_1, subheading_2 of Template:Switch trigger a new decision.
  5. choose a more concise name? statement_intro_text or
  6. is empty when max_key_recursion_depth (=50) is reached
  7. content of it see discussion http://biowikifarm.net/meta/Talk:JSON_Export_of_Wiki_Keys_(Key_Start,_Switch,_Image_Switch_etc.)#result.text
  8. internal note: IF template parameter “result” THEN plain text(“result”) ELSE plain text(“scientific_name”)
  9. http://biowikifarm.net/meta/Talk:JSON_Export_of_Wiki_Keys_(Key_Start,_Switch,_Image_Switch_etc.)#numeric_record_id
  10. a “key” has a content[…].type of either "imageswitch" or "switch" or "decisiontree"
  11. <a href="wiki_page_name_id_wikipage" class="wikipage localref">…</a>