pith 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. data/README.markdown +29 -0
  2. data/Rakefile +16 -0
  3. data/bin/pith +60 -0
  4. data/cucumber.yml +7 -0
  5. data/features/content_for.feature +29 -0
  6. data/features/content_for.feature~ +29 -0
  7. data/features/haml.feature +24 -0
  8. data/features/haml.feature~ +24 -0
  9. data/features/helpers.feature +23 -0
  10. data/features/ignorance.feature +26 -0
  11. data/features/ignorance.feature~ +26 -0
  12. data/features/include.feature +84 -0
  13. data/features/include.feature~ +84 -0
  14. data/features/incremental_rebuild.feature +24 -0
  15. data/features/layouts.feature +43 -0
  16. data/features/layouts.feature~ +43 -0
  17. data/features/linking.feature +79 -0
  18. data/features/linking.feature~ +79 -0
  19. data/features/metadata.feature +20 -0
  20. data/features/metadata.feature~ +20 -0
  21. data/features/step_definitions/build_steps.rb +46 -0
  22. data/features/step_definitions/build_steps.rb~ +29 -0
  23. data/features/support/env.rb +75 -0
  24. data/features/support/env.rb~ +43 -0
  25. data/features/support/rspec_matchers.rb +5 -0
  26. data/features/textile.feature +29 -0
  27. data/features/textile.feature~ +29 -0
  28. data/features/verbatim.feature +32 -0
  29. data/features/verbatim.feature~ +32 -0
  30. data/lib/pith.rb +1 -0
  31. data/lib/pith.rb~ +2 -0
  32. data/lib/pith/console_logger.rb +20 -0
  33. data/lib/pith/console_logger.rb~ +20 -0
  34. data/lib/pith/input.rb +189 -0
  35. data/lib/pith/input.rb~ +95 -0
  36. data/lib/pith/metadata.rb +26 -0
  37. data/lib/pith/metadata.rb~ +26 -0
  38. data/lib/pith/project.rb +68 -0
  39. data/lib/pith/project.rb~ +50 -0
  40. data/lib/pith/render_context.rb +77 -0
  41. data/lib/pith/render_context.rb~ +66 -0
  42. data/lib/pith/server.rb +42 -0
  43. data/lib/pith/server.rb~ +45 -0
  44. data/lib/pith/version.rb +3 -0
  45. data/lib/pith/version.rb~ +3 -0
  46. data/sample/_layouts/standard.haml +7 -0
  47. data/sample/index.html.haml +8 -0
  48. data/sample/stylesheets/app.css.sass +44 -0
  49. data/spec/pith/metadata_spec.rb +46 -0
  50. data/spec/pith/metadata_spec.rb~ +46 -0
  51. data/spec/pith/project_spec.rb +61 -0
  52. data/spec/spec_helper.rb +27 -0
  53. data/spec/spec_helper.rb~ +0 -0
  54. metadata +166 -0
