r80795 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r80794‎ | r80795 | r80796 >
Date:03:03, 23 January 2011
Author:brion
Status:ok (Comments)
Tags:
Comment:
CodeReview extension ported to use ResourceLoader.

Fairly minimal port; only one line of change to the actual JS to compensate for the change in script global context, and the CSS/JS files have been renamed and placed in a subdirectory. Will make it more native-friendly and add other AJAXy things later. :D
$wgCodeReviewStyleVersion is now gone; version management of the client-side assets is left to ResourceLoader.
Modified paths:
  • /trunk/extensions/CodeReview/CodeReview.php (modified) (history)
  • /trunk/extensions/CodeReview/codereview.css (deleted) (history)
  • /trunk/extensions/CodeReview/codereview.js (deleted) (history)
  • /trunk/extensions/CodeReview/modules (added) (history)
  • /trunk/extensions/CodeReview/modules/ext.codereview.css (added) (history)
  • /trunk/extensions/CodeReview/modules/ext.codereview.loaddiff.js (added) (history)
  • /trunk/extensions/CodeReview/ui/CodeRevisionView.php (modified) (history)
  • /trunk/extensions/CodeReview/ui/SpecialCode.php (modified) (history)
  • /trunk/extensions/Configure/scripts/findSettings.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CodeReview/codereview.css
