# -*- coding: utf-8; indent-tabs-mode: t; ruby-indent-level: 3; tab-width: 3 -*- # # Copyright (C) 2011-2012 Kouhei Sutou # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . facebook_use_iframe = false add_header_proc do tags = "" if @conf['social_widgets.facebook_user_id'] tags << <<-HTML HTML end if @conf['social_widgets.facebook_application_id'] tags << <<-HTML HTML end tags << <<-HTML HTML tags end def section_footer_social_widgets_footer_scripts <<-HTML HTML end fb_root = '
' unless @conf.header.include?(fb_root) options = {"xfbml" => 1} if @conf['social_widgets.facebook_application_id'] options = {"appId" => @conf['social_widgets.facebook_application_id']} end escaped_options = options.collect do |key, value| "#{key}=#{h(value)}" end options_in_url = escaped_options.join("&") fb_header = <<-END_OF_FB_JS_SDK #{fb_root} END_OF_FB_JS_SDK @conf.header = "#{fb_header}\n#{@conf.header}" end add_section_enter_proc do |date, index| @subtitles = {date => {}} '' end subtitle_proc = Proc.new do |date, index, subtitle| @subtitles[date][index] = subtitle.gsub(/(?:\[.*?\])/, '').strip subtitle end @subtitle_procs.unshift(subtitle_proc) add_section_leave_proc do |date, index| date_ymd = date.strftime('%Y%m%d') unescaped_url = "#{@conf.base_url}#{anchor(date_ymd)}" url = h(unescaped_url) subtitle = @subtitles[date][index] date_label = date.strftime('%Y-%m-%d') entry_title = h("#{subtitle} - #{@html_title}(#{date_label})") widgets = "
\n" widgets << "
\n" widgets << <<-GOOGLE_PLUSONE GOOGLE_PLUSONE widgets << <<-HATENA このエントリーをはてなブックマークに追加 HATENA widgets << <<-TWITTER_SHARE TWITTER_SHARE widgets << "
\n" widgets << <<-TWITTER_FOLLOW TWITTER_FOLLOW facebook_like_parameters = { :href => unescaped_url, :send => "true", :width => @conf["social_widgets.facebook_like_width"], :show_faces => "true", } if facebook_use_iframe html_parameters = facebook_like_parameters.collect do |key, value| "#{h(key)}=#{h(value)}" end.join("&") widgets << <<-FACEBOOK_LIKE FACEBOOK_LIKE else attributes = facebook_like_parameters.collect do |key, value| "data-#{key.to_s.gsub(/_/, '-')}=\"#{h(value)}\"" end.join(" \n") widgets << <<-FACEBOOK_LIKE FACEBOOK_LIKE end facebook_comments_parameters = { :href => unescaped_url, :width => @conf["social_widgets.facebook_comments_width"], } if facebook_use_iframe html_parameters = facebook_comments_parameters.collect do |key, value| "#{h(key)}=#{h(value)}" end.join("&") widgets << <<-FACEBOOK_COMMENTS FACEBOOK_COMMENTS else attributes = facebook_like_parameters.collect do |key, value| "data-#{key.to_s.gsub(/_/, '-')}=\"#{h(value)}\"" end.join(" \n") widgets << <<-FACEBOOK_COMMENTS FACEBOOK_COMMENTS end widgets << "
\n" widgets end