r99139 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99138‎ | r99139 | r99140 >
Date:20:49, 6 October 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
work on landing page ui
Modified paths:
  • /trunk/extensions/Contest/Contest.i18n.php (modified) (history)
  • /trunk/extensions/Contest/Contest.php (modified) (history)
  • /trunk/extensions/Contest/Contest.sql (modified) (history)
  • /trunk/extensions/Contest/includes/ContestChallenge.php (modified) (history)
  • /trunk/extensions/Contest/resources/contest.special.welcome.css (modified) (history)
  • /trunk/extensions/Contest/resources/contest.special.welcome.js (modified) (history)
  • /trunk/extensions/Contest/resources/images (added) (history)
  • /trunk/extensions/Contest/resources/images/blue_arrow_down.png (added) (history)
  • /trunk/extensions/Contest/resources/images/blue_arrow_right.png (added) (history)
  • /trunk/extensions/Contest/resources/images/button_arrow.png (added) (history)
  • /trunk/extensions/Contest/resources/images/button_arrow_hover.png (added) (history)
  • /trunk/extensions/Contest/resources/images/icon-box-hover-left-cap.png (added) (history)
  • /trunk/extensions/Contest/resources/images/icon-box-hover-right-cap.png (added) (history)
  • /trunk/extensions/Contest/resources/images/icon-box-hover.png (added) (history)
  • /trunk/extensions/Contest/resources/images/icon-box-left-cap.png (added) (history)
  • /trunk/extensions/Contest/resources/images/icon-box-right-cap.png (added) (history)
  • /trunk/extensions/Contest/resources/images/icon-box-selected-left-cap.png (added) (history)
  • /trunk/extensions/Contest/resources/images/icon-box-selected-right-cap.png (added) (history)
  • /trunk/extensions/Contest/resources/images/icon-box-selected.png (added) (history)
  • /trunk/extensions/Contest/resources/images/icon-box.png (added) (history)
  • /trunk/extensions/Contest/resources/images/select-bg-sprite.png (added) (history)
  • /trunk/extensions/Contest/resources/images/select-sprite.png (added) (history)
  • /trunk/extensions/Contest/resources/jquery.contestChallanges.js (added) (history)
  • /trunk/extensions/Contest/specials/SpecialContestWelcome.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Contest/Contest.i18n.php
@@ -98,7 +98,10 @@
9999 'contest-welcome-unknown' => 'There is no contest with the provided name.',
100100 'contest-welcome-rules' => 'In order to participate, you must agree to [[$1|the contest rules]].',
101101 'contest-welcome-signup' => 'Signup now',
 102+ 'contest-welcome-js-off' => 'Contest uses JavaScript for an improved interface. Your browser either does not support JavaScript or has JavaScript turned off.',
102103
 104+ 'contest-welcome-select-header' => 'Select your challange:',
 105+