@@ -1,181 +0,0 @@
2 -table.mw-codereview-meta td {
3 - vertical-align: top;
4 -}
5 -
6 -.mw-codereview-paths {
7 - max-height:600px;
8 - overflow:auto;
9 -}
10 -
11 -.TablePager_col_comments {
12 - text-align: center;
13 -}
14 -.TablePager_col_cr_message {
15 - max-width: 20em;
16 - overflow: hidden;
17 -}
18 -
19 -.TablePager_col_cr_timestamp {
20 - white-space: nowrap;
21 -}
22 -
23 -.mw-codereview-comment {
24 - border: solid 1px #aaaab3;
25 - padding: 0px;
26 - background: #eee;
27 - margin-bottom: 8px;
28 -}
29 -
30 -.mw-codereview-imgdiff {
31 - border: solid 1px #aaaab3;
32 - padding: 1em;
33 - background: #eee;
34 -}
35 -
36 -.mw-codereview-comment-meta {
37 - padding: 4px 8px;
38 -}
39 -
40 -.mw-codereview-comment-text {
41 - background: white;
42 - padding: 16px;
43 -}
44 -
45 -.mw-codereview-comment .mw-codereview-post-comment {
46 - padding: 16px;
47 - padding-left: 48px;
48 -}
49 -
50 -.mw-codereview-status-new,
51 -.mw-codereview-status-new td {
52 - background: #ffffc0 !important;
53 -}
54 -
55 -.mw-codereview-status-new:hover,
56 -.mw-codereview-status-new:hover td {
57 - background: #dfdfa0 !important;
58 -}
59 -
60 -.mw-codereview-status-fixme,
61 -.mw-codereview-status-fixme td {
62 - background: #ff9999 !important;
63 -}
64 -.mw-codereview-status-fixme:hover,
65 -.mw-codereview-status-fixme:hover td {
66 - background: #df0000 !important;
67 - color: white;
68 -}
69 -.mw-codereview-status-fixme:hover a,
70 -.mw-codereview-status-fixme:hover td a {
71 - color: #ff0 !important;
72 -}
73 -
74 -.mw-codereview-status-resolved,
75 -.mw-codereview-status-resolved td {
76 - background: #c0ffc0 !important;
77 -}
78 -.mw-codereview-status-resolved:hover,
79 -.mw-codereview-status-resolved:hover td {
80 - background: #a0dfa0 !important;
81 -}
82 -
83 -.mw-codereview-status-reverted,
84 -.mw-codereview-status-reverted td {
85 - background: #ddd !important;
86 - color: #666 !important;
87 - text-decoration: line-through !important;
88 -}
89 -.mw-codereview-status-reverted:hover,
90 -.mw-codereview-status-reverted:hover td {
91 - background: #aaa !important;
92 - text-decoration: line-through !important;
93 -}
94 -.mw-codereview-status-deferred,
95 -.mw-codereview-status-deferred td {
96 - color: #666;
97 -}
98 -
99 -.mw-codereview-status-old,
100 -.mw-codereview-status-old td {
101 - color: #666;
102 -}
103 -
104 -.mw-codereview-associateform {
105 - float: right;
106 -}
107 -
108 -.mw-codereview-signoffchecks {
109 - float: right;
110 -}
111 -
112 -.mw-codereview-struck td {
113 - text-decoration: line-through;
114 - background: #aaa;
115 -}
116 -
117 -.mw-codereview-success {
118 - color: #1a2;
119 -}
120 -.mw-codereview-fail {
121 - color: #d21;
122 -}
123 -
124 -/* Diffs */
125 -.mw-codereview-diff ins {
126 - text-decoration: none;
127 - color: green;
128 -}
129 -
130 -.mw-codereview-diff del {
131 - text-decoration: none;
132 - color: red;
133 -}
134 -
135 -.mw-codereview-diff .meta {
136 - color: darkcyan;
137 -}
138 -
139 -.mw-wordcloud-size-1, .mw-wordcloud-size-2,
140 -.mw-wordcloud-size-3, .mw-wordcloud-size-4,
141 -.mw-wordcloud-size-5, .mw-wordcloud-size-6,
142 -.mw-wordcloud-size-7, .mw-wordcloud-size-8,
143 -.mw-wordcloud-size-0 {
144 - padding: 4px 4px 4px 4px;
145 - letter-spacing: 3px;
146 -}
147 -.mw-wordcloud-size-1 {
148 - color: #000;
149 - font-size: 2.4em;
150 -}
151 -.mw-wordcloud-size-2 {
152 - color: #333;
153 - font-size:2.2em;
154 -}
155 -.mw-wordcloud-size-3 {
156 - color: #666;
157 - font-size: 2.0em;
158 -}
159 -.mw-wordcloud-size-4 {
160 - color: #999;
161 - font-size: 1.0em;
162 -}
163 -.mw-wordcloud-size-5 {
164 - color: #aaa;
165 - font-size: 1.6em;
166 -}
167 -.mw-wordcloud-size-6 {
168 - color: #bbb;
169 - font-size: 1.4em;
170 -}
171 -.mw-wordcloud-size-7 {
172 - color: #ccc;
173 - font-size: 1.2em;
174 -}
175 -.mw-wordcloud-size-8 {
176 - color: #ddd;
177 - font-size: .8em;
178 -}
179 -.mw-wordcloud-size-0 {
180 - color: #ccc;
181 - font-size: .6em;
182 -}
Index: trunk/extensions/CodeReview/codereview.js
@@ -1,45 +0,0 @@
2 -var CodeReview = new Object;
3 -CodeReview.loadDiff = function(repo, rev) {
4 - var path = wgScriptPath +
5 - "/api.php" +
6 - "?action=codediff" +
7 - "&format=json" +
8 - "&repo=" + encodeURIComponent(repo) +
9 - "&rev=" + encodeURIComponent(rev);
10 - var xmlhttp = sajax_init_object();
11 - if(xmlhttp){
12 - try {
13 - injectSpinner(CodeReview.diffTarget(), 'codereview-diff');
14 - xmlhttp.open("GET", path, true);
15 - xmlhttp.onreadystatechange=function(){
16 - if (xmlhttp.readyState==4) {
17 - CodeReview.decodeAndShowDiff(xmlhttp.responseText);
18 - removeSpinner('codereview-diff');
19 - }
20 - };
21 - xmlhttp.send(null);
22 - } catch (e) {
23 - if (window.location.hostname == "localhost") {
24 - alert("Your browser blocks XMLHttpRequest to 'localhost', try using a real hostname for development/testing.");
25 - }
26 - throw e;
27 - }
28 - }
29 -};
30 -CodeReview.decodeAndShowDiff = function(jsonText) {
31 - // bleah
32 - eval("var data=" + jsonText);
33 - if (typeof data.code != 'undefined' &&
34 - typeof data.code.rev != 'undefined' &&
35 - typeof data.code.rev.diff != 'undefined') {
36 - CodeReview.showDiff(data.code.rev.diff);
37 - } else {
38 - CodeReview.showDiff('Diff load failed. :(');
39 - }
40 -};
41 -CodeReview.diffTarget = function() {
42 - return document.getElementById('mw-codereview-diff');
43 -};
44 -CodeReview.showDiff = function(diffHtml) {
45 - CodeReview.diffTarget().innerHTML = diffHtml;
46 -};
Index: trunk/extensions/CodeReview/CodeReview.php
@@ -135,9 +135,21 @@
136136 // What is the default SVN import chunk size?
137137 $wgCodeReviewImportBatchSize = 400;
138138
139 -// Bump the version number every time you change a CodeReview .css/.js file
140 -$wgCodeReviewStyleVersion = 7;
 139+$commonModuleInfo = array(
 140+ 'localBasePath' => dirname( __FILE__ ) . '/modules',
 141+ 'remoteExtPath' => 'CodeReview/modules',
 142+);
