Current location

narf Source control manager Git

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshtrom <shtrom@1991c358-8f32-0410-a49a-990740bdf4c2>2014-04-22 12:24:38 +0000
committershtrom <shtrom@1991c358-8f32-0410-a49a-990740bdf4c2>2014-04-22 12:24:38 +0000
commitb5f041c3c530e1fd8a5b2707270a0540614dbc6f (patch)
treec89e9a17f337ede8e4bda9eb33f8f8d8dfbb5fd3 /Blogsum2WP.rb
parent0dbb61d7030e4747e28aa7fabae8ebac2ee5ffb0 (diff)
Accessing blogsum comments, and wordpress posts, comments and terms
git-svn-id: svn+ssh://scm.narf.ssji.net/svn/shtrom/scripts@1806 1991c358-8f32-0410-a49a-990740bdf4c2
Diffstat (limited to 'Blogsum2WP.rb')
-rwxr-xr-xBlogsum2WP.rb27
1 files changed, 21 insertions, 6 deletions
diff --git a/Blogsum2WP.rb b/Blogsum2WP.rb
index d4365f0..b00264a 100755
--- a/Blogsum2WP.rb
+++ b/Blogsum2WP.rb
@@ -40,38 +40,53 @@ end
class WpComment < ActiveRecord::Base
establish_connection $settings["wordpress"]
self.primary_key = :comment_ID
+ has_many :wp_commentmeta
belongs_to :wp_post
- has_many :wp_term_taxonomy, through: :wp_term_relationships
end
class WpCommentmetum < ActiveRecord::Base
establish_connection $settings["wordpress"]
self.primary_key = :meta_id
+ belongs_to :wp_comment, foreign_key: :comment_id
end
class WpPost < ActiveRecord::Base
establish_connection $settings["wordpress"]
self.primary_key = :ID
- has_many :wp_comment
+ has_many :wp_postmeta, foreign_key: :post_id
+ has_many :wp_comment, foreign_key: :comment_post_ID
+ has_many :wp_term_relationships, foreign_key: :object_id
+ has_many :wp_term_taxonomy, through: :wp_term_relationships
+ has_many :wp_term, through: :wp_term_taxonomy
end
class WpPostmetum < ActiveRecord::Base
establish_connection $settings["wordpress"]
self.primary_key = :meta_id
+ belongs_to :wp_post
end
class WpTerm < ActiveRecord::Base
establish_connection $settings["wordpress"]
self.primary_key = :term_id
- belongs_to :wp_term_taxonomy
+ has_one :wp_term_taxonomy
end
class WpTermRelationship < ActiveRecord::Base
establish_connection $settings["wordpress"]
- belongs_to :wp_post, foreign_key: :object_id
+ belongs_to :wp_post
belongs_to :wp_term_taxonomy, foreign_key: :term_taxonomy_id
end
class WpTermTaxonomy < ActiveRecord::Base
establish_connection $settings["wordpress"]
self.table_name = 'wp_term_taxonomy'
self.primary_key = :term_taxonomy_id
- has_one :wp_term, foreign_key: :term_id
+ belongs_to :wp_term, foreign_key: :term_id
+ has_many :wp_term_relationships
+ has_many :wp_post, through: :wp_term_relationships
end
+# Blogsum
puts Article.find(1).title
-puts Article.find(3).comment.instance_variables.map {|var| "#{var}: #{instance_variable_get(var)}"}
+puts Article.find(3).comment[0].comment
+
+#Wordpress
+puts WpPost.find(1).post_title
+puts WpPost.find(1).wp_comment[0].comment_content
+puts WpPost.find(1).wp_term_taxonomy
+puts WpPost.find(7).wp_term.map {|t| "#{t.name}, "}