fix textilization of pages

This commit is contained in:
Tom Preston-Werner 2008-10-19 23:10:24 -07:00
parent 33dbb78137
commit 2a82259fc9
3 changed files with 17 additions and 6 deletions

View File

@ -34,14 +34,14 @@ module AutoBlog
end end
def transform def transform
if self.ext == "textile" if self.ext == ".textile"
self.ext = "html" self.ext = ".html"
self.content = RedCloth.new(self.content).to_html self.content = RedCloth.new(self.content).to_html
end end
end end
def add_layout(layouts) def add_layout(layouts, posts)
payload = {"page" => self.data} payload = {"page" => self.data, "site" => {"posts" => posts}}
self.content = Liquid::Template.parse(self.content).render(payload) self.content = Liquid::Template.parse(self.content).render(payload)
layout = layouts[self.data["layout"]] || self.content layout = layouts[self.data["layout"]] || self.content
@ -53,7 +53,12 @@ module AutoBlog
def write(dest) def write(dest)
FileUtils.mkdir_p(File.join(dest, @dir)) FileUtils.mkdir_p(File.join(dest, @dir))
path = File.join(dest, @dir, @name) name = @name
if self.ext != ""
name = @name.split(".")[0..-2].join('.') + self.ext
end
path = File.join(dest, @dir, name)
File.open(path, 'w') do |f| File.open(path, 'w') do |f|
f.write(self.content) f.write(self.content)
end end

View File

@ -71,6 +71,12 @@ module AutoBlog
f.write(self.content) f.write(self.content)
end end
end end
def to_liquid
{ "title" => self.data["title"] || "",
"url" => self.url,
"date" => self.date }
end
end end
end end

View File

@ -63,7 +63,7 @@ module AutoBlog
transform_pages(File.join(dir, f)) transform_pages(File.join(dir, f))
else else
page = Page.new(self.source, dir, f) page = Page.new(self.source, dir, f)
page.add_layout(self.layouts) page.add_layout(self.layouts, self.posts)
page.write(self.dest) page.write(self.dest)
end end
end end