Sha256: 0be5ded188e7936e29ba1ea3393995fa26a91095c774bb7b955b7dc0a2c3a1a0

Contents?: true

Size: 1.82 KB

Versions: 26

Compression:

Stored size: 1.82 KB

Contents

# Twitter Summary Card plugin
#
#
# Copyright (c) 2013 Tatsuya Sato <satoryu.1981@gmail.com>

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|<meta name="#{k}" content="#{CGI.escapeHTML(v)}">|
  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
  <h2>Twitter Summary Card</h2>
  <p>
  Please refer to the following documentation at first.
  <ul>
    <li><a href="https://dev.twitter.com/docs/cards/types/summary-card" target="_blank">Summary Card | Twitter Developers</a></li>
  </ul>
  </p>

	<h3>Your tDiary's Twitte account</h3>
	<p><input name="twitter_summary_card.site" value="#{h(@conf['twitter_summary_card.site'])}"></p>

	<h3>Creator's Twitter account </h3>
	<p><input name="twitter_summary_card.creator" value="#{h(@conf['twitter_summary_card.creator'])}"></p>
  HTML
end

Version data entries

26 entries across 21 versions & 2 rubygems

Version Path
tdiary-contrib-5.0.10 plugin/twitter_summary_card.rb
tdiary-contrib-5.0.9 plugin/twitter_summary_card.rb
tdiary-contrib-5.0.8 plugin/twitter_summary_card.rb
tdiary-contrib-5.0.7 plugin/twitter_summary_card.rb
tdiary-contrib-5.0.6 plugin/twitter_summary_card.rb
tdiary-contrib-5.0.5 plugin/twitter_summary_card.rb
tdiary-5.0.5 vendor/bundle/bundler/gems/tdiary-contrib-fa9c20aa0d97/plugin/twitter_summary_card.rb
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/bundler/gems/tdiary-contrib-8299b30cbf3f/plugin/twitter_summary_card.rb
tdiary-5.0.5 vendor/bundle/bundler/gems/tdiary-contrib-8299b30cbf3f/plugin/twitter_summary_card.rb
tdiary-5.0.5 vendor/bundle/bundler/gems/tdiary-contrib-a3c5f37278c4/plugin/twitter_summary_card.rb
tdiary-5.0.5 vendor/bundle/bundler/gems/tdiary-contrib-f08988dfa0f6/plugin/twitter_summary_card.rb
tdiary-contrib-5.0.4 plugin/twitter_summary_card.rb
tdiary-5.0.4 vendor/bundle/bundler/gems/tdiary-contrib-8299b30cbf3f/plugin/twitter_summary_card.rb
tdiary-contrib-5.0.3 plugin/twitter_summary_card.rb
tdiary-contrib-5.0.2 plugin/twitter_summary_card.rb
tdiary-contrib-5.0.1 plugin/twitter_summary_card.rb
tdiary-contrib-5.0.0 plugin/twitter_summary_card.rb
tdiary-contrib-4.2.1 plugin/twitter_summary_card.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/bundler/gems/tdiary-contrib-2ab36447ae2a/plugin/twitter_summary_card.rb
tdiary-4.2.1 vendor/bundle/ruby/2.3.0/bundler/gems/tdiary-contrib-d189eb6688f1/plugin/twitter_summary_card.rb