pith 0.4.0 → 0.5.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.
- checksums.yaml +7 -0
- data/README.markdown +1 -1
- data/cucumber.yml +1 -1
- data/features/layouts.feature +7 -7
- data/features/relative_linking.feature +2 -2
- data/features/step_definitions/build_steps.rb +1 -1
- data/features/textile.feature +11 -5
- data/lib/pith/input.rb +1 -0
- data/lib/pith/plugins/compass.rb +1 -1
- data/lib/pith/render_context.rb +0 -3
- data/lib/pith/version.rb +1 -1
- data/spec/pith/config_spec.rb +9 -9
- data/spec/pith/input_spec.rb +17 -9
- data/spec/pith/pathname_ext_spec.rb +5 -5
- data/spec/pith/plugins/publication_spec.rb +7 -7
- data/spec/pith/project_spec.rb +13 -13
- data/spec/pith/server_spec.rb +8 -9
- data/spec/spec_helper.rb +2 -0
- metadata +74 -140
- data/features/content_for.feature~ +0 -29
- data/features/haml.feature~ +0 -24
- data/features/helpers.feature~ +0 -23
- data/features/ignorance.feature~ +0 -37
- data/features/include.feature~ +0 -84
- data/features/incremental_rebuild.feature~ +0 -24
- data/features/layouts.feature~ +0 -63
- data/features/linking.feature~ +0 -79
- data/features/metadata.feature~ +0 -20
- data/features/relative_linking.feature~ +0 -109
- data/features/step_definitions/build_steps.rb~ +0 -66
- data/features/support/env.rb~ +0 -86
- data/features/support/rspec_matchers.rb~ +0 -5
- data/features/textile.feature~ +0 -29
- data/features/verbatim.feature~ +0 -32
- data/lib/pith.rb~ +0 -1
- data/lib/pith/console_logger.rb~ +0 -16
- data/lib/pith/input.rb~ +0 -20
- data/lib/pith/metadata.rb~ +0 -26
- data/lib/pith/pathname_ext.rb~ +0 -16
- data/lib/pith/plugins/publication.rb~ +0 -2
- data/lib/pith/plugins/publication/input.rb~ +0 -50
- data/lib/pith/plugins/publication/project.rb~ +0 -14
- data/lib/pith/project.rb~ +0 -143
- data/lib/pith/reference_error.rb~ +0 -5
- data/lib/pith/render_context.rb~ +0 -117
- data/lib/pith/server.rb~ +0 -46
- data/lib/pith/version.rb~ +0 -3
- data/lib/pith/watcher.rb~ +0 -32
- data/sample/_out/index.html +0 -14
- data/sample/_out/stylesheets/app.css +0 -38
data/lib/pith/render_context.rb~
DELETED
@@ -1,117 +0,0 @@
|
|
1
|
-
require "ostruct"
|
2
|
-
require "pathname"
|
3
|
-
require "pith/reference_error"
|
4
|
-
require "set"
|
5
|
-
require "tilt"
|
6
|
-
|
7
|
-
module Pith
|
8
|
-
|
9
|
-
class RenderContext
|
10
|
-
|
11
|
-
include Tilt::CompileSite
|
12
|
-
|
13
|
-
def initialize(project)
|
14
|
-
@project = project
|
15
|
-
@input_stack = []
|
16
|
-
@dependencies = project.config_files.dup
|
17
|
-
self.extend(project.helper_module)
|
18
|
-
end
|
19
|
-
|
20
|
-
attr_reader :project
|
21
|
-
|
22
|
-
def page
|
23
|
-
@input_stack.first
|
24
|
-
end
|
25
|
-
|
26
|
-
def current_input
|
27
|
-
@input_stack.last
|
28
|
-
end
|
29
|
-
|
30
|
-
def render(input, locals = {}, &block)
|
31
|
-
with_input(input) do
|
32
|
-
result = input.render(self, locals, &block)
|
33
|
-
layout_ref = input.meta["layout"]
|
34
|
-
result = render_ref(layout_ref) { result } if layout_ref
|
35
|
-
result
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
attr_reader :dependencies
|
40
|
-
|
41
|
-
def include(template_ref, locals = {}, &block)
|
42
|
-
content_block = if block_given?
|
43
|
-
content = capture_haml(&block)
|
44
|
-
proc { content }
|
45
|
-
end
|
46
|
-
render_ref(template_ref, locals, &content_block)
|
47
|
-
end
|
48
|
-
|
49
|
-
alias :inside :include
|
50
|
-
|
51
|
-
def content_for
|
52
|
-
@content_for_hash ||= Hash.new { "" }
|
53
|
-
end
|
54
|
-
|
55
|
-
def relative_url_to(target_path)
|
56
|
-
url = target_path.relative_path_from(page.path.parent).to_str
|
57
|
-
url = url.sub(/index\.html$/, "") if project.assume_directory_index
|
58
|
-
url = url.sub(/\.html$/, "") if project.assume_content_negotiation
|
59
|
-
url = "./" if url.empty?
|
60
|
-
Pathname(url)
|
61
|
-
end
|
62
|
-
|
63
|
-
def href(target_ref)
|
64
|
-
relative_url_to(resolve_reference(target_ref))
|
65
|
-
end
|
66
|
-
|
67
|
-
def link(target_ref, label = nil)
|
68
|
-
target_path = resolve_reference(target_ref)
|
69
|
-
label ||= begin
|
70
|
-
target_input = input(target_path)
|
71
|
-
record_dependency_on(target_input.file)
|
72
|
-
target_input.title
|
73
|
-
rescue ReferenceError
|
74
|
-
"???"
|
75
|
-
end
|
76
|
-
url = relative_url_to(target_path)
|
77
|
-
%{<a href="#{url}">#{label}</a>}
|
78
|
-
end
|
79
|
-
|
80
|
-
def record_dependency_on(file)
|
81
|
-
@dependencies << file
|
82
|
-
end
|
83
|
-
|
84
|
-
private
|
85
|
-
|
86
|
-
def resolve_reference(ref)
|
87
|
-
if ref.respond_to?(:output_path)
|
88
|
-
ref.output_path
|
89
|
-
else
|
90
|
-
current_input.resolve_path(ref)
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
def input(path)
|
95
|
-
input = project.input(path)
|
96
|
-
raise(ReferenceError, %{Can't find "#{path}"}) if input.nil?
|
97
|
-
input
|
98
|
-
end
|
99
|
-
|
100
|
-
def with_input(input)
|
101
|
-
record_dependency_on(input.file)
|
102
|
-
@input_stack.push(input)
|
103
|
-
begin
|
104
|
-
yield
|
105
|
-
ensure
|
106
|
-
@input_stack.pop
|
107
|
-
end
|
108
|
-
end
|
109
|
-
|
110
|
-
def render_ref(template_ref, locals = {}, &block)
|
111
|
-
template_input = input(resolve_reference(template_ref))
|
112
|
-
render(template_input, locals, &block)
|
113
|
-
end
|
114
|
-
|
115
|
-
end
|
116
|
-
|
117
|
-
end
|
data/lib/pith/server.rb~
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
require "rack"
|
2
|
-
require "adsf/rack"
|
3
|
-
|
4
|
-
module Pith
|
5
|
-
|
6
|
-
module Server
|
7
|
-
|
8
|
-
def new(project)
|
9
|
-
Rack::Builder.new do
|
10
|
-
use Rack::CommonLogger
|
11
|
-
use Rack::ShowExceptions
|
12
|
-
use Rack::Lint
|
13
|
-
use Adsf::Rack::IndexFileFinder, :root => project.output_dir
|
14
|
-
use Pith::Server::DefaultToHtml, project.output_dir
|
15
|
-
run Rack::Directory.new(project.output_dir)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
extend self
|
20
|
-
|
21
|
-
class DefaultToHtml
|
22
|
-
|
23
|
-
def initialize(app, root)
|
24
|
-
@app = app
|
25
|
-
@root = root
|
26
|
-
end
|
27
|
-
|
28
|
-
def call(env)
|
29
|
-
|
30
|
-
path_info = ::Rack::Utils.unescape(env["PATH_INFO"])
|
31
|
-
file = "#{@root}#{path_info}"
|
32
|
-
unless File.exist?(file)
|
33
|
-
if File.exist?("#{file}.html")
|
34
|
-
env["PATH_INFO"] += ".html"
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
@app.call(env)
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
|
46
|
-
end
|
data/lib/pith/version.rb~
DELETED
data/lib/pith/watcher.rb~
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
module Pith
|
2
|
-
|
3
|
-
class Watcher
|
4
|
-
|
5
|
-
DEFAULT_INTERVAL = 2
|
6
|
-
|
7
|
-
def initialize(project, options = {})
|
8
|
-
@project = project
|
9
|
-
@interval = DEFAULT_INTERVAL
|
10
|
-
options.each do |k,v|
|
11
|
-
send("#{k}=", v)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
attr_accessor :project
|
16
|
-
attr_accessor :interval
|
17
|
-
|
18
|
-
def call
|
19
|
-
loop do
|
20
|
-
begin
|
21
|
-
project.build
|
22
|
-
rescue Exception => e
|
23
|
-
$stderr.puts "ERROR: #{e}"
|
24
|
-
e.backtrace.each { |line| $stderr.puts line }
|
25
|
-
end
|
26
|
-
sleep(interval)
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
data/sample/_out/index.html
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<link href='stylesheets/app.css' rel='stylesheet' type='text/css' />
|
5
|
-
</head>
|
6
|
-
<body>
|
7
|
-
<ol class='tabs'>
|
8
|
-
<li><a href="index.html">Introduction</a></li>
|
9
|
-
</ol>
|
10
|
-
<div class='box'>
|
11
|
-
<p>This is my site. Do you like it?</p>
|
12
|
-
</div>
|
13
|
-
</body>
|
14
|
-
</html>
|
@@ -1,38 +0,0 @@
|
|
1
|
-
.sidebar {
|
2
|
-
width: 19%;
|
3
|
-
float: right; }
|
4
|
-
|
5
|
-
.main {
|
6
|
-
width: 79%; }
|
7
|
-
|
8
|
-
.box {
|
9
|
-
-moz-border-radius: 0.5em;
|
10
|
-
-webkit-border-radius: 0.5em;
|
11
|
-
border: 2px solid grey;
|
12
|
-
padding: 0.5em; }
|
13
|
-
.box .heading {
|
14
|
-
font-size: 120%;
|
15
|
-
border-bottom: 1px solid #aaaaaa;
|
16
|
-
font-weight: bold;
|
17
|
-
margin-bottom: 0.5em; }
|
18
|
-
|
19
|
-
ol.tabs {
|
20
|
-
position: relative;
|
21
|
-
padding: 0;
|
22
|
-
margin: 0 0 -2px 1em;
|
23
|
-
list-style-type: none; }
|
24
|
-
ol.tabs li {
|
25
|
-
display: inline-block;
|
26
|
-
border: 2px solid grey;
|
27
|
-
-moz-border-radius-topleft: 0.5em;
|
28
|
-
-webkit-border-top-left-radius: 0.5em;
|
29
|
-
-moz-border-radius-topright: 0.5em;
|
30
|
-
-webkit-border-top-right-radius: 0.5em;
|
31
|
-
background: #cccccc;
|
32
|
-
padding: 0.5em; }
|
33
|
-
ol.tabs li.current {
|
34
|
-
border-bottom: 2px solid white;
|
35
|
-
background: white; }
|
36
|
-
ol.tabs li a {
|
37
|
-
color: inherit;
|
38
|
-
text-decoration: none; }
|