class Juli::Visitor::Html::Helper::FbComments

Helper-class for 'fb_like' helper

Constants

DEFAULT_TEMPLATE

default HTML template for facebook 'like' button. You can customize it in .juli/config facebook.like.template entry.

%{href} in the template will be replaced to the actual URL of current wiki page.

Public Class Methods

conf_template() click to toggle source

called on 'juli init' to generate config sample template.

# File lib/juli/visitor/html/helper/fb_comments.rb, line 14
    def self.conf_template
      <<EOM
# Facebook related setup is here.
#
#url_prefix: 'http://YOUR_HOST/juli'
#facebook:
#  like:
#    template:  '#{Juli::Visitor::Html::Helper::FbLike::DEFAULT_TEMPLATE}'
#  comments:
#    template:  '#{DEFAULT_TEMPLATE}'
EOM
    end
new() click to toggle source
# File lib/juli/visitor/html/helper/fb_comments.rb, line 27
def initialize
  @fb_conf  = conf['facebook']
end

Public Instance Methods

on_root(in_file, root, visitor = nil) click to toggle source

called on each parsed document

# File lib/juli/visitor/html/helper/fb_comments.rb, line 51
def on_root(in_file, root, visitor = nil)
  @in_file  = in_file
end
run(*args) click to toggle source
# File lib/juli/visitor/html/helper/fb_comments.rb, line 55
def run(*args)
  raise Juli::NoConfig if !conf['url_prefix']
  raise Juli::NoConfig if !@in_file

  template.gsub('%{href}',
      conf['url_prefix'] + '/' + to_wikiname(@in_file) + conf['ext'])
end
set_conf_default(conf) click to toggle source

set default value in conf if no .juli/conf defined.

Please overwrite this method when this implementation is not your case.

# File lib/juli/visitor/html/helper/fb_comments.rb, line 35
def set_conf_default(conf)
  conf['url_prefix']  = 'http://YOUR_HOST/juli' if !conf['url_prefix']
  conf['facebook']    = {}                      if !conf['facebook']
  if !conf['facebook']['comments']
    conf['facebook']['comments'] = {
      'template'  => self.class::DEFAULT_TEMPLATE
    }
  end
  if !conf['facebook']['like']
    conf['facebook']['like'] = {
      'template'  => Juli::Visitor::Html::Helper::FbLike::DEFAULT_TEMPLATE
    }
  end
end

Private Instance Methods

template() click to toggle source
# File lib/juli/visitor/html/helper/fb_comments.rb, line 64
def template
  @fb_conf['comments']['template']
end