Skip to content

Commit

Permalink
Add taxonomy ('tags') to Drupal6 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
clayton authored and parkr committed Jun 30, 2013
1 parent afa912d commit 0b33a12
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lib/jekyll/jekyll-import/drupal6.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ module Drupal6
n.title, \
nr.body, \
n.created, \
n.status \
FROM node AS n, \
node_revisions AS nr \
WHERE (n.type = 'blog' OR n.type = 'story') \
AND n.vid = nr.vid"
n.status, \
GROUP_CONCAT( td.name SEPARATOR ' ' ) AS 'tags' \
FROM node_revisions AS nr, \
node AS n \
JOIN term_node AS tn ON tn.nid = n.nid \
JOIN term_data AS td ON tn.tid = td.tid \
WHERE (n.type = 'blog' OR n.type = 'story') \
AND n.vid = nr.vid \
GROUP BY n.nid"

def self.process(dbname, user, pass, host = 'localhost', prefix = '')
db = Sequel.mysql(dbname, :user => user, :password => pass, :host => host, :encoding => 'utf8')
Expand Down Expand Up @@ -53,6 +57,7 @@ def self.process(dbname, user, pass, host = 'localhost', prefix = '')
node_id = post[:nid]
title = post[:title]
content = post[:body]
tags = post[:tags].downcase.strip
created = post[:created]
time = Time.at(created)
is_published = post[:status] == 1
Expand All @@ -66,6 +71,7 @@ def self.process(dbname, user, pass, host = 'localhost', prefix = '')
'layout' => 'post',
'title' => title.to_s,
'created' => created,
'categories' => tags
}.delete_if { |k,v| v.nil? || v == ''}.each_pair {
|k,v| ((v.is_a? String) ? v.force_encoding("UTF-8") : v)
}.to_yaml
Expand Down

2 comments on commit 0b33a12

@jinghao
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, this seems to have introduced a number of issues. One of them I fixed in #41 and @parkr merged. Another is that this now causes posts without tags to not get migrated (silently). Notice how you use a JOIN instead of LEFT OUTER JOIN. Lastly, tags/categories with spaces in them are not handled.

I'll see what I can do about the second and third problems.

@jinghao
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed the issues in #42

Please sign in to comment.