@@ -0,0 +1,29 @@
1
+ Pith
2
+ ====
3
+
4
+ Pith is a static web-site generator, written in Ruby.
5
+
6
+ Using Pith, you can:
7
+
8
+ * __Express yourself succintly__ using [Haml][haml], [Sass][sass], ERb, Markdown and Textile.
9
+
10
+ * __Encapsulate common markup__ in "partial" templates.
11
+
12
+ * __Separate content and layout__ using "layout" templates.
13
+
14
+ * __Easily link pages and resources__ using relative links.
15
+
16
+ * __Quickly test changes__ using the built-in web-server.
17
+
18
+ * __Define custom helper-methods__ to increase expressiveness.
19
+
20
+ Install it
21
+ ----------
22
+
23
+ Pith is packaged as a Ruby gem. Assuming you have Ruby, install it thusly:
24
+
25
+ gem install pith
26
+
27
+ [tilt]: http://github.com/rtomayko/tilt/
28
+ [haml]: http://haml-lang.com
29
+ [sass]: http://sass-lang.com
@@ -0,0 +1,16 @@
1
+ task :default => :spec
2
+
3
+ require 'spec/rake/spectask'
4
+
5
+ Spec::Rake::SpecTask.new(:spec) do |t|
6
+ t.spec_opts << ["--color"]
7
+ end
8
+
9
+ task :default => :cucumber
10
+
11
+ require 'cucumber/rake/task'
12
+
13
+ Cucumber::Rake::Task.new(:cucumber) do |t|
14
+ t.fork = true
15
+ t.profile = 'default'
16
+ end
@@ -0,0 +1,60 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require "rubygems"
4
+ require "optparse"
5
+ require "pathname"
6
+
7
+ $input_dir = Pathname(".")
8
+
9
+ BANNER = <<EOF
10
+ usage: pith [OPTIONS] [COMMAND]
11
+
12
+ Commands: (default: "build")
13
+
14
+ build Generate the website into OUTPUT_DIR.
15
+
16
+ serve Serve the website via HTTP, re-generating as required.
17
+
18
+ EOF
19
+
20
+ OptionParser.new do |opts|
21
+ opts.banner = BANNER
22
+ opts.separator " Options:"
23
+ opts.on("-i", "--input INPUT_DIR", 'Input directory', ' (default: ".")') do |dir|
24
+ $input_dir = Pathname(dir)
25
+ end
26
+ opts.on("-o", "--output OUTPUT_DIR", 'Output directory', ' (default: "INPUT_DIR/_out")') do |dir|
27
+ $output_dir = Pathname(dir)
28
+ end
29
+ opts.on_tail("-h", "--help", "Show this message") do
30
+ puts opts
31
+ exit
32
+ end
33
+ end.parse!
34
+
35
+ unless $output_dir
36
+ $output_dir = $input_dir + "_out"
37
+ puts %{Generating to "#{$output_dir}"}
38
+ end
39
+
40
+ $: << File.expand_path("../../lib", __FILE__)
41
+
42
+ require "pith/project"
43
+ require "pith/console_logger"
44
+
45
+ @project = Pith::Project.new(:input_dir => $input_dir, :output_dir => $output_dir)
46
+ @project.logger = Pith::ConsoleLogger.new
47
+
48
+ def build
49
+ @project.build
50
+ end
51
+
52
+ def serve
53
+ require "pith/server"
54
+ port = 4321
55
+ puts %{Taking the Pith at "http://localhost:#{port}"}
56
+ Pith::Server.run(@project, :Port => port)
57
+ end
58
+
59
+ action = ARGV.shift || "build"
60
+ self.send(action)
@@ -0,0 +1,7 @@
1
+ <%
2
+ rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : ""
3
+ rerun_opts = rerun.to_s.strip.empty? ? "--format progress features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}"
4
+ std_opts = "#{rerun_opts} --format rerun --out rerun.txt --strict --tags ~@wip --require features/support --require features/step_definitions"
5
+ %>
6
+ default: <%= std_opts %>
7
+ wip: --tags @wip:3 --wip features
@@ -0,0 +1,29 @@
1
+ Feature: templates can be used as layouts
2
+
3
+ I want to encapsulate a chunk of content
4
+ So that I can use it inside a layout
5
+
6
+ Scenario: Haml template with a layout
7
+
8
+ Given input file "index.html.haml" contains
9
+ """
10
+ = include "_layout.haml" do
11
+ - content_for[:sidebar] = capture_haml do
12
+ %p SIDEBAR
13
+ %p MAIN
14
+ """
15
+ And input file "_layout.haml" contains
16
+ """
17
+ #sidebar
18
+ = content_for[:sidebar]
19
+ = yield
20
+ """
21
+
22
+ When I build the site
23
+ Then output file "index.html" should contain
24
+ """
25
+ <div id='sidebar'>
26
+ <p>SIDEBAR</p>
27
+ </div>
28
+ <p>MAIN</p>
29
+ """
@@ -0,0 +1,29 @@
1
+ Feature: templates can be used as layouts
2
+
3
+ I want to encapsulate a chunk of content
4
+ So that I can use it inside a layout
5
+
6
+ Scenario: Haml template with a layout
7
+
8
+ Given input file "index.html.haml" contains
9
+ """
10
+ = include "_layout.haml" do
11
+ - content_for[:sidebar] = capture_haml do
12
+ %p SIDEBAR
13
+ %p MAIN
14
+ """
15
+ And input file "_layout.haml" contains
16
+ """
17
+ #sidebar
18
+ = content_for[:sidebar]
19
+ = yield
20
+ """
21
+
22
+ When I build the site
23
+ Then output file "index.html" should contain
24
+ """
25
+ <div id='sidebar'>
26
+ <p>SIDEBAR</p>
27
+ </div>
28
+ <p>MAIN</p>
29
+ """
@@ -0,0 +1,24 @@
1
+ Feature: support for Haml
2
+
3
+ I want to build pages using Haml
4
+ So that I can express markup succintly
5
+
6
+ Scenario: simple Haml page
7
+
8
+ Given input file "index.html.haml" contains
9
+ """
10
+ %h1 Header
11
+
12
+ %p
13
+ Some text
14
+ """
15
+
16
+ When I build the site
17
+
18
+ Then output file "index.html" should contain
19
+ """
20
+ <h1>Header</h1>
21
+ <p>
22
+ Some text
23
+ </p>
24
+ """
@@ -0,0 +1,24 @@
1
+ Feature: support for Haml
2
+
3
+ I want to build pages using Haml
4
+ So that I can express markup succintly
5
+
6
+ Scenario: simple Haml page
7
+
8
+ Given input file "index.html.haml" contains
9
+ """
10
+ %h1 Header
11
+
12
+ %p
13
+ Some text
14
+ """
15
+
16
+ When I build the site
17
+
18
+ Then output file "index.html" should contain
19
+ """
20
+ <h1>Header</h1>
21
+ <p>
22
+ Some text
23
+ </p>
24
+ """
@@ -0,0 +1,23 @@
1
+ Feature: helper methods
2
+
3
+ I want to extend Pith with helper methods
4
+ So that I can use them in templates
5
+
6
+ Scenario: call a helper from a template
7
+
8
+ Given input file "_pith/config.rb" contains
9
+ """
10
+ project.helpers do
11
+
12
+ def greet(subject = "mate")
13
+ "Hello, #{subject}"
14
+ end
15
+
16
+ end
17
+ """
18
+
19
+ And input file "index.html.haml" contains "= greet('World')"
20
+
21
+ When I build the site
22
+
23
+ Then output file "index.html" should contain "Hello, World"
@@ -0,0 +1,26 @@
1
+ Feature: ignorable files are ignored
2
+
3
+ I want any file (or directory) beginning with "_" to be ignored
4
+ So that I can place supporting files anywhere within the input directory
5
+
6
+ Scenario: a layout template at the input root
7
+
8
+ Given input file "_layout.haml" contains
9
+ """
10
+ Blah de blah
11
+ """
12
+
13
+ When I build the site
14
+
15
+ Then output file "_layout" should not exist
16
+
17
+ Scenario: a partial in a subdirectory
18
+
19
+ Given input file "_partials/foo.html.haml" contains
20
+ """
21
+ Blah de blah
22
+ """
23
+
24
+ When I build the site
25
+
26
+ Then output file "_partials/foo.html" should not exist
@@ -0,0 +1,26 @@
1
+ Feature: ignorable files are ignored
2
+
3
+ I want any file (or directory) beginning with "_" to be ignored
4
+ So that I can place supporting files anywhere within the input directory
5
+
6
+ Scenario: a layout template at the input root
7
+
8
+ Given input file "_layout.haml" contains
9
+ """
10
+ Blah de blah
11
+ """
12
+
13
+ When I build the site
14
+
15
+ Then output file "_layout" should not exist
16
+
17
+ Scenario: a partial in a subdirectory
18
+
19
+ Given input file "_partials/foo.html.haml" contains
20
+ """
21
+ Blah de blah
22
+ """
23
+
24
+ When I build the site
25
+
26
+ Then output file "_partials/foo.html" should not exist
@@ -0,0 +1,84 @@
1
+ Feature: templates can include other templates
2
+
3
+ I want to be able to include partials
4
+ So that I can reuse template fragments
5
+
6
+ Scenario: include a partial
7
+
8
+ Given input file "index.html.haml" contains "= include('_fragment.haml')"
9
+ And input file "_fragment.haml" contains "%p blah blah"
10
+ When I build the site
11
+ Then output file "index.html" should contain "<p>blah blah</p>"
12
+
13
+ Scenario: include a partial in the same sub-directory
14
+
15
+ Given input file "subdir/page.html.haml" contains "= include('_fragment.haml')"
16
+ And input file "subdir/_fragment.haml" contains "%p blah blah"
17
+ When I build the site
18
+ Then output file "subdir/page.html" should contain "<p>blah blah</p>"
19
+
20
+ Scenario: nested includes, differing directories
21
+
22
+ Given input file "page.html.haml" contains "= include('_partials/foo.haml')"
23
+ And input file "_partials/foo.haml" contains "= include('bar.haml')"
24
+ And input file "_partials/bar.haml" contains "bananas"
25
+ When I build the site
26
+ Then output file "page.html" should contain "bananas"
27
+
28
+ Scenario: include a partial located relative to site root
29
+
30
+ Given input file "subdir/page.html.haml" contains "= include('/_partials/fragment.haml')"
31
+ And input file "_partials/fragment.haml" contains "%p blah blah"
32
+ When I build the site
33
+ Then output file "subdir/page.html" should contain "<p>blah blah</p>"
34
+
35
+ Scenario: pass local variable to a partial
36
+
37
+ Given input file "index.html.haml" contains
38
+ """
39
+ = include("_list.haml", :items => [1,2,3])
40
+ """
41
+
42
+ And input file "_list.haml" contains
43
+ """
44
+ %ul
45
+ - items.each do |i|
46
+ %li= i
47
+ """
48
+
49
+ When I build the site
50
+
51
+ Then output file "index.html" should contain
52
+ """
53
+ <ul>
54
+ <li>1</li>
55
+ <li>2</li>
56
+ <li>3</li>
57
+ </ul>
58
+ """
59
+
60
+ Scenario: use instance variable in a partial
61
+
62
+ Given input file "index.html.haml" contains
63
+ """
64
+ - @items = [1,2,3]
65
+ = include("_list.haml")
66
+ """
67
+
68
+ And input file "_list.haml" contains
69
+ """
70
+ %ul
71
+ - @items.each do |i|
72
+ %li= i
73
+ """
74
+
75
+ When I build the site
76
+
77
+ Then output file "index.html" should contain
78
+ """
79
+ <ul>
80
+ <li>1</li>
81
+ <li>2</li>
82
+ <li>3</li>
83
+ </ul>
84
+ """
@@ -0,0 +1,84 @@
1
+ Feature: templates can include other templates
2
+
3
+ I want to be able to include partials
4
+ So that I can reuse template fragments
5
+
6
+ Scenario: include a partial
7
+
8
+ Given input file "index.html.haml" contains "= include('_fragment.haml')"
9
+ And input file "_fragment.haml" contains "%p blah blah"
10
+ When I build the site
11
+ Then output file "index.html" should contain "<p>blah blah</p>"
12
+
13
+ Scenario: include a partial in the same sub-directory
14
+
15
+ Given input file "subdir/page.html.haml" contains "= include('_fragment.haml')"
16
+ And input file "subdir/_fragment.haml" contains "%p blah blah"
17
+ When I build the site
18
+ Then output file "subdir/page.html" should contain "<p>blah blah</p>"
19
+
20
+ Scenario: nested includes, differing directories
21
+
22
+ Given input file "page.html.haml" contains "= include('_partials/foo.haml')"
23
+ And input file "_partials/foo.haml" contains "= include('bar.haml')"
24
+ And input file "_partials/bar.haml" contains "bananas"
25
+ When I build the site
26
+ Then output file "page.html" should contain "bananas"
27
+
28
+ Scenario: include a partial located relative to site root
29
+
30
+ Given input file "subdir/page.html.haml" contains "= include('/_partials/fragment.haml')"
31
+ And input file "_partials/fragment.haml" contains "%p blah blah"
32
+ When I build the site
33
+ Then output file "subdir/page.html" should contain "<p>blah blah</p>"
34
+
35
+ Scenario: pass local variable to a partial
36
+
37
+ Given input file "index.html.haml" contains
38
+ """
39
+ = include("_list.haml", :items => [1,2,3])
40
+ """
41
+
42
+ And input file "_list.haml" contains
43
+ """
44
+ %ul
45
+ - items.each do |i|
46
+ %li= i
47
+ """
48
+
49
+ When I build the site
50
+
51
+ Then output file "index.html" should contain
52
+ """
53
+ <ul>
54
+ <li>1</li>
55
+ <li>2</li>
56
+ <li>3</li>
57
+ </ul>
58
+ """
59
+
60
+ Scenario: use instance variable in a partial
61
+
62
+ Given input file "index.html.haml" contains
63
+ """
64
+ - @items = [1,2,3]
65
+ = include("_list.haml")
66
+ """
67
+
68
+ And input file "_list.haml" contains
69
+ """
70
+ %ul
71
+ - @items.each do |i|
72
+ %li= i
73
+ """
74
+
75
+ When I build the site
76
+
77
+ Then output file "index.html" should contain
78
+ """
79
+ <ul>
80
+ <li>1</li>
81
+ <li>2</li>
82
+ <li>3</li>
83
+ </ul>
84
+ """