### @export "post-properties" class Post include DataMapper::Resource storage_names[:default] = 'wp_posts' property :id, Integer, :serial => true # original field name ID property :post_date, DateTime property :post_content, Text property :post_title, String property :post_status, String property :post_name, String has n, :comments, :comment_approved => true, :order => [:comment_date] ### @export "perma-url" def filedir location = "../content/" # relative path to webby content dir location + "said/on/" + post_date.strftime("%Y/%m/%d/") + post_name end def filename filedir + "/index.txt" end ### @export "formatting" def webby_header %{--- title: #{post_title} created_at: #{post_date.to_s} --- } end def publish FileUtils.mkdir_p(filedir) File.open(filename, "w") do |f| f.write(webby_header) if [33].include?(id) # Post no. 33 and wp_format don't get along. f.write(post_content) else f.write(wp_format(post_content)) end if !comments.empty? f.write("\n\n