lib/jekyll/socialmeta.rb
# High priority so it doesn't have to process e.g. JCP pages
High priority so it doesn't have to process e.g. JCP pages
High priority so it doesn ' t have to process e . g . JCP pages
def generate(site)
        pconfig = site.config['socialmeta'] || {}
        return unless pconfig["enabled"].nil? || sconfig["enabled"]
        SocialMeta::debug_state pconfig["debug"]
        SocialMeta::start_main
        SocialMeta::screenshots site
        if pconfig['collection'].is_a?(String)
          pconfig['collection'] = pconfig['collection'].split(/,\s*/)
        end
        collections = [ pconfig['collection'], pconfig["collections"] ].
          flatten.compact.uniq
        collections = [ 'posts' ] if collections.empty?
        included = pconfig['include'] || []
        excluded = pconfig['exclude'] || []
        stats = {}
        collections.each do |collection|
          if collection == "pages"
            items = site.pages
          else
            next if !site.collections.has_key?(collection)
            items = site.collections[collection].docs
          end
          stats[collection] = {
            :total => 0,
            :skipped => 0,
            :render => 0
          }
          items.each do |item|
            next if item.respond_to?('html?') && !item.html?
            next if (!excluded.empty? && excluded.any? { |k, values|
              match?(item, k, values)
            })
            next if !(included.empty? || included.any? { |k, values|
              match?(item, k, values)
            })
            stats[collection][:total] += 1
            screenshot = Screenshot.new(item)
            site_url = (site.config['canonical'] || site.config['url']) + site.config['baseurl'] + item.url
            meta =  %Q{  <meta property="jog:url" content="#{site_url}"/>\n} +
                    %Q{  <meta property="jog:type" content="website"/>\n} +
                    %Q{  <meta property="jog:title" content="#{item.data['title']}"/>\n} +
                    %Q{  <meta property="jog:description" content="#{item.data['description'] || site.config['description']}"/>\n} +
                    %Q{  <meta property="jog:image" content="#{screenshot.url}"/>\n}
            item.data[DATA_PROP] = {
              "hello" => "Hello,",
              "world" => "World!",
              "meta" => meta
            }
            if screenshot.is_valid?
              SocialMeta::debug "Skipping #{item.url} (done)"
              stats[collection][:skipped] += 1
            else
              stats[collection][:render] += 1
            end
            SocialMeta::screenshots.enqueue(screenshot)
          end
          SocialMeta::info "[#{collection}] #{stats[collection][:total]} seen, #{stats[collection][:skipped]} skipped, #{stats[collection][:render]} rendering"
        end
        SocialMeta::end_main
      end
def generate ( site ) pconfig = site . config [ 'socialmeta' ] || { } return unless pconfig [ "enabled" ] . nil? || sconfig [ "enabled" ] SocialMeta :: debug_state pconfig [ "debug" ] SocialMeta :: start_main SocialMeta :: screenshots site if pconfig [ 'collection' ] . is_a? ( String ) pconfig [ 'collection' ] = pconfig [ 'collection' ] . split ( / , \s * / ) end collections = [ pconfig [ 'collection' ] , pconfig [ "collections" ] ] . flatten . compact . uniq collections = [ 'posts' ] if collections . empty? included = pconfig [ 'include' ] || [ ] excluded = pconfig [ 'exclude' ] || [ ] stats = { } collections . each do | collection | if collection == "pages" items = site . pages else next if ! site . collections . has_key? ( collection ) items = site . collections [ collection ] . docs end stats [ collection ] = { :total => 0 , :skipped => 0 , :render => 0 } items . each do | item | next if item . respond_to? ( 'html?' ) && ! item . html? next if ( ! excluded . empty? && excluded . any? { | k , values | match? ( item , k , values ) } ) next if ! ( included . empty? || included . any? { | k , values | match? ( item , k , values ) } ) stats [ collection ] [ :total ] += 1 screenshot = Screenshot . new ( item ) site_url = ( site . config [ 'canonical' ] || site . config [ 'url' ] ) + site . config [ 'baseurl' ] + item . url meta = %Q{  <meta property="jog:url" content="#{site_url}"/>\n} + %Q{  <meta property="jog:type" content="website"/>\n} + %Q{  <meta property="jog:title" content="#{item.data['title']}"/>\n} + %Q{  <meta property="jog:description" content="#{item.data['description'] || site.config['description']}"/>\n} + %Q{  <meta property="jog:image" content="#{screenshot.url}"/>\n} item . data [ DATA_PROP ] = { "hello" => "Hello," , "world" => "World!" , "meta" => meta } if screenshot . is_valid? SocialMeta :: debug "Skipping #{item.url} (done)" stats [ collection ] [ :skipped ] += 1 else stats [ collection ] [ :render ] += 1 end SocialMeta :: screenshots . enqueue ( screenshot ) end SocialMeta :: info "[#{collection}] #{stats[collection][:total]} seen, #{stats[collection][:skipped]} skipped, #{stats[collection][:render]} rendering" end SocialMeta :: end_main end
High priority so it doesn't have to process e.g.
High priority so it doesn ' t have to process e . g .
# Run through each specified collection # Skip if source file is older than image # Still enqueue because Jekyll may wipe out _site and created our dest_dirs if starting from scratch
site
<not_specific>