class Kentico::Kontent::SiteProcessing::KenticoKontentImporter

Public Class Methods

new(config) click to toggle source
# File lib/kontent-jekyll/site_processing/kentico_kontent_importer.rb, line 18
def initialize(config)
  @config = config
  @items = []
  @taxonomy_groups = []
end

Public Instance Methods

items_by_type(language) click to toggle source
# File lib/kontent-jekyll/site_processing/kentico_kontent_importer.rb, line 24
def items_by_type(language)
  retrieve_items(language)
    .group_by { |item| item.system.type }
end
taxonomies() click to toggle source
# File lib/kontent-jekyll/site_processing/kentico_kontent_importer.rb, line 29
def taxonomies
  @taxonomy_groups = retrieve_taxonomies
end

Private Instance Methods

custom_headers() click to toggle source

Add extra headers like tracking

# File lib/kontent-jekyll/site_processing/kentico_kontent_importer.rb, line 80
def custom_headers
  {
    'X-KC-SOURCE' => "#{GEM_NAME};#{VERSION}",
  }
end
delivery_client() click to toggle source
# File lib/kontent-jekyll/site_processing/kentico_kontent_importer.rb, line 43
def delivery_client
  project_id = value_for(@config, Constants::KenticoConfigKeys::PROJECT_ID)
  secure_key = value_for(@config, Constants::KenticoConfigKeys::SECURE_KEY)

  Kentico::Kontent::Delivery::DeliveryClient.new(
    project_id: project_id,
    secure_key: secure_key,
    content_link_url_resolver: content_link_url_resolver,
    inline_content_item_resolver: inline_content_item_resolver
  )
end
inline_content_item_resolver() click to toggle source
# File lib/kontent-jekyll/site_processing/kentico_kontent_importer.rb, line 35
def inline_content_item_resolver
  @inline_content_item_resolver ||= Resolvers::InlineContentItemResolver.for(@config)
end
retrieve_items(language) click to toggle source
# File lib/kontent-jekyll/site_processing/kentico_kontent_importer.rb, line 63
def retrieve_items(language)
  client = delivery_client.items
  client = client.language(language) if language
  client
    .custom_headers(custom_headers)
    .request_latest_content
    .depth(@config.max_linked_items_depth || 1)
    .execute { |response| return response.items }
end
retrieve_taxonomies() click to toggle source
# File lib/kontent-jekyll/site_processing/kentico_kontent_importer.rb, line 55
def retrieve_taxonomies
  delivery_client
    .taxonomies
    .custom_headers(custom_headers)
    .request_latest_content
    .execute { |response| return response.taxonomies }
end
value_for(config, key) click to toggle source
# File lib/kontent-jekyll/site_processing/kentico_kontent_importer.rb, line 73
def value_for(config, key)
  potential_value = config[key]
  return ENV[potential_value.gsub('ENV_', '')] if !potential_value.nil? && potential_value.start_with?('ENV_')
  potential_value
end