howl 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore CHANGED
@@ -21,4 +21,4 @@ pkg
21
21
  .sass-cache
22
22
 
23
23
  ## PROJECT::SPECIFIC
24
- test/fixtures/site
24
+ test/fixtures/generated
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.4.0
data/howl.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{howl}
8
- s.version = "0.3.0"
8
+ s.version = "0.4.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Clinton R. Nixon"]
@@ -36,15 +36,15 @@ Gem::Specification.new do |s|
36
36
  "lib/howl/site.rb",
37
37
  "lib/howl/template.rb",
38
38
  "lib/howl/view.rb",
39
- "test/fixtures/pages/css/modules/colors.scss",
40
- "test/fixtures/pages/css/screen.scss",
41
- "test/fixtures/pages/has_template.html",
42
- "test/fixtures/pages/index.html",
43
- "test/fixtures/pages/no_yaml.html",
44
- "test/fixtures/pages/simple.html",
45
39
  "test/fixtures/posts/first_post.html",
46
40
  "test/fixtures/posts/markdown_post.md",
47
41
  "test/fixtures/posts/no_date.html",
42
+ "test/fixtures/site/css/modules/colors.scss",
43
+ "test/fixtures/site/css/screen.scss",
44
+ "test/fixtures/site/has_template.html",
45
+ "test/fixtures/site/index.html",
46
+ "test/fixtures/site/no_yaml.html",
47
+ "test/fixtures/site/simple.html",
48
48
  "test/fixtures/templates/alt.html",
49
49
  "test/fixtures/templates/default.html",
50
50
  "test/fixtures/templates/post.html",
data/lib/howl/page.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Howl
2
2
  class Page < Template
3
3
  def output_path
4
- site.path("site") + path.relative_path_from(site.path "pages").dirname + output_filename
4
+ site.output_path(path.relative_path_from(site.pages_path).dirname + output_filename)
5
5
  end
6
6
  end
7
7
  end
data/lib/howl/post.rb CHANGED
@@ -11,7 +11,7 @@ module Howl
11
11
  end
12
12
 
13
13
  def output_path
14
- site.path("site/posts") + date.strftime("%Y/%m/%d") + output_filename
14
+ site.output_path("posts") + date.strftime("%Y/%m/%d") + output_filename
15
15
  end
16
16
 
17
17
  def title
@@ -21,5 +21,15 @@ module Howl
21
21
  def dom_id
22
22
  title.slugify
23
23
  end
24
+
25
+ def link
26
+ "/" + output_path.relative_path_from(site.output_path).to_s
27
+ end
28
+
29
+ def rendered_content
30
+ render_view = view.dup
31
+ render_view.delete('template')
32
+ converter.convert(Mustache.render(@content, render_view))
33
+ end
24
34
  end
25
35
  end
data/lib/howl/site.rb CHANGED
@@ -10,24 +10,39 @@ module Howl
10
10
  root + path
11
11
  end
12
12
 
13
+ def posts_path(path = '')
14
+ root + "posts" + path
15
+ end
16
+
17
+ def templates_path(path = '')
18
+ root + "templates" + path
19
+ end
20
+
21
+ def pages_path(path = '')
22
+ root + "site" + path
23
+ end
24
+
25
+ def output_path(path = '')
26
+ root + "generated" + path
27
+ end
28
+
13
29
  def pages
14
- @pages ||= Dir[path "pages/**/*.*"].map { |path| Page.new(path, self) }
30
+ @pages ||= Dir[pages_path "**/*.*"].map { |path| Page.new(path, self) }
15
31
  end
16
32
 
17
33
  def posts
18
- @posts ||= Dir[path "posts/**/*.*"].map { |path| Post.new(path, self) }.sort
34
+ @posts ||= Dir[posts_path "**/*.*"].map { |path| Post.new(path, self) }.sort
19
35
  end
20
36
 
21
37
  def templates
