Sha256: b0958554914dc01e2a8e552a6261b7e16bd4999d96139eb3c3362fbdf93ae709

Contents?: true

Size: 1.5 KB

Versions: 10

Compression:

Stored size: 1.5 KB

Contents

# frozen_string_literal: true

require "jekyll-import/importers/drupal_common"

module JekyllImport
  module Importers
    class Drupal6 < Importer
      include DrupalCommon
      extend DrupalCommon::ClassMethods

      def self.build_query(prefix, types, _engine)
        types = types.join("' OR n.type = '")
        types = "n.type = '#{types}'"

        query = <<SQL
                SELECT n.nid,
                       n.title,
                       nr.body,
                       nr.teaser,
                       n.created,
                       n.status,
                       n.type,
                       GROUP_CONCAT( td.name SEPARATOR '|' ) AS 'tags'
                FROM #{prefix}node_revisions AS nr,
                     #{prefix}node AS n
                     LEFT OUTER JOIN #{prefix}term_node AS tn ON tn.nid = n.nid
                     LEFT OUTER JOIN #{prefix}term_data AS td ON tn.tid = td.tid
                WHERE (#{types})
                  AND n.vid = nr.vid
                GROUP BY n.nid
SQL

        query
      end

      def self.aliases_query(prefix)
        "SELECT src AS source, dst AS alias FROM #{prefix}url_alias WHERE src = ?"
      end

      def self.post_data(sql_post_data)
        content = sql_post_data[:body].to_s
        summary = sql_post_data[:teaser].to_s
        tags = (sql_post_data[:tags] || "").downcase.strip

        data = {
          "excerpt"    => summary,
          "categories" => tags.split("|"),
        }

        [data, content]
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
jekyll-import-0.20.0 lib/jekyll-import/importers/drupal6.rb
jekyll-import-0.19.2 lib/jekyll-import/importers/drupal6.rb
jekyll-import-0.19.1 lib/jekyll-import/importers/drupal6.rb
jekyll-import-0.19.0 lib/jekyll-import/importers/drupal6.rb
jekyll-import-0.18.1 lib/jekyll-import/importers/drupal6.rb
jekyll-import-0.18.0 lib/jekyll-import/importers/drupal6.rb
jekyll-import-0.17.1 lib/jekyll-import/importers/drupal6.rb
jekyll-import-0.17.0 lib/jekyll-import/importers/drupal6.rb
jekyll-import-0.16.0 lib/jekyll-import/importers/drupal6.rb
jekyll-import-0.15.0 lib/jekyll-import/importers/drupal6.rb