r22551 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22550‎ | r22551 | r22552 >
Date:03:11, 30 May 2007
Author:david
Status:old
Tags:
Comment:
User color coding. Kind of ugly yet.
Modified paths:
  • /branches/liquidthreads/extensions/LqtExtension.php (modified) (history)
  • /branches/liquidthreads/skins/monobook/main.css (modified) (history)

Diff [purge]

Index: branches/liquidthreads/skins/monobook/main.css
@@ -83,7 +83,12 @@
8484 background-color: white;
8585 }
8686
87 -.lqt_post { border: solid 0px #ddd; margin-bottom: 0em; padding: 0 0 0.5em 0; }
 87+.lqt_post {
 88+ /*border: solid 1px #ddd;
 89+ border-left: 2px solid;*/
 90+ margin-bottom: 0em;
 91+ padding: 0 0 0.5em 0em;
 92+}
8893
8994 .lqt_post_highlight { border: solid 1px #fabd23; margin-top: 0.1in; padding: 0.2em; }
9095
@@ -93,8 +98,19 @@
9499 margin: 0em 0 0em 0 ;
95100 font-size: smaller;
96101 color: #777;
 102+
 103+ padding-left: 0.3em; /* for post colors */
 104+ border-left: 0.3em solid;
97105 }
98106
 107+.lqt_post_color_1 { border-left-color: #cd9800; }
 108+.lqt_post_color_2 { border-left-color: #cd0098; }
 109+.lqt_post_color_3 { border-left-color: #98cd00; }
 110+.lqt_post_color_4 { border-left-color: #9800cd; }
 111+.lqt_post_color_5 { border-left-color: #0098cd; }
 112+.lqt_post_color_6 { border-left-color: #00cd98; }
 113+
 114+
99115 .lqt_footer li {
100116 display: inline;
101117 list-style-type: none;
@@ -135,10 +151,10 @@
136152 .lqt_post:hover .lqt_footer {
137153 color: black;
138154 }
139 -
 155+/*
140156 .lqt_post:hover {
141157 border-color: #aaa;
142 -}
 158+}*/
143159
144160 .lqt_post .lqt_footer:hover a {
145161 color: #002bb8;
Index: branches/liquidthreads/extensions/LqtExtension.php
@@ -38,15 +38,21 @@
3939 protected $title;
4040 protected $request;
4141
 42+ protected $user_colors;
 43+ protected $user_color_index;
 44+ const number_of_user_colors = 6;
 45+
4246 function __construct(&$output, &$article, &$title, &$user, &$request) {
4347 $this->article = $article;
4448 $this->output = $output;
4549 $this->user = $user;
4650 $this->title = $title;
4751 $this->request = $request;
 52+ $this->user_colors = array();
 53+ $this->user_color_index = 1;
4854 }
49 -
5055
 56+
5157 /** h1, h2, h3, etc. */
5258 var $headerLevel = 1;
5359
@@ -231,7 +237,8 @@
232238
233239 function showThreadFooter( $thread ) {
234240
235 - $this->output->addHTML(wfOpenElement('ul', array('class'=>'lqt_footer')));
 241+ $color_number = $this->selectNewUserColor( $thread->rootPost()->originalAuthor() );
 242+ $this->output->addHTML(wfOpenElement('ul', array('class'=>"lqt_footer lqt_post_color_$color_number" )));
236243
237244 $this->output->addHTML( wfOpenElement( 'li' ) );
238245 $p = new Parser(); $sig = $p->getUserSig( $thread->rootPost()->originalAuthor() );
@@ -251,9 +258,24 @@
252259 $this->output->addHTML(wfCloseELement('ul'));
253260 }
254261
 262+ function selectNewUserColor( $user ) {
 263+ $userkey = $user->isAnon() ? "anon:" . $user->getName() : "user:" . $user->getId();
 264+
 265+ if( !array_key_exists( $userkey, $this->user_colors ) ) {
 266+ $this->user_colors[$userkey] = $this->user_color_index;
 267+ $this->user_color_index += 1;
 268+ if ( $this->user_color_index > self::number_of_user_colors ) {
 269+ $this->user_color_index = 1;
 270+ }
 271+ }
 272+ return $this->user_colors[$userkey];
 273+ }
 274+
255275 function showRootPost( $thread ) {
256276 $post = $thread->rootPost();
257277
 278+/* $color_number = $this->selectNewUserColor( $thread->rootPost()->originalAuthor() );
 279+ $this->openDiv( "lqt_post lqt_post_color_$color_number" );*/
258280 $this->openDiv( 'lqt_post' );
259281
260282 if( $this->commandApplies( 'lqt_edit_post', $post ) ) {
@@ -306,6 +328,15 @@
307329 unset($content_actions['edit']);
308330 unset($content_actions['addsection']);
309331 unset($content_actions['history']);
 332+ unset($content_actions['watch']);
 333+
 334+ /*
 335+ TODO:
 336+ We could make these tabs actually follow the tab metaphor if we repointed
 337+ the 'history' and 'edit' tabs to the original subject page. That way 'discussion'
 338+ would just be one of four ways to view the article. But then those other tabs, for
 339+ logged-in users, don't really fit the metaphor. What to do, what to do?
 340+ */
310341 }
311342 function show() {
312343 global $wgHooks;
@@ -319,7 +350,7 @@
320351 $url = $this->lqtTalkpageUrl( $this->title, 'lqt_new_thread_form' );
321352 $this->output->addHTML("<strong><a href=\"$url\">Start a Discussion</a></strong>");
322353 }
323 - $threads = Thread::allThreadsOfArticle($this->article);
 354+ $threads = Thread::latestNThreadsOfArticle($this->article, 10);
324355 foreach($threads as $t) {
325356 $this->showThread($t);
326357 }