141143
 144+// Styles and any code common to all Special:Code subviews:
 145+$wgResourceModules['ext.codereview'] = array(
 146+ 'styles' => 'ext.codereview.css',
 147+) + $commonModuleInfo;
 148+
 149+// On-demand diff loader for CodeRevisionView:
 150+$wgResourceModules['ext.codereview.loaddiff'] = array(
 151+ 'scripts' => 'ext.codereview.loaddiff.js'
 152+) + $commonModuleInfo;
 153+
142154 // If you are running a closed svn, fill the following two lines with the username and password
143155 // of a user allowed to access it. Otherwise, leave it false.
144156 // This is only necessary if using the shell method to access Subversion
Index: trunk/extensions/CodeReview/modules/ext.codereview.css
@@ -0,0 +1,181 @@
 2+table.mw-codereview-meta td {
 3+ vertical-align: top;
 4+}
 5+
 6+.mw-codereview-paths {
 7+ max-height:600px;
 8+ overflow:auto;
 9+}
 10+
 11+.TablePager_col_comments {
 12+ text-align: center;
 13+}
 14+.TablePager_col_cr_message {
 15+ max-width: 20em;
 16+ overflow: hidden;
 17+}
 18+
 19+.TablePager_col_cr_timestamp {
 20+ white-space: nowrap;
 21+}
 22+
 23+.mw-codereview-comment {
 24+ border: solid 1px #aaaab3;
 25+ padding: 0px;
 26+ background: #eee;
 27+ margin-bottom: 8px;
 28+}
 29+
 30+.mw-codereview-imgdiff {
 31+ border: solid 1px #aaaab3;
 32+ padding: 1em;
 33+ background: #eee;
 34+}
 35+
 36+.mw-codereview-comment-meta {
 37+ padding: 4px 8px;
 38+}
 39+
 40+.mw-codereview-comment-text {
 41+ background: white;
 42+ padding: 16px;
 43+}
 44+
 45+.mw-codereview-comment .mw-codereview-post-comment {
 46+ padding: 16px;
 47+ padding-left: 48px;
 48+}
 49+
 50+.mw-codereview-status-new,
 51+.mw-codereview-status-new td {
 52+ background: #ffffc0 !important;
 53+}
 54+
 55+.mw-codereview-status-new:hover,
 56+.mw-codereview-status-new:hover td {
 57+ background: #dfdfa0 !important;
 58+}
 59+
 60+.mw-codereview-status-fixme,
 61+.mw-codereview-status-fixme td {
 62+ background: #ff9999 !important;
 63+}
 64+.mw-codereview-status-fixme:hover,
 65+.mw-codereview-status-fixme:hover td {
 66+ background: #df0000 !important;
 67+ color: white;
 68+}
 69+.mw-codereview-status-fixme:hover a,
 70+.mw-codereview-status-fixme:hover td a {
 71+ color: #ff0 !important;
 72+}
 73+
 74+.mw-codereview-status-resolved,
 75+.mw-codereview-status-resolved td {
 76+ background: #c0ffc0 !important;
 77+}
 78+.mw-codereview-status-resolved:hover,
 79+.mw-codereview-status-resolved:hover td {
 80+ background: #a0dfa0 !important;
 81+}
 82+
 83+.mw-codereview-status-reverted,
 84+.mw-codereview-status-reverted td {
 85+ background: #ddd !important;
 86+ color: #666 !important;
 87+ text-decoration: line-through !important;
 88+}
 89+.mw-codereview-status-reverted:hover,
 90+.mw-codereview-status-reverted:hover td {
 91+ background: #aaa !important;
 92+ text-decoration: line-through !important;
 93+}
 94+.mw-codereview-status-deferred,
 95+.mw-codereview-status-deferred td {
 96+ color: #666;
 97+}
 98+
 99+.mw-codereview-status-old,
 100+.mw-codereview-status-old td {
 101+ color: #666;
 102+}
 103+
 104+.mw-codereview-associateform {
 105+ float: right;
 106+}
 107+
 108+.mw-codereview-signoffchecks {
 109+ float: right;
 110+}
 111+
 112+.mw-codereview-struck td {
 113+ text-decoration: line-through;
 114+ background: #aaa;
 115+}
 116+
 117+.mw-codereview-success {
 118+ color: #1a2;
 119+}
 120+.mw-codereview-fail {
 121+ color: #d21;
 122+}
 123+
 124+/* Diffs */
 125+.mw-codereview-diff ins {
 126+ text-decoration: none;
 127+ color: green;
 128+}
 129+
 130+.mw-codereview-diff del {
 131+ text-decoration: none;
 132+ color: red;
 133+}
 134+
 135+.mw-codereview-diff .meta {
 136+ color: darkcyan;
 137+}
 138+
 139+.mw-wordcloud-size-1, .mw-wordcloud-size-2,
 140+.mw-wordcloud-size-3, .mw-wordcloud-size-4,
 141+.mw-wordcloud-size-5, .mw-wordcloud-size-6,
 142+.mw-wordcloud-size-7, .mw-wordcloud-size-8,
 143+.mw-wordcloud-size-0 {
 144+ padding: 4px 4px 4px 4px;
 145+ letter-spacing: 3px;
 146+}
 147+.mw-wordcloud-size-1 {
 148+ color: #000;
 149+ font-size: 2.4em;
 150+}
 151+.mw-wordcloud-size-2 {
 152+ color: #333;
 153+ font-size:2.2em;
 154+}
 155+.mw-wordcloud-size-3 {
 156+ color: #666;
 157+ font-size: 2.0em;
 158+}
 159+.mw-wordcloud-size-4 {
 160+ color: #999;
 161+ font-size: 1.0em;
 162+}
 163+.mw-wordcloud-size-5 {
 164+ color: #aaa;
 165+ font-size: 1.6em;
 166+}
 167+.mw-wordcloud-size-6 {
 168+ color: #bbb;
 169+ font-size: 1.4em;
 170+}
 171+.mw-wordcloud-size-7 {
 172+ color: #ccc;
 173+ font-size: 1.2em;
 174+}
 175+.mw-wordcloud-size-8 {
 176+ color: #ddd;
 177+ font-size: .8em;
 178+}
 179+.mw-wordcloud-size-0 {
 180+ color: #ccc;
 181+ font-size: .6em;
 182+}
