webby 0.8.4 → 0.9.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/History.txt +19 -0
- data/Manifest.txt +104 -91
- data/README.txt +27 -45
- data/Rakefile +4 -5
- data/bin/webby +2 -1
- data/bin/webby-gen +8 -0
- data/{data/Rakefile → examples/blog/Sitefile} +0 -2
- data/examples/{webby → blog}/tasks/blog.rake +5 -4
- data/{data → examples/blog}/templates/atom_feed.erb +10 -11
- data/{data → examples/blog}/templates/blog/month.erb +1 -1
- data/{data → examples/blog}/templates/blog/post.erb +1 -0
- data/{data → examples/blog}/templates/blog/year.erb +1 -1
- data/examples/presentation/{Rakefile → Sitefile} +0 -4
- data/examples/presentation/content/{_sample_code.txt → presentation/_sample_code.txt} +0 -0
- data/examples/presentation/content/{index.txt → presentation/index.txt} +0 -0
- data/{data/content → examples/presentation/content/presentation}/s5/blank.gif +0 -0
- data/{data/content → examples/presentation/content/presentation}/s5/bodybg.gif +0 -0
- data/{data/content → examples/presentation/content/presentation}/s5/framing.css +0 -0
- data/{data/content → examples/presentation/content/presentation}/s5/iepngfix.htc +0 -0
- data/{data/content → examples/presentation/content/presentation}/s5/opera.css +0 -0
- data/{data/content → examples/presentation/content/presentation}/s5/outline.css +0 -0
- data/{data/content → examples/presentation/content/presentation}/s5/pretty.css +0 -0
- data/{data/content → examples/presentation/content/presentation}/s5/print.css +0 -0
- data/{data/content → examples/presentation/content/presentation}/s5/s5-core.css +0 -0
- data/{data/content → examples/presentation/content/presentation}/s5/slides.css +0 -0
- data/{data/content → examples/presentation/content/presentation}/s5/slides.js +0 -0
- data/examples/presentation/layouts/{presentation.rhtml → presentation.txt} +3 -3
- data/examples/presentation/templates/{_partial.erb → _code_partial.erb} +0 -0
- data/examples/tumblog/Sitefile +9 -0
- data/examples/tumblog/content/css/tumblog.css +308 -0
- data/examples/tumblog/content/images/tumblog/permalink.gif +0 -0
- data/examples/tumblog/content/images/tumblog/rss.gif +0 -0
- data/examples/tumblog/content/tumblog/200806/the-noble-chicken/index.txt +12 -0
- data/examples/tumblog/content/tumblog/200807/historical-perspectives-on-the-classic-chicken-joke/index.txt +12 -0
- data/examples/tumblog/content/tumblog/200807/mad-city-chickens/index.txt +10 -0
- data/examples/tumblog/content/tumblog/200807/the-wisdom-of-the-dutch/index.txt +11 -0
- data/examples/tumblog/content/tumblog/200807/up-a-tree/index.txt +13 -0
- data/examples/tumblog/content/tumblog/index.txt +37 -0
- data/examples/tumblog/content/tumblog/rss.txt +37 -0
- data/examples/tumblog/layouts/tumblog/default.txt +44 -0
- data/examples/tumblog/layouts/tumblog/post.txt +15 -0
- data/examples/tumblog/lib/tumblog_helper.rb +32 -0
- data/examples/tumblog/tasks/tumblog.rake +30 -0
- data/examples/tumblog/templates/atom_feed.erb +40 -0
- data/examples/tumblog/templates/tumblog/conversation.erb +12 -0
- data/examples/tumblog/templates/tumblog/link.erb +10 -0
- data/examples/tumblog/templates/tumblog/photo.erb +13 -0
- data/examples/tumblog/templates/tumblog/post.erb +12 -0
- data/examples/tumblog/templates/tumblog/quote.erb +11 -0
- data/examples/webby/{Rakefile → Sitefile} +2 -2
- data/examples/webby/content/communicate/index.txt +28 -0
- data/examples/webby/content/css/background.gif +0 -0
- data/examples/webby/content/css/site.css +52 -20
- data/examples/webby/content/index.txt +7 -8
- data/examples/webby/content/learn/index.txt +28 -0
- data/examples/webby/content/reference/index.txt +3 -1
- data/examples/webby/content/release-notes/rel-0-9-0/index.txt +73 -0
- data/examples/webby/content/sitemap.txt +31 -0
- data/examples/webby/content/tips_and_tricks/index.txt +1 -1
- data/examples/webby/content/tutorial/index.txt +17 -17
- data/examples/webby/content/{manual → user-manual}/index.txt +53 -50
- data/examples/webby/layouts/{default.rhtml → default.txt} +8 -15
- data/examples/webby/templates/page.erb +1 -1
- data/examples/website/Sitefile +7 -0
- data/{data → examples/website}/content/css/blueprint/License.txt +0 -0
- data/{data → examples/website}/content/css/blueprint/Readme.txt +0 -0
- data/{data → examples/website}/content/css/blueprint/compressed/print.css +0 -0
- data/{data → examples/website}/content/css/blueprint/compressed/screen.css +0 -0
- data/{data → examples/website}/content/css/blueprint/lib/forms.css +0 -0
- data/{data → examples/website}/content/css/blueprint/lib/grid.css +0 -0
- data/{data → examples/website}/content/css/blueprint/lib/grid.png +0 -0
- data/{data → examples/website}/content/css/blueprint/lib/ie.css +0 -0
- data/{data → examples/website}/content/css/blueprint/lib/reset.css +0 -0
- data/{data → examples/website}/content/css/blueprint/lib/typography.css +0 -0
- data/{data → examples/website}/content/css/blueprint/plugins/buttons/Readme +0 -0
- data/{data → examples/website}/content/css/blueprint/plugins/buttons/buttons.css +0 -0
- data/{data → examples/website}/content/css/blueprint/plugins/buttons/icons/cross.png +0 -0
- data/{data → examples/website}/content/css/blueprint/plugins/buttons/icons/key.png +0 -0
- data/{data → examples/website}/content/css/blueprint/plugins/buttons/icons/tick.png +0 -0
- data/{data → examples/website}/content/css/blueprint/plugins/css-classes/Readme +0 -0
- data/{data → examples/website}/content/css/blueprint/plugins/css-classes/css-classes.css +0 -0
- data/{data → examples/website}/content/css/blueprint/plugins/fancy-type/Readme +0 -0
- data/{data → examples/website}/content/css/blueprint/plugins/fancy-type/fancy-type-compressed.css +0 -0
- data/{data → examples/website}/content/css/blueprint/plugins/fancy-type/fancy-type.css +0 -0
- data/{data → examples/website}/content/css/blueprint/print.css +0 -0
- data/{data → examples/website}/content/css/blueprint/screen.css +0 -0
- data/{data → examples/website}/content/css/coderay.css +0 -0
- data/{data → examples/website}/content/css/site.css +0 -0
- data/{data → examples/website}/content/index.txt +2 -1
- data/{data/layouts/default.rhtml → examples/website/layouts/default.txt} +1 -1
- data/{data → examples/website}/lib/breadcrumbs.rb +0 -0
- data/{data → examples/website}/templates/_partial.erb +0 -0
- data/{data → examples/website}/templates/page.erb +0 -0
- data/{data → examples/website}/templates/presentation.erb +0 -0
- data/lib/webby/apps/generator.rb +283 -0
- data/lib/webby/apps/main.rb +221 -0
- data/lib/webby/apps.rb +12 -0
- data/lib/webby/builder.rb +8 -10
- data/lib/webby/core_ext/enumerable.rb +11 -0
- data/lib/webby/{utils.rb → core_ext/hash.rb} +2 -26
- data/lib/webby/core_ext/kernel.rb +21 -0
- data/lib/webby/core_ext/string.rb +163 -0
- data/lib/webby/core_ext/time.rb +9 -0
- data/lib/webby/filters/haml.rb +13 -5
- data/lib/webby/filters/markdown.rb +12 -4
- data/lib/webby/filters/outline.rb +3 -2
- data/lib/webby/filters/sass.rb +12 -4
- data/lib/webby/filters/textile.rb +12 -4
- data/lib/webby/filters/tidy.rb +10 -8
- data/lib/webby/filters.rb +2 -0
- data/lib/webby/helpers/graphviz_helper.rb +1 -2
- data/lib/webby/helpers/tex_img_helper.rb +6 -10
- data/lib/webby/renderer.rb +5 -3
- data/lib/webby/resources/layout.rb +1 -1
- data/lib/webby/resources/page.rb +1 -1
- data/lib/webby/resources/resource.rb +13 -3
- data/lib/webby/resources.rb +16 -0
- data/{data → lib/webby}/tasks/build.rake +0 -0
- data/{examples/presentation → lib/webby}/tasks/create.rake +1 -1
- data/{data → lib/webby}/tasks/deploy.rake +0 -0
- data/{examples → lib}/webby/tasks/growl.rake +4 -1
- data/{data → lib/webby}/tasks/heel.rake +0 -0
- data/{data → lib/webby}/tasks/validate.rake +0 -0
- data/lib/webby.rb +11 -5
- data/spec/core_ext/hash_spec.rb +47 -0
- data/spec/core_ext/string_spec.rb +110 -0
- data/spec/core_ext/time_spec.rb +19 -0
- data/spec/webby/apps/generator_spec.rb +111 -0
- data/spec/webby/apps/main_spec.rb +75 -0
- data/spec/webby/helpers/capture_helper_spec.rb +1 -1
- data/spec/webby/resources_spec.rb +17 -0
- data/tasks/gem.rake +10 -2
- data/tasks/git.rake +41 -0
- data/tasks/rubyforge.rake +2 -2
- data/tasks/website.rake +38 -38
- metadata +125 -98
- data/data/tasks/blog.rake +0 -71
- data/data/tasks/create.rake +0 -22
- data/data/tasks/growl.rake +0 -12
- data/data/tasks/setup.rb +0 -17
- data/examples/presentation/content/s5/blank.gif +0 -0
- data/examples/presentation/content/s5/bodybg.gif +0 -0
- data/examples/presentation/content/s5/framing.css +0 -23
- data/examples/presentation/content/s5/iepngfix.htc +0 -42
- data/examples/presentation/content/s5/opera.css +0 -7
- data/examples/presentation/content/s5/outline.css +0 -15
- data/examples/presentation/content/s5/pretty.css +0 -86
- data/examples/presentation/content/s5/print.css +0 -1
- data/examples/presentation/content/s5/s5-core.css +0 -9
- data/examples/presentation/content/s5/slides.css +0 -3
- data/examples/presentation/content/s5/slides.js +0 -553
- data/examples/presentation/tasks/blog.rake +0 -71
- data/examples/presentation/tasks/build.rake +0 -27
- data/examples/presentation/tasks/deploy.rake +0 -22
- data/examples/presentation/tasks/growl.rake +0 -12
- data/examples/presentation/tasks/heel.rake +0 -28
- data/examples/presentation/tasks/setup.rb +0 -17
- data/examples/presentation/tasks/validate.rake +0 -19
- data/examples/webby/tasks/build.rake +0 -27
- data/examples/webby/tasks/create.rake +0 -22
- data/examples/webby/tasks/deploy.rake +0 -22
- data/examples/webby/tasks/heel.rake +0 -28
- data/examples/webby/tasks/setup.rb +0 -17
- data/examples/webby/tasks/validate.rake +0 -19
- data/lib/webby/main.rb +0 -227
|
@@ -97,10 +97,9 @@ module TexImgHelper
|
|
|
97
97
|
%x[pdflatex -interaction=batchmode out.tex &> #{dev_null}]
|
|
98
98
|
|
|
99
99
|
convert = "\\( -density #{res} out.pdf -trim +repage \\) "
|
|
100
|
-
convert << "\\(
|
|
101
|
-
convert << "
|
|
102
|
-
convert << "
|
|
103
|
-
convert << "+swap -compose over -composite #{out_file}"
|
|
100
|
+
convert << "\\( -clone 0 -negate -background #{fg} -channel A -combine \\) "
|
|
101
|
+
convert << "\\( -clone 0 -background #{bg} -channel A -combine \\) "
|
|
102
|
+
convert << "-delete 0 -compose dst-over -composite #{out_file}"
|
|
104
103
|
%x[convert #{convert} &> #{dev_null}]
|
|
105
104
|
ensure
|
|
106
105
|
Dir.chdir(pwd)
|
|
@@ -124,12 +123,9 @@ module TexImgHelper
|
|
|
124
123
|
end
|
|
125
124
|
end # module TexImgHelper
|
|
126
125
|
|
|
127
|
-
%
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
if 0 == $?.exitstatus
|
|
131
|
-
register(TexImgHelper)
|
|
132
|
-
end
|
|
126
|
+
if cmd_available?(%w[pdflatex --version]) \
|
|
127
|
+
and cmd_available?(%w[convert --help])
|
|
128
|
+
register(TexImgHelper)
|
|
133
129
|
end
|
|
134
130
|
|
|
135
131
|
end # module Webby::Helpers
|
data/lib/webby/renderer.rb
CHANGED
|
@@ -37,9 +37,9 @@ class Renderer
|
|
|
37
37
|
|
|
38
38
|
loop {
|
|
39
39
|
::File.open(page.destination, 'w') do |fd|
|
|
40
|
-
fd.write(renderer.
|
|
40
|
+
fd.write(renderer._layout_page)
|
|
41
41
|
end
|
|
42
|
-
break unless renderer.
|
|
42
|
+
break unless renderer._next_page
|
|
43
43
|
}
|
|
44
44
|
end
|
|
45
45
|
|
|
@@ -244,7 +244,7 @@ class Renderer
|
|
|
244
244
|
#
|
|
245
245
|
def _render_layout_for( res )
|
|
246
246
|
return unless res.layout
|
|
247
|
-
lyt = Resources.
|
|
247
|
+
lyt = Resources.find_layout(res.layout)
|
|
248
248
|
return if lyt.nil?
|
|
249
249
|
|
|
250
250
|
_track_rendering(lyt.path) {
|
|
@@ -267,6 +267,8 @@ class Renderer
|
|
|
267
267
|
# go to the next page; break out if there is no next page
|
|
268
268
|
if @pager.next?
|
|
269
269
|
@pager = @pager.next
|
|
270
|
+
@_content_for.clear
|
|
271
|
+
@_bindings.clear
|
|
270
272
|
else
|
|
271
273
|
@page.number = nil
|
|
272
274
|
return false
|
|
@@ -43,7 +43,7 @@ class Layout < Resource
|
|
|
43
43
|
return @mdata['extension'] if @mdata.has_key? 'extension'
|
|
44
44
|
|
|
45
45
|
if @mdata.has_key? 'layout'
|
|
46
|
-
lyt = ::Webby::Resources.
|
|
46
|
+
lyt = ::Webby::Resources.find_layout(@mdata['layout'])
|
|
47
47
|
ext = lyt ? lyt.extension : nil
|
|
48
48
|
end
|
|
49
49
|
end
|
data/lib/webby/resources/page.rb
CHANGED
|
@@ -105,7 +105,7 @@ class Page < Resource
|
|
|
105
105
|
return @mdata['extension'] if @mdata.has_key? 'extension'
|
|
106
106
|
|
|
107
107
|
if @mdata.has_key? 'layout'
|
|
108
|
-
lyt = ::Webby::Resources.
|
|
108
|
+
lyt = ::Webby::Resources.find_layout(@mdata['layout'])
|
|
109
109
|
ext = lyt ? lyt.extension : nil
|
|
110
110
|
return ext if ext
|
|
111
111
|
end
|
|
@@ -72,10 +72,20 @@ class Resource
|
|
|
72
72
|
# resource[key] => value or nil
|
|
73
73
|
#
|
|
74
74
|
# Returns the value associated with the given meta-data key. Key is
|
|
75
|
-
#
|
|
75
|
+
# converted into a string.
|
|
76
76
|
#
|
|
77
77
|
def []( key )
|
|
78
|
-
@mdata[key]
|
|
78
|
+
@mdata[key.to_s]
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# call-seq:
|
|
82
|
+
# resource[key] = value
|
|
83
|
+
#
|
|
84
|
+
# Sets the given meta-data key to the value. Key is converted into a
|
|
85
|
+
# string.
|
|
86
|
+
#
|
|
87
|
+
def []=( key, value )
|
|
88
|
+
@mdata[key.to_s] = value
|
|
79
89
|
end
|
|
80
90
|
|
|
81
91
|
# call-seq:
|
|
@@ -111,7 +121,7 @@ class Resource
|
|
|
111
121
|
# check to see if the layout is dirty, and if it is then we
|
|
112
122
|
# are dirty, too
|
|
113
123
|
if @mdata.has_key? 'layout'
|
|
114
|
-
lyt = ::Webby::Resources.
|
|
124
|
+
lyt = ::Webby::Resources.find_layout(@mdata['layout'])
|
|
115
125
|
unless lyt.nil?
|
|
116
126
|
return true if lyt.dirty?
|
|
117
127
|
end
|
data/lib/webby/resources.rb
CHANGED
|
@@ -71,6 +71,22 @@ module Webby::Resources
|
|
|
71
71
|
filename.sub(%r/\A(?:\.\/|\/)/o, '').freeze
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
+
# Returns the layout resource corresponding to the given _filename_ or
|
|
75
|
+
# +nil+ if no layout exists under that filename.
|
|
76
|
+
#
|
|
77
|
+
def find_layout( filename )
|
|
78
|
+
return if filename.nil?
|
|
79
|
+
|
|
80
|
+
fn = ::Webby::Resources::File.basename(filename)
|
|
81
|
+
dir = ::File.dirname(filename)
|
|
82
|
+
dir = '.' == dir ? '' : dir
|
|
83
|
+
|
|
84
|
+
layouts.find(:filename => fn, :in_directory => dir)
|
|
85
|
+
|
|
86
|
+
rescue RuntimeError
|
|
87
|
+
raise Webby::Error, "could not find layout #{filename.inspect}"
|
|
88
|
+
end
|
|
89
|
+
|
|
74
90
|
end # class << self
|
|
75
91
|
|
|
76
92
|
end # module Webby::Resources
|
|
File without changes
|
|
@@ -10,7 +10,7 @@ namespace :create do
|
|
|
10
10
|
|
|
11
11
|
desc "Create a new #{name}"
|
|
12
12
|
task name do |t|
|
|
13
|
-
page, title, dir = Webby::Builder.new_page_info
|
|
13
|
+
page, title, dir = Webby::Builder.new_page_info
|
|
14
14
|
page = Webby::Builder.create(page, :from => template,
|
|
15
15
|
:locals => {:title => title, :directory => dir})
|
|
16
16
|
exec(::Webby.editor, page) unless ::Webby.editor.nil?
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/lib/webby.rb
CHANGED
|
@@ -18,7 +18,7 @@ Logging::Appender.stdout.layout = Logging::Layouts::Pattern.new(
|
|
|
18
18
|
module Webby
|
|
19
19
|
|
|
20
20
|
# :stopdoc:
|
|
21
|
-
VERSION = '0.
|
|
21
|
+
VERSION = '0.9.0' # :nodoc:
|
|
22
22
|
LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
|
|
23
23
|
PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
|
|
24
24
|
# :startdoc:
|
|
@@ -47,6 +47,7 @@ module Webby
|
|
|
47
47
|
:base => nil,
|
|
48
48
|
:create_mode => 'page',
|
|
49
49
|
:blog_dir => 'blog',
|
|
50
|
+
:tumblog_dir => 'tumblog',
|
|
50
51
|
|
|
51
52
|
# Items for running the heel webserver
|
|
52
53
|
:heel_port => 4331,
|
|
@@ -159,7 +160,7 @@ module Webby
|
|
|
159
160
|
# <tt>File.join</tt>.
|
|
160
161
|
#
|
|
161
162
|
def self.libpath( *args )
|
|
162
|
-
args.empty? ? LIBPATH : ::File.join(LIBPATH,
|
|
163
|
+
args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
|
|
163
164
|
end
|
|
164
165
|
|
|
165
166
|
# Returns the path for Webby. If any arguments are given,
|
|
@@ -167,7 +168,7 @@ module Webby
|
|
|
167
168
|
# <tt>File.join</tt>.
|
|
168
169
|
#
|
|
169
170
|
def self.path( *args )
|
|
170
|
-
args.empty? ? PATH : ::File.join(PATH,
|
|
171
|
+
args.empty? ? PATH : ::File.join(PATH, args.flatten)
|
|
171
172
|
end
|
|
172
173
|
|
|
173
174
|
# call-seq:
|
|
@@ -201,19 +202,24 @@ end # module Webby
|
|
|
201
202
|
|
|
202
203
|
|
|
203
204
|
# call-seq:
|
|
204
|
-
# try_require( library ) => true or false
|
|
205
|
+
# try_require( library, gemname = nil ) => true or false
|
|
205
206
|
#
|
|
206
207
|
# Try to laod the given _library_ using the built-in require, but do not
|
|
207
208
|
# raise a LoadError if unsuccessful. Returns +true+ if the _library_ was
|
|
208
209
|
# successfully loaded; returns +false+ otherwise.
|
|
209
210
|
#
|
|
210
|
-
|
|
211
|
+
# If a _gemname_ is given, then the "gem gemname" command will be called
|
|
212
|
+
# before the library is loaded.
|
|
213
|
+
#
|
|
214
|
+
def try_require( lib, gemname = nil )
|
|
215
|
+
gem gemname unless gemname.nil?
|
|
211
216
|
require lib
|
|
212
217
|
true
|
|
213
218
|
rescue LoadError
|
|
214
219
|
false
|
|
215
220
|
end
|
|
216
221
|
|
|
222
|
+
Webby.require_all_libs_relative_to(__FILE__, ::File.join(%w[webby core_ext]))
|
|
217
223
|
Webby.require_all_libs_relative_to(__FILE__)
|
|
218
224
|
|
|
219
225
|
end # unless defined?
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
|
|
2
|
+
require ::File.expand_path(
|
|
3
|
+
::File.join(::File.dirname(__FILE__), %w[.. spec_helper]))
|
|
4
|
+
|
|
5
|
+
describe Hash do
|
|
6
|
+
|
|
7
|
+
it "should stringify keys" do
|
|
8
|
+
h = {
|
|
9
|
+
:one => 1,
|
|
10
|
+
:two => 2,
|
|
11
|
+
3 => 'three',
|
|
12
|
+
[3,4] => :thirty_four
|
|
13
|
+
}.stringify_keys
|
|
14
|
+
h.keys.sort.should == %w[3 34 one two]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should symbolize keys" do
|
|
18
|
+
h = {
|
|
19
|
+
'foo' => 42,
|
|
20
|
+
'bar' => 'baz'
|
|
21
|
+
}.symbolize_keys
|
|
22
|
+
|
|
23
|
+
h.has_key?('foo').should == false
|
|
24
|
+
h.has_key?('bar').should == false
|
|
25
|
+
|
|
26
|
+
h.has_key?(:foo).should == true
|
|
27
|
+
h.has_key?(:bar).should == true
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
describe "when sanitizing values" do
|
|
31
|
+
[
|
|
32
|
+
['none', nil], ['nil', nil],
|
|
33
|
+
['true', true], ['yes', true],
|
|
34
|
+
['false', false], ['no', false]
|
|
35
|
+
].each do |from, to|
|
|
36
|
+
|
|
37
|
+
it "should convert #{from.inspect} to #{to.inspect}" do
|
|
38
|
+
h = {:key => from}
|
|
39
|
+
h.sanitize!
|
|
40
|
+
h[:key].should == to
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# EOF
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
|
|
2
|
+
require ::File.expand_path(
|
|
3
|
+
::File.join(::File.dirname(__FILE__), %w[.. spec_helper]))
|
|
4
|
+
|
|
5
|
+
describe String do
|
|
6
|
+
|
|
7
|
+
describe "#/" do
|
|
8
|
+
it "should join other strings to form a file path" do
|
|
9
|
+
path = 'foo' / 'bar' / 'baz'
|
|
10
|
+
path.should == ::File.join(%w[foo bar baz])
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe "#titlecase" do
|
|
15
|
+
it "should not capitalize small words" do
|
|
16
|
+
'and on the other hand of fate we have a ring'.titlecase.
|
|
17
|
+
should == 'And on the Other Hand of Fate We Have a Ring'
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "should not modify words that contain capital letters other than the first character" do
|
|
21
|
+
'the iTunes store is down'.titlecase.
|
|
22
|
+
should == 'The iTunes Store Is Down'
|
|
23
|
+
"what's up with the MacUpdate site".titlecase.
|
|
24
|
+
should == "What's Up With the MacUpdate Site"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "should skip words with line dots (example.com or del.icio.us)" do
|
|
28
|
+
'the website example.com is used in documentation'.titlecase.
|
|
29
|
+
should == 'The Website example.com Is Used in Documentation'
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "should always capitlize the first and last words of the title" do
|
|
33
|
+
'a little bit of'.titlecase.should == 'A Little Bit Of'
|
|
34
|
+
'iTunes is being released'.titlecase.should == 'iTunes Is Being Released'
|
|
35
|
+
%q("a quoted title if").titlecase.should == %q("A Quoted Title If")
|
|
36
|
+
%q(and if you do via?).titlecase.should == %q(And if You Do Via?)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "should caplitalize a small word after a colon" do
|
|
40
|
+
%q(starting sub-phrase with a small word: a trick, perhaps?).titlecase.
|
|
41
|
+
should == %q(Starting Sub-Phrase With a Small Word: A Trick, Perhaps?)
|
|
42
|
+
|
|
43
|
+
%q(sub-phrase with a small word in quotes: 'a trick, perhaps?').titlecase.
|
|
44
|
+
should == %q(Sub-Phrase With a Small Word in Quotes: 'A Trick, Perhaps?')
|
|
45
|
+
|
|
46
|
+
%q(sub-phrase with a small word in quotes: "a trick, perhaps?").titlecase.
|
|
47
|
+
should == %q(Sub-Phrase With a Small Word in Quotes: "A Trick, Perhaps?")
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "should properly handle contractions" do
|
|
51
|
+
%q(this isn't going to work).titlecase.
|
|
52
|
+
should == %q(This Isn't Going to Work)
|
|
53
|
+
|
|
54
|
+
%q(MicroSoft won't go down that route).titlecase.
|
|
55
|
+
should == %q(MicroSoft Won't Go Down That Route)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
it "should capitalize phrases inside quotations" do
|
|
59
|
+
%q(Q&A with steve jobs: 'that's what happens in technology').titlecase.
|
|
60
|
+
should == %q(Q&A With Steve Jobs: 'That's What Happens in Technology')
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
describe "#to_url" do
|
|
66
|
+
it "should convert characters to words" do
|
|
67
|
+
given = "10% Inspiration & 90% Perspiration"
|
|
68
|
+
expected = "10-percent-inspiration-and-90-percent-perspiration"
|
|
69
|
+
|
|
70
|
+
given.to_url.should == expected
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it "should convert entities to words" do
|
|
74
|
+
given = "Tea & crumpets & crêpes for me!"
|
|
75
|
+
expected = "tea-and-crumpets-and-crepes-for-me"
|
|
76
|
+
|
|
77
|
+
given.to_url.should == expected
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
it "should remove html tags" do
|
|
81
|
+
given = "I Am <strong>Awesome</strong>"
|
|
82
|
+
expected = "i-am-awesome"
|
|
83
|
+
|
|
84
|
+
given.to_url.should == expected
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
it "should convert ellipses" do
|
|
88
|
+
given = "The Suspense... Is... Killing Me"
|
|
89
|
+
expected = "the-suspense-dot-dot-dot-is-dot-dot-dot-killing-me"
|
|
90
|
+
|
|
91
|
+
given.to_url.should == expected
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
it "should convert underscores to dashes" do
|
|
95
|
+
given = "How to use attr_accessible and attr_protected"
|
|
96
|
+
expected = "how-to-use-attr-accessible-and-attr-protected"
|
|
97
|
+
|
|
98
|
+
given.to_url.should == expected
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
it "should remove punctuation" do
|
|
102
|
+
given = "I'm just making sure there's nothing wrong with things!"
|
|
103
|
+
expected = "im-just-making-sure-theres-nothing-wrong-with-things"
|
|
104
|
+
|
|
105
|
+
given.to_url.should == expected
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# EOF
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
|
|
2
|
+
require ::File.expand_path(
|
|
3
|
+
::File.join(::File.dirname(__FILE__), %w[.. spec_helper]))
|
|
4
|
+
|
|
5
|
+
describe Time do
|
|
6
|
+
|
|
7
|
+
it "should serialize to a YAML string" do
|
|
8
|
+
now = Time.now
|
|
9
|
+
|
|
10
|
+
utc_offset = now.utc_offset / 3600
|
|
11
|
+
sign, utc_offset = utc_offset < 0 ? ['-', -utc_offset] : ['', utc_offset]
|
|
12
|
+
str = "%s.%06d %s%02d:00" %
|
|
13
|
+
[now.strftime('%Y-%m-%d %H:%M:%S'), now.usec, sign, utc_offset]
|
|
14
|
+
|
|
15
|
+
now.to_y.should == str
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# EOF
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
|
|
2
|
+
require ::File.expand_path(
|
|
3
|
+
::File.join(::File.dirname(__FILE__), %w[.. .. spec_helper]))
|
|
4
|
+
require 'stringio'
|
|
5
|
+
|
|
6
|
+
describe Webby::Apps::Generator do
|
|
7
|
+
|
|
8
|
+
before :each do
|
|
9
|
+
@generator = Webby::Apps::Generator.new
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
it "should return a list of available templates" do
|
|
13
|
+
ary = %w[blog presentation tumblog webby website].map {|t| Webby.path('examples', t)}
|
|
14
|
+
@generator.templates.should == ary
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it "should pretend to create a site" do
|
|
18
|
+
@generator.parse %w[-p website foo]
|
|
19
|
+
@generator.pretend?.should == true
|
|
20
|
+
|
|
21
|
+
@generator = Webby::Apps::Generator.new
|
|
22
|
+
@generator.parse %w[website foo]
|
|
23
|
+
@generator.pretend?.should == false
|
|
24
|
+
|
|
25
|
+
@generator = Webby::Apps::Generator.new
|
|
26
|
+
@generator.parse %w[--pretend website foo]
|
|
27
|
+
@generator.pretend?.should == true
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should return a list of all the site files from the template" do
|
|
31
|
+
@generator.parse %w[website foo]
|
|
32
|
+
|
|
33
|
+
h = @generator.site_files
|
|
34
|
+
h.keys.sort.should == [
|
|
35
|
+
"",
|
|
36
|
+
"content",
|
|
37
|
+
"content/css",
|
|
38
|
+
"content/css/blueprint",
|
|
39
|
+
"content/css/blueprint/compressed",
|
|
40
|
+
"content/css/blueprint/lib",
|
|
41
|
+
"content/css/blueprint/plugins",
|
|
42
|
+
"content/css/blueprint/plugins/buttons",
|
|
43
|
+
"content/css/blueprint/plugins/buttons/icons",
|
|
44
|
+
"content/css/blueprint/plugins/css-classes",
|
|
45
|
+
"content/css/blueprint/plugins/fancy-type",
|
|
46
|
+
"layouts",
|
|
47
|
+
"lib",
|
|
48
|
+
"templates"
|
|
49
|
+
]
|
|
50
|
+
h["content"].should == %w[content/index.txt]
|
|
51
|
+
h["layouts"].should == %w[layouts/default.txt]
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
describe "when parsing command line arguments" do
|
|
55
|
+
|
|
56
|
+
before :each do
|
|
57
|
+
@strio = StringIO.new
|
|
58
|
+
@generator = Webby::Apps::Generator.new
|
|
59
|
+
@generator.instance_variable_set(:@stdout, @strio)
|
|
60
|
+
|
|
61
|
+
class << @strio
|
|
62
|
+
def to_s
|
|
63
|
+
seek 0
|
|
64
|
+
str = read
|
|
65
|
+
truncate 0
|
|
66
|
+
return str
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it "should force the overwriting of files on collision" do
|
|
72
|
+
@generator.options[:collision].should be_nil
|
|
73
|
+
@generator.parse %w[-f website foo]
|
|
74
|
+
@generator.options[:collision].should == :force
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it "should skip files on collision" do
|
|
78
|
+
@generator.options[:collision].should be_nil
|
|
79
|
+
@generator.parse %w[-s website foo]
|
|
80
|
+
@generator.options[:collision].should == :skip
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it "should update only the rake files in the tasks folder" do
|
|
84
|
+
@generator.options[:update].should be_nil
|
|
85
|
+
@generator.parse %w[-u website foo]
|
|
86
|
+
@generator.options[:update].should == true
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
it "should pretend to generate / alter files" do
|
|
90
|
+
@generator.options[:pretend].should be_nil
|
|
91
|
+
@generator.parse %w[-p website foo]
|
|
92
|
+
@generator.options[:pretend].should == true
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
it "should exit if a site is not specified" do
|
|
96
|
+
lambda{@generator.parse %w[website]}.
|
|
97
|
+
should raise_error(SystemExit, 'exit')
|
|
98
|
+
@strio.to_s.split("\n").first.
|
|
99
|
+
should == 'Usage: webby-gen [options] template site'
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
it "should exit if an unknown template is given" do
|
|
103
|
+
lambda{@generator.parse %w[foo bar]}.
|
|
104
|
+
should raise_error(SystemExit, 'exit')
|
|
105
|
+
@strio.to_s.split("\n").last.
|
|
106
|
+
should == " Could not find template 'foo'"
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# EOF
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
|
|
2
|
+
require ::File.expand_path(
|
|
3
|
+
::File.join(::File.dirname(__FILE__), %w[.. .. spec_helper]))
|
|
4
|
+
|
|
5
|
+
# ---------------------------------------------------------------------------
|
|
6
|
+
describe Webby::Apps::Main do
|
|
7
|
+
before do
|
|
8
|
+
@main = Webby::Apps::Main.new
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
describe ".capture_command_line_args" do
|
|
12
|
+
it "should set the raw arguments" do
|
|
13
|
+
raw = ["The Raw Arguments"]
|
|
14
|
+
args = @main.capture_command_line_args(raw)
|
|
15
|
+
args.raw.should == raw
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "should set the page with one argument by downcasing" do
|
|
19
|
+
page = "This-is-a-page"
|
|
20
|
+
args = @main.capture_command_line_args([page])
|
|
21
|
+
args.page.should == page.downcase
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "should set the page with two or more arguments by joining" do
|
|
25
|
+
page = %w(this is a page)
|
|
26
|
+
args = @main.capture_command_line_args(page)
|
|
27
|
+
args.page.should == page.join('-')
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it "should set the dir from the page's dirname" do
|
|
31
|
+
page = "foo/bar/this-is-a-page.txt"
|
|
32
|
+
args = @main.capture_command_line_args([page])
|
|
33
|
+
args.dir.should == "foo/bar"
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it "should set the slug from the page's basename" do
|
|
37
|
+
page = "foo/bar/this-is-a-page.txt"
|
|
38
|
+
args = @main.capture_command_line_args([page])
|
|
39
|
+
args.slug.should == "this-is-a-page"
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it "should turn the slug into a url" do
|
|
43
|
+
page = "10% Inspiration & 90% Perspiration"
|
|
44
|
+
args = @main.capture_command_line_args([page])
|
|
45
|
+
args.slug.should == "10-percent-inspiration-and-90-percent-perspiration"
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "should set the page by combining the dir and slug" do
|
|
49
|
+
page = "10% Inspiration & 90% Perspiration"
|
|
50
|
+
args = @main.capture_command_line_args([page])
|
|
51
|
+
args.page.should == "10-percent-inspiration-and-90-percent-perspiration"
|
|
52
|
+
|
|
53
|
+
page = "foo/bar/10% Inspiration & 90% Perspiration"
|
|
54
|
+
args = @main.capture_command_line_args([page])
|
|
55
|
+
args.page.should == "foo/bar/10-percent-inspiration-and-90-percent-perspiration"
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# TODO: Is this desired behavior?
|
|
59
|
+
it "should set the title by joining the raw args, getting the basename, and titlecasing" do
|
|
60
|
+
page = "foo/bar/this-is-a-page.txt"
|
|
61
|
+
args = @main.capture_command_line_args([page])
|
|
62
|
+
args.title.should == "This-Is-a-Page"
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
describe ".parse" do
|
|
67
|
+
it "should pass environment variables to the rake application" do
|
|
68
|
+
ARGV = ary = []
|
|
69
|
+
args = %w[rebuild foo BASE=http://www.example.com bar]
|
|
70
|
+
@main.parse args
|
|
71
|
+
ary.should == %w[rebuild BASE=http://www.example.com]
|
|
72
|
+
args.should == %w[foo bar]
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
require ::File.join(::File.dirname(__FILE__), %w[.. spec_helper])
|
|
4
|
+
|
|
5
|
+
# ---------------------------------------------------------------------------
|
|
6
|
+
describe Webby::Resources do
|
|
7
|
+
it "should raise a useful error if there are no layouts" do
|
|
8
|
+
layouts = mock("Layouts")
|
|
9
|
+
Webby::Resources.stub!(:layouts).and_return(layouts)
|
|
10
|
+
layouts.should_receive(:find).and_raise RuntimeError
|
|
11
|
+
|
|
12
|
+
lambda do
|
|
13
|
+
Webby::Resources.find_layout("default")
|
|
14
|
+
end.should raise_error(Webby::Error, 'could not find layout "default"')
|
|
15
|
+
|
|
16
|
+
end
|
|
17
|
+
end
|
data/tasks/gem.rake
CHANGED
|
@@ -91,8 +91,11 @@ namespace :gem do
|
|
|
91
91
|
end
|
|
92
92
|
|
|
93
93
|
desc 'Install the gem'
|
|
94
|
-
task :install => [:clobber, :package] do
|
|
95
|
-
sh "#{SUDO} #{GEM} install --
|
|
94
|
+
task :install => [:clobber, 'gem:package'] do
|
|
95
|
+
sh "#{SUDO} #{GEM} install --local pkg/#{PROJ.gem._spec.full_name}"
|
|
96
|
+
|
|
97
|
+
# use this version of the command for rubygems > 1.0.0
|
|
98
|
+
#sh "#{SUDO} #{GEM} install --no-update-sources pkg/#{PROJ.gem._spec.full_name}"
|
|
96
99
|
end
|
|
97
100
|
|
|
98
101
|
desc 'Uninstall the gem'
|
|
@@ -106,6 +109,11 @@ namespace :gem do
|
|
|
106
109
|
desc 'Reinstall the gem'
|
|
107
110
|
task :reinstall => [:uninstall, :install]
|
|
108
111
|
|
|
112
|
+
desc 'Cleanup the gem'
|
|
113
|
+
task :cleanup do
|
|
114
|
+
sh "#{SUDO} #{GEM} cleanup #{PROJ.gem._spec.name}"
|
|
115
|
+
end
|
|
116
|
+
|
|
109
117
|
end # namespace :gem
|
|
110
118
|
|
|
111
119
|
desc 'Alias to gem:package'
|