Skip to content

Commit

Permalink
Add disqus comments to doc compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
choptastic committed Sep 1, 2012
1 parent 5a00403 commit 6dda2bf
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 6 deletions.
13 changes: 7 additions & 6 deletions COMPILE_DOCS
@@ -1,19 +1,20 @@
COMPILING THE NITROGEN DOCUMENTATION COMPILING THE NITROGEN DOCUMENTATION




Compiling the documentation uses Org-mode for Emacs. compiling the documentation uses Org-mode for Emacs and a simple Perl script for adding Disqus comments.


Editing the HTML is not recommended, as the org-mode compiler just overwrites all HTML anyway. Editing the HTML is not recommended, as the org-mode compiler just overwrites all HTML anyway. Instead, edit the org-mode files found in doc/org-mode.


Instead, edit the org-mode files found in doc/org-mode. Make sure you have emacs installed, with htmlize (version 1.34 or later), erlang-mode, and org-mode installed.

Make sure you have emacs installed, with the htmlize[1] (version 1.34 or later), erlang-mode, and org-mode installed.


On Ubuntu, these packages can all be installed with: On Ubuntu, these packages can all be installed with:


sudo apt-get install emacs erlang-mode org-mode emacs-goodies-el sudo apt-get install emacs erlang-mode org-mode emacs-goodies-el




Once this is done, you can compile the docs from the command line with: Then you can compile the docs from the command line with


$ make docs $ make docs


Also worth noting is that the Disqus comment injection script expects perl to be in the PATH
1 change: 1 addition & 0 deletions Makefile
Expand Up @@ -8,5 +8,6 @@ clean:


docs: docs:
./make_docs.el ./make_docs.el
@(cd doc;perl add_disqus.pl)


doc: docs doc: docs
40 changes: 40 additions & 0 deletions doc/add_disqus.pl
@@ -0,0 +1,40 @@
#!/usr/bin/perl

use strict;


my $raw_inject = &read_file("disqus.html");
my @files = `find html/* | grep \\.html\$`;

for my $file (@files) {
chomp($file);
print "Injecting Disqus code into $file...";
my $to_inject = $raw_inject;
$to_inject =~ s/<page-identifier>/$file/g;
my $contents = &read_file($file);
if($contents =~ /<div id="disqus_thread">/) {
print "already done\n";
}else{
$contents =~ s!</div>[\s\n]*</body>!</div>$to_inject</body>!g;
&write_file($file,$contents);
print "done\n";
}
}

sub write_file
{
my ($filename,$contents) = @_;
open my $fh, ">$filename" or die "error opening $filename: $!";
print $fh $contents;
close $fh;
}


sub read_file
{
my ($filename) = @_;
open my $fh, "<$filename" or die "error opening $filename: $!";
my $contents = do { local $/; <$fh> };
close $fh;
return $contents;
}
15 changes: 15 additions & 0 deletions doc/disqus.html
@@ -0,0 +1,15 @@
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'nitrogenproject'; // required: replace example with your forum shortname
var disqus_identifier = '<page-identifier>'; //This will be replaced with the path part of the url

/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
<a href="http://disqus.com" class="dsq-brlink">comments powered by <span class="logo-disqus">Disqus</span></a>

0 comments on commit 6dda2bf

Please sign in to comment.