Property changes on: trunk/extensions/CodeReview/modules/ext.codereview.css
___________________________________________________________________
Added: svn:eol-style
1183 + native
Index: trunk/extensions/CodeReview/modules/ext.codereview.loaddiff.js
@@ -0,0 +1,45 @@
 2+var CodeReview = window.CodeReview = new Object;
 3+CodeReview.loadDiff = function(repo, rev) {
 4+ var path = wgScriptPath +
 5+ "/api.php" +
 6+ "?action=codediff" +
 7+ "&format=json" +
 8+ "&repo=" + encodeURIComponent(repo) +
 9+ "&rev=" + encodeURIComponent(rev);
 10+ var xmlhttp = sajax_init_object();
 11+ if(xmlhttp){
 12+ try {
 13+ injectSpinner(CodeReview.diffTarget(), 'codereview-diff');
 14+ xmlhttp.open("GET", path, true);
 15+ xmlhttp.onreadystatechange=function(){
 16+ if (xmlhttp.readyState==4) {
 17+ CodeReview.decodeAndShowDiff(xmlhttp.responseText);
 18+ removeSpinner('codereview-diff');
 19+ }
 20+ };
 21+ xmlhttp.send(null);
 22+ } catch (e) {
 23+ if (window.location.hostname == "localhost") {
 24+ alert("Your browser blocks XMLHttpRequest to 'localhost', try using a real hostname for development/testing.");
 25+ }
 26+ throw e;
 27+ }
 28+ }
 29+};
 30+CodeReview.decodeAndShowDiff = function(jsonText) {
 31+ // bleah
 32+ eval("var data=" + jsonText);
 33+ if (typeof data.code != 'undefined' &&
 34+ typeof data.code.rev != 'undefined' &&
 35+ typeof data.code.rev.diff != 'undefined') {
 36+ CodeReview.showDiff(data.code.rev.diff);
 37+ } else {
 38+ CodeReview.showDiff('Diff load failed. :(');
 39+ }
 40+};
 41+CodeReview.diffTarget = function() {
 42+ return document.getElementById('mw-codereview-diff');
 43+};
 44+CodeReview.showDiff = function(diffHtml) {
 45+ CodeReview.diffTarget().innerHTML = diffHtml;
 46+};
