giraffesoft-webby 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +218 -0
- data/README.rdoc +92 -0
- data/Rakefile +62 -0
- data/bin/webby +41 -0
- data/bin/webby-gen +41 -0
- data/examples/blog/Sitefile +7 -0
- data/examples/blog/tasks/blog.rake +72 -0
- data/examples/blog/templates/atom_feed.erb +40 -0
- data/examples/blog/templates/blog/month.erb +22 -0
- data/examples/blog/templates/blog/post.erb +16 -0
- data/examples/blog/templates/blog/year.erb +22 -0
- data/examples/presentation/Sitefile +10 -0
- data/examples/presentation/content/css/uv/twilight.css +137 -0
- data/examples/presentation/content/presentation/_sample_code.txt +10 -0
- data/examples/presentation/content/presentation/index.txt +63 -0
- data/examples/presentation/content/presentation/s5/blank.gif +0 -0
- data/examples/presentation/content/presentation/s5/bodybg.gif +0 -0
- data/examples/presentation/content/presentation/s5/framing.css +23 -0
- data/examples/presentation/content/presentation/s5/iepngfix.htc +42 -0
- data/examples/presentation/content/presentation/s5/opera.css +7 -0
- data/examples/presentation/content/presentation/s5/outline.css +15 -0
- data/examples/presentation/content/presentation/s5/pretty.css +86 -0
- data/examples/presentation/content/presentation/s5/print.css +25 -0
- data/examples/presentation/content/presentation/s5/s5-core.css +9 -0
- data/examples/presentation/content/presentation/s5/slides.css +3 -0
- data/examples/presentation/content/presentation/s5/slides.js +553 -0
- data/examples/presentation/layouts/presentation.txt +43 -0
- data/examples/presentation/templates/_code_partial.erb +13 -0
- data/examples/presentation/templates/presentation.erb +40 -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/Sitefile +19 -0
- data/examples/webby/content/communicate/index.txt +28 -0
- data/examples/webby/content/css/background.gif +0 -0
- data/examples/webby/content/css/blueprint/print.css +76 -0
- data/examples/webby/content/css/blueprint/screen.css +696 -0
- data/examples/webby/content/css/coderay.css +96 -0
- data/examples/webby/content/css/site.css +196 -0
- data/examples/webby/content/css/uv/twilight.css +137 -0
- data/examples/webby/content/index.txt +37 -0
- data/examples/webby/content/learn/index.txt +28 -0
- data/examples/webby/content/reference/index.txt +204 -0
- data/examples/webby/content/release-notes/index.txt +21 -0
- data/examples/webby/content/release-notes/rel-0-9-0/index.txt +74 -0
- data/examples/webby/content/release-notes/rel-0-9-1/index.txt +93 -0
- data/examples/webby/content/release-notes/rel-0-9-2/index.txt +14 -0
- data/examples/webby/content/release-notes/rel-0-9-3/index.txt +47 -0
- data/examples/webby/content/robots.txt +6 -0
- data/examples/webby/content/script/jquery.corner.js +152 -0
- data/examples/webby/content/script/jquery.js +31 -0
- data/examples/webby/content/sitemap.txt +31 -0
- data/examples/webby/content/tips_and_tricks/index.txt +97 -0
- data/examples/webby/content/tutorial/index.txt +135 -0
- data/examples/webby/content/user-manual/index.txt +419 -0
- data/examples/webby/layouts/default.txt +49 -0
- data/examples/webby/templates/page.erb +10 -0
- data/examples/website/Sitefile +7 -0
- data/examples/website/content/css/blueprint/ie.css +26 -0
- data/examples/website/content/css/blueprint/plugins/buttons/icons/cross.png +0 -0
- data/examples/website/content/css/blueprint/plugins/buttons/icons/key.png +0 -0
- data/examples/website/content/css/blueprint/plugins/buttons/icons/tick.png +0 -0
- data/examples/website/content/css/blueprint/plugins/buttons/readme.txt +32 -0
- data/examples/website/content/css/blueprint/plugins/buttons/screen.css +97 -0
- data/examples/website/content/css/blueprint/plugins/fancy-type/readme.txt +14 -0
- data/examples/website/content/css/blueprint/plugins/fancy-type/screen.css +71 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/icons/doc.png +0 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/icons/email.png +0 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/icons/external.png +0 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/icons/feed.png +0 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/icons/im.png +0 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/icons/pdf.png +0 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/icons/visited.png +0 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/icons/xls.png +0 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/readme.txt +18 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/screen.css +40 -0
- data/examples/website/content/css/blueprint/plugins/rtl/readme.txt +10 -0
- data/examples/website/content/css/blueprint/plugins/rtl/screen.css +109 -0
- data/examples/website/content/css/blueprint/print.css +30 -0
- data/examples/website/content/css/blueprint/screen.css +251 -0
- data/examples/website/content/css/blueprint/src/forms.css +49 -0
- data/examples/website/content/css/blueprint/src/grid.css +212 -0
- data/examples/website/content/css/blueprint/src/grid.png +0 -0
- data/examples/website/content/css/blueprint/src/ie.css +59 -0
- data/examples/website/content/css/blueprint/src/print.css +85 -0
- data/examples/website/content/css/blueprint/src/reset.css +38 -0
- data/examples/website/content/css/blueprint/src/typography.css +105 -0
- data/examples/website/content/css/coderay.css +111 -0
- data/examples/website/content/css/site.css +67 -0
- data/examples/website/content/index.txt +19 -0
- data/examples/website/layouts/default.txt +61 -0
- data/examples/website/lib/breadcrumbs.rb +28 -0
- data/examples/website/templates/_partial.erb +10 -0
- data/examples/website/templates/page.erb +18 -0
- data/lib/webby.rb +233 -0
- data/lib/webby/apps.rb +12 -0
- data/lib/webby/apps/generator.rb +276 -0
- data/lib/webby/apps/main.rb +258 -0
- data/lib/webby/auto_builder.rb +157 -0
- data/lib/webby/builder.rb +172 -0
- data/lib/webby/core_ext/enumerable.rb +11 -0
- data/lib/webby/core_ext/hash.rb +28 -0
- data/lib/webby/core_ext/kernel.rb +26 -0
- data/lib/webby/core_ext/string.rb +163 -0
- data/lib/webby/core_ext/time.rb +9 -0
- data/lib/webby/filters.rb +85 -0
- data/lib/webby/filters/basepath.rb +97 -0
- data/lib/webby/filters/erb.rb +9 -0
- data/lib/webby/filters/haml.rb +18 -0
- data/lib/webby/filters/markdown.rb +16 -0
- data/lib/webby/filters/maruku.rb +16 -0
- data/lib/webby/filters/outline.rb +309 -0
- data/lib/webby/filters/sass.rb +17 -0
- data/lib/webby/filters/slides.rb +56 -0
- data/lib/webby/filters/textile.rb +16 -0
- data/lib/webby/filters/tidy.rb +76 -0
- data/lib/webby/filters/wiki_words.rb +14 -0
- data/lib/webby/helpers.rb +30 -0
- data/lib/webby/helpers/capture_helper.rb +141 -0
- data/lib/webby/helpers/coderay_helper.rb +69 -0
- data/lib/webby/helpers/graphviz_helper.rb +136 -0
- data/lib/webby/helpers/tag_helper.rb +65 -0
- data/lib/webby/helpers/tex_img_helper.rb +133 -0
- data/lib/webby/helpers/ultraviolet_helper.rb +63 -0
- data/lib/webby/helpers/url_helper.rb +241 -0
- data/lib/webby/journal.rb +126 -0
- data/lib/webby/link_validator.rb +160 -0
- data/lib/webby/renderer.rb +389 -0
- data/lib/webby/resources.rb +137 -0
- data/lib/webby/resources/db.rb +251 -0
- data/lib/webby/resources/layout.rb +54 -0
- data/lib/webby/resources/meta_file.rb +211 -0
- data/lib/webby/resources/page.rb +81 -0
- data/lib/webby/resources/partial.rb +85 -0
- data/lib/webby/resources/resource.rb +201 -0
- data/lib/webby/resources/static.rb +36 -0
- data/lib/webby/stelan/mktemp.rb +135 -0
- data/lib/webby/stelan/paginator.rb +165 -0
- data/lib/webby/tasks/build.rake +27 -0
- data/lib/webby/tasks/create.rake +25 -0
- data/lib/webby/tasks/deploy.rake +22 -0
- data/lib/webby/tasks/growl.rake +16 -0
- data/lib/webby/tasks/validate.rake +19 -0
- 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/data/hooligans/bad_meta_data_1.txt +34 -0
- data/spec/data/hooligans/bad_meta_data_2.txt +34 -0
- data/spec/data/html/anchor.html +11 -0
- data/spec/data/html/external.html +10 -0
- data/spec/data/html/invalid-relative.html +10 -0
- data/spec/data/html/relative-anchor.html +10 -0
- data/spec/data/html/relative-invalid-anchor.html +10 -0
- data/spec/data/html/relative.html +10 -0
- data/spec/data/outline/basic.out +81 -0
- data/spec/data/outline/basic.txt +25 -0
- data/spec/data/outline/no_clobber.out +86 -0
- data/spec/data/outline/numbering.out +81 -0
- data/spec/data/outline/numbering_only.out +21 -0
- data/spec/data/outline/toc_range_1.out +66 -0
- data/spec/data/outline/toc_range_2.out +55 -0
- data/spec/data/outline/toc_style.out +81 -0
- data/spec/data/site/Sitefile +9 -0
- data/spec/data/site/content/_partial.txt +10 -0
- data/spec/data/site/content/css/coderay.css +111 -0
- data/spec/data/site/content/css/site.css +67 -0
- data/spec/data/site/content/css/tumblog.css +308 -0
- data/spec/data/site/content/images/tumblog/permalink.gif +0 -0
- data/spec/data/site/content/images/tumblog/rss.gif +0 -0
- data/spec/data/site/content/index.txt +19 -0
- data/spec/data/site/content/photos.txt +21 -0
- data/spec/data/site/content/tumblog/200806/the-noble-chicken/index.txt +12 -0
- data/spec/data/site/content/tumblog/200807/historical-perspectives-on-the-classic-chicken-joke/index.txt +12 -0
- data/spec/data/site/content/tumblog/200807/mad-city-chickens/index.txt +10 -0
- data/spec/data/site/content/tumblog/200807/the-wisdom-of-the-dutch/index.txt +11 -0
- data/spec/data/site/content/tumblog/200807/up-a-tree/index.txt +13 -0
- data/spec/data/site/content/tumblog/index.txt +37 -0
- data/spec/data/site/content/tumblog/rss.txt +37 -0
- data/spec/data/site/layouts/default.txt +58 -0
- data/spec/data/site/layouts/tumblog/default.txt +44 -0
- data/spec/data/site/layouts/tumblog/post.txt +15 -0
- data/spec/data/site/lib/breadcrumbs.rb +28 -0
- data/spec/data/site/lib/tumblog_helper.rb +32 -0
- data/spec/data/site/tasks/tumblog.rake +30 -0
- data/spec/data/site/templates/_partial.erb +10 -0
- data/spec/data/site/templates/atom_feed.erb +40 -0
- data/spec/data/site/templates/page.erb +18 -0
- data/spec/data/site/templates/presentation.erb +40 -0
- data/spec/data/site/templates/tumblog/conversation.erb +12 -0
- data/spec/data/site/templates/tumblog/link.erb +10 -0
- data/spec/data/site/templates/tumblog/photo.erb +13 -0
- data/spec/data/site/templates/tumblog/post.erb +12 -0
- data/spec/data/site/templates/tumblog/quote.erb +11 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +58 -0
- data/spec/webby/apps/generator_spec.rb +117 -0
- data/spec/webby/apps/main_spec.rb +88 -0
- data/spec/webby/filters/basepath_spec.rb +167 -0
- data/spec/webby/filters/maruku_spec.rb +31 -0
- data/spec/webby/filters/outline_spec.rb +92 -0
- data/spec/webby/filters/textile_spec.rb +31 -0
- data/spec/webby/helpers/capture_helper_spec.rb +56 -0
- data/spec/webby/link_validator_spec.rb +154 -0
- data/spec/webby/renderer_spec.rb +139 -0
- data/spec/webby/resources/db_spec.rb +250 -0
- data/spec/webby/resources/layout_spec.rb +83 -0
- data/spec/webby/resources/meta_file_spec.rb +171 -0
- data/spec/webby/resources/page_spec.rb +111 -0
- data/spec/webby/resources/partial_spec.rb +58 -0
- data/spec/webby/resources/resource_spec.rb +219 -0
- data/spec/webby/resources/static_spec.rb +49 -0
- data/spec/webby/resources_spec.rb +69 -0
- data/tasks/mswin32.rake +38 -0
- data/tasks/website.rake +37 -0
- metadata +372 -0
@@ -0,0 +1,165 @@
|
|
1
|
+
# This code was originally written by Bruce Williams, and it is available
|
2
|
+
# as the Paginator gem. I've added a few helper methods and modifications so
|
3
|
+
# it plays a little more nicely with Webby. Specifically, a Webby::Resource
|
4
|
+
# can be given to the Page and used to generate links to the previous and
|
5
|
+
# next pages.
|
6
|
+
#
|
7
|
+
# Many thanks to Bruce Williams for letting me use his work. Drop him a note
|
8
|
+
# of praise scribbled on the back of a $100 bill. He'd appreciate it.
|
9
|
+
|
10
|
+
require 'forwardable'
|
11
|
+
|
12
|
+
module Webby
|
13
|
+
class Paginator
|
14
|
+
|
15
|
+
include Enumerable
|
16
|
+
|
17
|
+
class ArgumentError < ::ArgumentError; end
|
18
|
+
class MissingCountError < ArgumentError; end
|
19
|
+
class MissingSelectError < ArgumentError; end
|
20
|
+
|
21
|
+
attr_reader :per_page, :count, :resource, :filename, :directory
|
22
|
+
|
23
|
+
# Instantiate a new Paginator object
|
24
|
+
#
|
25
|
+
# Provide:
|
26
|
+
# * A total count of the number of objects to paginate
|
27
|
+
# * The number of objects in each page
|
28
|
+
# * A block that returns the array of items
|
29
|
+
# * The block is passed the item offset
|
30
|
+
# (and the number of items to show per page, for
|
31
|
+
# convenience, if the arity is 2)
|
32
|
+
def initialize(count, per_page, resource, &select)
|
33
|
+
@count, @per_page, @resource = count, per_page, resource
|
34
|
+
@meta_data = @resource._meta_data.dup
|
35
|
+
@filename = @resource.filename
|
36
|
+
@directory = @resource.directory
|
37
|
+
unless select
|
38
|
+
raise MissingSelectError, "Must provide block to select data for each page"
|
39
|
+
end
|
40
|
+
@select = select
|
41
|
+
end
|
42
|
+
|
43
|
+
# Total number of pages
|
44
|
+
def number_of_pages
|
45
|
+
(@count / @per_page).to_i + (@count % @per_page > 0 ? 1 : 0)
|
46
|
+
end
|
47
|
+
|
48
|
+
# First page object
|
49
|
+
def first
|
50
|
+
page 1
|
51
|
+
end
|
52
|
+
|
53
|
+
# Last page object
|
54
|
+
def last
|
55
|
+
page number_of_pages
|
56
|
+
end
|
57
|
+
|
58
|
+
def each
|
59
|
+
1.upto(number_of_pages) do |number|
|
60
|
+
yield page(number)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
# Retrieve page object by number
|
65
|
+
def page(number)
|
66
|
+
number = (n = number.to_i) > 0 ? n : 1
|
67
|
+
Page.new(self, number, lambda {
|
68
|
+
offset = (number - 1) * @per_page
|
69
|
+
args = [offset]
|
70
|
+
args << @per_page if @select.arity == 2
|
71
|
+
@select.call(*args)
|
72
|
+
})
|
73
|
+
end
|
74
|
+
|
75
|
+
# Finalizer method that should be called when the paginator is finished
|
76
|
+
def reset
|
77
|
+
resource._reset(@meta_data)
|
78
|
+
end
|
79
|
+
|
80
|
+
# Page object
|
81
|
+
#
|
82
|
+
# Retrieves items for a page and provides metadata about the position
|
83
|
+
# of the page in the paginator
|
84
|
+
class Page
|
85
|
+
|
86
|
+
include Enumerable
|
87
|
+
|
88
|
+
attr_reader :number, :pager, :url
|
89
|
+
|
90
|
+
def initialize(pager, number, select) #:nodoc:
|
91
|
+
@pager, @number = pager, number
|
92
|
+
@offset = (number - 1) * pager.per_page
|
93
|
+
@select = select
|
94
|
+
|
95
|
+
@pager.reset
|
96
|
+
if number > 1
|
97
|
+
if ::Webby.site.create_mode == 'directory'
|
98
|
+
@pager.resource['directory'] = File.join(@pager.directory, number.to_s)
|
99
|
+
else
|
100
|
+
@pager.resource['filename'] = @pager.filename + number.to_s
|
101
|
+
end
|
102
|
+
end
|
103
|
+
@url = @pager.resource.url
|
104
|
+
end
|
105
|
+
|
106
|
+
# Retrieve the items for this page
|
107
|
+
# * Caches
|
108
|
+
def items
|
109
|
+
@items ||= @select.call
|
110
|
+
end
|
111
|
+
|
112
|
+
# Checks to see if there's a page before this one
|
113
|
+
def prev?
|
114
|
+
@number > 1
|
115
|
+
end
|
116
|
+
|
117
|
+
# Get previous page (if possible)
|
118
|
+
def prev
|
119
|
+
@pager.page(@number - 1) if prev?
|
120
|
+
end
|
121
|
+
|
122
|
+
# Checks to see if there's a page after this one
|
123
|
+
def next?
|
124
|
+
@number < @pager.number_of_pages
|
125
|
+
end
|
126
|
+
|
127
|
+
# Get next page (if possible)
|
128
|
+
def next
|
129
|
+
@pager.page(@number + 1) if next?
|
130
|
+
end
|
131
|
+
|
132
|
+
# The "item number" of the first item on this page
|
133
|
+
def first_item_number
|
134
|
+
1 + @offset
|
135
|
+
end
|
136
|
+
|
137
|
+
# The "item number" of the last item on this page
|
138
|
+
def last_item_number
|
139
|
+
if next?
|
140
|
+
@offset + @pager.per_page
|
141
|
+
else
|
142
|
+
@pager.count
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def ==(other) #:nodoc:
|
147
|
+
@pager == other.pager && self.number == other.number
|
148
|
+
end
|
149
|
+
|
150
|
+
def each(&block)
|
151
|
+
items.each(&block)
|
152
|
+
end
|
153
|
+
|
154
|
+
def method_missing(meth, *args, &block) #:nodoc:
|
155
|
+
if @pager.respond_to?(meth)
|
156
|
+
@pager.__send__(meth, *args, &block)
|
157
|
+
else
|
158
|
+
super
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
end
|
163
|
+
|
164
|
+
end # class Paginator
|
165
|
+
end # module Webby
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
task :configure_basepath do
|
3
|
+
Webby.site.base = ENV['BASE'] if ENV.has_key?('BASE')
|
4
|
+
end
|
5
|
+
|
6
|
+
desc "Build the website"
|
7
|
+
task :build => :configure_basepath do |t|
|
8
|
+
Webby::Builder.run
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "Rebuild the website"
|
12
|
+
task :rebuild => :configure_basepath do |t|
|
13
|
+
Webby::Builder.run :rebuild => true
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "Continuously build the website"
|
17
|
+
task :autobuild => :configure_basepath do |t|
|
18
|
+
Webby::AutoBuilder.run
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "Delete the website"
|
22
|
+
task :clobber do |t|
|
23
|
+
rm_rf Webby.site.output_dir
|
24
|
+
mkdir Webby.site.output_dir
|
25
|
+
end
|
26
|
+
|
27
|
+
# EOF
|
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
namespace :create do
|
3
|
+
|
4
|
+
FileList["#{Webby.site.template_dir}/*"].each do |template|
|
5
|
+
next unless test(?f, template)
|
6
|
+
name = template.pathmap '%n'
|
7
|
+
|
8
|
+
# if the file is a partial template
|
9
|
+
name = $1 if name =~ %r/^_(.*)/
|
10
|
+
|
11
|
+
desc "Create a new #{name}"
|
12
|
+
task name do |t|
|
13
|
+
page, title, dir = Webby::Builder.new_page_info
|
14
|
+
page = Webby::Builder.create(page, :from => template,
|
15
|
+
:locals => {:title => title, :directory => dir})
|
16
|
+
unless ::Webby.editor.nil?
|
17
|
+
args = [::Webby.editor.split, page].flatten
|
18
|
+
exec(*args)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end # each
|
22
|
+
|
23
|
+
end # namespace :create
|
24
|
+
|
25
|
+
# EOF
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
require 'rake/contrib/sshpublisher'
|
3
|
+
|
4
|
+
namespace :deploy do
|
5
|
+
|
6
|
+
desc 'Deploy to the server using rsync'
|
7
|
+
task :rsync do
|
8
|
+
cmd = "rsync #{SITE.rsync_args.join(' ')} "
|
9
|
+
cmd << "#{SITE.output_dir}/ #{SITE.user}@#{SITE.host}:#{SITE.remote_dir}"
|
10
|
+
sh cmd
|
11
|
+
end
|
12
|
+
|
13
|
+
desc 'Deploy to the server using ssh'
|
14
|
+
task :ssh do
|
15
|
+
Rake::SshDirPublisher.new(
|
16
|
+
"#{SITE.user}@#{SITE.host}", SITE.remote_dir, SITE.output_dir
|
17
|
+
).upload
|
18
|
+
end
|
19
|
+
|
20
|
+
end # deploy
|
21
|
+
|
22
|
+
# EOF
|
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
unless WINDOWS
|
3
|
+
|
4
|
+
task :growl do
|
5
|
+
growl = Logging::Appenders::Growl.new('growl',
|
6
|
+
:layout => Logging::Layouts::Pattern.new(:pattern => "%5l - Webby\000%m"),
|
7
|
+
:coalesce => true,
|
8
|
+
:separator => "\000"
|
9
|
+
)
|
10
|
+
Logging::Logger['Webby'].add_appenders(growl)
|
11
|
+
Logging::Logger['Webby::Journal'].add_appenders(growl)
|
12
|
+
end
|
13
|
+
|
14
|
+
end # unless WINDOWS
|
15
|
+
|
16
|
+
# EOF
|
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
namespace :validate do
|
3
|
+
|
4
|
+
desc 'Validate hyperlinks (exclude external sites)'
|
5
|
+
task :internal => :build do
|
6
|
+
Webby::LinkValidator.validate(:external => false)
|
7
|
+
end
|
8
|
+
|
9
|
+
desc 'Validate hyperlinks (include external sites)'
|
10
|
+
task :external => :build do
|
11
|
+
Webby::LinkValidator.validate(:external => true)
|
12
|
+
end
|
13
|
+
|
14
|
+
end # validate
|
15
|
+
|
16
|
+
desc 'Alias to validate:internal'
|
17
|
+
task :validate => 'validate:internal'
|
18
|
+
|
19
|
+
# EOF
|
@@ -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
|