lib/siteleaf/post.rb in siteleaf-0.9.23 vs lib/siteleaf/post.rb in siteleaf-1.0.0

- old
+ new

@@ -14,7 +14,23 @@ def assets result = Client.get "posts/#{self.id}/assets" result.map { |r| Asset.new(r) } if result end + def filename(posts_path = 'posts') + paths = url.sub('/','').split('/') + basename = "#{paths.pop}.markdown" + path = paths.join('_') + if path == posts_path + if draft? + path = 'drafts' + else + path = 'posts' + date = Time.parse(published_at).strftime('%Y-%m-%d') + basename = "#{date}-#{basename}" + end + end + "_#{path}/#{basename}" + end + end end \ No newline at end of file