henshin 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -1
- data/README.markdown +0 -1
- data/Rakefile +4 -1
- data/VERSION +1 -1
- data/bin/files.rb +46 -0
- data/bin/henshin +47 -79
- data/henshin.gemspec +37 -14
- data/lib/henshin.rb +50 -36
- data/lib/henshin/archive.rb +161 -0
- data/lib/henshin/categories.rb +6 -1
- data/lib/henshin/ext.rb +2 -53
- data/lib/henshin/gen.rb +16 -15
- data/lib/henshin/plugin.rb +20 -7
- data/lib/henshin/plugins/highlight.rb +31 -0
- data/lib/henshin/plugins/liquid.rb +48 -14
- data/lib/henshin/plugins/maruku.rb +3 -4
- data/lib/henshin/plugins/sass.rb +7 -6
- data/lib/henshin/plugins/textile.rb +3 -4
- data/lib/henshin/post.rb +50 -8
- data/lib/henshin/site.rb +60 -34
- data/lib/henshin/tags.rb +5 -1
- data/test/site/css/{print.sass → includes/reset.sass} +0 -3
- data/test/site/css/{screen.css → print.css} +1 -4
- data/test/site/css/screen.sass +70 -0
- data/test/site/includes/head.html +1 -0
- data/test/site/index.html +12 -2
- data/test/site/layouts/archive_date.html +19 -0
- data/test/site/layouts/archive_month.html +19 -0
- data/test/site/layouts/archive_year.html +19 -0
- data/test/site/layouts/category_index.html +5 -4
- data/test/site/layouts/category_page.html +2 -2
- data/test/site/layouts/main.html +1 -36
- data/test/site/layouts/post.html +15 -5
- data/test/site/layouts/tag_index.html +3 -3
- data/test/site/layouts/tag_page.html +2 -2
- data/test/site/options.yaml +7 -4
- data/test/site/posts/Testing-Stuff.markdown +7 -1
- data/test/test_archives.rb +27 -0
- data/test/test_categories.rb +0 -0
- data/test/test_gens.rb +28 -7
- data/test/test_options.rb +4 -2
- data/test/test_posts.rb +50 -14
- data/test/test_site.rb +55 -7
- data/test/test_statics.rb +0 -0
- data/test/test_tags.rb +0 -0
- data/test/text_exts.rb +0 -0
- metadata +86 -17
- data/lib/henshin/plugins/pygments.rb +0 -17
@@ -0,0 +1 @@
|
|
1
|
+
<link rel="stylesheet" href="/css/screen.css" type="text/css" />
|
data/test/site/index.html
CHANGED
@@ -5,10 +5,20 @@ title: Home Page
|
|
5
5
|
|
6
6
|
|
7
7
|
<header>
|
8
|
-
<h1>
|
8
|
+
<h1>{{ gen.title }}</h1>
|
9
9
|
</header>
|
10
10
|
|
11
11
|
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
|
12
|
+
<hr/>
|
12
13
|
|
13
|
-
<
|
14
|
+
<h2>Posts</h2>
|
15
|
+
<ul>
|
16
|
+
{% for post in site.posts %}
|
17
|
+
<li><time>{{ post.date | date_to_string }}</time> - <a href="{{ post.url }}">{{ post.title }}</a></li>
|
18
|
+
{% endfor %}
|
19
|
+
</ul>
|
14
20
|
|
21
|
+
<ul>
|
22
|
+
<li><a href="/categories/">Categories</a></li>
|
23
|
+
<li><a href="/tags/">Tags</a></li>
|
24
|
+
</ul>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8" />
|
5
|
+
<title>{{ site.title }}</title>
|
6
|
+
{% include head.html %}
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
|
10
|
+
<h2>{{ archive.date }}</h2>
|
11
|
+
<ul>
|
12
|
+
{% for post in archive.posts %}
|
13
|
+
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
|
14
|
+
{% endfor %}
|
15
|
+
</ul>
|
16
|
+
|
17
|
+
<span>Copyright © {{ site.author }}</span>
|
18
|
+
</body>
|
19
|
+
</html>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8" />
|
5
|
+
<title>{{ site.title }}</title>
|
6
|
+
{% include head.html %}
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
|
10
|
+
<h2>{{ archive.date }}</h2>
|
11
|
+
<ul>
|
12
|
+
{% for post in archive.posts %}
|
13
|
+
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
|
14
|
+
{% endfor %}
|
15
|
+
</ul>
|
16
|
+
|
17
|
+
<span>Copyright © {{ site.author }}</span>
|
18
|
+
</body>
|
19
|
+
</html>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html lang="en">
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8" />
|
5
|
+
<title>{{ site.title }}</title>
|
6
|
+
{% include head.html %}
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
|
10
|
+
<h2>{{ archive.date }}</h2>
|
11
|
+
<ul>
|
12
|
+
{% for post in archive.posts %}
|
13
|
+
<li><a href="{{ post.url }}">{{ post.title }}</a></li>
|
14
|
+
{% endfor %}
|
15
|
+
</ul>
|
16
|
+
|
17
|
+
<span>Copyright © {{ site.author }}</span>
|
18
|
+
</body>
|
19
|
+
</html>
|
@@ -3,18 +3,19 @@
|
|
3
3
|
<head>
|
4
4
|
<meta charset="utf-8" />
|
5
5
|
<title>{{ site.title }}</title>
|
6
|
-
|
6
|
+
{% include head.html %}
|
7
7
|
</head>
|
8
8
|
<body>
|
9
|
-
|
9
|
+
<a href="/">Home</a>
|
10
|
+
|
10
11
|
<h2>A List of Categories</h2>
|
11
12
|
<ul>
|
12
13
|
{% for category in site.categories %}
|
13
14
|
<li>
|
14
|
-
{{ category.name }}
|
15
|
+
<a href="{{ category.url }}">{{ category.name }}</a>
|
15
16
|
<ul>
|
16
17
|
{% for post in category.posts %}
|
17
|
-
<li>{{ post.
|
18
|
+
<li><time>{{ post.date | date_to_string }}</time> - <a href="{{ post.url }}">{{ post.title }}</a></li>
|
18
19
|
{% endfor %}
|
19
20
|
</ul>
|
20
21
|
</li>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<head>
|
4
4
|
<meta charset="utf-8" />
|
5
5
|
<title>{{ site.title }}</title>
|
6
|
-
|
6
|
+
{% include head.html %}
|
7
7
|
</head>
|
8
8
|
<body>
|
9
9
|
|
@@ -11,7 +11,7 @@
|
|
11
11
|
|
12
12
|
<ul>
|
13
13
|
{% for post in category.posts %}
|
14
|
-
<li>{{ post.
|
14
|
+
<li><time>{{ post.date | date_to_string }}</time> - <a href="{{ post.url }}">{{ post.title }}</a></li>
|
15
15
|
{% endfor %}
|
16
16
|
</ul>
|
17
17
|
|
data/test/site/layouts/main.html
CHANGED
@@ -3,47 +3,12 @@
|
|
3
3
|
<head>
|
4
4
|
<meta charset="utf-8" />
|
5
5
|
<title>{{ site.title }}</title>
|
6
|
-
|
6
|
+
{% include head.html %}
|
7
7
|
</head>
|
8
8
|
<body>
|
9
9
|
|
10
10
|
{{ yield }}
|
11
11
|
|
12
|
-
|
13
|
-
<h2>A List of Posts</h2>
|
14
|
-
<ul>
|
15
|
-
{% for post in site.posts %}
|
16
|
-
<li><a href="{{ post.url }}">{{ post.title }}</a> - {{ post.date }}</li>
|
17
|
-
{% endfor %}
|
18
|
-
</ul>
|
19
|
-
|
20
|
-
<h2>A List of Tags</h2>
|
21
|
-
<ul>
|
22
|
-
{% for tag in site.tags %}
|
23
|
-
<li>
|
24
|
-
{{ tag.name }}
|
25
|
-
<ul>
|
26
|
-
{% for post in tag.posts %}
|
27
|
-
<li>{{ post.title }} - {{ post.date }}</li>
|
28
|
-
{% endfor %}
|
29
|
-
</ul>
|
30
|
-
</li>
|
31
|
-
{% endfor %}
|
32
|
-
</ul>
|
33
|
-
|
34
|
-
<h2>A List of Categories</h2>
|
35
|
-
<ul>
|
36
|
-
{% for category in site.categories %}
|
37
|
-
<li>{{ category.name }}</li>
|
38
|
-
<ul>
|
39
|
-
{% for post in category.posts %}
|
40
|
-
<li>{{ post.title }} - {{ post.date }}</li>
|
41
|
-
{% endfor %}
|
42
|
-
</ul>
|
43
|
-
{% endfor %}
|
44
|
-
</ul>
|
45
|
-
|
46
|
-
|
47
12
|
<span>Copyright © {{ site.author }}</span>
|
48
13
|
</body>
|
49
14
|
</html>
|
data/test/site/layouts/post.html
CHANGED
@@ -3,17 +3,27 @@
|
|
3
3
|
<head>
|
4
4
|
<meta charset="utf-8" />
|
5
5
|
<title>{{ post.title }}</title>
|
6
|
-
|
6
|
+
{% include head.html %}
|
7
7
|
</head>
|
8
8
|
<body>
|
9
9
|
|
10
|
+
<nav>
|
11
|
+
{% if post.next %}
|
12
|
+
<a href="{{ post.next.url }}">←</a> 
|
13
|
+
{% endif %}
|
14
|
+
<a href="/">Home</a>
|
15
|
+
{% if post.prev %}
|
16
|
+
 <a href="{{ post.prev.url }}">→</a>
|
17
|
+
{% endif %}
|
18
|
+
</nav>
|
19
|
+
|
10
20
|
<header>
|
11
|
-
<h1>{{ post.title }}</h1
|
12
|
-
<time>{{ post.date }}</time>
|
21
|
+
<h1>{{ post.title }}</h1>
|
22
|
+
<time>{{ post.date | date_to_string }}</time>
|
13
23
|
|
14
|
-
<ul>
|
24
|
+
<ul class="tags">
|
15
25
|
{% for tag in post.tags %}
|
16
|
-
<li>{{ tag }}</li>
|
26
|
+
<li><a href="{{ tag.url }}">{{ tag.name }}</a></li>
|
17
27
|
{% endfor %}
|
18
28
|
</ul>
|
19
29
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<head>
|
4
4
|
<meta charset="utf-8" />
|
5
5
|
<title>{{ site.title }}</title>
|
6
|
-
|
6
|
+
{% include head.html %}
|
7
7
|
</head>
|
8
8
|
<body>
|
9
9
|
|
@@ -11,10 +11,10 @@
|
|
11
11
|
<ul>
|
12
12
|
{% for tag in site.tags %}
|
13
13
|
<li>
|
14
|
-
{{ tag.name }}
|
14
|
+
<a href="{{ tag.url }}">{{ tag.name }}</a>
|
15
15
|
<ul>
|
16
16
|
{% for post in tag.posts %}
|
17
|
-
<li>{{ post.
|
17
|
+
<li><time>{{ post.date | date_to_string }}</time> - <a href="{{ post.url }}">{{ post.title }}</a></li>
|
18
18
|
{% endfor %}
|
19
19
|
</ul>
|
20
20
|
</li>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<head>
|
4
4
|
<meta charset="utf-8" />
|
5
5
|
<title>{{ site.title }}</title>
|
6
|
-
|
6
|
+
{% include head.html %}
|
7
7
|
</head>
|
8
8
|
<body>
|
9
9
|
|
@@ -11,7 +11,7 @@
|
|
11
11
|
|
12
12
|
<ul>
|
13
13
|
{% for post in tag.posts %}
|
14
|
-
<li>{{ post.
|
14
|
+
<li><time>{{ post.date | date_to_string }}</time> - <a href="{{ post.url }}">{{ post.title }}</a></li>
|
15
15
|
{% endfor %}
|
16
16
|
</ul>
|
17
17
|
|
data/test/site/options.yaml
CHANGED
@@ -5,10 +5,13 @@ author: Joshua Hawxwell
|
|
5
5
|
|
6
6
|
layout: post
|
7
7
|
|
8
|
-
exclude: []
|
8
|
+
exclude: ['includes']
|
9
9
|
post_name: '{title-with-dashes}.{extension}'
|
10
|
-
permalink: '/{year}/{month}/{date}
|
11
|
-
plugins: [maruku, sass, pygments, liquid, test, textile]
|
10
|
+
permalink: '/{year}/{month}/{date}/{title}/index.html'
|
11
|
+
plugins: [maruku, sass, pygments, liquid, test, textile, highlight]
|
12
12
|
|
13
13
|
sass:
|
14
|
-
style: :compact
|
14
|
+
style: :compact
|
15
|
+
|
16
|
+
liquid:
|
17
|
+
include_dir: includes
|
@@ -5,4 +5,10 @@ tags: test, markdown
|
|
5
5
|
category: test
|
6
6
|
---
|
7
7
|
|
8
|
-
So Lorem ipsum dolor *sit amet*, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim __ad minim__ veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
8
|
+
So Lorem ipsum dolor *sit amet*, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim __ad minim__ veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
9
|
+
|
10
|
+
$highlight ruby
|
11
|
+
def hello
|
12
|
+
puts "hello"
|
13
|
+
end
|
14
|
+
$end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__) ,'helper')
|
2
|
+
|
3
|
+
class TestArchives < Test::Unit::TestCase
|
4
|
+
context "An archive" do
|
5
|
+
|
6
|
+
setup do
|
7
|
+
@site = new_site
|
8
|
+
end
|
9
|
+
|
10
|
+
should "turn to hash" do
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
should "turn to hash of dates" do
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
should "turn to hash of months" do
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
should "turn to hash of years" do
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
File without changes
|
data/test/test_gens.rb
CHANGED
@@ -5,28 +5,49 @@ class TestGens < Test::Unit::TestCase
|
|
5
5
|
|
6
6
|
setup do
|
7
7
|
@site = new_site
|
8
|
-
@gen = Henshin::Gen.new
|
8
|
+
@gen = Henshin::Gen.new "#{root_dir}/index.html", @site
|
9
9
|
remove_site
|
10
10
|
end
|
11
11
|
|
12
12
|
should "read frontmatter" do
|
13
13
|
@site.read_layouts
|
14
14
|
@gen.read_yaml
|
15
|
-
assert_equal
|
16
|
-
assert_equal
|
15
|
+
assert_equal 'Home Page', @gen.title
|
16
|
+
assert_equal File.open("#{root_dir}/layouts/main.html", "r"){|f| f.read}, @gen.layout
|
17
17
|
end
|
18
18
|
|
19
|
-
should "
|
19
|
+
should "render with correct layout" do
|
20
|
+
@site.read_layouts
|
21
|
+
@gen.read_yaml
|
22
|
+
# index.html uses 'layout: main'
|
23
|
+
assert_equal File.open("#{root_dir}/layouts/main.html", "r"){|f| f.read}, @gen.layout
|
24
|
+
end
|
25
|
+
|
26
|
+
should "have the correct permalink and url" do
|
20
27
|
@gen.read_yaml
|
21
|
-
assert_equal
|
22
|
-
assert_equal @gen.url
|
28
|
+
assert_equal '/index.html', @gen.permalink
|
29
|
+
assert_equal '/', @gen.url
|
30
|
+
end
|
31
|
+
|
32
|
+
should "respond to #to_hash" do
|
33
|
+
@gen.process
|
34
|
+
assert_equal @gen.title, @gen.to_hash['title']
|
35
|
+
assert_equal @gen.permalink, @gen.to_hash['permalink']
|
36
|
+
assert_equal @gen.url, @gen.to_hash['url']
|
37
|
+
assert_equal @gen.content, @gen.to_hash['content']
|
23
38
|
end
|
24
39
|
|
25
40
|
should "allow a hash to be added to the payload" do
|
26
41
|
payload = { :name => 'people', :payload => {'fname' => 'John', 'sname' => 'Doe'} }
|
27
42
|
gen = Henshin::Gen.new( "#{root_dir}/index.html", @site, payload )
|
28
43
|
gen.read_yaml
|
29
|
-
assert_equal gen.payload['people']
|
44
|
+
assert_equal payload[:payload], gen.payload['people']
|
45
|
+
end
|
46
|
+
|
47
|
+
should "be sortable" do
|
48
|
+
another_gen = Henshin::Gen.new( "#{root_dir}/css/print.sass", @site )
|
49
|
+
gen_array = [@gen, another_gen]
|
50
|
+
assert_equal gen_array.reverse, gen_array.sort
|
30
51
|
end
|
31
52
|
|
32
53
|
end
|
data/test/test_options.rb
CHANGED
@@ -44,11 +44,13 @@ class TestOptions < Test::Unit::TestCase
|
|
44
44
|
|
45
45
|
override = {:time_zone => '+01:00'}
|
46
46
|
configured = Henshin.configure(override)
|
47
|
-
assert_equal
|
47
|
+
assert_equal '+01:00', configured[:time_zone]
|
48
48
|
end
|
49
49
|
|
50
50
|
should "load plugins" do
|
51
|
-
|
51
|
+
opts = Henshin::Defaults.dup
|
52
|
+
opts[:plugins] = ['maruku']
|
53
|
+
loaded = Henshin.load_plugins(opts)
|
52
54
|
assert loaded[0].is_a? MarukuPlugin
|
53
55
|
end
|
54
56
|
|
data/test/test_posts.rb
CHANGED
@@ -5,6 +5,9 @@ class TestPosts < Test::Unit::TestCase
|
|
5
5
|
|
6
6
|
setup do
|
7
7
|
@site = new_site
|
8
|
+
@site.read
|
9
|
+
@site.process
|
10
|
+
@post = Henshin::Post.new( "#{root_dir}/posts/lorem-ipsum.markdown", @site )
|
8
11
|
remove_site
|
9
12
|
end
|
10
13
|
|
@@ -14,25 +17,58 @@ class TestPosts < Test::Unit::TestCase
|
|
14
17
|
site.config[:file_name] = "{date}-{title-with-dashes}.{extension}"
|
15
18
|
post = Henshin::Post.new( post_file, site )
|
16
19
|
post.read_name
|
17
|
-
assert_equal post.title
|
18
|
-
assert_equal
|
19
|
-
assert_equal post.extension
|
20
|
+
assert_equal 'Lorem Ipsum', post.title
|
21
|
+
assert_equal Time.parse('2010-08-10'), post.date
|
22
|
+
assert_equal 'markdown', post.extension
|
20
23
|
end
|
21
24
|
|
22
|
-
should "
|
23
|
-
post_file = "#{root_dir}/posts/
|
25
|
+
should "get category from folder" do
|
26
|
+
post_file = "#{root_dir}/posts/category/test-post.markdown"
|
24
27
|
post = Henshin::Post.new( post_file, @site )
|
25
|
-
post.
|
26
|
-
assert_equal post.
|
27
|
-
assert_equal post.date, Time.parse('2010-05-15 at 13:23:47')
|
28
|
-
assert_equal post.tags, ['test', 'lorem']
|
28
|
+
post.read_name
|
29
|
+
assert_equal 'category', post.category
|
29
30
|
end
|
30
31
|
|
31
|
-
should "
|
32
|
-
|
33
|
-
|
34
|
-
post.
|
35
|
-
|
32
|
+
should "render with correct layout" do
|
33
|
+
@post.process
|
34
|
+
# lorem-ipsum.markdown uses default 'layout: post'
|
35
|
+
assert_equal File.open("#{root_dir}/layouts/post.html"){|f| f.read} , @post.layout
|
36
|
+
end
|
37
|
+
|
38
|
+
should "read frontmatter" do
|
39
|
+
@post.read_yaml
|
40
|
+
assert_equal 'Lorem Ipsum', @post.title
|
41
|
+
assert_equal Time.parse('2010-05-15 at 13:23:47'), @post.date
|
42
|
+
assert_equal ['test', 'lorem'], @post.tags
|
43
|
+
end
|
44
|
+
|
45
|
+
should "have the correct permalink and url" do
|
46
|
+
@post.process
|
47
|
+
assert_equal "/2010/5/15/lorem-ipsum/index.html", @post.permalink
|
48
|
+
assert_equal "/2010/5/15/lorem-ipsum/", @post.url
|
49
|
+
end
|
50
|
+
|
51
|
+
should "respond to #to_hash" do
|
52
|
+
@post.process
|
53
|
+
assert_equal @post.title, @post.to_hash['title']
|
54
|
+
assert_equal @post.author, @post.to_hash['author']
|
55
|
+
assert_equal @post.permalink, @post.to_hash['permalink']
|
56
|
+
assert_equal @post.url, @post.to_hash['url']
|
57
|
+
assert_equal @post.date, @post.to_hash['date']
|
58
|
+
assert_equal @post.category, @post.to_hash['category']
|
59
|
+
assert_equal @post.content, @post.to_hash['content']
|
60
|
+
end
|
61
|
+
|
62
|
+
should "be sortable" do
|
63
|
+
another_post = Henshin::Post.new( "#{root_dir}/posts/Testing-Stuff.markdown", @site )
|
64
|
+
post_array = [another_post, @post]
|
65
|
+
assert_equal post_array.reverse, post_array.sort
|
66
|
+
end
|
67
|
+
|
68
|
+
should "sort by url if dates are same" do
|
69
|
+
another_post = Henshin::Post.new( "#{root_dir}/posts/same-date.markdown", @site )
|
70
|
+
post_array = [another_post, @post]
|
71
|
+
assert_equal post_array.reverse, post_array.sort
|
36
72
|
end
|
37
73
|
|
38
74
|
end
|