103106 // Special:ContestSignup & Special:ContestSubmission
104107 'contest-signup-unknown' => 'There is no contest with the provided name.',
105108 'contest-signup-submit' => 'Signup',
Index: trunk/extensions/Contest/specials/SpecialContestWelcome.php
@@ -62,7 +62,6 @@
6363 $this->showChallenges( $contest );
6464 $this->showOpportunities( $contest );
6565 $this->showRules( $contest );
66 - $this->showSignupLinks( $contest );
6766
6867 $out->addModules( 'contest.special.welcome' );
6968 }
@@ -87,32 +86,41 @@
8887 * @param Contest $contest
8988 */
9089 protected function showChallenges( Contest $contest ) {
91 - $out = $this->getOutput();
 90+ $this->showNoJSFallback( $contest );
 91+
 92+ $this->getOutput()->addHTML( '<div id="contest-challanges"></div>' );
9293
 94+ $this->addContestJS( $contest );
 95+ }
 96+
 97+ protected function addContestJS( Contest $contest ) {
 98+ $challanges = array();
 99+
93100 foreach ( $contest->getChallenges() as /* ContestChallenge */ $challenge ) {
94 - $out->addHTML( '<fieldset>' );
95 -
96 - $out->addHTML( Html::element( 'legend', array(), $challenge->getField( 'title' ) ) );
97 -
98 - $out->addHTML( '<div class="contest-challenge">' );
99 -
100 - $out->addHTML( Html::element(
101 - 'button',
102 - array(
103 - 'class' => 'contest-signup challenge-signup',
104 - 'data-contest-target' => $this->getSignupLink( $contest->getField( 'name' ), $challenge->getId() )
105 - ),
106 - wfMsg( 'contest-welcome-signup' )
107 - ) );
108 -
109 - $out->addHTML( Html::element( 'p', array(), $challenge->getField( 'text' ) ) );
110 -
111 - $out->addHTML( '</div>' );
112 -
113 - $out->addHTML( '</fieldset>' );
 101+ $data = $challenge->toArray();
 102+ $data['target'] = $this->getSignupLink( $contest->getField( 'name' ), $challenge->getId() );
 103+ $challanges[] = $data;
114104 }
 105+
 106+ $this->getOutput()->addScript(
 107+ Skin::makeVariablesScript(
 108+ array(
 109+ 'ContestChallanges' => $challanges,
 110+ 'ContestConfig' => array()
 111+ )
 112+ )
 113+ );
115114 }
116115
 116+ protected function showNoJSFallback( Contest $contest ) {
 117+ $out = $this->getOutput();
 118+
 119+ $out->addHTML( '<noscript>' );
 120+ $out->addHTML( '<p class="errorbox">' . htmlspecialchars( wfMsg( 'contest-welcome-js-off' ) ) . '</p>' );
 121+ // TODO?
 122+ $out->addHTML( '</noscript>' );
 123+ }
 124+
