middleman / middleman-blog

Blog Engine Extension for Middleman
https://middlemanapp.com
MIT License
325 stars 179 forks source link

Middleman build fails when "Middleman article" is used to create article (Timestamp mismatch) #94

Closed debajit closed 11 years ago

debajit commented 11 years ago

Steps to Reproduce: • Create a blog article using "middleman article title" • Run middleman build

Expected Results: The build should not fail.

Actual Results: The build fails.

Notes: This is because the markdown filename contains only the date, whereas the frontmatter contains the time as well. date: 2006-06-10 00:00 +00:00

erikthered commented 11 years ago

You need to set the timezone in your config.rb. For example:

Time.zone = "US/Eastern"

This happens because Middleman assumes UTC by default, which is not the case if you're on Windows or something else using localtime.

debajit commented 11 years ago

In my config.rb, I have:

Time.zone = "America/Los_Angeles"

(I am on OS X Mountain Lion)

erikthered commented 11 years ago

Well, that was my best guess. Maybe since the offset in your frontmatter is set for UTC (+00:00) it's causing a problem? You could try setting the timezone to UTC or removing the timezone if all of your articles are set for +00:00.

Sorry this is kind of a shot in the dark. Maybe one of the devs can help.

debajit commented 11 years ago

Yes, removing the time part of the date-time string is a workaround (so I'm not stuck or anything). The issue that I wanted to point out here is that "middleman article " for a middleman blog creates a filename with only the date (without the time) but adds a YAML frontmatter with the date and time strings which does not build out of the box.

tdreyno commented 11 years ago

Understood.

bhollis commented 11 years ago

The timestamp isn't even mandatory - it's just in the template so people know they can include it if they want multiple posts from the same day to sort correctly. We should figure out how to generate that timestamp in the specified time zone...

bhollis commented 11 years ago

OK, I've fixed it to generate the timestamp in the right time zone.

atmosx commented 9 years ago

Hello,

I am moving from Octopress to Middleman. I made a quick script to fix the dates and worked fine for me:

require 'fileutils'
require 'time'

files = Dir.glob("*.markdown")
puts "Processing #{files.count} files"
files.each do |f|
  list = []
  list << f
  File.readlines(f).each do |line|
    if line.include?("date: ")
      string = line[6,19]
      string.include?("\n") ? s = string.strip : s = string
      time = Time.parse(string)
      FileUtils.touch f, mtime: time
    end
  end
end
puts "Finished!" 

Best regards

UPDATE: Apparently it works for SOME posts but not for others. I can't tell why though.