Page MenuHomePhabricator

Add option to download the data from any table or chart
Closed, ResolvedPublic

Description

As the title says :)

Would be nice to let people export in different formats: JSON/TSV/CSV/wikitable and for the charts, a PNG and maybe even a Print option.

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald TranscriptJul 22 2017, 10:48 AM
MusikAnimal renamed this task from Add option to download the data ("Pages created") to Add option to download the data from any table or chart.Jul 22 2017, 6:14 PM
MusikAnimal updated the task description. (Show Details)
MusikAnimal moved this task from Inbox to Other on the XTools board.
MusikAnimal added a subscriber: MusikAnimal.EditedNov 15 2017, 7:37 PM

This is easy-ish, just a lot of busy work. For GCI I think we should limit this to the Edit Counter, and only for downloading wikitext. For each view, you'd have an accompanying section_name.wikitext.twig view that renders the same data but in wikitext. Then you'd add a link to the section header. So for the general stats section, in editCounter/result.html.twig:

{% set headerLink %}
    <a href="{{ path('EditCounterGeneralStats', {project:project.domain, username:user.username})}}">{{ msg("general-stats") }}</a>
{% endset %}
{% set downloadLink %}
    <a href="{{ path('EditCounterGeneralStats', {project:project.domain, username:user.username})}}?format=wikitext">{{ msg("export-wikitext") }}</a>
{% endset %}
{{ layout.content_block(headerLink, content, downloadLink, 'general-stats', true) }}

(see layout.html.twig for how content_block works, and articleInfo/result.wikitext.twig for an example wikitext template)

In the controller, at the bottom of each relevant action:

// Output the relevant format template.
$format = $request->query->get('format', 'html');
if ($format == '') {
    // The default above doesn't work when the 'format' parameter is blank.
    $format = 'html';
}
$response = $this->render("editCounter/general_stats.$format.twig", [
    'xtTitle' => $this->user->getUsername(),
    'xtPage' => 'ec',
    'is_sub_request' => $isSubRequest,
    'user' => $this->user,
    'project' => $this->project,
    'ec' => $this->editCounter,
]);
if ($format === 'wikitext') {
    $response->headers->set('Content-Type', 'text/plain');
}

return $response;

So the requirements to do this are familiarity with:

  • Wikitext
  • Twig
  • Basic PHP

Is that too much for GCI? Like I said, this is easy-ish, but not sure about good first bug

MusikAnimal moved this task from Other to Working on the XTools board.EditedJan 31 2018, 9:14 PM
MusikAnimal claimed this task.

Wikitext and CSV download options have now been added to most of the sections of the Edit Counter. I'll continue to add download options to other tools, as well.

Example to get the month counts of a user: https://xtools.wmflabs.org/ec-monthcounts/en.wikipedia.org/L235?format=wikitext

MusikAnimal closed this task as Resolved.Mar 29 2018, 3:10 AM
MusikAnimal moved this task from Working to Complete on the XTools board.

This task was originally (T171378#3463164) about exporting from Pages Created. That tool now exports to all of the requested formats. Several other places across XTools have export options, but not all. It's actually a lot of busy work, and fragile because any changes we make to the main tool need to be made to the other view formats as well. For this reason I'm going to close this as resolved, and we can add export options for other tools as requested.