117125 /**
118126 * Show the opportunities for this contest.
119127 *
@@ -137,27 +145,6 @@
138146 }
139147
140148 /**
141 - * Show the signup links for this contest.
142 - *
143 - * @since 0.1
144 - *
145 - * @param Contest $contest
146 - */
147 - protected function showSignupLinks( Contest $contest ) {
148 - $out = $this->getOutput();
149 -
150 - $out->addHTML( Html::element(
151 - 'button',
152 - array(
153 - 'id' => 'contest-signup',
154 - 'class' => 'contest-signup',
155 - 'data-contest-target' => $this->getSignupLink( $contest->getField( 'name' ) )
156 - ),
157 - wfMsg( 'contest-welcome-signup' )
158 - ) );
159 - }
160 -
161 - /**
162149 * Gets the URL for the signup links.
163150 * When the user has to login, this will be to the login page,
164151 * with a retunrto to the signup page.
@@ -176,15 +163,15 @@
177164
178165 $signupitle = SpecialPage::getTitleFor( 'ContestSignup', $contestName );
179166
180 - if ( $this->getUser()->isLoggedIn() ) {
 167+// if ( $this->getUser()->isLoggedIn() ) {
181168 return $signupitle->getLocalURL();
182 - }
183 - else {
184 - return SpecialPage::getTitleFor( 'UserLogin' )->getLocalURL( array(
185 - //'type' => 'signup',
186 - 'returnto' => $signupitle->getFullText()
187 - ) );
188 - }
 169+// }
 170+// else {
 171+// return SpecialPage::getTitleFor( 'Userlogin' )->getLocalURL( array(
 172+// //'type' => 'signup',
 173+// 'returnto' => $signupitle->getFullText()
 174+// ) );
 175+// }
189176 }
190177
191178 /**
@@ -203,7 +190,7 @@
204191 if ( is_null( $title ) ) {
205192 return '';
206193 }
207 -
 194+
208195 $article = new Article( $title, 0 );
209196 return $article->getContent();
210197 }
Index: trunk/extensions/Contest/Contest.php
@@ -166,12 +166,16 @@
167167 $wgResourceModules['contest.special.welcome'] = $moduleTemplate + array(
168168 'scripts' => array(
169169 'contest.special.welcome.js',
 170+ 'jquery.contestChallanges.js'
170171 ),
171172 'styles' => array(
172173 'contest.special.welcome.css',
173174 ),
174175 'dependencies' => array(
175176 'jquery.ui.button'
 177+ ),
 178+ 'messages' => array(
 179+ 'contest-welcome-select-header'
176180 )
177181 );
178182
Index: trunk/extensions/Contest/includes/ContestChallenge.php
@@ -85,6 +85,7 @@
8686 'contest_id' => 'id',
8787 'text' => 'str',
8888 'title' => 'str',
 89+ 'oneline' => 'str',
8990 );
9091 }
9192
@@ -99,6 +100,7 @@
100101 return array(
101102 'text' => '',
102103 'title' => '',
 104+ 'oneline' => '',
103105 );
104106 }
105107
Index: trunk/extensions/Contest/resources/contest.special.welcome.css
@@ -6,11 +6,178 @@
77 * @author Jeroen De Dauw <jeroendedauw at gmail dot com>
88 */
99
10 -button.challenge-signup {
 10+
 11+/* dialog type selection */
 12+/*#mw-codechallenge-dialog*/ #contest-challanges-list {
 13+ float: left;
 14+ width: 250px;
 15+}
 16+
 17+/*#mw-codechallenge-dialog*/ #contest-challanges-list ul {
 18+ list-style: none;
 19+ margin: 0;
 20+ padding: 0;
 21+}
 22+
 23+/*#mw-codechallenge-dialog*/ #contest-challanges-list ul li,
 24+/*#mw-codechallenge-dialog*/ #contest-challanges-list a
 25+{
 26+ display: block;
 27+ width: 250px;
 28+ height: 66px;
 29+ padding: 0;
 30+ margin: 0;
 31+ position: relative;
 32+ text-decoration: none;
 33+ outline: none;
 34+}
 35+
 36+/*#mw-codechallenge-dialog*/ #contest-challanges-list a:hover,
 37+/*#mw-codechallenge-dialog*/ #contest-challanges-list a:focus {
 38+ text-decoration:none;
 39+}
 40+
 41+/* IGNORED BY IE6 */
 42+/*#mw-codechallenge-dialog*/ #contest-challanges-list ul > li,
 43+/*#mw-codechallenge-dialog*/ #contest-challanges-list ul li > a {
 44+ display: inline-block;
 45+}
 46+
 47+/*#mw-codechallenge-dialog*/ #contest-challanges-list a .mw-codechallenge-left-cap,
 48+/*#mw-codechallenge-dialog*/ #contest-challanges-list a .mw-codechallenge-right-cap {
 49+ padding: 0;
 50+ margin: 0;
 51+ width: 6px;
 52+ height: 66px;
1153 position: absolute;
12 - right: 5px;
 54+ top: 0px;
