Index: branches/liquidthreads/skins/monobook/main.css |
— | — | @@ -33,6 +33,42 @@ |
34 | 34 | margin-bottom: .1em; |
35 | 35 | }*/ |
36 | 36 | |
| 37 | +.lqt_thread_showhide { |
| 38 | + margin-left: 1em; |
| 39 | + margin-bottom: 0.5em; |
| 40 | +} |
| 41 | + |
| 42 | +.lqt_thread_permalink_summary { |
| 43 | + clear: both; |
| 44 | + border: solid 1px #ddd; |
| 45 | + padding-left: 1em; padding-right: 1em; |
| 46 | + margin: 2em 2em 0.7em 1em; |
| 47 | +} |
| 48 | +.lqt_thread_permalink_summary_title { |
| 49 | + float: left; |
| 50 | + margin-left: 1em; |
| 51 | + font-weight: bold; |
| 52 | +} |
| 53 | +.lqt_thread_permalink_summary_edit { |
| 54 | + float: right; |
| 55 | + margin-right: 2em; |
| 56 | + font-weight: bold; |
| 57 | + font-size: smaller; |
| 58 | +} |
| 59 | + |
| 60 | +.lqt_summarize_command { |
| 61 | + display: block; |
| 62 | + float: right; |
| 63 | + position: relative; |
| 64 | + top: -3em; |
| 65 | + font-size: smaller; |
| 66 | + font-weight: bold; |
| 67 | +} |
| 68 | + |
| 69 | +h1.lqt_header { |
| 70 | + padding-right: 4.2em; |
| 71 | +} |
| 72 | + |
37 | 73 | .lqt_archive_widget { |
38 | 74 | /* floats to the right of the main h1 page title. */ |
39 | 75 | float:right; |
— | — | @@ -48,14 +84,7 @@ |
49 | 85 | padding-right: 4.5em; |
50 | 86 | } |
51 | 87 | |
52 | | -#lqt_archive_hide_show { |
53 | | - display: block; |
54 | | -} |
55 | 88 | |
56 | | -#lqt_archive_toc { |
57 | | - display: none; |
58 | | -} |
59 | | - |
60 | 89 | h1.lqt_header { |
61 | 90 | |
62 | 91 | font-size: 150%; /* same as h2 normally is */ |
— | — | @@ -69,11 +98,6 @@ |
70 | 99 | margin-right: 4pt; |
71 | 100 | } |
72 | 101 | |
73 | | -.lqt_archive_browser { |
74 | | - margin-top: 1em; |
75 | | - margin-bottom: 1em; |
76 | | -} |
77 | | - |
78 | 102 | .lqt_deleted_notice { |
79 | 103 | color: #999; |
80 | 104 | font-style: italic; |
Index: branches/liquidthreads/skins/common/lqt.js |
— | — | @@ -11,6 +11,28 @@ |
12 | 12 | } |
13 | 13 | } |
14 | 14 | |
| 15 | +function lqt_handle_hide_show() { |
| 16 | + var threadid = this.id.replace(/lqt_thread_showhide_/g, "lqt_thread_id_"); |
| 17 | + var thread = document.getElementById(threadid); |
| 18 | + if ( thread.style.display == 'none' ) thread.style.display = 'block'; |
| 19 | + else thread.style.display = 'none'; |
| 20 | +} |
| 21 | + |
| 22 | +function lqt_hide_all_hidden_threads() { |
| 23 | + var els = getElementsByClassName(document, 'div', ['lqt_thread_hidden']); |
| 24 | + for (var i in els) { |
| 25 | + e = els[i]; |
| 26 | + e.style.display = 'none'; |
| 27 | + var link = document.createElement('a'); |
| 28 | + link.className = 'lqt_thread_showhide'; |
| 29 | + link.id = e.id.replace(/lqt_thread_id_/g, "lqt_thread_showhide_"); |
| 30 | + link.innerHTML = 'Show this thread'; |
| 31 | + lqt_add_event(link, 'click', lqt_handle_hide_show); |
| 32 | + e.parentNode.insertBefore(link, e); |
| 33 | + } |
| 34 | +} |
| 35 | + |
| 36 | + |
15 | 37 | function lqt_on_load() { |
16 | 38 | if(!document.getElementById) return; |
17 | 39 | |
— | — | @@ -23,6 +45,8 @@ |
24 | 46 | if (success) { |
25 | 47 | document.getElementById('lqt_archive_go_button').className = "lqt_hidden"; |
26 | 48 | } |
| 49 | + |
| 50 | + lqt_hide_all_hidden_threads(); |
27 | 51 | } |
28 | 52 | |
29 | 53 | addOnloadHook(lqt_on_load); |
\ No newline at end of file |
Index: branches/liquidthreads/extensions/LqtExtension.php |
— | — | @@ -88,19 +88,16 @@ |
89 | 89 | return $this->request->getVal($command) == $thread->id(); |
90 | 90 | } |
91 | 91 | |
92 | | - function permalinkUrl( $thread ) { |
93 | | - return SpecialPage::getTitleFor('Thread', $thread->id())->getFullURL(); |
| 92 | + function permalinkUrl( $thread, $query ='' ) { |
| 93 | + return SpecialPage::getTitleFor('Thread', $thread->id())->getFullURL($query); |
94 | 94 | } |
95 | 95 | |
96 | 96 | /************************* |
97 | 97 | * Simple HTML methods * |
98 | 98 | *************************/ |
99 | 99 | |
100 | | - function openDiv( $class = null ) { |
101 | | - if ( $class ) |
102 | | - $this->output->addHTML( wfOpenElement( 'div', array('class'=>$class) ) ); |
103 | | - else |
104 | | - $this->output->addHTML( wfOpenElement( 'div') ); |
| 100 | + function openDiv( $class='', $id='' ) { |
| 101 | + $this->output->addHTML( wfOpenElement( 'div', array('class'=>$class, 'id'=>$id) ) ); |
105 | 102 | } |
106 | 103 | |
107 | 104 | function closeDiv() { |
— | — | @@ -136,13 +133,21 @@ |
137 | 134 | $this->showEditingFormInGeneral( null, 'reply', $thread ); |
138 | 135 | } |
139 | 136 | |
140 | | - function showEditingFormInGeneral( $thread, $edit_type, $edit_applies_to ) { |
| 137 | + function showSummarizeForm( $thread ) { |
| 138 | + $this->showEditingFormInGeneral( null, 'summarize', $thread ); |
| 139 | + } |
| 140 | + |
| 141 | + private function showEditingFormInGeneral( $thread, $edit_type, $edit_applies_to ) { |
141 | 142 | // If there is no article (reply or new), we need a randomly-generated title. |
142 | 143 | // On the first pass, we generate one. After that, we find it in the request. |
143 | | - if ( $thread == null ) { |
| 144 | + if ($edit_type == 'summarize' && $edit_applies_to->summary() ) { |
| 145 | + $article = $edit_applies_to->summary(); |
| 146 | + } else if ( $thread == null ) { |
144 | 147 | $rt = Title::newFromURL( $this->request->getVal('lqt_edit_post') ); |
145 | 148 | $t = $rt ? $rt : $this->scratchTitle(); |
146 | 149 | $article = new Article( $t ); |
| 150 | + } else if ($edit_type == 'summarize') { |
| 151 | + $article = $edit_applies_to->summary(); |
147 | 152 | } else { |
148 | 153 | $article = $thread->rootPost(); |
149 | 154 | } |
— | — | @@ -153,7 +158,8 @@ |
154 | 159 | $e->editFormTextBeforeContent .= |
155 | 160 | $this->perpetuate('lqt_edit_post', 'hidden') . |
156 | 161 | $this->perpetuate('lqt_reply_to', 'hidden') . |
157 | | - $this->perpetuate('lqt_new_thread_form', 'hidden'); |
| 162 | + $this->perpetuate('lqt_new_thread_form', 'hidden') . |
| 163 | + $this->perpetuate('lqt_summarize', 'hidden'); |
158 | 164 | |
159 | 165 | if ( /*$thread == null*/ $edit_type=='new' || ($thread && $thread->superthread() == null) ) { |
160 | 166 | // This is a top-level post; show the subject line. |
— | — | @@ -178,19 +184,23 @@ |
179 | 185 | } |
180 | 186 | |
181 | 187 | // For replies and new posts, insert the associated thread object into the DB. |
182 | | - if ($edit_type != 'editExisting' && $e->didSave) { |
| 188 | + if ($edit_type != 'editExisting' && $edit_type != 'summarize' && $e->didSave) { |
183 | 189 | $thread = Thread::newThread( $article, $this->article ); |
184 | 190 | if ( $edit_type == 'reply' ) { |
185 | 191 | $thread->setSuperthread( $edit_applies_to ); |
| 192 | + } else { |
| 193 | + $thread->touch(); |
186 | 194 | } |
187 | 195 | } |
| 196 | + |
| 197 | + if ($edit_type == 'summarize' && $e->didSave) { |
| 198 | + $edit_applies_to->setSummary( $article ); |
| 199 | + } |
188 | 200 | |
189 | 201 | $subject = $this->request->getVal('lqt_subject_field', ''); |
190 | 202 | if ( $e->didSave && $subject != '' ) { |
191 | 203 | $thread->setSubject( Sanitizer::stripAllTags($subject) ); |
192 | 204 | } |
193 | | - |
194 | | - if ($e->didSave) $thread->touch(); // TODO reduntent if above $thread->setX called. |
195 | 205 | } |
196 | 206 | |
197 | 207 | function scratchTitle() { |
— | — | @@ -306,17 +316,37 @@ |
307 | 317 | |
308 | 318 | function showThreadHeading( $thread ) { |
309 | 319 | if ( $thread->hasSubject() ) |
310 | | - $this->output->addHTML( wfElement( "h{$this->headerLevel}", array('class'=>'lqt_header'), $thread->subject() ) ); |
| 320 | + $this->output->addHTML( wfElement( "h{$this->headerLevel}", |
| 321 | + array('class'=>'lqt_header'), |
| 322 | + $thread->subject() ) ); |
| 323 | + if ( !$thread->superthread() && !$thread->summary() ) { |
| 324 | + $url = $this->permalinkUrl( $thread, 'lqt_summarize=1' ); |
| 325 | + $this->output->addHTML( <<<HTML |
| 326 | + <span class="lqt_summarize_command">[<a href="{$url}">Summarize</a>]</span> |
| 327 | +HTML |
| 328 | + ); |
| 329 | + } |
311 | 330 | } |
312 | 331 | |
313 | | - function showThread( $thread ) { |
| 332 | + function showThread( $thread, $suppress_summaries = false ) { |
314 | 333 | $this->showThreadHeading( $thread ); |
| 334 | + |
| 335 | + if( $thread->summary() && !$suppress_summaries ) { |
| 336 | + $this->showSummary($thread); |
| 337 | + $this->openDiv('lqt_thread lqt_thread_hidden', "lqt_thread_id_{$thread->id()}"); |
| 338 | + } else { |
| 339 | + $this->openDiv('lqt_thread', "lqt_thread_id_{$thread->id()}"); |
| 340 | + } |
| 341 | + |
| 342 | + |
315 | 343 | $this->showRootPost( $thread ); |
316 | 344 | $this->indent(); |
317 | 345 | foreach( $thread->subthreads() as $st ) { |
318 | 346 | $this->showThread($st); |
319 | 347 | } |
320 | 348 | $this->unindent(); |
| 349 | + |
| 350 | + $this->closeDiv(); |
321 | 351 | } |
322 | 352 | |
323 | 353 | function indent() { |
— | — | @@ -329,6 +359,21 @@ |
330 | 360 | $this->output->addHTML( wfCloseElement( 'dl') ); |
331 | 361 | $this->headerLevel -= 1; |
332 | 362 | } |
| 363 | + |
| 364 | + function showSummary($t) { |
| 365 | + if ( !$t->summary() ) return; |
| 366 | + $this->output->addHTML(<<<HTML |
| 367 | + <span class="lqt_thread_permalink_summary_title"> |
| 368 | + This thread has been summarized as follows: |
| 369 | + </span><span class="lqt_thread_permalink_summary_edit"> |
| 370 | + [<a href="{$this->permalinkUrl($t,'lqt_summarize=1')}">edit</a>] |
| 371 | + </span> |
| 372 | +HTML |
| 373 | + ); |
| 374 | + $this->openDiv('lqt_thread_permalink_summary'); |
| 375 | + $this->showPostBody($t->summary()); |
| 376 | + $this->closeDiv(); |
| 377 | + } |
333 | 378 | } |
334 | 379 | |
335 | 380 | class TalkpageView extends LqtView { |
— | — | @@ -436,7 +481,7 @@ |
437 | 482 | parent::showThreadHeading($thread); |
438 | 483 | } |
439 | 484 | } |
440 | | - |
| 485 | + |
441 | 486 | function show() { |
442 | 487 | /* Extract the numeric ID after the slash in the URL. */ |
443 | 488 | $title_string = $this->request->getVal('title'); |
— | — | @@ -468,8 +513,15 @@ |
469 | 514 | $this->output->setSubtitle( "from " . $talkpage_link ); |
470 | 515 | } |
471 | 516 | |
472 | | - $this->showThread($t); |
| 517 | + if( $this->request->getBool('lqt_summarize') ) { |
| 518 | + $this->showSummarizeForm($t); |
| 519 | + } else if ( $t->summary() ) { |
| 520 | + $this->showSummary($t); |
| 521 | + } |
| 522 | + |
| 523 | + $this->showThread($t, true); |
473 | 524 | } |
| 525 | + |
474 | 526 | } |
475 | 527 | |
476 | 528 | /* |
Index: branches/liquidthreads/extensions/LqtModel.php |
— | — | @@ -138,6 +138,17 @@ |
139 | 139 | return $this->rootPost; |
140 | 140 | } |
141 | 141 | |
| 142 | + function summary() { |
| 143 | + if ( !$this->summaryId ) return null; |
| 144 | + if ( !$this->summary ) $this->summary = new Post( Title::newFromID( $this->summaryId ) ); |
| 145 | + return $this->summary; |
| 146 | + } |
| 147 | + |
| 148 | + function setSummary( $post ) { |
| 149 | + $this->summaryId = $post->getID(); |
| 150 | + $this->updateRecord(); |
| 151 | + } |
| 152 | + |
142 | 153 | function hasSubject() { |
143 | 154 | return $this->subject != null; |
144 | 155 | } |