Luis Felipe Schenone has uploaded a new change for review.

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


Change subject: First commit
......................................................................

First commit

Submitting the basic extension files

Change-Id: Ibe34b71d66a5f6e21d0ffd288f5d9487ae4ca22b
---
A SectionDisqus.body.php
A SectionDisqus.css
A SectionDisqus.i18n.php
A SectionDisqus.js
A SectionDisqus.php
5 files changed, 125 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/SectionDisqus 
refs/changes/60/79760/1

diff --git a/SectionDisqus.body.php b/SectionDisqus.body.php
new file mode 100644
index 0000000..0c65a6a
--- /dev/null
+++ b/SectionDisqus.body.php
@@ -0,0 +1,33 @@
+<?php
+
+class SectionDisqus {
+
+       static function addResources( &$out ) {
+               $out->addModules( 'ext.SectionDisqus' );
+               return true;
+       }
+
+       static function addDisqusButton( $skin, $title, $section, $tooltip, 
&$result ) {
+               $result .= ' <span class="disqus_button">[ <a 
onclick="window.showDisqusDialog(' . $tooltip . ');">disqus</a> ]</span>';
+               return true;
+       }
+
+       static function addDisqusDialog( &$data ) {
+               global $wgSectionDisqusShortname;
+               $data .= '<div id="disqus_dialog" title="Discuss this 
section"><div id="disqus_thread"></div></div>';
+               $data .= '<script type="text/javascript">
+
+                       var disqus_url = "http://wikineering.org/";;
+                       var disqus_shortname = "' . $wgSectionDisqusShortname . 
'";
+
+                       (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);
+                       })();
+                       </script>';
+               return true;
+       }
+}
\ No newline at end of file
diff --git a/SectionDisqus.css b/SectionDisqus.css
new file mode 100644
index 0000000..5ee6210
--- /dev/null
+++ b/SectionDisqus.css
@@ -0,0 +1,9 @@
+.disqus_button {
+       cursor: pointer;
+       font-size: small;
+       font-weight: normal;
+}
+
+#disqus_dialog {
+       display: none;
+}
\ No newline at end of file
diff --git a/SectionDisqus.i18n.php b/SectionDisqus.i18n.php
new file mode 100644
index 0000000..509e78f
--- /dev/null
+++ b/SectionDisqus.i18n.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * Internationalisation for SectionDisqus extension
+ *
+ * @file
+ * @ingroup Extensions
+ */
+
+$messages = array();
+
+/** English
+ * @author Luis Felipe Schenone
+ */
+$messages['en'] = array(
+       'sectiondisqus-desc' => 'Adds a "Discuss" button next to the "Edit" 
button of every section, that when clicked, opens a Disqus lightbox for that 
section.',
+);
+
+/** Message documentation (Message documentation)
+ * @author Raimond Spekking
+ * @author Shirayuki
+ */
+$messages['qqq'] = array(
+       'sectiondisqus-desc' => 
'{{desc|name=SectionDisqus|url=http://www.mediawiki.org/wiki/Extension:HoverGallery}}',
+);
+
+/** Spanish (español)
+ * @author Luis Felipe Schenone
+ */
+$messages['es'] = array(
+       'sectiondisqus-desc' => 'Añade un botón "Discutir" junto al botón 
"Editar" de cada sección, que al clickearlo, abre una ventana de discusión para 
esa sección.',
+);
diff --git a/SectionDisqus.js b/SectionDisqus.js
new file mode 100644
index 0000000..6945eeb
--- /dev/null
+++ b/SectionDisqus.js
@@ -0,0 +1,15 @@
+window.showDisqusDialog = function( tooltip ) {
+
+       $( '#disqus_dialog' ).dialog({'width':800,'position':'top'});
+
+       //Use the URL (without parameters) plus the section tooltip as 
identifier
+       var url = identifier = location.protocol + '//' + location.hostname + 
location.pathname + '#!'  + section;
+
+       //Reset Disqus to show the thread corresponding to the clicked section
+       DISQUS.reset({
+               reload: true,
+               config: function () {
+                       this.page.identifier = identifier;
+               }
+       });
+}
\ No newline at end of file
diff --git a/SectionDisqus.php b/SectionDisqus.php
new file mode 100644
index 0000000..ff28796
--- /dev/null
+++ b/SectionDisqus.php
@@ -0,0 +1,37 @@
+<?php
+/**
+ * SectionDisqus extension
+ *
+ * @file
+ * @ingroup Extensions
+ *
+ * @author Luis Felipe Schenone <[email protected]>
+ * @license GPL v2 or later
+ * @version 0.1
+ */
+
+$wgExtensionCredits['specialpage'][] = array(
+       'path'           => __FILE__,
+       'name'           => 'SectionDisqus',
+       'description'    => 'Adds a "disqus" button next to the "edit" button 
of every section, that when clicked, opens a Disqus dialog for that section.',
+       'descriptionmsg' => 'sectiondisqus-desc',
+       'version'        => '0.1',
+       'author'         => 'Luis Felipe Schenone',
+       'url'            => 
'http://www.mediawiki.org/wiki/Extension:SectionDisqus'
+);
+
+$wgResourceModules['ext.SectionDisqus'] = array(
+       'scripts' => 'SectionDisqus.js',
+       'styles' => 'SectionDisqus.css',
+       'position' => 'top',
+       'dependencies' => array( 'jquery.ui.dialog' ),
+       'localBasePath' => __DIR__,
+       'remoteExtPath' => 'SectionDisqus',
+);
+
+$wgExtensionMessagesFiles['SectionDisqus'] = __DIR__ . 
'/SectionDisqus.i18n.php';
+$wgAutoloadClasses['SectionDisqus'] = __DIR__ . '/SectionDisqus.body.php';
+
+$wgHooks['BeforePageDisplay'][] = 'SectionDisqus::addResources';
+$wgHooks['DoEditSectionLink'][]  = 'SectionDisqus::addDisqusButton';
+$wgHooks['SkinAfterContent'][] = 'SectionDisqus::addDisqusDialog';
\ No newline at end of file

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibe34b71d66a5f6e21d0ffd288f5d9487ae4ca22b
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/SectionDisqus
Gerrit-Branch: master
Gerrit-Owner: Luis Felipe Schenone <[email protected]>

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

Reply via email to