1355 }
1456
15 -div.contest-challenge {
16 - position: relative;
 57+/*#mw-codechallenge-dialog*/ #contest-challanges-list a .mw-codechallenge-l-cap,
 58+/*#mw-codechallenge-dialog*/ #contest-challanges-list a .mw-codechallenge-r-cap,
 59+/*#mw-codechallenge-dialog*/ #contest-challanges-list a .mw-codechallenge-icon-box {
 60+ background-repeat: no-repeat;
 61+ height: 66px;
 62+ position: absolute;
 63+}
 64+
 65+/*#mw-codechallenge-dialog*/ #contest-challanges-list a .mw-codechallenge-l-cap,
 66+/*#mw-codechallenge-dialog*/ #contest-challanges-list a .mw-codechallenge-r-cap {
 67+ width: 6px;
 68+}
 69+
 70+/*#mw-codechallenge-dialog*/ #contest-challanges-list a .mw-codechallenge-l-cap {
 71+ /* @noflip */
 72+ left: 0px;
 73+ /* @embed */
 74+ background-image: url(images/icon-box-left-cap.png);
 75+}
 76+
 77+/*#mw-codechallenge-dialog*/ #contest-challanges-list a:hover .mw-codechallenge-l-cap,
 78+/*#mw-codechallenge-dialog*/ #contest-challanges-list a:focus .mw-codechallenge-l-cap {
 79+ /* @embed */
 80+ background-image: url(images/icon-box-hover-left-cap.png);
 81+}
 82+
 83+/*#mw-codechallenge-dialog*/ #contest-challanges-list a.selected .mw-codechallenge-l-cap {
 84+ /* @embed */
 85+ background-image: url(images/icon-box-selected-left-cap.png);
 86+}
 87+
 88+/*#mw-codechallenge-dialog*/ #contest-challanges-list a .mw-codechallenge-r-cap {
 89+ /* @noflip */
 90+ right: 0px;
 91+ /* @embed */
 92+ background-image: url(images/icon-box-right-cap.png);
 93+}
 94+
 95+/*#mw-codechallenge-dialog*/ #contest-challanges-list a:hover .mw-codechallenge-r-cap,
 96+/*#mw-codechallenge-dialog*/ #contest-challanges-list a:focus .mw-codechallenge-r-cap {
 97+ /* @embed */
 98+ background-image: url(images/icon-box-hover-right-cap.png);
 99+}
 100+
 101+/*#mw-codechallenge-dialog*/ #contest-challanges-list a.selected .mw-codechallenge-r-cap {
 102+ /* @embed */
 103+ background-image: url(images/icon-box-selected-right-cap.png);
 104+}
 105+
 106+/*#mw-codechallenge-dialog*/ #contest-challanges-list a .mw-codechallenge-inside {
 107+ padding: 0;
 108+ margin: 0;
 109+ width: 238px;
 110+ height: 66px;
 111+ position: absolute;
 112+ top: 0px;
 113+ left: 6px;
 114+
 115+ /* @embed */
 116+ background-image: url(images/select-bg-sprite.png);
 117+ background-position: 0px 0px;
 118+ background-repeat: repeat-x;
 119+}
 120+
 121+/*#mw-codechallenge-dialog*/ #contest-challanges-list a:hover .mw-codechallenge-inside,
 122+/*#mw-codechallenge-dialog*/ #contest-challanges-list a:focus .mw-codechallenge-inside {
 123+ background-position: 0px -66px;
 124+}
 125+
 126+/*#mw-codechallenge-dialog*/ #contest-challanges-list a.selected .mw-codechallenge-inside {
 127+ background-position: 0px -132px;
 128+}
 129+
 130+/*#mw-codechallenge-dialog*/ #contest-challanges-list a .mw-codechallenge-icon-box {
 131+ padding: 0;
 132+ margin: 0;
 133+ width: 53px;
 134+ height: 53px;
 135+ position: absolute;
 136+ right: 0px;
 137+ top: 5px;
 138+ /* @embed */
 139+ background-image: url(images/icon-box.png);
 140+}
 141+
 142+/*#mw-codechallenge-dialog*/ #contest-challanges-list a .mw-codechallenge-icon-box img {
 143+ padding: 0;
 144+ margin: 0;
 145+ width: 53px;
 146+ height: 53px;
 147+ position: absolute:
 148+ top: 0px;
 149+ left: 0px;
 150+}
 151+
 152+/*#mw-codechallenge-dialog*/ #contest-challanges-list a:hover .mw-codechallenge-icon-box,
 153+/*#mw-codechallenge-dialog*/ #contest-challanges-list a:focus .mw-codechallenge-icon-box {
 154+ /* @embed */
 155+ background-image: url(images/icon-box-hover.png);
 156+}
 157+
 158+/*#mw-codechallenge-dialog*/ #contest-challanges-list a.selected .mw-codechallenge-icon-box {
 159+ /* @embed */
 160+ background-image: url(images/icon-box-selected.png);
 161+}
 162+
 163+/*#mw-codechallenge-dialog*/ #contest-challanges-list a .mw-codechallenge-link-text {
 164+ padding: 0;
 165+ margin: 0;
 166+ width: 170px;
 167+ height: 53px;
 168+ position: absolute;
 169+ left: 64px;
 170+ top: 5px;
 171+ line-height: 53px;
 172+ font-size: 1.2em;
 173+ font-weight: bold;
 174+ text-decoration: none;
 175+ color: white;
 176+}
 177+
 178+/*#mw-codechallenge-dialog*/ #contest-challanges-list a .mw-codechallenge-no-icon .mw-codechallenge-link-text {
 179+ left: 3px;
 180+}
 181+
 182+#mw-codechallenge-dialog a {
 183+ color: #0645AD;
