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
Description
Details
Subject | Repo | Branch | Lines +/- | |
---|---|---|---|---|
Allow admin to specify twig template for wikitext export report | wikimedia/iegreview | master | +101 -36 |
Related Objects
Event Timeline
@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.
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 %}
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
Change 211525 merged by jenkins-bot:
Allow admin to specify twig template for wikitext export report