lib/wp2middleman/post.rb in wp2middleman-0.0.1 vs lib/wp2middleman/post.rb in wp2middleman-0.0.2
- old
+ new
@@ -10,20 +10,22 @@
def title
post.css('title').text
end
- def title_for_filename
- title.gsub(/[^\w\s_-]+/, '')
- .gsub(/(^|\b\s)\s+($|\s?\b)/, '\\1\\2')
- .gsub(/\s+/, '-')
+ def valid?
+ !(post_date.nil? || title.nil? || date_published.nil? || content.nil?)
end
- def filename
- "#{date_published}-#{title_for_filename}"
+ def attachment?
+ type == 'attachment'
end
+ def field(field)
+ post.xpath(field).first.inner_text
+ end
+
def post_date
post.xpath("wp:post_date").first.inner_text
end
def date_published
@@ -42,20 +44,9 @@
status == 'publish'
end
def content
post.at_xpath(".//content:encoded").inner_text
- end
-
- def markdown_content
- html = HTMLPage.new :contents => content
- html.comment do |node,_|
- "#{node}"
- end
- html.iframe do |node,_|
- "#{node}"
- end
- html.markdown
end
def tags
tags = []
categories = post.xpath("category")