Ladsgroup has uploaded a new change for review.

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

Change subject: Re-introduce "Templatize Special:Contributions lines"
......................................................................

Re-introduce "Templatize Special:Contributions lines"

The original change was 1bce6db10e99840cfbd10fa074c93d8d96d88412
It got reverted in I8f63e002e34a9d13e2597a27e3dd918a687d1e7c
Fixed issues raised

Change-Id: I047038d6164bd6e32909d25bb37002b43bfd3a92
---
M includes/specials/SpecialContributions.php
A includes/templates/SpecialContributionsLine.mustache
2 files changed, 41 insertions(+), 20 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/41/278841/1

diff --git a/includes/specials/SpecialContributions.php 
b/includes/specials/SpecialContributions.php
index 7b8aa4c..decdad0 100644
--- a/includes/specials/SpecialContributions.php
+++ b/includes/specials/SpecialContributions.php
@@ -1101,16 +1101,13 @@
                                $userlink = '';
                        }
 
+                       $flags = [];
                        if ( $rev->getParentId() === 0 ) {
-                               $nflag = ChangesList::flag( 'newpage' );
-                       } else {
-                               $nflag = '';
+                               $flags[] = ChangesList::flag( 'newpage' );
                        }
 
                        if ( $rev->isMinor() ) {
-                               $mflag = ChangesList::flag( 'minor' );
-                       } else {
-                               $mflag = '';
+                               $flags[] = ChangesList::flag( 'minor' );
                        }
 
                        $del = Linker::getRevDeleteLink( $user, $rev, $page );
@@ -1121,15 +1118,6 @@
                        $diffHistLinks = $this->msg( 'parentheses' )
                                ->rawParams( $difftext . 
$this->messages['pipe-separator'] . $histlink )
                                ->escaped();
-                       $ret = "{$del}{$d} 
{$diffHistLinks}{$chardiff}{$nflag}{$mflag} ";
-                       $ret .= "{$link}{$userlink} {$comment} {$topmarktext}";
-
-                       # Denote if username is redacted for this edit
-                       if ( $rev->isDeleted( Revision::DELETED_USER ) ) {
-                               $ret .= " <strong>" .
-                                       $this->msg( 'rev-deleted-user-contribs' 
)->escaped() .
-                                       "</strong>";
-                       }
 
                        # Tags, if any.
                        list( $tagSummary, $newClasses ) = 
ChangeTags::formatSummaryRow(
@@ -1138,20 +1126,47 @@
                                $this->getContext()
                        );
                        $classes = array_merge( $classes, $newClasses );
-                       $ret .= " $tagSummary";
+
+                       $templateParams = [
+                               'del' => $del,
+                               'timestamp' => $d,
+                               'diffHistLinks' => $diffHistLinks,
+                               'charDifference' => $chardiff,
+                               'flags' => $flags,
+                               'articleLink' => $link,
+                               'userlink' => $userlink,
+                               'logText' => $comment,
+                               'topmarktext' => $topmarktext,
+                               'tagSummary' => $tagSummary,
+                       ];
+
+                       # Denote if username is redacted for this edit
+                       if ( $rev->isDeleted( Revision::DELETED_USER ) ) {
+                               $templateParams['rev-deleted-user-contribs'] =
+                                       $this->msg( 'rev-deleted-user-contribs' 
)->escaped();
+                       }
+
+                       $templateParser = new TemplateParser();
+                       $ret = $templateParser->processTemplate(
+                               'SpecialContributionsLine',
+                               $templateParams
+                       );
                }
 
                // Let extensions add data
                Hooks::run( 'ContributionsLineEnding', [ $this, &$ret, $row, 
&$classes ] );
 
+               // TODO: Handle exceptions in the catch block above.  Do any 
extensions rely on
+               // receiving empty rows?
+
                if ( $classes === [] && $ret === '' ) {
                        wfDebug( "Dropping Special:Contribution row that could 
not be formatted\n" );
-                       $ret = "<!-- Could not format Special:Contribution row. 
-->\n";
-               } else {
-                       $ret = Html::rawElement( 'li', [ 'class' => $classes ], 
$ret ) . "\n";
+                       return "<!-- Could not format Special:Contribution row. 
-->\n";
                }
 
-               return $ret;
+               // FIXME: The signature of the ContributionsLineEnding hook 
makes it
+               // very awkward to move this LI wrapper into the template.
+               return Html::rawElement( 'li', [ 'class' => $classes ], $ret ) 
. "\n";
        }
 
        /**
diff --git a/includes/templates/SpecialContributionsLine.mustache 
b/includes/templates/SpecialContributionsLine.mustache
new file mode 100644
index 0000000..7a33401
--- /dev/null
+++ b/includes/templates/SpecialContributionsLine.mustache
@@ -0,0 +1,6 @@
+{{{ del }}}{{{ timestamp }}}
+{{{ diffHistLinks }}}{{{ charDifference }}}{{# flags }}{{{ . }}}{{/ flags }}
+{{{ articleLink }}}{{{ userlink }}}
+{{{ logText }}}
+{{{ topmarktext }}}{{# rev-deleted-user-contribs }} <strong>{{{ . 
}}}</strong>{{/ rev-deleted-user-contribs }}
+{{{ tagSummary }}}

-- 
To view, visit https://gerrit.wikimedia.org/r/278841
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I047038d6164bd6e32909d25bb37002b43bfd3a92
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to