Cicalese has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/320096

Change subject: Make comments searchable; refactor
......................................................................

Make comments searchable; refactor

Change-Id: Idbc0c57c569d10c21fcd5ada6953dc1526d8e5dc
---
D CommentStreams.php
D api/ApiCSQueryDatabase.php
R includes/ApiCSDeleteComment.php
R includes/ApiCSEditComment.php
R includes/ApiCSPostComment.php
R includes/ApiCSQueryComment.php
R includes/Comment.php
R includes/CommentStreams.php
R includes/CommentStreamsHooks.php
D js+css/CommentStreams.Data.js
D js+css/images/more.png
D js+css/images/thumbs-down.png
D js+css/images/thumbs-up.png
D js+css/images/user.png
D php/DatabaseQuerier.php
R resources/CommentStreams.css
R resources/CommentStreams.js
R resources/CommentStreamsQuerier.js
R resources/spin.min.js
D sql/downvotes.sql
D sql/nextComment.sql
D sql/upvotes.sql
22 files changed, 0 insertions(+), 405 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/CommentStreams 
refs/changes/96/320096/1

diff --git a/CommentStreams.php b/CommentStreams.php
deleted file mode 100644
index aa50561..0000000
--- a/CommentStreams.php
+++ /dev/null
@@ -1,43 +0,0 @@
-<?php
-/*
- * Copyright (c) 2016 The MITRE Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-/**
-* To activate the functionality of this extension include the following
-* in your LocalSettings.php file:
-* wfLoadExtension("CommentStreams");
-*/
-
-if ( function_exists( 'wfLoadExtension' ) ) {
-       wfLoadExtension( 'CommentStreams' );
-       // Keep i18n globals so mergeMessageFileList.php doesn't break
-       $wgMessagesDirs['CommentStreams'] = __DIR__ . "/i18n";
-       $wgExtensionMessagesFiles['CommentStreamsNamespaces'] = __DIR__ . 
'/i18n/CommentStreams.namespaces.php';
-       wfWarn(
-               'Deprecated PHP entry point used for CommentStreams extension. 
Please use wfLoadExtension instead, ' .
-               'see https://www.mediawiki.org/wiki/Extension_registration for 
more details.'
-       );
-       return;
-}
-else {
-       die( 'This version of CommentStreams requires MediaWiki 1.25+.');
-}
diff --git a/api/ApiCSQueryDatabase.php b/api/ApiCSQueryDatabase.php
deleted file mode 100644
index cde58f4..0000000
--- a/api/ApiCSQueryDatabase.php
+++ /dev/null
@@ -1,74 +0,0 @@
-<?php
-/*
- * Copyright (c) 2016 The MITRE Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-class ApiCSQueryDatabase extends ApiBase {
-
-       public function __construct( $main, $action ) {
-               parent::__construct( $main, $action );
-       }
-       public function execute() {
-               $query = $this->getMain()->getVal( 'query' );
-               if($query == 'childrenCount') {
-                       $parent = $this->getMain()->getVal( 'parentCommentId' );
-                       if(!$parent) {
-                               $this->getResult()->addValue(null, "error", 
array('code' => 'missingparent', 
-                                                                               
                                                        'info' => 'you must 
provide a parent comment page ID'));
-                               return true;
-                       }
-                       $childrenCount = 
DatabaseQuerier::numberOfChildCommentsForParentCommentId($parent);
-                       $this->getResult()->addValue( null, 
$this->getModuleName(), array('query' => $query,
-                                                                               
                                                                                
'childrenCount' => $childrenCount));
-               }
-               else {
-                       $this->getResult()->addValue(null, "error", 
array('code' => 'unrecognizedparameter', 'info' => 'query parameter 
unrecognized'));
-               }
-               return true;
-       }
-       public function getDescription() {
-               return 'Query for CommentStreams information.';
-       }
-       public function getAllowedParams() {
-               return array(
-                       'query' => array(
-                               ApiBase::PARAM_TYPE => 'string',
-                               ApiBase::PARAM_REQUIRED => true
-                       ),
-                       'parentCommentId' => array(
-                               ApiBase::PARAM_TYPE => 'integer',
-                               ApiBase::PARAM_REQUIRED => false
-                       )
-               );
-       }
-       public function getParamDescription() {
-               return array(
-                       'query' => 'type of query. Allowed values: 
childrenCount',
-                       'parentCommentId' => 'page ID of the parent comment'
-               );
-       }
-       public function getExamples() {
-               return null;
-       }
-       public function getHelpUrls() {
-               return '';
-       }
-}
diff --git a/api/ApiCSDeleteComment.php b/includes/ApiCSDeleteComment.php
similarity index 100%
rename from api/ApiCSDeleteComment.php
rename to includes/ApiCSDeleteComment.php
diff --git a/api/ApiCSEditComment.php b/includes/ApiCSEditComment.php
similarity index 100%
rename from api/ApiCSEditComment.php
rename to includes/ApiCSEditComment.php
diff --git a/api/ApiCSPostComment.php b/includes/ApiCSPostComment.php
similarity index 100%
rename from api/ApiCSPostComment.php
rename to includes/ApiCSPostComment.php
diff --git a/api/ApiCSQueryComment.php b/includes/ApiCSQueryComment.php
similarity index 100%
rename from api/ApiCSQueryComment.php
rename to includes/ApiCSQueryComment.php
diff --git a/php/Comment.php b/includes/Comment.php
similarity index 100%
rename from php/Comment.php
rename to includes/Comment.php
diff --git a/php/CommentManager.php b/includes/CommentStreams.php
similarity index 100%
rename from php/CommentManager.php
rename to includes/CommentStreams.php
diff --git a/php/CommentStreams_body.php b/includes/CommentStreamsHooks.php
similarity index 100%
rename from php/CommentStreams_body.php
rename to includes/CommentStreamsHooks.php
diff --git a/js+css/CommentStreams.Data.js b/js+css/CommentStreams.Data.js
deleted file mode 100644
index 418bf77..0000000
--- a/js+css/CommentStreams.Data.js
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2016 The MITRE Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-window.CommentStreams = ( function( mw, $, my ) {
-       my.Data = {
-               isLoggedIn: false,
-               userPageURL: "",
-               associatedPageId: "",
-               associatedPageTitle:"",
-               newestStreamsOnTop: false,
-               smwInstalled: false,
-               semanticTitlePropertyName: "",
-               spinnerOptions: {
-                       lines: 11, // The number of lines to draw
-                       length: 8, // The length of each line
-                       width: 4, // The line thickness
-                       radius: 8, // The radius of the inner circle
-                       corners: 1, // Corner roundness (0..1)
-                       rotate: 0, // The rotation offset
-                       direction: 1, // 1: clockwise, -1: counterclockwise
-                       color: '#000', // #rgb or #rrggbb or array of colors
-                       speed: 1, // Rounds per second
-                       trail: 60, // ƒfterglow percentage
-                       shadow: false, // Whether to render a shadow
-                       hwaccel: false, // Whether to use hardware acceleration
-                       className: 'spinner', // The CSS class to assign to the 
spinner
-                       zIndex: 2e9, // The z-index (defaults to 2000000000)
-                       top: '50%', // Top position relative to parent
-                       left: '50%' // Left position relative to parent
-               },
-               initializeConstants: function(isLoggedIn, userPageURL, 
associatedPageId, associatedPageTitle, smwInstalled, semanticTitlePropertyName, 
newestStreamsOnTop) {
-                       this.isLoggedIn = isLoggedIn;
-                       this.userPageURL = userPageURL;
-                       this.associatedPageId = associatedPageId;
-                       this.associatedPageTitle = associatedPageTitle;
-                       this.smwInstalled = smwInstalled == 1 ? true : false;
-                       this.semanticTitlePropertyName = 
semanticTitlePropertyName;
-                       this.newestStreamsOnTop = newestStreamsOnTop == 1 ? 
true : false;
-               },
-               log: function(text) {
-                       if ( ( window.console !== undefined ) )
-                               window.console.log( text );
-               }
-       };
-
-       return my;
-}( mediaWiki, jQuery, window.CommentStreams || {} ) );
diff --git a/js+css/images/more.png b/js+css/images/more.png
deleted file mode 100644
index 27d5adc..0000000
--- a/js+css/images/more.png
+++ /dev/null
Binary files differ
diff --git a/js+css/images/thumbs-down.png b/js+css/images/thumbs-down.png
deleted file mode 100644
index b78ef3d..0000000
--- a/js+css/images/thumbs-down.png
+++ /dev/null
Binary files differ
diff --git a/js+css/images/thumbs-up.png b/js+css/images/thumbs-up.png
deleted file mode 100644
index 600f07f..0000000
--- a/js+css/images/thumbs-up.png
+++ /dev/null
Binary files differ
diff --git a/js+css/images/user.png b/js+css/images/user.png
deleted file mode 100644
index adb8e83..0000000
--- a/js+css/images/user.png
+++ /dev/null
Binary files differ
diff --git a/php/DatabaseQuerier.php b/php/DatabaseQuerier.php
deleted file mode 100644
index 984a982..0000000
--- a/php/DatabaseQuerier.php
+++ /dev/null
@@ -1,202 +0,0 @@
-<?php
-/*
- * Copyright (c) 2016 The MITRE Corporation
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
-
-class DatabaseQuerier {
-       
-       public static function commentsForPageId( $contentPageId ) {
-
-               global $wgCommentStreamsUserRealNamePropertyName;
-               global $wgCommentStreamsSMWinstalled;
-
-               $dbr = wfGetDB( DB_SLAVE );
-               $result = $dbr->select(
-                       'cs_comment_data',
-                       array('page_id', 'assoc_page_id', 'parent_page_id', 
'comment_title'),
-                       array(
-                               'assoc_page_id' => $contentPageId
-                       ),
-                       __METHOD__
-               );
-
-               $databaseResults = array();
-
-               foreach($result as $row) {
-                       $databaseResults[] = array(
-                               'page_id' => $row->page_id,
-                               'assoc_page_id' => $row->assoc_page_id,
-                               'parent_page_id' => $row->parent_page_id,
-                               'comment_title' => $row->comment_title
-                       );
-               }
-
-               $comments = array();
-
-               foreach($databaseResults as $row) {
-                       $title = $row['comment_title'];
-                       $page_id = $row['page_id'];
-                       $associated_page_id = $contentPageId;
-                       $parent_id = $row['parent_page_id'];
-
-                       // create WikiPage object to get the page text and 
username/real name
-                       $wikipage = WikiPage::newFromId($page_id);
-                       $pageText = ContentHandler::getContentText( 
$wikipage->getContent( Revision::RAW ) );
-                       $user = 
User::newFromId($wikipage->getOldestRevision()->getUser());
-                       $username = $user->getName();
-
-                       $userTitleObject = Title::newFromText($username, 
NS_USER);
-                       if($wgCommentStreamsSMWinstalled && 
$wgCommentStreamsUserRealNamePropertyName !== null) {
-                               $userRealName = 
DatabaseQuerier::queryForUserRealNameProperty($userTitleObject, 
$wgCommentStreamsUserRealNamePropertyName);
-                               if($userRealName == null)
-                                       $userRealName = $user->getRealName();
-                       }
-                       else
-                               $userRealName = $user->getRealName();
-                       // create Title object to get creation date
-                       $titleObject = Title::newFromID($page_id);
-                       $timestamp = 
MWTimestamp::getLocalInstance($titleObject->getEarliestRevTime());
-                       $creationDate = $timestamp;
-
-                       $title = htmlspecialchars($title);
-                       $comment = new Comment($title, $pageText, $page_id, 
$associated_page_id, $parent_id, $username, $userRealName, $creationDate);
-                       $comments[] = $comment;
-               }
-
-               return $comments;
-       }
-
-       public static function commentTitleForPageId( $pageId ) {
-               $dbr = wfGetDB( DB_SLAVE );
-               $result = $dbr->select(
-                       'cs_comment_data',
-                       'comment_title',
-                       array(
-                               'page_id' => $pageId
-                       ),
-                       __METHOD__
-               );
-               if($result->current())
-                       return 
htmlspecialchars($result->current()->comment_title);
-               else
-                       return null;
-       }
-
-       public static function numberOfChildCommentsForParentCommentId( 
$parentId ) {
-               $dbr = wfGetDB( DB_SLAVE );
-               $result = $dbr->select(
-                       'cs_comment_data',
-                       array('page_id'),
-                       array(
-                               'parent_page_id' => $parentId
-                       ),
-                       __METHOD__
-               );
-               $numRows = $result->numRows();
-               return is_numeric( $numRows ) ? $numRows : 0;
-       }
-
-       public static function getNextCommentNumber() {
-               $dbr = wfGetDB( DB_SLAVE );
-               $result = $dbr->select(
-                       'cs_next_comment',
-                       array('next_comment_number')
-               );
-
-               return $result->current()->next_comment_number;
-       }
-
-       public static function incrementNextCommentNumber() {
-               $currentCommentNumber = self::getNextCommentNumber();
-
-               $dbw = wfGetDB( DB_MASTER );
-               $dbw->update(
-                       'cs_next_comment',
-                       array('next_comment_number' => $currentCommentNumber+1),
-                       array('next_comment_number' => $currentCommentNumber)
-               );
-       }
-       public static function setNextCommentNumberOrHigher($newNumber) {
-               // Set the comment number to either this value, or the current 
value +1,
-               // whichever is higher. (This is for concurrency issues, in 
case the current value
-               // was incremented since it had been fetched.)
-               $currentCommentNumber = self::getNextCommentNumber();
-
-               $dbw = wfGetDB( DB_MASTER );
-               $dbw->update(
-                       'cs_next_comment',
-                       array('next_comment_number' => max($newNumber, 
$currentCommentNumber+1)),
-                       array('next_comment_number' => $currentCommentNumber)
-               );      
-       }
-       public static function addCommentDataToDatabase($pageId, 
$commentedPageId, $commentTitle, $parentCommentId=null) {
-               $dbw = wfGetDB( DB_MASTER );
-               $dbw-> insert(
-                       'cs_comment_data',
-                       array(
-                               'page_id' => $pageId,
-                               'assoc_page_id' => $commentedPageId,
-                               'comment_title' => $commentTitle,
-                               'parent_page_id' => $parentCommentId
-                       )
-               );
-       }
-       public static function deleteCommentDataFromDatabase($pageId) {
-               $dbw = wfGetDB( DB_MASTER );
-               $dbw->delete(
-                       'cs_comment_data',
-                       array(
-                               'page_id' => $pageId
-                       )
-               );
-       }
-
-       public static function updateCommentTitle($pageId, $title) {
-               $dbw = wfGetDB( DB_MASTER );
-               $dbw->update(
-                       'cs_comment_data',
-                       array('comment_title' => $title),
-                       array('page_id' => $pageId)
-               );
-       }
-       
-       public static function queryForUserRealNameProperty($title, 
$propertyName) { 
-               $store = \SMW\StoreFactory::getStore();
-
-       $subject = SMWDIWikiPage::newFromTitle( $title );
-       $data = $store->getSemanticData( $subject );
-       $property = SMWDIProperty::newFromUserLabel( $propertyName );
-       $values = $data->getPropertyValues( $property );
- 
-       if(count($values) == 0)
-               return null;
-
-               // this property should only have one value so pick the first 
one
-       $value = $values[0];
-               if ( $value->getDIType() == SMWDataItem::TYPE_STRING ||
-                       $value->getDIType() == SMWDataItem::TYPE_BLOB ) {
-                       return $value->getString();
-               }
-               else {
-                       return null;
-               }
-       }
-}
diff --git a/js+css/CommentStreams.css b/resources/CommentStreams.css
similarity index 100%
rename from js+css/CommentStreams.css
rename to resources/CommentStreams.css
diff --git a/js+css/CommentStreams.Controller.js b/resources/CommentStreams.js
similarity index 100%
rename from js+css/CommentStreams.Controller.js
rename to resources/CommentStreams.js
diff --git a/js+css/CommentStreams.Querier.js 
b/resources/CommentStreamsQuerier.js
similarity index 100%
rename from js+css/CommentStreams.Querier.js
rename to resources/CommentStreamsQuerier.js
diff --git a/js+css/spin.min.js b/resources/spin.min.js
similarity index 100%
rename from js+css/spin.min.js
rename to resources/spin.min.js
diff --git a/sql/downvotes.sql b/sql/downvotes.sql
deleted file mode 100644
index af3f9e3..0000000
--- a/sql/downvotes.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-CREATE TABLE IF NOT EXISTS cs_downvotes
-(
-page_id int(10) unsigned,
-user_id int(10) unsigned,
-FOREIGN KEY (page_id) REFERENCES page(page_id),
-FOREIGN KEY (user_id) REFERENCES user(user_id)
-);
\ No newline at end of file
diff --git a/sql/nextComment.sql b/sql/nextComment.sql
deleted file mode 100644
index 8de489d..0000000
--- a/sql/nextComment.sql
+++ /dev/null
@@ -1,6 +0,0 @@
-CREATE TABLE IF NOT EXISTS cs_next_comment
-(
-next_comment_number int unsigned
-);
-
-INSERT INTO cs_next_comment values(1);
\ No newline at end of file
diff --git a/sql/upvotes.sql b/sql/upvotes.sql
deleted file mode 100644
index c469610..0000000
--- a/sql/upvotes.sql
+++ /dev/null
@@ -1,7 +0,0 @@
-CREATE TABLE IF NOT EXISTS cs_upvotes
-(
-page_id int(10) unsigned,
-user_id int(10) unsigned,
-FOREIGN KEY (page_id) REFERENCES page(page_id),
-FOREIGN KEY (user_id) REFERENCES user(user_id)
-);
\ No newline at end of file

-- 
To view, visit https://gerrit.wikimedia.org/r/320096
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idbc0c57c569d10c21fcd5ada6953dc1526d8e5dc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/CommentStreams
Gerrit-Branch: master
Gerrit-Owner: Cicalese <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to