Class: JekyllImport::Importers::Drupal7

Inherits:
JekyllImport::Importer show all
Extended by:
JekyllImport::Importers::DrupalCommon::ClassMethods
Includes:
DrupalCommon
Defined in:
lib/jekyll-import/importers/drupal7.rb

Constant Summary

Constants included from JekyllImport::Importers::DrupalCommon::ClassMethods

JekyllImport::Importers::DrupalCommon::ClassMethods::DEFAULTS

Class Method Summary collapse

Methods included from JekyllImport::Importers::DrupalCommon::ClassMethods

process, require_deps, specify_options

Methods included from DrupalCommon

#aliases_query, #build_query, #post_data, #validate

Methods inherited from JekyllImport::Importer

inherited, run, stringify_keys, subclasses

Class Method Details

.aliases_query(prefix) ⇒ Object



30
31
32
# File 'lib/jekyll-import/importers/drupal7.rb', line 30

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

.build_query(prefix, types) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/jekyll-import/importers/drupal7.rb', line 9

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

  query = <<EOS
          SELECT n.nid,
                 n.title,
                 fdb.body_value,
                 fdb.body_summary,
                 n.created,
                 n.status,
                 n.type,
                 (SELECT GROUP_CONCAT(td.name SEPARATOR '|') FROM taxonomy_term_data td, taxonomy_index ti WHERE ti.tid = td.tid AND ti.nid = n.nid) AS 'tags'
          FROM #{prefix}node AS n
          LEFT JOIN #{prefix}field_data_body AS fdb ON fdb.entity_id = n.nid AND fdb.entity_type = 'node'
          WHERE (#{types})
EOS

  return query
end

.post_data(sql_post_data) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/jekyll-import/importers/drupal7.rb', line 34

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

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

  return data, content
end