wikiFoodia2 Implementation

WikiFoodia2 Implementation

Assuming one can use Mediawiki.


My idea was that when the editor clicks save, one should hopefully be able too execute a callback function at the server before anything else is done.

The wikitext should contain two tables formatted like this.

{| class=barCodeNumber
|123456789012
|}


{| class=productProperty
!productProperty!!value
|-
|nitrate||5mg
|-
|sugar||50g
|-
|mercury||5mg
|}

The callback function has a simple wiki parser (like my own wiki-software https://emagnusandersson.se/mmmWiki). (Basically regular expressions).

The parser doesn't have to be particularly advanced (it doesn't have to be able to handle nested tables etc).

The callback function checks that the barcode number(s) are unique (and that there is no syntax error etc).

If there is an error (the barcode number(s) uniqness is violated or whatever) then hopefully one can exit elegantly with an error message.


New database tables: productProperty with columns idPage, propertyName, propertyValue

Note that the propertyValue can store both value and unit in the same string since the editor community themselves can agree (I think (I hope)) on what unit is most suitable.

The server would then have to respond to cross-site requests from the client.

The request would contain an array of barcodes (JSON encoded):

{
  arrWantedProperty:["sugar", "nitrate"],
  arrBarCode:[123456789012, 123456789013, 123456789015]
}

... and returned would be array of objects (corresponding to the elements of "arrBarCode") each with properties corresponding to the "wantedProperty"

 [{sugar:"5g"}, {sugar:"5g", nitrate:"5mg"}, {sugar:"5g", nitrate:"6mg"}]