# Twitter Summary Card plugin
#
#
# Copyright (c) 2013 Tatsuya Sato
def twitter_summary_card_description
section_index = @cgi.params['p'][0]
if @mode == 'day' and section_index
diary = @diaries[@date.strftime('%Y%m%d')]
sections = diary.instance_variable_get(:@sections)
section = sections[section_index.to_i - 1].body_to_html
@conf.shorten(apply_plugin(section, true), 200)
else
@conf.description
end
end
add_header_proc do
headers = {
'twitter:card' => 'summary',
'twitter:site' => @conf['twitter_summary_card.site'] || @conf['twitter_summary_card.creator'],
'twitter:creator' => @conf['twitter_summary_card.creator'],
'twitter:title' => title_tag.match(/>([^<]+)/).to_a[1],
'twitter:description' => twitter_summary_card_description,
'twitter:image:src' => @conf.banner
}
headers = headers.select { |_, v| v && not(v.empty?) }
headers = headers.map do |k, v|
%Q||
end
headers.join("\n")
end
add_conf_proc('Twitter Summary Card', 'Twitter Summary Card') do
if @mode == 'saveconf'
@conf['twitter_summary_card.site'] = @cgi.params['twitter_summary_card.site'][0]
@conf['twitter_summary_card.creator'] = @cgi.params['twitter_summary_card.creator'][0]
end
<<-HTML
Twitter Summary Card
Please refer to the following documentation at first.
Your tDiary's Twitte account
Creator's Twitter account
HTML
end