Extension:HyperComments
<translate> This extension stores its source code on a wiki page.</translate> <translate> Please be aware that this code may be unreviewed or maliciously altered.</translate> <translate> They may contain security holes, outdated interfaces that are no longer compatible etc.</translate> <translate> Note:</translate> <translate> No [[<tvar name=localisation>Special:MyLanguage/Localisation#Translation resources</tvar>|localisation]] updates are provided for this extension by <tvar name=twn>translatewiki.net </tvar>.</translate> |
<translate> This extension is currently not actively maintained!</translate> <translate> Although it may still work, any bug reports or feature requests will more than likely be ignored.</translate> |
HyperComments Release status: unmaintained |
|
---|---|
Implementation | User interface |
Description | Adds a HyperComments box at the bottom of every article page |
Author(s) | (Dmitry Ogarkovtalk) |
Latest version | 1.0 (2014-10-27) |
MediaWiki | 1.18+ |
Database changes | No |
License | GNU General Public License 2.0 |
Download | No link |
Example | Какой велосипед купить - Rulus.ru |
$wgHyperCommentsId |
|
Quarterly downloads | Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin'). |
Public wikis using | Lua error in Module:Extension at line 172: bad argument #1 to 'inNamespace' (unrecognized namespace name 'skin'). |
The HyperComments extension adds a HyperComments box at the bottom of every article page, except for the main page. It is based on Extension:FacebookComments, with a few minor fixes.
Installation
Copy and paste the code below to the files:
$IP/extensions/HyperComments/HyperComments.php
and
$IP/extensions/HyperComments/HyperComments.class.php
.
Add the following to your LocalSettings.php:
$wgHyperCommentsId = '?????'; // Your HyperComments widget ID
require_once("$IP/extensions/HyperComments/HyperComments.php");
To position the comments box (div#comments
), add some margins to your MediaWiki:Common.css, for example:
#comments {
margin: 2em 0;
}
Code
- HyperComments.php
<?php
/*
* MediaWiki extension to add HyperComments on every article page
* Installation instructions can be found on
* http://www.mediawiki.org/wiki/Extension:HyperComments
*
* @ingroup Extensions
* @author Dmitry Ogarkov
* @license GNU Public License
*/
if( !defined( 'MEDIAWIKI' ) ) exit;
$dir = dirname(__FILE__).'/';
$wgAutoloadClasses['HyperComments'] = $dir.'HyperComments.class.php';
$wgHooks['SkinAfterBottomScripts'][] = 'HyperComments::renderHyperComments';
$wgExtensionCredits['parserhook'][] = array(
'path' => __FILE__,
'name' => 'HyperComments',
'version' => '1.0',
'author' => 'Dmitry Ogarkov',
'url' => 'https://www.mediawiki.org/wiki/Extension:HyperComments',
'description' => 'Adds a HyperComments box at the bottom of every article page'
);
- HyperComments.class.php
<?php
/*
* Class file for the HyperComments extension
*
* @ingroup Extensions
* @author Dmitry Ogarkov
* @license GNU Public License
*/
if( !defined( 'MEDIAWIKI' ) ) exit;
class HyperComments {
static function getURL() {
if ( isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']=='on' ) { $protocol = 'https'; $port = '443'; }
else { $protocol = 'http'; $port = '80'; }
$port = $_SERVER['SERVER_PORT']==$port ? '' : ':' . $_SERVER['SERVER_PORT'];
return $protocol.'://'.$_SERVER['HTTP_HOST'].$port;
}
static function renderHyperComments( $skin, &$text ) {
global $mediaWiki, $wgOut, $wgArticlePath, $wgScriptPath;
global $wgHyperCommentsId;
$title = $skin->getTitle();
if( isset($_REQUEST['redirect']) ) return true;
if( isset($mediaWiki) ) {
if( $mediaWiki->getAction() != 'view' ) return true;
}
if( !$title->exists() ) return true;
if( $title->getNamespace() != 0) return true;
if( $title->isMainPage() ) return true;
if( !isset($wgHyperCommentsId) ) $wgHyperCommentsId = '';
$comments = '<div id="comments">';
// HyperComments code below
$comments .= '<div id="hypercomments_widget"></div>';
$comments .= '<script type="text/javascript">';
$comments .= '_hcwp = window._hcwp || [];';
$comments .= '_hcwp.push({widget:"Stream", widget_id:'.$wgHyperCommentsId.'});';
$comments .= '(function() {';
$comments .= 'if("HC_LOAD_INIT" in window)return;';
$comments .= 'HC_LOAD_INIT = true;';
$comments .= 'var lang = "ru";';
$comments .= 'var hcc = document.createElement("script"); hcc.type = "text/javascript"; hcc.async = true;';
$comments .= 'hcc.src = ("https:" == document.location.protocol ? "https" : "http")+"://w.hypercomments.com/widget/hc/'.$wgHyperCommentsId.'/"+lang+"/widget.js";';
$comments .= 'var s = document.getElementsByTagName("script")[0];';
$comments .= 's.parentNode.insertBefore(hcc, s.nextSibling);';
$comments .= '})();';
$comments .= '</script>';
$comments .= '</div>';
$wgOut->addHTML($comments);
return true;
}
}
Configuration
- $wgHyperCommentsId
- Your HyperComments widget ID.
See also
- Pages with script errors
- Pages with broken file links
- Extensions which host their code in-wiki
- Unmaintained extensions
- Extensions without an image
- User interface extensions
- Extensions without a compatibility policy
- Extensions with manual MediaWiki version
- GPL licensed extensions
- SkinAfterBottomScripts extensions
- All extensions
- Extensions not in ExtensionJson