Permalink
Browse files

textilize posts

  • Loading branch information...
1 parent 1c93bd0 commit 7fd8fd2b14f3ef1f6624c3d2538d89253cf1c20e @mojombo mojombo committed Oct 20, 2008
Showing with 18 additions and 3 deletions.
  1. +1 −0 .gitignore
  2. +1 −0 lib/autoblog.rb
  3. +5 −0 lib/autoblog/post.rb
  4. +11 −3 test/test_post.rb
View
@@ -0,0 +1 @@
+test/dest/
View
@@ -11,6 +11,7 @@
# 3rd party
require 'liquid'
+require 'redcloth'
# internal requires
require 'autoblog/site'
View
@@ -17,6 +17,7 @@ def initialize(base, name)
self.process(name)
self.read_yaml(base, name)
self.set_defaults
+ self.transform
end
def process(name)
@@ -48,6 +49,10 @@ def set_defaults
self.data["layout"] ||= "default"
end
+ def transform
+ self.content = RedCloth.new(self.content).to_html
+ end
+
def add_layout(layouts)
payload = {"page" => self.data}
self.content = Liquid::Template.parse(self.content).render(payload)
View
@@ -23,23 +23,31 @@ def test_url
p = Post.allocate
p.process("2008-10-19-foo-bar.textile")
- assert_equal "/2008/10/19/foo-bar", p.url
+ assert_equal "/2008/10/19/foo-bar.html", p.url
end
def test_read_yaml
p = Post.allocate
p.read_yaml(File.join(File.dirname(__FILE__), *%w[source posts]), "2008-10-18-foo-bar.textile")
assert_equal({"title" => "Foo Bar"}, p.data)
- assert_equal "\nh1. {{ page.title }}\n\nBest post ever", p.content
+ assert_equal "\nh1. {{ page.title }}\n\nBest *post* ever", p.content
+ end
+
+ def test_transform
+ p = Post.allocate
+ p.read_yaml(File.join(File.dirname(__FILE__), *%w[source posts]), "2008-10-18-foo-bar.textile")
+ p.transform
+
+ assert_equal "<h1>{{ page.title }}</h1>\n\n\n\t<p>Best <strong>post</strong> ever</p>", p.content
end
def test_add_layout
p = Post.new(File.join(File.dirname(__FILE__), *%w[source posts]), "2008-10-18-foo-bar.textile")
layouts = {"default" => "<<< {{ content }} >>>"}
p.add_layout(layouts)
- assert_equal "<<< \nh1. Foo Bar\n\nBest post ever >>>", p.content
+ assert_equal "<<< <h1>Foo Bar</h1>\n\n\n\t<p>Best <strong>post</strong> ever</p> >>>", p.content
end
def test_write

0 comments on commit 7fd8fd2

Please sign in to comment.