Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial checkin

darcs-hash:20090107203146-7ad00-fc10aea2ec015c5cde3fbeeca915645b144a0889.gz
  • Loading branch information...
commit 98b45113181a63c4e3a33d7f514fc0537e93391c 0 parents
@splitbrain authored
Showing with 97 additions and 0 deletions.
  1. +5 −0 style.css
  2. +92 −0 syntax.php
5 style.css
@@ -0,0 +1,5 @@
+div.dokuwiki div#disqus__thread {
+ width: 80%;
+ margin: 0;
+ padding: 0;
+}
92 syntax.php
@@ -0,0 +1,92 @@
+<?php
+/**
+ *
+ * @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+
+if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
+if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
+require_once(DOKU_PLUGIN.'syntax.php');
+
+
+/**
+ * All DokuWiki plugins to extend the parser/rendering mechanism
+ * need to inherit from this class
+ */
+class syntax_plugin_disqus extends DokuWiki_Syntax_Plugin {
+
+ /**
+ * return some info
+ */
+ function getInfo(){
+ return array(
+ 'author' => 'Andreas Gohr',
+ 'email' => 'andi@splitbrain.org',
+ 'date' => '2009-01-07',
+ 'name' => 'Disqus Plugin',
+ 'desc' => 'Embed Disqus discussion threads',
+ 'url' => 'http://wiki.splitbrain.org/plugin:disqus',
+ );
+ }
+
+ /**
+ * What kind of syntax are we?
+ */
+ function getType(){
+ return 'substition';
+ }
+
+ function getPType(){
+ return 'block';
+ }
+
+ /**
+ * Where to sort in?
+ */
+ function getSort(){
+ return 160;
+ }
+
+ /**
+ * Connect pattern to lexer
+ */
+ function connectTo($mode) {
+ $this->Lexer->addSpecialPattern('~~DISQUS~~',$mode,'plugin_disqus');
+ }
+
+ /**
+ * Handle the match
+ */
+ function handle($match, $state, $pos, &$handler){
+ return array();
+ }
+
+ /**
+ * Create output
+ */
+ function render($mode, &$R, $data) {
+ global $ID;
+ global $INFO;
+
+ if($mode != 'xhtml') return false;
+
+ $R->doc .= '<script charset="utf-8" type="text/javascript">
+ <!--//--><![CDATA[//><!--'."\n";
+ if($this->getConf('devel'))
+ $R->doc .= 'var disqus_developer = '.$this->getConf('devel').";\n";
+ $R->doc .= "var disqus_url = '".wl($ID,'',true)."';\n";
+ $R->doc .= "var disqus_title = '".addslashes($INFO['meta']['title'])."';\n";
+ $R->doc .= "var disqus_message = '".addslashes($INFO['meta']['abstract'])."';\n";
+ $R->doc .= 'var disqus_container_id = \'disqus__thread\';
+ //--><!]]>
+ </script>';
+ $R->doc .= '<div id="disqus__thread"></div>';
+ $R->doc .= '<script type="text/javascript" src="http://disqus.com/forums/'.$this->getConf('shortname').'/embed.js"></script>';
+ $R->doc .= '<noscript><a href="http://'.$this->getConf('shortname').'.disqus.com/?url=ref">View the discussion thread.</a></noscript>';
+
+ return true;
+ }
+}
+
+//Setup VIM: ex: et ts=4 enc=utf-8 :
Please sign in to comment.
Something went wrong with that request. Please try again.