1 Jun 2007 05:55
SVN: [22618] branches/liquidthreads
<david <at> svn.wikimedia.org>
2007-06-01 03:55:39 GMT
2007-06-01 03:55:39 GMT
Revision: 22618
Author: david
Date: 2007-06-01 03:55:35 +0000 (Fri, 01 Jun 2007)
Log Message:
-----------
Preliminary support for summaries. Everything works except the hide/show code, now done in javascript
without ajax, is incompatible with doing any other operations. So we'll probably have to move that server
side. It'll be faster that way anyways.
Modified Paths:
--------------
branches/liquidthreads/extensions/LqtExtension.php
branches/liquidthreads/extensions/LqtModel.php
branches/liquidthreads/skins/common/lqt.js
branches/liquidthreads/skins/monobook/main.css
Modified: branches/liquidthreads/extensions/LqtExtension.php
===================================================================
--- branches/liquidthreads/extensions/LqtExtension.php 2007-06-01 03:41:53 UTC (rev 22617)
+++ branches/liquidthreads/extensions/LqtExtension.php 2007-06-01 03:55:35 UTC (rev 22618)
<at> <at> -88,19 +88,16 <at> <at>
return $this->request->getVal($command) == $thread->id();
}
- function permalinkUrl( $thread ) {
- return SpecialPage::getTitleFor('Thread', $thread->id())->getFullURL();
+ function permalinkUrl( $thread, $query ='' ) {
+ return SpecialPage::getTitleFor('Thread', $thread->id())->getFullURL($query);
}
/*************************
* Simple HTML methods *
*************************/
- function openDiv( $class = null ) {
- if ( $class )
- $this->output->addHTML( wfOpenElement( 'div', array('class'=>$class) ) );
- else
- $this->output->addHTML( wfOpenElement( 'div') );
+ function openDiv( $class='', $id='' ) {
+ $this->output->addHTML( wfOpenElement( 'div', array('class'=>$class, 'id'=>$id) ) );
}
function closeDiv() {
<at> <at> -136,13 +133,21 <at> <at>
$this->showEditingFormInGeneral( null, 'reply', $thread );
}
- function showEditingFormInGeneral( $thread, $edit_type, $edit_applies_to ) {
+ function showSummarizeForm( $thread ) {
+ $this->showEditingFormInGeneral( null, 'summarize', $thread );
+ }
+
+ private function showEditingFormInGeneral( $thread, $edit_type, $edit_applies_to ) {
// If there is no article (reply or new), we need a randomly-generated title.
// On the first pass, we generate one. After that, we find it in the request.
- if ( $thread == null ) {
+ if ($edit_type == 'summarize' && $edit_applies_to->summary() ) {
+ $article = $edit_applies_to->summary();
+ } else if ( $thread == null ) {
$rt = Title::newFromURL( $this->request->getVal('lqt_edit_post') );
$t = $rt ? $rt : $this->scratchTitle();
$article = new Article( $t );
+ } else if ($edit_type == 'summarize') {
+ $article = $edit_applies_to->summary();
} else {
$article = $thread->rootPost();
}
<at> <at> -153,7 +158,8 <at> <at>
$e->editFormTextBeforeContent .=
$this->perpetuate('lqt_edit_post', 'hidden') .
$this->perpetuate('lqt_reply_to', 'hidden') .
- $this->perpetuate('lqt_new_thread_form', 'hidden');
+ $this->perpetuate('lqt_new_thread_form', 'hidden') .
+ $this->perpetuate('lqt_summarize', 'hidden');
if ( /*$thread == null*/ $edit_type=='new' || ($thread && $thread->superthread() == null) ) {
// This is a top-level post; show the subject line.
<at> <at> -178,19 +184,23 <at> <at>
}
// For replies and new posts, insert the associated thread object into the DB.
- if ($edit_type != 'editExisting' && $e->didSave) {
+ if ($edit_type != 'editExisting' && $edit_type != 'summarize' && $e->didSave) {
$thread = Thread::newThread( $article, $this->article );
if ( $edit_type == 'reply' ) {
$thread->setSuperthread( $edit_applies_to );
+ } else {
+ $thread->touch();
}
}
+
+ if ($edit_type == 'summarize' && $e->didSave) {
+ $edit_applies_to->setSummary( $article );
+ }
$subject = $this->request->getVal('lqt_subject_field', '');
if ( $e->didSave && $subject != '' ) {
$thread->setSubject( Sanitizer::stripAllTags($subject) );
}
-
- if ($e->didSave) $thread->touch(); // TODO reduntent if above $thread->setX called.
}
function scratchTitle() {
<at> <at> -306,17 +316,37 <at> <at>
function showThreadHeading( $thread ) {
if ( $thread->hasSubject() )
- $this->output->addHTML( wfElement( "h{$this->headerLevel}", array('class'=>'lqt_header'),
$thread->subject() ) );
+ $this->output->addHTML( wfElement( "h{$this->headerLevel}",
+ array('class'=>'lqt_header'),
+ $thread->subject() ) );
+ if ( !$thread->superthread() && !$thread->summary() ) {
+ $url = $this->permalinkUrl( $thread, 'lqt_summarize=1' );
+ $this->output->addHTML( <<<HTML
+ <span class="lqt_summarize_command">[<a href="{$url}">Summarize</a>]</span>
+HTML
+ );
+ }
}
- function showThread( $thread ) {
+ function showThread( $thread, $suppress_summaries = false ) {
$this->showThreadHeading( $thread );
+
+ if( $thread->summary() && !$suppress_summaries ) {
+ $this->showSummary($thread);
+ $this->openDiv('lqt_thread lqt_thread_hidden', "lqt_thread_id_{$thread->id()}");
+ } else {
+ $this->openDiv('lqt_thread', "lqt_thread_id_{$thread->id()}");
+ }
+
+
$this->showRootPost( $thread );
$this->indent();
foreach( $thread->subthreads() as $st ) {
$this->showThread($st);
}
$this->unindent();
+
+ $this->closeDiv();
}
function indent() {
<at> <at> -329,6 +359,21 <at> <at>
$this->output->addHTML( wfCloseElement( 'dl') );
$this->headerLevel -= 1;
}
+
+ function showSummary($t) {
+ if ( !$t->summary() ) return;
+ $this->output->addHTML(<<<HTML
+ <span class="lqt_thread_permalink_summary_title">
+ This thread has been summarized as follows:
+ </span><span class="lqt_thread_permalink_summary_edit">
+ [<a href="{$this->permalinkUrl($t,'lqt_summarize=1')}">edit</a>]
+ </span>
+HTML
+ );
+ $this->openDiv('lqt_thread_permalink_summary');
+ $this->showPostBody($t->summary());
+ $this->closeDiv();
+ }
}
class TalkpageView extends LqtView {
<at> <at> -436,7 +481,7 <at> <at>
parent::showThreadHeading($thread);
}
}
-
+
function show() {
/* Extract the numeric ID after the slash in the URL. */
$title_string = $this->request->getVal('title');
<at> <at> -468,8 +513,15 <at> <at>
$this->output->setSubtitle( "from " . $talkpage_link );
}
- $this->showThread($t);
+ if( $this->request->getBool('lqt_summarize') ) {
+ $this->showSummarizeForm($t);
+ } else if ( $t->summary() ) {
+ $this->showSummary($t);
+ }
+
+ $this->showThread($t, true);
}
+
}
/*
Modified: branches/liquidthreads/extensions/LqtModel.php
===================================================================
--- branches/liquidthreads/extensions/LqtModel.php 2007-06-01 03:41:53 UTC (rev 22617)
+++ branches/liquidthreads/extensions/LqtModel.php 2007-06-01 03:55:35 UTC (rev 22618)
<at> <at> -138,6 +138,17 <at> <at>
return $this->rootPost;
}
+ function summary() {
+ if ( !$this->summaryId ) return null;
+ if ( !$this->summary ) $this->summary = new Post( Title::newFromID( $this->summaryId ) );
+ return $this->summary;
+ }
+
+ function setSummary( $post ) {
+ $this->summaryId = $post->getID();
+ $this->updateRecord();
+ }
+
function hasSubject() {
return $this->subject != null;
}
Modified: branches/liquidthreads/skins/common/lqt.js
===================================================================
--- branches/liquidthreads/skins/common/lqt.js 2007-06-01 03:41:53 UTC (rev 22617)
+++ branches/liquidthreads/skins/common/lqt.js 2007-06-01 03:55:35 UTC (rev 22618)
<at> <at> -11,6 +11,28 <at> <at>
}
}
+function lqt_handle_hide_show() {
+ var threadid = this.id.replace(/lqt_thread_showhide_/g, "lqt_thread_id_");
+ var thread = document.getElementById(threadid);
+ if ( thread.style.display == 'none' ) thread.style.display = 'block';
+ else thread.style.display = 'none';
+}
+
+function lqt_hide_all_hidden_threads() {
+ var els = getElementsByClassName(document, 'div', ['lqt_thread_hidden']);
+ for (var i in els) {
+ e = els[i];
+ e.style.display = 'none';
+ var link = document.createElement('a');
+ link.className = 'lqt_thread_showhide';
+ link.id = e.id.replace(/lqt_thread_id_/g, "lqt_thread_showhide_");
+ link.innerHTML = 'Show this thread';
+ lqt_add_event(link, 'click', lqt_handle_hide_show);
+ e.parentNode.insertBefore(link, e);
+ }
+}
+
+
function lqt_on_load() {
if(!document.getElementById) return;
<at> <at> -23,6 +45,8 <at> <at>
if (success) {
document.getElementById('lqt_archive_go_button').className = "lqt_hidden";
}
+
+ lqt_hide_all_hidden_threads();
}
addOnloadHook(lqt_on_load);
\ No newline at end of file
Modified: branches/liquidthreads/skins/monobook/main.css
===================================================================
--- branches/liquidthreads/skins/monobook/main.css 2007-06-01 03:41:53 UTC (rev 22617)
+++ branches/liquidthreads/skins/monobook/main.css 2007-06-01 03:55:35 UTC (rev 22618)
<at> <at> -33,6 +33,42 <at> <at>
margin-bottom: .1em;
}*/
+.lqt_thread_showhide {
+ margin-left: 1em;
+ margin-bottom: 0.5em;
+}
+
+.lqt_thread_permalink_summary {
+ clear: both;
+ border: solid 1px #ddd;
+ padding-left: 1em; padding-right: 1em;
+ margin: 2em 2em 0.7em 1em;
+}
+.lqt_thread_permalink_summary_title {
+ float: left;
+ margin-left: 1em;
+ font-weight: bold;
+}
+.lqt_thread_permalink_summary_edit {
+ float: right;
+ margin-right: 2em;
+ font-weight: bold;
+ font-size: smaller;
+}
+
+.lqt_summarize_command {
+ display: block;
+ float: right;
+ position: relative;
+ top: -3em;
+ font-size: smaller;
+ font-weight: bold;
+}
+
+h1.lqt_header {
+ padding-right: 4.2em;
+}
+
.lqt_archive_widget {
/* floats to the right of the main h1 page title. */
float:right;
<at> <at> -48,14 +84,7 <at> <at>
padding-right: 4.5em;
}
-#lqt_archive_hide_show {
- display: block;
-}
-#lqt_archive_toc {
- display: none;
-}
-
h1.lqt_header {
font-size: 150%; /* same as h2 normally is */
<at> <at> -69,11 +98,6 <at> <at>
margin-right: 4pt;
}
-.lqt_archive_browser {
- margin-top: 1em;
- margin-bottom: 1em;
-}
-
.lqt_deleted_notice {
color: #999;
font-style: italic;
RSS Feed