Luis Felipe Schenone has uploaded a new change for review. https://gerrit.wikimedia.org/r/84751
Change subject: Updated and renamed version of AvbDisqus ...................................................................... Updated and renamed version of AvbDisqus AvbDisqus is an old extension with code currently at https://www.mediawiki.org/wiki/Extension:AvbDisqus I rewrote the extension and renamed it to DisqusTag. Change-Id: I0a2dae39b4d2c2611d4d8533ff6e3dda1361602c --- A DisqusTag.body.php A DisqusTag.css A DisqusTag.i18n.php A DisqusTag.js A DisqusTag.php 5 files changed, 127 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DisqusTag refs/changes/51/84751/1 diff --git a/DisqusTag.body.php b/DisqusTag.body.php new file mode 100644 index 0000000..57dfbeb --- /dev/null +++ b/DisqusTag.body.php @@ -0,0 +1,34 @@ +<?php + +class DisqusTag { + + public static function addModule( &$out ) { + $out->addModules( 'ext.DisqusTag' ); + return true; + } + + public static function setParserHook( Parser $parser ) { + $parser->setHook( 'disqus', 'DisqusTag::renderDisqusLink' ); + return true; + } + + public static function addDisqusElements( &$data ) { + global $wgDisqusShortname; + $data .= '<div id="disqus_dialog" title="Discuss"><div id="disqus_thread"></div></div>'; + $data .= '<script type="text/javascript">var disqus_shortname = "' . $wgDisqusShortname . '";</script>'; + return true; + } + + public static function renderDisqusLink( $input, array $args, Parser $parser, PPFrame $frame ) { + $id = ''; + if ( array_key_exists( 'id', $args ) ) { + $id = $args['id']; + } + $title = 'Discuss'; + if ( $input ) { + $title = $input; + } + $link = '<a id="disqus-' . $id . '" href="" onclick="window.showDisqusDialog(\'' . $id . '\'); return false;">' . $title . '</a>'; + return $link; + } +} \ No newline at end of file diff --git a/DisqusTag.css b/DisqusTag.css new file mode 100644 index 0000000..d7f4a1e --- /dev/null +++ b/DisqusTag.css @@ -0,0 +1,3 @@ +#disqus_dialog { + display: none; +} \ No newline at end of file diff --git a/DisqusTag.i18n.php b/DisqusTag.i18n.php new file mode 100644 index 0000000..0817a58 --- /dev/null +++ b/DisqusTag.i18n.php @@ -0,0 +1,30 @@ +<?php +/** + * Internationalisation for DisqusTag extension + * + * @file + * @ingroup Extensions + */ + +$messages = array(); + +/** Message documentation (Message documentation) + * @author Luis Felipe Schenone + */ +$messages['qqq'] = array( + 'disqustag-desc' => '{{desc|name=DisqusTag|url=http://www.mediawiki.org/wiki/Extension:DisqusTag}}', +); + +/** English + * @author Luis Felipe Schenone + */ +$messages['en'] = array( + 'disqustag-desc' => 'Introduces a <code><disqus></code> tag that inserts an inline button to pop up a <a href="http://disqus.com/">Disqus</a> discussion.', +); + +/** Spanish (español) + * @author Luis Felipe Schenone + */ +$messages['es'] = array( + 'disqustag-desc' => 'Introduce una etiqueta <code><disqus></code> que inserta un botón que abre una discusión <a href="http://disqus.com/">Disqus</a>.', +); \ No newline at end of file diff --git a/DisqusTag.js b/DisqusTag.js new file mode 100644 index 0000000..ff55ff4 --- /dev/null +++ b/DisqusTag.js @@ -0,0 +1,33 @@ +window.showDisqusDialog = function( id ) { + + $( '#disqus_dialog' ).dialog({'width':800,'position':'top'}); + + var identifier = url = location.protocol + '//' + location.hostname + location.pathname + '#!' + id + + //Reset Disqus to show the thread corresponding to the clicked button + DISQUS.reset({ + reload: true, + config: function () { + this.page.identifier = identifier; + this.page.url = url; + } + }); +} + +(function() { + var dsq = document.createElement("script"); + dsq.type = "text/javascript"; + dsq.async = true; + dsq.src = "//" + disqus_shortname + ".disqus.com/embed.js"; + document.getElementsByTagName("body")[0].appendChild(dsq); +})(); + +$(document).ready(function () { + var disqusPublicKey = "dUXyNmUOx05XoQceDqOmabxgh6Kfez3uNSZlIDw2USxYWh2BmJjtzt3HwoFbudu0"; + var disqusShortname = "wikineering"; + + var urlArray = []; + $('.count-comments').each(function () { + var url = $(this).attr('data-disqus-url'); + urlArray.push('link:' + url); +}); \ No newline at end of file diff --git a/DisqusTag.php b/DisqusTag.php new file mode 100644 index 0000000..fd7af1b --- /dev/null +++ b/DisqusTag.php @@ -0,0 +1,27 @@ +<?php + +$wgExtensionCredits['parserhook'][] = array( + 'path' => __FILE__, + 'name' => 'DisqusTag', + 'descriptionmsg' => 'disqustag-desc', + 'version' => '0.2', + 'author' => array( 'Alexey Beloblotskiy', 'Luis Felipe Schenone' ), + 'url' => 'https://www.mediawiki.org/wiki/Extension:DisqusTag', +); + +$wgResourceModules['ext.DisqusTag'] = array( + 'scripts' => 'DisqusTag.js', + 'styles' => 'DisqusTag.css', + 'position' => 'bottom', + 'dependencies' => array( 'jquery.ui.dialog' ), + 'localBasePath' => __DIR__, + 'remoteExtPath' => 'DisqusTag', +); + +$wgExtensionMessagesFiles['DisqusTag'] = __DIR__ . '/DisqusTag.i18n.php'; +$wgAutoloadClasses['DisqusTag'] = __DIR__ . '/DisqusTag.body.php'; + +$wgHooks['BeforePageDisplay'][] = 'DisqusTag::addModule'; +$wgHooks['ParserFirstCallInit'][] = 'DisqusTag::setParserHook'; +$wgHooks['SkinAfterContent'][] = 'DisqusTag::addDisqusElements'; +$wgHooks['PageContentSave'][] = 'DisqusTag::addDisqusTags'; \ No newline at end of file -- To view, visit https://gerrit.wikimedia.org/r/84751 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0a2dae39b4d2c2611d4d8533ff6e3dda1361602c Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/DisqusTag Gerrit-Branch: master Gerrit-Owner: Luis Felipe Schenone <scheno...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits