Page MenuHomePhabricator

Allow campaigns to specify wikitext report template
Closed, ResolvedPublic

Description

The current wikitext template is for the IEG scoring. Here is the updated template for Inspire: https://meta.wikimedia.org/wiki/Template:Inspire/Review/Score

Event Timeline

AlexWang assigned this task to Niharika.
AlexWang raised the priority of this task from to High.
AlexWang updated the task description. (Show Details)
AlexWang moved this task to Backlog on the Wikimedia-IEG-grant-review board.
AlexWang subscribed.
bd808 renamed this task from Updating wikitext template to Allow campaigns to specify wikitext report tamplate.Mar 20 2015, 3:17 AM
bd808 renamed this task from Allow campaigns to specify wikitext report tamplate to Allow campaigns to specify wikitext report template.
bd808 removed Niharika as the assignee of this task.
bd808 lowered the priority of this task from High to Medium.
bd808 set Security to None.

@bd808 I was thinking about this. If we let the reviewers give us the text blob and ask them to place special keywords such as $title, $q1average, $q2average, $comments etc at the desired places, which we then loop through and replace in PHP/Twig template, would that be an elegant solution?
On the frontend we can display a legend for what keywords map to what value beside the textarea.

Notes about this from mine and Bryan's 1-on-1 yesterday-

  • Creating an interface that lets the admin(s) specify the Twig template structure itself -- i.e. construct the twig template syntax from the user input. (A bit unclear on what this would look like on the frontend)
  • Validate the syntax (see http://twig.sensiolabs.org/doc/recipes.html) and save it to db.
  • Render page from syntax stored in db.

See also: http://twig.sensiolabs.org/doc/advanced.html

In T93248#1231189, @NiharikaKohli wrote:
  • Creating an interface that lets the admin(s) specify the Twig template structure itself -- i.e. construct the twig template syntax from the user input. (A bit unclear on what this would look like on the frontend)

I think it would just look like a textarea that gets used to input the template code. The template itself would just override a per-row block for formatting the report content. This would be an easy refactor of the current data/templates/reports/wikitext.html template.

A template to match the current Inspire setup might look something like this:

{% extends 'reports/wikitext.html' %}
{% block row %}
  <div class="panel panel-default">
    <div class="panel-heading">
      <h4 class="panel-title">
        <a class="accordion-toggle collapsed block" data-toggle="collapse" data-parent="#accordion" href="#proposal{{ row.id }}">
          {{ row.title }}
          ·
          <small>{{ "theme-#{row.theme}"|message }}</small>
          ·
          <small>
            {{ row.pcnt|number_format(2) }}%
            ({{ row.recommend }}/{{ row.rcnt }}){{ row.conditional }}
          </small>
        </a>
      </h4>
    </div>
    <div id="proposal{{ row.id }}" class="panel-collapse collapse">
      <div class="panel-body form-group">
        <a href="{{ row.url|raw }}" target="_blank">{{ row.title }}</a>
        <textarea class="form-control" rows="10" readonly>
==Aggregated feedback from the committee for ''{{ row.title }}''==
{{ '{{' }}Inspire/Review/Score
{% for label, qid in questions %}
| {{ label }} score={{ row[qid]|number_format(1) }}
{% endfor %}
| comments=
{% for comment in row.comments %}
* {{ comment|replace( { "\n":' ' } ) }}
{% endfor %}
{{ '}}' }}
</textarea>
      </div>
    </div>
  </div>
{% endblock row %}

To be clear, are we asking the Admin to input code by themselves into the textarea?

In T93248#1231603, @NiharikaKohli wrote:

To be clear, are we asking the Admin to input code by themselves into the textarea?

Yeah. It's not the prettiest solution in the world, but it is flexible and honestly not worse than wikitext. That's why we need validation before saving by compiling the template and checking for errors.

Change 211525 had a related patch set uploaded (by Niharika29):
[WIP]Allow admin to specify twig template for wikitext export report

https://gerrit.wikimedia.org/r/211525

Change 211525 merged by jenkins-bot:
Allow admin to specify twig template for wikitext export report

https://gerrit.wikimedia.org/r/211525

bd808 moved this task from Done to Archive on the Wikimedia-IEG-grant-review board.