New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correctly handle wordpressdotcom drafts #213

Merged
merged 3 commits into from Aug 16, 2015
Jump to file or symbol
Failed to load files and symbols.
+25 −3
Diff settings

Always

Just for now

Viewing a subset of changes. View all
Prev

Correctly handle draft posts.

* Store them in ./_drafts, not ./_posts
* Don't prepend the date to the filename
  • Loading branch information...
danbernier committed Aug 10, 2015
commit a0435721a3c023c788b2689548000a0f69be41d8
@@ -70,7 +70,9 @@ def permalink_title
end
def published_at
Time.parse(@node.at('wp:post_date').inner_text)
if published?
Time.parse(@node.at('wp:post_date').inner_text)
end
end
def status
@@ -82,11 +84,19 @@ def post_type
end
def file_name
"#{published_at.strftime('%Y-%m-%d')}-#{permalink_title}.html"
if published?
"#{published_at.strftime('%Y-%m-%d')}-#{permalink_title}.html"
else
"#{permalink_title}.html"
end
end
def directory_name
"_#{post_type}s"
if !published? && post_type == 'post'
'_drafts'
else
"_#{post_type}s"
end
end
def published?
@@ -90,6 +90,18 @@ def item
Importers::WordpressDotCom::Item.new(node)
end
should "extract a nil publish-date" do
assert_equal(nil, item.published_at)
end
should 'not put the date in the file_name' do
assert_equal('post-name.html', item.file_name)
end
should "put the file in ./_drafts" do
assert_equal('_drafts', item.directory_name)
end
should 'know its status' do
assert_equal('draft', item.status)
end
ProTip! Use n and p to navigate between commits in a pull request.