tDiaryにDISQUSのコメント欄をつけた

投稿日: 2016年05月08日 更新日: 2017年07月22日

このブログ(tDiary)にDISQUSのコメント欄をつけました。

そのためのプラグイン、disqus.rb作りました。

テストコメントでもいいのでコメント頂けると助かります。

# 既存ツッコミフォームを非表示にする
@conf.hide_comment_form = true

def permalink( date, index = nil, escape = true )
        ymd = date.strftime( "%Y%m%d" )
        uri = @conf.index.dup
        uri.sub!( %r|\A(?!https?://)|i, @conf.base_url )
        uri.gsub!( %r|/\.(?=/)|, "" ) # /././ -> /
        link = uri + anchor( "#{ymd}p%02d" % index )
        link.sub!( "#", "%23" ) if escape
        link
end

def disqus_form(date)
        return '' if feed?

        r = <<-HTML
<div id="disqus_thread"></div>
<script>
var disqus_config = function () {
this.page.url = '#{permalink(date, index, false)}'; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = '#{permalink(date, index, false)}'; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
};
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');

s.src = '//pc-memo.disqus.com/embed.js';

s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
        HTML

end

add_body_leave_proc do |date|
        if @mode=='day' then disqus_form(date) end
end

add_header_proc do
        # 既存ツッコミフォームを非表示にする
        r = <<-HTML
<style>
.comment{
  display: none;
}
</style>
        HTML
end

名前:宮内 はじめ

Code for Nagoya名誉代表

E2D3名古屋支部長

プログラマーです。GISやデータビズが好きです。このサイトは宮内の個人的なメモです。

プロフィール

お問い合わせ