Property changes on: trunk/extensions/CodeReview/modules/ext.codereview.loaddiff.js
___________________________________________________________________
Added: svn:eol-style
147 + native
Index: trunk/extensions/CodeReview/ui/SpecialCode.php
@@ -9,7 +9,7 @@
1010 }
1111
1212 public function execute( $subpage ) {
13 - global $wgOut, $wgUser, $wgExtensionAssetsPath, $wgCodeReviewStyleVersion;
 13+ global $wgOut, $wgUser;
1414
1515 if ( !$this->userCanExecute( $wgUser ) ) {
1616 $this->displayRestrictionError();
@@ -17,7 +17,8 @@
1818 }
1919
2020 $this->setHeaders();
21 - $wgOut->addStyle( "$wgExtensionAssetsPath/CodeReview/codereview.css?$wgCodeReviewStyleVersion" );
 21+ // Base styles used for all code review UI actions.
 22+ $wgOut->addModules( 'ext.codereview' );
2223
2324 $view = $this->getViewFrom( $subpage );
2425 if( $view ) {
Index: trunk/extensions/CodeReview/ui/CodeRevisionView.php
@@ -428,10 +428,10 @@
429429 }
430430
431431 protected function stubDiffLoader() {
432 - global $wgOut, $wgExtensionAssetsPath, $wgCodeReviewStyleVersion;
 432+ global $wgOut;
433433 $encRepo = Xml::encodeJsVar( $this->mRepo->getName() );
434434 $encRev = Xml::encodeJsVar( $this->mRev->getId() );
435 - $wgOut->addScriptFile( "$wgExtensionAssetsPath/CodeReview/codereview.js?$wgCodeReviewStyleVersion" );
 435+ $wgOut->addModules( 'ext.codereview.loaddiff' );
436436 $wgOut->addInlineScript(
437437 "addOnloadHook(
438438 function() {
Index: trunk/extensions/Configure/scripts/findSettings.php
@@ -64,7 +64,6 @@
6565 'wgCheckUserStyleVersion',
6666 'wgCaptcha', 'wgConfirmEditIP',
6767 'wgCitationCache', 'wgCitationCounter', 'wgCitationRunning',
68 - 'wgCodeReviewStyleVersion',
6968 'wgCollectionVersion', 'wgCollectionStyleVersion',
7069 'wgCSS',
7170 'wgDeleteQueueStyleVersion',

Comments

#Comment by 😂 (talk | contribs)   18:22, 26 January 2011

Giving this to Roan, I don't know resource loader stuff.

#Comment by Catrope (talk | contribs)   23:23, 26 January 2011

Untagging. This is not in 1.17 and not up for merging right now.

#Comment by Reedy (talk | contribs)   20:54, 31 January 2011

On a clean install, the revision lists don't seem to be getting CSS applied to them...

#Comment by Brion VIBBER (talk | contribs)   20:20, 1 February 2011

I'm not seeing this problem with a fresh install of trunk r81315.

#Comment by Reedy (talk | contribs)   20:21, 1 February 2011

God knows then. Just tried it and it seems fine. Stupid no-reasoned transient bugs

#Comment by Reach Out to the Truth (talk | contribs)   20:46, 1 February 2011

I've seen it too. Worked fine with ResourceLoader debug mode enabled, so it may have been a ResourceLoader/minification bug that has since been fixed. I can't test it right now though.

#Comment by Reedy (talk | contribs)   21:55, 2 March 2011

Gonna mark this ok. Seems fine, maybe a couple of little RL related bugs, but this isn't this at fault

Status & tagging log