I'm adding an API module to retrieve UploadWizard upload campaign information, which we need for the upcoming mobile application for Wiki Loves Monuments. Essentially the app will include a very limited implementation of a couple steps of UploadWizard for things like license selection and filling the ID field and description, so we have one consistent set of configuration for both web upload (using UploadWizard) and mobile uploads (using the app).
The change waiting review in gerrit: https://gerrit.wikimedia.org/r/#/c/7832/
If anybody's got a prime usage in mind for reading UploadWizard campaign data from the API and has recommendations for adjusting the output format (maybe for making the editing view more AJAX-y) please give a shout -- this is not final and we can adjust it.
Currently it'll return XML like this:
<?xml version="1.0"?><api> <uploadcampaign> <campaigns> <campaign name="wlm-es" id="2" isenabled="0" autoCategories="" autoWikiText="" defaultAlt="" defaultCategories="" defaultDescription="" defaultLat="" defaultLon="" defaultOwnWorkLicence="cc-by-sa-3.0" headerLabelPage="sdfsdf" idField="sdfafsdfd" idFieldInitialValue="" idFieldLabel="" idFieldLabelPage="" idFieldMaxLength="25" licensesOwnWork="cc-by-sa-3.0|cc-by-3.0|cc-zero" ownWorkOption="choice" skipTutorial="" thanksLabelPage="" tutorialHelpdeskCoords="27, 1319, 691, 1384" tutorialTemplate="Licensing_tutorial_$1.svg" tutorialWidth="720" /> </campaigns> </uploadcampaign></api>
or JSON like this:
{ "uploadcampaign": { "campaigns": [ { "name": "wlm-es", "id": 2, "isenabled": 0, "autoCategories": "", "autoWikiText": "", "defaultAlt": "", "defaultCategories": "", "defaultDescription": "", "defaultLat": "", "defaultLon": "", "defaultOwnWorkLicence": "cc-by-sa-3.0", "headerLabelPage": "sdfsdf", "idField": "sdfafsdfd", "idFieldInitialValue": "", "idFieldLabel": "", "idFieldLabelPage": "", "idFieldMaxLength": "25", "licensesOwnWork": "cc-by-sa-3.0|cc-by-3.0|cc-zero", "ownWorkOption": "choice", "skipTutorial": "", "thanksLabelPage": "", "tutorialHelpdeskCoords": "27, 1319, 691, 1384", "tutorialTemplate": "Licensing_tutorial_$1.svg", "tutorialWidth": "720" } ] } }
-- brion
On 17/05/12 00:36, Brion Vibber wrote:
I'm adding an API module to retrieve UploadWizard upload campaign information, which we need for the upcoming mobile application for Wiki Loves Monuments. Essentially the app will include a very limited implementation of a couple steps of UploadWizard for things like license selection and filling the ID field and description, so we have one consistent set of configuration for both web upload (using UploadWizard) and mobile uploads (using the app).
The change waiting review in gerrit: https://gerrit.wikimedia.org/r/#/c/7832/
If anybody's got a prime usage in mind for reading UploadWizard campaign data from the API and has recommendations for adjusting the output format (maybe for making the editing view more AJAX-y) please give a shout -- this is not final and we can adjust it.
Currently it'll return XML like this:
<?xml version="1.0"?>
<api> <uploadcampaign> <campaigns> <campaign name="wlm-es" id="2" isenabled="0" autoCategories="" autoWikiText="" defaultAlt="" defaultCategories="" defaultDescription="" defaultLat="" defaultLon="" defaultOwnWorkLicence="cc-by-sa-3.0" headerLabelPage="sdfsdf" idField="sdfafsdfd" idFieldInitialValue="" idFieldLabel="" idFieldLabelPage="" idFieldMaxLength="25" licensesOwnWork="cc-by-sa-3.0|cc-by-3.0|cc-zero" ownWorkOption="choice" skipTutorial="" thanksLabelPage="" tutorialHelpdeskCoords="27, 1319, 691, 1384" tutorialTemplate="Licensing_tutorial_$1.svg" tutorialWidth="720" /> </campaigns> </uploadcampaign> </api>
I don't think it should contain all campaign parameters as a single tag, as parameters. Specially evil is the licensesOwnWork="cc-by-sa-3.0|cc-by-3.0|cc-zero".
I'd move it to a format like: <campaigns> <campaign> <id>wlm-es</id> <name>wlm-es</name> <licenses> <ownwork default="cc-by-sa-3.0"> <license>cc-by-sa-3.0</license> <license>cc-by-3.0</license> <license>cc-zero</license> </ownwork> </licenses> <fields> <field> <name>sdfafsdfd</name> <initialValue/> <label/> <labelPage/> <maxLength>25</maxLength> </fields> <tutorial skip="0"> <template placeholder="$1">Licensing_tutorial_$1.svg</template> <width>720</width> <helpdeskCoords x0="27" x1="1319" y1="691" y2="1384" /> </tutorial> </campaigns>
Not necessariliy like that, some options could get collapsed into attributes. But not with everything as attributes.
On Thu, May 17, 2012 at 8:36 AM, Platonides platonides@gmail.com wrote:
I don't think it should contain all campaign parameters as a single tag, as parameters. Specially evil is the licensesOwnWork="cc-by-sa-3.0|cc-by-3.0|cc-zero".
The data's stored as a bunch of simple key-value pairs, including that pipe-separated list. I'm a bit leery of imposing structure where it doesn't necessarily already exist.
I'd prefer a more JSON-friendly structure, such as arrays for the array fields, but making something that also works in the horrid back-compat XML output format is awkward.
I'll see if I can whip up something that looks a little friendlier though...
-- brion
On 20/05/12 23:10, Brion Vibber wrote:
On Thu, May 17, 2012 at 8:36 AM, Platonides platonides@gmail.com wrote:
I don't think it should contain all campaign parameters as a single tag, as parameters. Specially evil is the licensesOwnWork="cc-by-sa-3.0|cc-by-3.0|cc-zero".
The data's stored as a bunch of simple key-value pairs, including that pipe-separated list.
That's horrible! If it went to store it that way, at least it should have provided an accessor which translated it into an array. When the extension is the only consumer, we have some flexibility for later fixing the interface. If there third-party apps are reading from such API, it gets set in stone and we can no longer fix it. I'd at least provide a sane interface through the api. It's not so urgent to fix the extension, but it should eventually be done, too.
Hey,
The data's stored as a bunch of simple key-value pairs, including that pipe-separated list.
That's horrible!
I think you might be missing some context to make that judgment.
at least it should have provided an accessor which translated it into an
array.
It does. But if you then go implode the array such as done here at line 62, then of course you don't have an array any more: https://gerrit.wikimedia.org/r/#/c/7832/2/api/ApiUploadCampaign.php,unified
Cheers
-- Jeroen De Dauw http://www.bn2vs.com Don't panic. Don't be evil. --
On Sun, May 20, 2012 at 2:17 PM, Platonides Platonides@gmail.com wrote:
On 20/05/12 23:10, Brion Vibber wrote:
On Thu, May 17, 2012 at 8:36 AM, Platonides platonides@gmail.com
wrote:
I don't think it should contain all campaign parameters as a single tag, as parameters. Specially evil is the licensesOwnWork="cc-by-sa-3.0|cc-by-3.0|cc-zero".
The data's stored as a bunch of simple key-value pairs, including that pipe-separated list.
That's horrible! If it went to store it that way, at least it should have provided an accessor which translated it into an array.
That it does; with some tweaking I can make it output nicely as an array for both JSON and XML too. But beyond that, there's not much structure to the UploadWizardCampaign class's configuration array.
-- brion
When the extension is the only consumer, we have some flexibility for later fixing the interface. If there third-party apps are reading from such API, it gets set in stone and we can no longer fix it. I'd at least provide a sane interface through the api. It's not so urgent to fix the extension, but it should eventually be done, too.
Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Ok, updated patchset at https://gerrit.wikimedia.org/r/#/c/7832/
Thoughts? Worth adding more structure or is this good enough?
JSON output looks like this (config portion is now optional, leave it out to just get a list of campaigns):
{ "uploadcampaign": { "campaigns": [ { "name": "wlm-fake", "id": 1, "isenabled": 0, "config": { "autoCategories": [ "AutoCat1", "AutoCat2" ], "autoWikiText": "", "defaultAlt": "", "defaultCategories": [ "ListCat1", "ListCat2" ], "defaultDescription": "", "defaultLat": "", "defaultLon": "", "defaultOwnWorkLicence": "cc-by-sa-3.0", "headerLabelPage": "", "idField": "", "idFieldInitialValue": "", "idFieldLabel": "", "idFieldLabelPage": "", "idFieldMaxLength": "25", "licensesOwnWork": [ "cc-by-sa-3.0", "cc-by-3.0", "cc-zero" ], "ownWorkOption": "choice", "skipTutorial": "", "thanksLabelPage": "", "tutorialHelpdeskCoords": "27, 1319, 691, 1384", "tutorialTemplate": "Licensing_tutorial_$1.svg", "tutorialWidth": "720" } } ] } }
or xml:
<api> <uploadcampaign> <campaigns> <campaign> <name xml:space="preserve">wlm-fake</name> <id xml:space="preserve">1</id> <isenabled xml:space="preserve">0</isenabled> <config> <autoCategories> <category>AutoCat1</category> <category>AutoCat2</category> </autoCategories> <autoWikiText xml:space="preserve" /> <defaultAlt xml:space="preserve" /> <defaultCategories> <category>ListCat1</category> <category>ListCat2</category> </defaultCategories> <defaultDescription xml:space="preserve" /> <defaultLat xml:space="preserve" /> <defaultLon xml:space="preserve" /> <defaultOwnWorkLicence xml:space="preserve">cc-by-sa-3.0</defaultOwnWorkLicence> <headerLabelPage xml:space="preserve" /> <idField xml:space="preserve" /> <idFieldInitialValue xml:space="preserve" /> <idFieldLabel xml:space="preserve" /> <idFieldLabelPage xml:space="preserve" /> <idFieldMaxLength xml:space="preserve">25</idFieldMaxLength> <licensesOwnWork> <license>cc-by-sa-3.0</license> <license>cc-by-3.0</license> <license>cc-zero</license> </licensesOwnWork> <ownWorkOption xml:space="preserve">choice</ownWorkOption> <skipTutorial xml:space="preserve" /> <thanksLabelPage xml:space="preserve" /> <tutorialHelpdeskCoords xml:space="preserve">27, 1319, 691, 1384</tutorialHelpdeskCoords> <tutorialTemplate xml:space="preserve">Licensing_tutorial_$1.svg</tutorialTemplate> <tutorialWidth xml:space="preserve">720</tutorialWidth> </config> </campaign> </campaigns> </uploadcampaign></api> (The xml:space="preserve"s all come in from the framework, I didn't add em!)
-- brion
On Sun, May 20, 2012 at 2:59 PM, Brion Vibber brion@pobox.com wrote:
Ok, updated patchset at https://gerrit.wikimedia.org/r/#/c/7832/
Thoughts? Worth adding more structure or is this good enough?
I'll assume this is ok for now since no one objects. :) Anybody want to help review it?
-- brion
wikitech-l@lists.wikimedia.org