22
- @templates ||= Hash[Dir[root + "templates/*"].map { |path|
38
+ @templates ||= Hash[Dir[templates_path('*')].map { |path|
23
39
  [Pathname.new(path).relative_path_from(path "templates").to_s,
24
40
  Template.new(path, self)]
25
41
  }]
26
42
  end
27
43
 
28
44
  def write_to_disk
29
- FileUtils.rm_r(path "site") if File.exist?(path "site")
30
- #raise (pages + posts).map(&:class).inspect
45
+ FileUtils.rm_r(output_path) if File.exist?(output_path)
31
46
  (pages + posts).each do |page|
32
47
  FileUtils.makedirs(page.output_path.dirname)
33
48
  page.output_path.open("w") do |fh|
File without changes
File without changes
File without changes
File without changes
File without changes
data/test/howl_test.rb CHANGED
@@ -5,7 +5,7 @@ context "Site" do
5
5
  setup { @site = Site.new(fixture_path) }
6
6
 
7
7
  should("find all pages") {
8
- topic.pages == Dir[fixture_path("pages/**/*.*")].map { |path| Page.new(path, topic) }
8
+ topic.pages == Dir[fixture_path("site/**/*.*")].map { |path| Page.new(path, topic) }
9
9
  }
10
10
 
11
11
  should("write out all pages") {
@@ -18,7 +18,7 @@ context "Site" do
18
18
  should("write out all posts") {
19
19
  topic.write_to_disk
20
20
  topic.posts.map { |post|
21
- Dir[topic.path("site/posts") + "**/*.*"].map { |path|
21
+ Dir[topic.path("generated/posts") + "**/*.*"].map { |path|
22
22
  File.basename(path, File.extname(path))
23
23
  }.include?(post.path.basename(post.extension).to_s)
24
24
  }.all?
@@ -26,7 +26,7 @@ context "Site" do
26
26
 
27
27
  context "Page" do
28
28
  context "simple.html" do
29
- setup { Page.new(fixture_path("pages/simple.html"), @site) }
29
+ setup { Page.new(fixture_path("site/simple.html"), @site) }
30
30
 
31
31
  asserts("#content") { topic.content.strip }.equals "<h1>{{title}}</h1>"
32
32
  asserts("#view is correct") {
@@ -35,12 +35,12 @@ context "Site" do
35
35
  asserts("#rendered") { topic.render.strip }.equals "<h1>This is a simple page</h1>"
36
36
 
37
37
  should("be able to find its output path") {
38
- topic.output_path == (topic.site.path "site/simple.html")
38
+ topic.output_path == (topic.site.output_path "simple.html")
39
39
  }
40
40
  end
41
41
 
42
42
  context "no_yaml.html" do
43
- setup { Page.new(fixture_path("pages/no_yaml.html"), @site) }
43
+ setup { Page.new(fixture_path("site/no_yaml.html"), @site) }
44
44
 
45
45
  asserts("#content") { topic.content.strip }.equals "This page has no YAML front-matter."
46
46
  asserts("#view is correct") {
@@ -50,7 +50,7 @@ context "Site" do
50
50
  end
51
51
 
52
52
  context "has_template.html" do
53
- setup { Page.new(fixture_path("pages/has_template.html"), @site) }
53
+ setup { Page.new(fixture_path("site/has_template.html"), @site) }
54
54
 
55
55
  asserts("#rendered") { topic.render.clean }.equals %Q[
56
56
  <html>
@@ -64,7 +64,7 @@ context "Site" do
64
64
  end
65
65
 
66
66
  context "index.html" do
67
- setup { Page.new(fixture_path("pages/index.html"), @site) }
67
+ setup { Page.new(fixture_path("site/index.html"), @site) }
68
68
 
69
69
  should "show all posts" do
70
70
  doc = Nokogiri.parse(topic.render)
@@ -83,9 +83,15 @@ context "Site" do
83
83
  }
84
84
 
85
85
  asserts(:output_path).equals {
86
- topic.site.path("site/posts/2010/09/04") + "first_post.html"
86
+ topic.site.path("generated/posts/2010/09/04") + "first_post.html"
87
87
  }
88
88
 
89
+ should("render content") {
90
+ topic.rendered_content.clean == topic.converter.convert(topic.content).clean
91
+ }
92
+
93
+ asserts(:link).equals { "/posts/2010/09/04/first_post.html" }
94
+
89
95
  context "without a date" do
90
96
  setup { Post.new(fixture_path("posts/no_date.html"), @site) }
91
97
 
data/test/teststrap.rb CHANGED
@@ -21,3 +21,5 @@ class Mustache
21
21
  true
22
22
  end
23
23
  end
24
+
25
+ Riot.verbose
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 3
7
+ - 4
8
8
  - 0
9
- version: 0.3.0
9
+ version: 0.4.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Clinton R. Nixon
@@ -125,15 +125,15 @@ files:
125
125
  - lib/howl/site.rb
126
126
  - lib/howl/template.rb
127
127
  - lib/howl/view.rb
128
- - test/fixtures/pages/css/modules/colors.scss
129
- - test/fixtures/pages/css/screen.scss
130
- - test/fixtures/pages/has_template.html
131
- - test/fixtures/pages/index.html
132
- - test/fixtures/pages/no_yaml.html
133
- - test/fixtures/pages/simple.html
134
128
  - test/fixtures/posts/first_post.html
135
129
  - test/fixtures/posts/markdown_post.md
136
130
  - test/fixtures/posts/no_date.html
131
+ - test/fixtures/site/css/modules/colors.scss
132
+ - test/fixtures/site/css/screen.scss
133
+ - test/fixtures/site/has_template.html
134
+ - test/fixtures/site/index.html
135
+ - test/fixtures/site/no_yaml.html
136
+ - test/fixtures/site/simple.html
137
137
  - test/fixtures/templates/alt.html
138
138
  - test/fixtures/templates/default.html
139
139
  - test/fixtures/templates/post.html