Index: trunk/extensions/FlaggedRevs/FlaggedRevs.php |
— | — | @@ -255,7 +255,7 @@ |
256 | 256 | $wgAvailableRights[] = 'stablesettings'; |
257 | 257 | |
258 | 258 | # Bump this number every time you change flaggedrevs.css/flaggedrevs.js |
259 | | -$wgFlaggedRevStyleVersion = 77; |
| 259 | +$wgFlaggedRevStyleVersion = '78'; |
260 | 260 | |
261 | 261 | $wgExtensionFunctions[] = 'efLoadFlaggedRevs'; |
262 | 262 | |
— | — | @@ -492,6 +492,10 @@ |
493 | 493 | |
494 | 494 | # Database schema changes |
495 | 495 | $wgHooks['LoadExtensionSchemaUpdates'][] = 'FlaggedRevsHooks::addSchemaUpdates'; |
| 496 | + |
| 497 | +# Performance Don't show content on diff |
| 498 | +$wgHooks['ArticleContentOnDiff'][] = 'FlaggedRevsHooks::addCustomHtml'; |
| 499 | + |
496 | 500 | # ######## |
497 | 501 | |
498 | 502 | function efSetFlaggedRevsConditionalHooks() { |
Index: trunk/extensions/FlaggedRevs/FlaggedRevs.hooks.php |
— | — | @@ -53,15 +53,18 @@ |
54 | 54 | if ( !$fa || !$fa->isReviewable() ) { |
55 | 55 | return true; |
56 | 56 | } |
57 | | - global $wgJsMimeType, $wgFlaggedRevStyleVersion; |
| 57 | + global $wgJsMimeType, $wgFlaggedRevStyleVersion, $wgStylePath, $wgStyleVersion; |
58 | 58 | $stylePath = FlaggedRevs::styleUrlPath(); |
59 | 59 | # Get JS/CSS file locations |
60 | 60 | $encCssFile = htmlspecialchars( "$stylePath/flaggedrevs.css?$wgFlaggedRevStyleVersion" ); |
61 | 61 | $encJsFile = htmlspecialchars( "$stylePath/flaggedrevs.js?$wgFlaggedRevStyleVersion" ); |
| 62 | + |
| 63 | + //TODO fix this to use the correct method |
62 | 64 | # Add CSS file |
63 | | - $wgOut->addExtensionStyle( $encCssFile ); |
| 65 | + //$wgOut->addExtensionStyle( $encCssFile ); |
64 | 66 | # Add main JS file |
65 | 67 | $head = "<script type=\"{$wgJsMimeType}\" src=\"{$encJsFile}\"></script>"; |
| 68 | + $head .= "<link rel=\"stylesheet\" href=\"{$encCssFile}\"></link>"; |
66 | 69 | # Add review form JS for reviewers |
67 | 70 | if ( $wgUser->isAllowed( 'review' ) ) { |
68 | 71 | $encJsFile = htmlspecialchars( "$stylePath/review.js?$wgFlaggedRevStyleVersion" ); |
— | — | @@ -108,6 +111,8 @@ |
109 | 112 | $stableId = null; |
110 | 113 | } |
111 | 114 | $globalVars['wgStableRevisionId'] = $stableId; |
| 115 | + $globalVars['wgLatestRevisionId'] = $fa->getLatest(); |
| 116 | + $globalVars['wgPageId'] = $fa->getID(); |
112 | 117 | if ( $wgUser->isAllowed( 'review' ) ) { |
113 | 118 | $ajaxReview = (object) array( |
114 | 119 | 'sendMsg' => wfMsgHtml( 'revreview-submit' ), |
— | — | @@ -1805,6 +1810,20 @@ |
1806 | 1811 | $view->addToDiffView( $diff, $oldRev, $newRev ); |
1807 | 1812 | return true; |
1808 | 1813 | } |
| 1814 | + |
| 1815 | + /* |
| 1816 | + * If an article is reviewable, get custom article contents from the FlaggedArticleView |
| 1817 | + */ |
| 1818 | + public static function addCustomHtml( $diffEngine, &$out ) { |
| 1819 | + $fa = FlaggedArticle::getTitleInstance( $out->getTitle() ); |
| 1820 | + if ( !$fa->isReviewable() ) { |
| 1821 | + return true; // nothing to do |
| 1822 | + } |
| 1823 | + |
| 1824 | + $view = FlaggedArticleView::singleton(); |
| 1825 | + $view->addCustomHtml( $out ); |
| 1826 | + return false; |
| 1827 | + } |
1809 | 1828 | |
1810 | 1829 | public static function addRevisionIDField( $editPage, $out ) { |
1811 | 1830 | $view = FlaggedArticleView::singleton(); |
Index: trunk/extensions/FlaggedRevs/FlaggedArticleView.php |
— | — | @@ -164,9 +164,9 @@ |
165 | 165 | */ |
166 | 166 | public function displayTag() { |
167 | 167 | global $wgOut; |
168 | | - $this->load(); |
| 168 | + $this->load(); |
169 | 169 | // Sanity check that this is a reviewable page |
170 | | - if ( $this->article->isReviewable() ) { |
| 170 | + if ( $this->article->isReviewable() ) { |
171 | 171 | $wgOut->appendSubtitle( $this->reviewNotice ); |
172 | 172 | } |
173 | 173 | return true; |
— | — | @@ -1811,4 +1811,19 @@ |
1812 | 1812 | } |
1813 | 1813 | return true; |
1814 | 1814 | } |
| 1815 | + |
| 1816 | + /* |
| 1817 | + * If this is a diff page then replace the article contents with a link to the specific revision. |
| 1818 | + * This will be replaced with artice content using javascript and an api call. |
| 1819 | + */ |
| 1820 | + public function addCustomHtml( OutputPage &$out ) { |
| 1821 | + global $wgTitle, $wgScript, $wgRequest; |
| 1822 | + $this->load(); |
| 1823 | + if ( $wgRequest->getVal( 'oldid' ) ) { |
| 1824 | + $oldId = $wgRequest->getVal( 'oldid' ); |
| 1825 | + $oldRevisionUrl = $wgScript . '?title=' . $wgTitle . '&oldid=' . $oldId; |
| 1826 | + $out->addHTML( "<div id='mw-fr-revisioncontents'>Click <a href='" . $oldRevisionUrl . "' >here</a> to view this revision.</div>" ); |
| 1827 | + } |
| 1828 | + |
| 1829 | + } |
1815 | 1830 | } |
Index: trunk/extensions/FlaggedRevs/client/flaggedrevs.css |
— | — | @@ -336,3 +336,18 @@ |
337 | 337 | .fr-hiddenform { |
338 | 338 | display: none; |
339 | 339 | } |
| 340 | + |
| 341 | +.loading { |
| 342 | + display: block; |
| 343 | + color: #666666; |
| 344 | + padding-left: 32px; |
| 345 | + height: 32px; |
| 346 | +} |
| 347 | +.spinner { |
| 348 | + background-image: url(img/loading-small.gif) !important; |
| 349 | + background-position: left center; |
| 350 | + background-repeat: no-repeat; |
| 351 | + margin-left: 0.5em; |
| 352 | + margin-top: -0.25em; |
| 353 | + float: left; |
| 354 | +} |
Index: trunk/extensions/FlaggedRevs/client/flaggedrevs.js |
— | — | @@ -182,9 +182,57 @@ |
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
| 186 | +FlaggedRevs.getRevisionContents = function() { |
| 187 | + //get the contents div and replace it with actual parsed article contents via an API call. |
| 188 | + var contentsDiv = document.getElementById("mw-fr-revisioncontents"); |
| 189 | + var prevLink = document.getElementById("differences-prevlink"); |
| 190 | + var nextLink = document.getElementById("differences-nextlink"); |
| 191 | + var timeoutId = null; |
| 192 | + if( contentsDiv ) { |
| 193 | + var diffUIParams = document.getElementById("mw-fr-diff-dataform"); |
| 194 | + var oldRevId = diffUIParams.getElementsByTagName('input')[1].value; |
| 195 | + contentsDiv.innerHTML = "<span class='loading spinner'></span><span class='loading' >Waiting for contents</span>"; |
| 196 | + var requestArgs = 'action=parse&prop=text&format=xml'; |
| 197 | + if ( window.wgLatestRevisionId == oldRevId ) { |
| 198 | + requestArgs += '&pageid=' + window.wgPageId; |
| 199 | + } else { |
| 200 | + requestArgs += '&oldid=' + oldRevId; |
| 201 | + } |
| 202 | + timeoutId = window.setTimeout( function() { |
| 203 | + $.ajax({ |
| 204 | + url : wgScriptPath + '/api.php', |
| 205 | + type : "GET", |
| 206 | + data : requestArgs, |
| 207 | + dataType: "xml", |
| 208 | + success : function( result ) { |
| 209 | + contents = $(result).find("text"); |
| 210 | + if ( contents ) { |
| 211 | + contentsDiv.innerHTML = contents.text(); |
| 212 | + } |
| 213 | + }, |
| 214 | + error : function(xmlHttpRequest, textStatus, errThrown) { |
| 215 | + alert("error: " + textStauts); |
| 216 | + } |
| 217 | + }); |
| 218 | + }, 1000 ); |
| 219 | + } |
| 220 | + if ( prevLink && timeoutId ) { |
| 221 | + prevLink.onclick = function() { |
| 222 | + window.clearTimeout( timeoutId ); |
| 223 | + } |
| 224 | + } |
| 225 | + if ( nextLink && timeoutId ) { |
| 226 | + nextLink.onclick = function() { |
| 227 | + window.clearTimeout( timeoutId ); |
| 228 | + } |
| 229 | + } |
| 230 | +} |
| 231 | + |
186 | 232 | FlaggedRevs.setJSTriggers = function() { |
187 | 233 | FlaggedRevs.enableShowhide(); |
188 | 234 | FlaggedRevs.setCheckTrigger(); |
| 235 | + FlaggedRevs.getRevisionContents(); |
189 | 236 | } |
190 | 237 | |
191 | | -hookEvent("load", FlaggedRevs.setJSTriggers); |
| 238 | +//TODO figure out the correct way to do this |
| 239 | +window.onload = FlaggedRevs.setJSTriggers; |
Index: trunk/extensions/FlaggedRevs/client/img/loading-small.gif |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |
Property changes on: trunk/extensions/FlaggedRevs/client/img/loading-small.gif |
___________________________________________________________________ |
Added: svn:mime-type |
192 | 240 | + application/octet-stream |