r89566 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89565‎ | r89566 | r89567 >
Date:14:56, 6 June 2011
Author:reedy
Status:resolved (Comments)
Tags:
Comment:
Followup r89564

Strip out the ?feed= functionality, update urls to point at the API!
Modified paths:
  • /trunk/phase3/includes/specials/SpecialContributions.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialContributions.php
@@ -116,10 +116,14 @@
117117 }
118118
119119 // Add RSS/atom links
120 - $this->setSyndicated();
121 - $feedType = $wgRequest->getVal( 'feed' );
122 - if( $feedType ) {
123 - return $this->feed( $feedType );
 120+ global $wgFeedClasses;
 121+ $apiParams = array( 'action' => 'feedcontributions', 'user' => $wgUser->getName() );
 122+ $feedTemplate = wfScript( 'api' ) . '?';
 123+
 124+ foreach( $wgFeedClasses as $format => $class ) {
 125+ $theseParams = $apiParams + array( 'feedformat' => $format );
 126+ $url = $feedTemplate . wfArrayToCGI( $theseParams );
 127+ $wgOut->addFeedLink( $format, $url );
124128 }
125129
126130 if ( wfRunHooks( 'SpecialContributionsBeforeMainOutput', array( $id ) ) ) {
@@ -150,7 +154,6 @@
151155 }
152156 $wgOut->preventClickjacking( $pager->getPreventClickjacking() );
153157
154 -
155158 # Show the appropriate "footer" message - WHOIS tools, etc.
156159 if( $target != 'newbies' ) {
157160 $message = 'sp-contributions-footer';
@@ -173,12 +176,6 @@
174177 }
175178 }
176179
177 - protected function setSyndicated() {
178 - global $wgOut;
179 - $wgOut->setSyndicated( true );
180 - $wgOut->setFeedAppendQuery( wfArrayToCGI( $this->opts ) );
181 - }
182 -
183180 /**
184181 * Generates the subheading with links
185182 * @param $nt Title object for the target
@@ -411,103 +408,6 @@
412409 Xml::closeElement( 'form' );
413410 return $f;
414411 }
415 -
416 - /**
417 - * Output a subscription feed listing recent edits to this page.
418 - * @param $type String
419 - */
420 - protected function feed( $type ) {
421 - global $wgFeed, $wgFeedClasses, $wgFeedLimit, $wgOut;
422 -
423 - if( !$wgFeed ) {
424 - $wgOut->addWikiMsg( 'feed-unavailable' );
425 - return;
426 - }
427 -
428 - if( !isset( $wgFeedClasses[$type] ) ) {
429 - $wgOut->addWikiMsg( 'feed-invalid' );
430 - return;
431 - }
432 -
433 - $feed = new $wgFeedClasses[$type](
434 - $this->feedTitle(),
435 - wfMsgExt( 'tagline', 'parsemag' ),
436 - $this->getTitle()->getFullUrl() . "/" . urlencode($this->opts['target'])
437 - );
438 -
439 - // Already valid title
440 - $nt = Title::makeTitleSafe( NS_USER, $this->opts['target'] );
441 - $target = $this->opts['target'] == 'newbies' ? 'newbies' : $nt->getText();
442 -
443 - $pager = new ContribsPager( array(
444 - 'target' => $target,
445 - 'namespace' => $this->opts['namespace'],
446 - 'year' => $this->opts['year'],
447 - 'month' => $this->opts['month'],
448 - 'tagFilter' => $this->opts['tagFilter'],
449 - 'deletedOnly' => $this->opts['deletedOnly'],
450 - 'topOnly' => $this->opts['topOnly'],
451 - 'showSizeDiff' => $this->opts['showSizeDiff'],
452 - ) );
453 -
454 - $pager->mLimit = min( $this->opts['limit'], $wgFeedLimit );
455 -
456 - $feed->outHeader();
457 - if( $pager->getNumRows() > 0 ) {
458 - foreach ( $pager->mResult as $row ) {
459 - $feed->outItem( $this->feedItem( $row ) );
460 - }
461 - }
462 - $feed->outFooter();
463 - }
464 -
465 - protected function feedTitle() {
466 - global $wgLanguageCode, $wgSitename;
467 - $desc = $this->getDescription();
468 - return "$wgSitename - $desc [$wgLanguageCode]";
469 - }
470 -
471 - protected function feedItem( $row ) {
472 - $title = Title::MakeTitle( intval( $row->page_namespace ), $row->page_title );
473 - if( $title ) {
474 - $date = $row->rev_timestamp;
475 - $comments = $title->getTalkPage()->getFullURL();
476 - $revision = Revision::newFromTitle( $title, $row->rev_id );
477 -
478 - return new FeedItem(
479 - $title->getPrefixedText(),
480 - $this->feedItemDesc( $revision ),
481 - $title->getFullURL(),
482 - $date,
483 - $this->feedItemAuthor( $revision ),
484 - $comments
485 - );
486 - } else {
487 - return null;
488 - }
489 - }
490 -
491 - /**
492 - * @param $revision Revision
493 - * @return string
494 - */
495 - protected function feedItemAuthor( $revision ) {
496 - return $revision->getUserText();
497 - }
498 -
499 - /**
500 - * @param $revision Revision
501 - * @return string
502 - */
503 - protected function feedItemDesc( $revision ) {
504 - if( $revision ) {
505 - return '<p>' . htmlspecialchars( $revision->getUserText() ) . wfMsgForContent( 'colon-separator' ) .
506 - htmlspecialchars( FeedItem::stripComment( $revision->getComment() ) ) .
507 - "</p>\n<hr />\n<div>" .
508 - nl2br( htmlspecialchars( $revision->getText() ) ) . "</div>";
509 - }
510 - return '';
511 - }
512412 }
513413
514414 /**

Follow-up revisions

RevisionCommit summaryAuthorDate
r89568Refactoring to r89566...reedy15:07, 6 June 2011
r90775Followup r89566...reedy16:41, 25 June 2011
r90847Followup r89566, r89568, make links point to the user whom the contributions ...reedy19:33, 26 June 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r89564* (bug 26763) Make RSS/Atom of user contributions more visible...reedy14:50, 6 June 2011

Comments

#Comment by Reedy (talk | contribs)   15:09, 6 June 2011

The only thing about this commit, is if we should keep ?feed=blah and HTTP 301 redirect it or something? :/

#Comment by Bawolff (talk | contribs)   18:14, 6 June 2011

I think we should, simply because some people might just assume that you can add ?feed=atom to a special page to get a feed, since that works for most places you can get a feed, even for things like history pages.

#Comment by Raymond (talk | contribs)   20:20, 24 June 2011

Change status to FIXME because all existing URls are broken now.

#Comment by Duplicatebug (talk | contribs)   19:07, 26 June 2011

Using $wgUser for user looks wrong, because you want not your own list at this point

#Comment by Reedy (talk | contribs)   19:33, 26 June 2011

Bleh, cheers.

Came from me stealing it from the watchlist code originally

Status & tagging log