-
Notifications
You must be signed in to change notification settings - Fork 334
Expand file tree
/
Copy pathdrupal6.rb
More file actions
58 lines (48 loc) · 1.7 KB
/
drupal6.rb
File metadata and controls
58 lines (48 loc) · 1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# 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,
ua.dst AS alias,
n.type,
GROUP_CONCAT( td.name SEPARATOR '|' ) AS 'tags'
FROM #{prefix}node_revisions AS nr, url_alias AS ua,
#{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
AND ua.src = CONCAT( 'node/', n.nid)
GROUP BY n.nid, ua.dst
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("|").uniq,
}
data["permalink"] = "/" + sql_post_data[:alias] if sql_post_data[:alias]
[data, content]
end
end
end
end