class JekyllImport::Importers::WordpressDotCom::Item
Public Class Methods
Source
# File lib/jekyll-import/importers/wordpressdotcom.rb, line 56 def initialize(node) raise "Node is nil" if node.nil? @node = node end
Public Instance Methods
Source
# File lib/jekyll-import/importers/wordpressdotcom.rb, line 117 def directory_name @directory_name ||= if !published? && post_type == "post" "_drafts" else "_#{post_type}s" end end
Source
# File lib/jekyll-import/importers/wordpressdotcom.rb, line 129 def excerpt @excerpt ||= begin text = Nokogiri::HTML(text_for("excerpt:encoded")).text text.empty? ? nil : text end end
Source
# File lib/jekyll-import/importers/wordpressdotcom.rb, line 109 def file_name @file_name ||= if published? "#{published_at.strftime("%Y-%m-%d")}-#{permalink_title}.html" else "#{permalink_title}.html" end end
Source
# File lib/jekyll-import/importers/wordpressdotcom.rb, line 105 def parent_id @parent_id ||= text_for("wp:post_parent") end
Source
# File lib/jekyll-import/importers/wordpressdotcom.rb, line 81 def permalink @permalink ||= begin uri = text_for("link") uri = @node.at("link").next_sibling.text if uri.empty? URI(uri.to_s.strip).path end end
Source
# File lib/jekyll-import/importers/wordpressdotcom.rb, line 71 def permalink_title post_name = text_for("wp:post_name") # Fallback to "prettified" title if post_name is empty (can happen) @permalink_title ||= if post_name.empty? WordpressDotCom.sluggify(title) else post_name end end
Source
# File lib/jekyll-import/importers/wordpressdotcom.rb, line 97 def post_password @post_password ||= text_for("wp:post_password") end
Source
# File lib/jekyll-import/importers/wordpressdotcom.rb, line 101 def post_type @post_type ||= text_for("wp:post_type") end
Source
# File lib/jekyll-import/importers/wordpressdotcom.rb, line 125 def published? @published ||= (status == "publish") end
Source
# File lib/jekyll-import/importers/wordpressdotcom.rb, line 89 def published_at @published_at ||= Time.parse(text_for("wp:post_date")) if published? end
Source
# File lib/jekyll-import/importers/wordpressdotcom.rb, line 93 def status @status ||= text_for("wp:status") end
Source
# File lib/jekyll-import/importers/wordpressdotcom.rb, line 62 def text_for(path) subnode = @node.at_xpath("./#{path}") || @node.at(path) || @node.children.find { |child| child.name == path } subnode.text end
Source
# File lib/jekyll-import/importers/wordpressdotcom.rb, line 67 def title @title ||= text_for("title").strip end