Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Wikipedia: Wikitech

Re: [Mediawiki-api] UploadWizard campaign info API format

 

 

Wikipedia wikitech RSS feed   Index | Next | Previous | View Threaded


platonides at gmail

May 17, 2012, 8:36 AM

Post #1 of 7 (215 views)
Permalink
Re: [Mediawiki-api] UploadWizard campaign info API format

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.

_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


brion at wikimedia

May 20, 2012, 2:10 PM

Post #2 of 7 (208 views)
Permalink
Re: [Mediawiki-api] UploadWizard campaign info API format [In reply to]

On Thu, May 17, 2012 at 8:36 AM, Platonides <platonides [at] gmail> 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
_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


Platonides at gmail

May 20, 2012, 2:17 PM

Post #3 of 7 (207 views)
Permalink
Re: [Mediawiki-api] UploadWizard campaign info API format [In reply to]

On 20/05/12 23:10, Brion Vibber wrote:
> On Thu, May 17, 2012 at 8:36 AM, Platonides <platonides [at] gmail> 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.


_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


jeroendedauw at gmail

May 20, 2012, 2:26 PM

Post #4 of 7 (198 views)
Permalink
Re: [Mediawiki-api] UploadWizard campaign info API format [In reply to]

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.
--
_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


brion at pobox

May 20, 2012, 2:44 PM

Post #5 of 7 (201 views)
Permalink
Re: [Mediawiki-api] UploadWizard campaign info API format [In reply to]

On Sun, May 20, 2012 at 2:17 PM, Platonides <Platonides [at] gmail> wrote:

> On 20/05/12 23:10, Brion Vibber wrote:
> > On Thu, May 17, 2012 at 8:36 AM, Platonides <platonides [at] gmail>
> 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 [at] lists
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>
_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


brion at pobox

May 20, 2012, 2:59 PM

Post #6 of 7 (200 views)
Permalink
Re: [Mediawiki-api] UploadWizard campaign info API format [In reply to]

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
_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


brion at pobox

May 24, 2012, 10:38 AM

Post #7 of 7 (202 views)
Permalink
Re: [Mediawiki-api] UploadWizard campaign info API format [In reply to]

On Sun, May 20, 2012 at 2:59 PM, Brion Vibber <brion [at] pobox> 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 mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Wikipedia wikitech RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.