public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
update mephisto wordpress converter to WP 2.3 [Aubrey]
technoweenie (author)
Sun Feb 03 10:40:09 -0800 2008
commit  885b67417c782139785cb4fc36cf251da148795b
tree    bbeae39ccd66fb995a4c0d613efe33f68500cf3f
parent  aa2a339404fa179b7250930e471554dd32e0a528
...
1
2
3
4
5
 
 
 
6
7
8
...
83
84
85
86
87
88
89
 
90
91
92
93
94
95
 
 
 
 
 
 
 
 
96
97
98
...
1
2
 
 
3
4
5
6
7
8
9
...
84
85
86
 
 
 
 
87
88
89
90
91
92
 
93
94
95
96
97
98
99
100
101
102
103
0
@@ -1,8 +1,9 @@
0
 require 'converters/word_press/post'
0
 require 'converters/word_press/comment'
0
-require 'converters/word_press/category'
0
-require 'converters/word_press/post_category'
0
 require 'converters/word_press/user'
0
+require 'converters/word_press/term'
0
+require 'converters/word_press/term_relationship'
0
+require 'converters/word_press/term_taxonomy'
0
 class WordPressConverter < BaseConverter
0
   def self.convert(options = {})
0
     converter = new(options)
0
@@ -83,16 +84,20 @@ class WordPressConverter < BaseConverter
0
   end
0
   
0
   def tagging_from_sections(wp_article)
0
- tags = wp_article.categories.inject([]) do |memo, cat|
0
- memo << cat.category_nicename
0
- end
0
- tags.join(',')
0
+ wp_article.tags.join(',')
0
   end
0
 
0
   def find_or_create_sections(wp_article)
0
     home_section = sections['']
0
     wp_article.categories.inject([home_section.id]) do |memo, cat|
0
- memo << (sections[::Section.permalink_for(cat.cat_name)] || site.sections.create(:name => cat.cat_name)).id
0
+ existing = Section.find_by_name(cat)
0
+ if (existing)
0
+ memo << existing.id
0
+ else
0
+ new = site.sections.create(:name => cat)
0
+ new.save!
0
+ memo << new.id
0
+ end
0
     end
0
   end
0
 end
...
4
5
6
7
 
 
 
 
8
9
10
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
13
14
...
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
0
@@ -4,11 +4,26 @@ module WordPress
0
     set_primary_key 'ID'
0
     establish_connection configurations['wp']
0
     has_many :comments, :foreign_key => 'comment_parent', :class_name => 'WordPress::Comment'
0
-
0
+ has_many :term_relationships, :foreign_key => 'object_id'
0
+ has_many :term_taxonomies, :through => :term_relationships,
0
+ :class_name => 'WordPress::TermTaxonomy'
0
+
0
     def categories
0
- category_ids = WordPress::PostCategory.find_all_by_post_id(self.ID)
0
- categories = category_ids.inject([]) {|categories, postcat| categories << WordPress::Category.find_by_cat_ID(postcat.category_id) }
0
- categories
0
+ term_taxonomies.inject([]) do |list, taxonomy|
0
+ if taxonomy.taxonomy.eql?('category')
0
+ list << taxonomy.term.name
0
+ end
0
+ list
0
+ end
0
+ end
0
+
0
+ def tags
0
+ term_taxonomies.inject([]) do |list, taxonomy|
0
+ if taxonomy.taxonomy.eql?('post_tag')
0
+ list << taxonomy.term.name
0
+ end
0
+ list
0
+ end
0
     end
0
 
0
     def comments

Comments

    No one has commented yet.