17184 }
\ No newline at end of file
Index: trunk/extensions/Contest/resources/contest.special.welcome.js
@@ -10,9 +10,10 @@
1111
1212 $( document ).ready( function() {
1313
14 - $( '.contest-signup' ).button().click( function() {
15 - window.location = $( this ).attr( 'data-contest-target' );
16 - } );
 14+ $( '#contest-challanges' ).contestChallanges(
 15+ mw.config.get( 'ContestChallanges' ),
 16+ mw.config.get( 'ContestConfig' )
 17+ );
1718
1819 } );
1920
Index: trunk/extensions/Contest/resources/images/icon-box-selected-left-cap.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/Contest/resources/images/icon-box-selected-left-cap.png
___________________________________________________________________
Added: svn:mime-type
2021 + image/png
Index: trunk/extensions/Contest/resources/images/blue_arrow_right.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/Contest/resources/images/blue_arrow_right.png
___________________________________________________________________
Added: svn:mime-type
2122 + image/png
Index: trunk/extensions/Contest/resources/images/icon-box.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/Contest/resources/images/icon-box.png
___________________________________________________________________
Added: svn:mime-type
2223 + image/png
Index: trunk/extensions/Contest/resources/images/icon-box-hover.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/Contest/resources/images/icon-box-hover.png
___________________________________________________________________
Added: svn:mime-type
2324 + image/png
Index: trunk/extensions/Contest/resources/images/icon-box-selected-right-cap.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/Contest/resources/images/icon-box-selected-right-cap.png
___________________________________________________________________
Added: svn:mime-type
2425 + image/png
Index: trunk/extensions/Contest/resources/images/select-sprite.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/Contest/resources/images/select-sprite.png
___________________________________________________________________
Added: svn:mime-type
2526 + image/png
Index: trunk/extensions/Contest/resources/images/icon-box-selected.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/Contest/resources/images/icon-box-selected.png
___________________________________________________________________
Added: svn:mime-type
2627 + image/png
Index: trunk/extensions/Contest/resources/images/button_arrow.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/Contest/resources/images/button_arrow.png
___________________________________________________________________
Added: svn:mime-type
2728 + image/png
Index: trunk/extensions/Contest/resources/images/icon-box-left-cap.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/Contest/resources/images/icon-box-left-cap.png
___________________________________________________________________
Added: svn:mime-type
2829 + image/png
Index: trunk/extensions/Contest/resources/images/blue_arrow_down.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/Contest/resources/images/blue_arrow_down.png
___________________________________________________________________
Added: svn:mime-type
2930 + image/png
Index: trunk/extensions/Contest/resources/images/button_arrow_hover.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/Contest/resources/images/button_arrow_hover.png
___________________________________________________________________
Added: svn:mime-type
3031 + image/png
Index: trunk/extensions/Contest/resources/images/icon-box-hover-left-cap.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/Contest/resources/images/icon-box-hover-left-cap.png
___________________________________________________________________
Added: svn:mime-type
3132 + image/png
Index: trunk/extensions/Contest/resources/images/select-bg-sprite.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/Contest/resources/images/select-bg-sprite.png
___________________________________________________________________
Added: svn:mime-type
3233 + image/png
Index: trunk/extensions/Contest/resources/images/icon-box-right-cap.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/Contest/resources/images/icon-box-right-cap.png
___________________________________________________________________
Added: svn:mime-type
3334 + image/png
Index: trunk/extensions/Contest/resources/images/icon-box-hover-right-cap.png
Cannot display: file marked as a binary type.
svn:mime-type = image/png
Property changes on: trunk/extensions/Contest/resources/images/icon-box-hover-right-cap.png
___________________________________________________________________
Added: svn:mime-type
3435 + image/png
Index: trunk/extensions/Contest/resources/jquery.contestChallanges.js
@@ -0,0 +1,66 @@
 2+/**
 3+ * JavasSript for the Contest MediaWiki extension.
 4+ * @see https://secure.wikimedia.org/wikipedia/mediawiki/wiki/Extension:Contest
 5+ *
 6+ * @licence GNU GPL v3 or later
 7+ * @author Jeroen De Dauw <jeroendedauw at gmail dot com>
 8+ */
 9+
 10+( function ( $, mw ) { $.fn.contestChallanges = function( challanges, config ) {
 11+
 12+ this.challanges = challanges;
 13+ this.config = config;
 14+
 15+ var _this = this;
 16+ var $this = $( this );
 17+
 18+ this.challangesList = null;
 19+
 20+ this.showChallange = function( challange ) {
 21+ // TODO
 22+ console.log( challange );
 23+ };
 24+
 25+ this.addChallange = function( challange ) {
 26+ var item = $( '<a />' ).attr( 'href', '#' ).html( '' ).click( function() {
 27+ _this.showChallange( challange );
 28+ } );
 29+
 30+ item.append( $( '<div />' ).attr( 'class', 'mw-codechallenge-l-cap' ) );
 31+
 32+ var innerDiv = $( '<div />' ).attr( 'class', 'mw-codechallenge-inside' );
 33+
 34+ innerDiv.html( $( '<div />' ).attr( 'class', 'mw-codechallenge-link-text' )
 35+ .html( $( '<p />' ).text( challange.title ) )
 36+ .append( $( '<p />' ).text( challange.oneline ) )
 37+ );
 38+
 39+ innerDiv.append( $( '<div />' ).attr( 'class', 'mw-codechallenge-icon-box' ) );
 40+ item.append( innerDiv );
 41+
 42+ item.append( $( '<div />' ).attr( 'class', 'mw-codechallenge-r-cap' ) );
 43+
 44+ this.challangesList.append( $( '<li />' ).html( item ) );
 45+ }
 46+
 47+ this.initChallanges = function() {
 48+ this.challangesList = $( '<ul />' ).attr( 'id', 'contest-challanges-list' );
 49+
 50+ for ( i in this.challanges ) {
 51+ this.addChallange( this.challanges[i] );
 52+ }
 53+ };
 54+
 55+ this.init = function() {
 56+ $this.html( $( '<h3 />' ).text( mw.msg( 'contest-welcome-select-header' ) ) );
 57+
 58+ this.initChallanges();
 59+
 60+ $this.append( this.challangesList );
 61+ };
 62+
 63+ this.init();
 64+
 65+ return this;
 66+
 67+}; } )( window.jQuery, window.mediaWiki );
Property changes on: trunk/extensions/Contest/resources/jquery.contestChallanges.js
___________________________________________________________________
Added: svn:eol-style
168 + native
Index: trunk/extensions/Contest/Contest.sql
@@ -48,7 +48,8 @@
4949 challenge_contest_id INT unsigned NOT NULL,
5050
5151 challenge_text TEXT NOT NULL,
52 - challenge_title VARCHAR(255) NOT NULL
 52+ challenge_title VARCHAR(255) NOT NULL,
 53+ challenge_oneline TEXT NOT NULL
5354 ) /*$wgDBTableOptions*/;
5455
5556 -- Judge votes

Status & tagging log