TwP-webby 0.9.2 → 0.9.3
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 +13 -0
- data/Manifest.txt +44 -34
- data/Rakefile +2 -2
- data/bin/webby +33 -0
- data/bin/webby-gen +33 -0
- data/examples/presentation/content/presentation/s5/bodybg.gif +0 -0
- data/examples/presentation/content/presentation/s5/print.css +25 -1
- data/examples/webby/content/release-notes/rel-0-9-3/index.txt +47 -0
- data/lib/webby/apps/generator.rb +41 -48
- data/lib/webby/apps/main.rb +22 -0
- data/lib/webby/auto_builder.rb +78 -6
- data/lib/webby/builder.rb +9 -9
- data/lib/webby/core_ext/kernel.rb +5 -0
- data/lib/webby/filters/wiki_words.rb +14 -0
- data/lib/webby/helpers/url_helper.rb +6 -0
- data/lib/webby/journal.rb +126 -0
- data/lib/webby/renderer.rb +11 -6
- data/lib/webby/resources/meta_file.rb +8 -5
- data/lib/webby/stelan/paginator.rb +2 -2
- data/lib/webby/tasks/growl.rake +4 -3
- data/lib/webby.rb +3 -10
- 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/{Sitefile → site/Sitefile} +0 -0
- data/spec/data/{content → site/content}/_partial.txt +0 -0
- data/spec/data/{content → site/content}/css/coderay.css +0 -0
- data/spec/data/{content → site/content}/css/site.css +0 -0
- data/spec/data/{content → site/content}/css/tumblog.css +0 -0
- data/spec/data/{content → site/content}/images/tumblog/permalink.gif +0 -0
- data/spec/data/{content → site/content}/images/tumblog/rss.gif +0 -0
- data/spec/data/{content → site/content}/index.txt +0 -0
- data/spec/data/{content → site/content}/photos.txt +0 -0
- data/spec/data/{content → site/content}/tumblog/200806/the-noble-chicken/index.txt +0 -0
- data/spec/data/{content → site/content}/tumblog/200807/historical-perspectives-on-the-classic-chicken-joke/index.txt +0 -0
- data/spec/data/{content → site/content}/tumblog/200807/mad-city-chickens/index.txt +0 -0
- data/spec/data/{content → site/content}/tumblog/200807/the-wisdom-of-the-dutch/index.txt +0 -0
- data/spec/data/{content → site/content}/tumblog/200807/up-a-tree/index.txt +0 -0
- data/spec/data/{content → site/content}/tumblog/index.txt +0 -0
- data/spec/data/{content → site/content}/tumblog/rss.txt +0 -0
- data/spec/data/{layouts → site/layouts}/default.txt +0 -0
- data/spec/data/{layouts → site/layouts}/tumblog/default.txt +0 -0
- data/spec/data/{layouts → site/layouts}/tumblog/post.txt +0 -0
- data/spec/data/{lib → site/lib}/breadcrumbs.rb +0 -0
- data/spec/data/{lib → site/lib}/tumblog_helper.rb +0 -0
- data/spec/data/{tasks → site/tasks}/tumblog.rake +0 -0
- data/spec/data/{templates → site/templates}/_partial.erb +0 -0
- data/spec/data/{templates → site/templates}/atom_feed.erb +0 -0
- data/spec/data/{templates → site/templates}/page.erb +0 -0
- data/{examples/website → spec/data/site}/templates/presentation.erb +0 -0
- data/spec/data/{templates → site/templates}/tumblog/conversation.erb +0 -0
- data/spec/data/{templates → site/templates}/tumblog/link.erb +0 -0
- data/spec/data/{templates → site/templates}/tumblog/photo.erb +0 -0
- data/spec/data/{templates → site/templates}/tumblog/post.erb +0 -0
- data/spec/data/{templates → site/templates}/tumblog/quote.erb +0 -0
- data/spec/spec_helper.rb +4 -4
- data/spec/webby/apps/generator_spec.rb +3 -2
- data/spec/webby/filters/basepath_spec.rb +167 -0
- data/spec/webby/filters/outline_spec.rb +92 -0
- data/spec/webby/renderer_spec.rb +1 -1
- data/spec/webby/resources/db_spec.rb +1 -1
- data/spec/webby/resources/layout_spec.rb +1 -1
- data/spec/webby/resources/meta_file_spec.rb +27 -13
- data/spec/webby/resources/page_spec.rb +1 -1
- data/spec/webby/resources/resource_spec.rb +1 -1
- data/spec/webby/resources_spec.rb +1 -1
- data/tasks/gem.rake +93 -32
- data/tasks/manifest.rake +3 -4
- data/tasks/rubyforge.rake +2 -4
- metadata +67 -57
- data/lib/webby/stelan/spawner.rb +0 -339
- data/lib/webby/tasks/heel.rake +0 -28
- data/spec/data/templates/presentation.erb +0 -40
data/History.txt
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
+
== 0.9.3 / 2008-10-08
|
|
2
|
+
|
|
3
|
+
* 4 minor enhancements
|
|
4
|
+
- Added a "wikiwords" filter to process [[text]] as links to other pages
|
|
5
|
+
(thanks to Paul)
|
|
6
|
+
- Added colorization to the output text (facets gem required)
|
|
7
|
+
- Replaced the Heel webserver with webrick
|
|
8
|
+
- Special windows version with windows line endings in generated files
|
|
9
|
+
* 2 bug fixes
|
|
10
|
+
- Fixed a bug on Windows where line endings were messing with meta-data
|
|
11
|
+
- The paginator was not linking correctly back to the first page from
|
|
12
|
+
subsequent pages in a list
|
|
13
|
+
|
|
1
14
|
== 0.9.2 / 2008-09-11
|
|
2
15
|
|
|
3
16
|
* 1 bug fix
|
data/Manifest.txt
CHANGED
|
@@ -64,6 +64,7 @@ examples/webby/content/release-notes/index.txt
|
|
|
64
64
|
examples/webby/content/release-notes/rel-0-9-0/index.txt
|
|
65
65
|
examples/webby/content/release-notes/rel-0-9-1/index.txt
|
|
66
66
|
examples/webby/content/release-notes/rel-0-9-2/index.txt
|
|
67
|
+
examples/webby/content/release-notes/rel-0-9-3/index.txt
|
|
67
68
|
examples/webby/content/robots.txt
|
|
68
69
|
examples/webby/content/script/jquery.corner.js
|
|
69
70
|
examples/webby/content/script/jquery.js
|
|
@@ -103,7 +104,6 @@ examples/website/layouts/default.txt
|
|
|
103
104
|
examples/website/lib/breadcrumbs.rb
|
|
104
105
|
examples/website/templates/_partial.erb
|
|
105
106
|
examples/website/templates/page.erb
|
|
106
|
-
examples/website/templates/presentation.erb
|
|
107
107
|
lib/webby.rb
|
|
108
108
|
lib/webby/apps.rb
|
|
109
109
|
lib/webby/apps/generator.rb
|
|
@@ -125,6 +125,7 @@ lib/webby/filters/sass.rb
|
|
|
125
125
|
lib/webby/filters/slides.rb
|
|
126
126
|
lib/webby/filters/textile.rb
|
|
127
127
|
lib/webby/filters/tidy.rb
|
|
128
|
+
lib/webby/filters/wiki_words.rb
|
|
128
129
|
lib/webby/helpers.rb
|
|
129
130
|
lib/webby/helpers/capture_helper.rb
|
|
130
131
|
lib/webby/helpers/coderay_helper.rb
|
|
@@ -133,6 +134,7 @@ lib/webby/helpers/tag_helper.rb
|
|
|
133
134
|
lib/webby/helpers/tex_img_helper.rb
|
|
134
135
|
lib/webby/helpers/ultraviolet_helper.rb
|
|
135
136
|
lib/webby/helpers/url_helper.rb
|
|
137
|
+
lib/webby/journal.rb
|
|
136
138
|
lib/webby/link_validator.rb
|
|
137
139
|
lib/webby/renderer.rb
|
|
138
140
|
lib/webby/resources.rb
|
|
@@ -145,53 +147,61 @@ lib/webby/resources/resource.rb
|
|
|
145
147
|
lib/webby/resources/static.rb
|
|
146
148
|
lib/webby/stelan/mktemp.rb
|
|
147
149
|
lib/webby/stelan/paginator.rb
|
|
148
|
-
lib/webby/stelan/spawner.rb
|
|
149
150
|
lib/webby/tasks/build.rake
|
|
150
151
|
lib/webby/tasks/create.rake
|
|
151
152
|
lib/webby/tasks/deploy.rake
|
|
152
153
|
lib/webby/tasks/growl.rake
|
|
153
|
-
lib/webby/tasks/heel.rake
|
|
154
154
|
lib/webby/tasks/validate.rake
|
|
155
155
|
spec/core_ext/hash_spec.rb
|
|
156
156
|
spec/core_ext/string_spec.rb
|
|
157
157
|
spec/core_ext/time_spec.rb
|
|
158
|
-
spec/data/Sitefile
|
|
159
|
-
spec/data/content/_partial.txt
|
|
160
|
-
spec/data/content/css/coderay.css
|
|
161
|
-
spec/data/content/css/site.css
|
|
162
|
-
spec/data/content/css/tumblog.css
|
|
163
|
-
spec/data/content/images/tumblog/permalink.gif
|
|
164
|
-
spec/data/content/images/tumblog/rss.gif
|
|
165
|
-
spec/data/content/index.txt
|
|
166
|
-
spec/data/content/photos.txt
|
|
167
|
-
spec/data/content/tumblog/200806/the-noble-chicken/index.txt
|
|
168
|
-
spec/data/content/tumblog/200807/historical-perspectives-on-the-classic-chicken-joke/index.txt
|
|
169
|
-
spec/data/content/tumblog/200807/mad-city-chickens/index.txt
|
|
170
|
-
spec/data/content/tumblog/200807/the-wisdom-of-the-dutch/index.txt
|
|
171
|
-
spec/data/content/tumblog/200807/up-a-tree/index.txt
|
|
172
|
-
spec/data/content/tumblog/index.txt
|
|
173
|
-
spec/data/content/tumblog/rss.txt
|
|
174
158
|
spec/data/hooligans/bad_meta_data_1.txt
|
|
175
159
|
spec/data/hooligans/bad_meta_data_2.txt
|
|
176
|
-
spec/data/
|
|
177
|
-
spec/data/
|
|
178
|
-
spec/data/
|
|
179
|
-
spec/data/
|
|
180
|
-
spec/data/
|
|
181
|
-
spec/data/
|
|
182
|
-
spec/data/
|
|
183
|
-
spec/data/
|
|
184
|
-
spec/data/
|
|
185
|
-
spec/data/
|
|
186
|
-
spec/data/
|
|
187
|
-
spec/data/
|
|
188
|
-
spec/data/
|
|
189
|
-
spec/data/
|
|
190
|
-
spec/data/
|
|
160
|
+
spec/data/outline/basic.out
|
|
161
|
+
spec/data/outline/basic.txt
|
|
162
|
+
spec/data/outline/no_clobber.out
|
|
163
|
+
spec/data/outline/numbering.out
|
|
164
|
+
spec/data/outline/numbering_only.out
|
|
165
|
+
spec/data/outline/toc_range_1.out
|
|
166
|
+
spec/data/outline/toc_range_2.out
|
|
167
|
+
spec/data/outline/toc_style.out
|
|
168
|
+
spec/data/site/Sitefile
|
|
169
|
+
spec/data/site/content/_partial.txt
|
|
170
|
+
spec/data/site/content/css/coderay.css
|
|
171
|
+
spec/data/site/content/css/site.css
|
|
172
|
+
spec/data/site/content/css/tumblog.css
|
|
173
|
+
spec/data/site/content/images/tumblog/permalink.gif
|
|
174
|
+
spec/data/site/content/images/tumblog/rss.gif
|
|
175
|
+
spec/data/site/content/index.txt
|
|
176
|
+
spec/data/site/content/photos.txt
|
|
177
|
+
spec/data/site/content/tumblog/200806/the-noble-chicken/index.txt
|
|
178
|
+
spec/data/site/content/tumblog/200807/historical-perspectives-on-the-classic-chicken-joke/index.txt
|
|
179
|
+
spec/data/site/content/tumblog/200807/mad-city-chickens/index.txt
|
|
180
|
+
spec/data/site/content/tumblog/200807/the-wisdom-of-the-dutch/index.txt
|
|
181
|
+
spec/data/site/content/tumblog/200807/up-a-tree/index.txt
|
|
182
|
+
spec/data/site/content/tumblog/index.txt
|
|
183
|
+
spec/data/site/content/tumblog/rss.txt
|
|
184
|
+
spec/data/site/layouts/default.txt
|
|
185
|
+
spec/data/site/layouts/tumblog/default.txt
|
|
186
|
+
spec/data/site/layouts/tumblog/post.txt
|
|
187
|
+
spec/data/site/lib/breadcrumbs.rb
|
|
188
|
+
spec/data/site/lib/tumblog_helper.rb
|
|
189
|
+
spec/data/site/tasks/tumblog.rake
|
|
190
|
+
spec/data/site/templates/_partial.erb
|
|
191
|
+
spec/data/site/templates/atom_feed.erb
|
|
192
|
+
spec/data/site/templates/page.erb
|
|
193
|
+
spec/data/site/templates/presentation.erb
|
|
194
|
+
spec/data/site/templates/tumblog/conversation.erb
|
|
195
|
+
spec/data/site/templates/tumblog/link.erb
|
|
196
|
+
spec/data/site/templates/tumblog/photo.erb
|
|
197
|
+
spec/data/site/templates/tumblog/post.erb
|
|
198
|
+
spec/data/site/templates/tumblog/quote.erb
|
|
191
199
|
spec/spec.opts
|
|
192
200
|
spec/spec_helper.rb
|
|
193
201
|
spec/webby/apps/generator_spec.rb
|
|
194
202
|
spec/webby/apps/main_spec.rb
|
|
203
|
+
spec/webby/filters/basepath_spec.rb
|
|
204
|
+
spec/webby/filters/outline_spec.rb
|
|
195
205
|
spec/webby/filters/textile_spec.rb
|
|
196
206
|
spec/webby/helpers/capture_helper_spec.rb
|
|
197
207
|
spec/webby/renderer_spec.rb
|
data/Rakefile
CHANGED
|
@@ -14,7 +14,7 @@ PROJ.url = 'http://webby.rubyforge.org/'
|
|
|
14
14
|
PROJ.description = paragraphs_of('README.txt', 3).join("\n\n")
|
|
15
15
|
PROJ.rubyforge.name = 'webby'
|
|
16
16
|
PROJ.version = Webby::VERSION
|
|
17
|
-
PROJ.release_name = '
|
|
17
|
+
PROJ.release_name = 'Bill Gates Alien Love Child'
|
|
18
18
|
|
|
19
19
|
PROJ.ruby_opts = %w[-W0]
|
|
20
20
|
PROJ.exclude << %w(^examples/[^/]+/output ^tasks/archive ^tags$ ^webby.gemspec$)
|
|
@@ -40,8 +40,8 @@ TwP
|
|
|
40
40
|
ANN
|
|
41
41
|
|
|
42
42
|
depend_on 'directory_watcher'
|
|
43
|
-
depend_on 'heel'
|
|
44
43
|
depend_on 'hpricot', '= 0.6.0'
|
|
44
|
+
depend_on 'launchy'
|
|
45
45
|
depend_on 'logging'
|
|
46
46
|
depend_on 'rake'
|
|
47
47
|
depend_on 'rspec'
|
data/bin/webby
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'logging'
|
|
5
|
+
|
|
6
|
+
::Logging.configure {
|
|
7
|
+
logger('Webby') {
|
|
8
|
+
level :info
|
|
9
|
+
appenders 'stdout'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
logger('Webby::Journal') {
|
|
13
|
+
level :info
|
|
14
|
+
additive false
|
|
15
|
+
appenders 'journal'
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
appender('stdout') {
|
|
19
|
+
type 'Stdout'
|
|
20
|
+
layout {
|
|
21
|
+
type 'Pattern'
|
|
22
|
+
pattern "[%d] %5l: %m\n"
|
|
23
|
+
date_pattern "%H:%M:%S"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
appender('journal') {
|
|
28
|
+
type 'Stdout'
|
|
29
|
+
layout {
|
|
30
|
+
type 'Pattern'
|
|
31
|
+
pattern "%m\n"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
3
36
|
require File.expand_path(
|
|
4
37
|
File.join(File.dirname(__FILE__), %w[.. lib webby]))
|
|
5
38
|
|
data/bin/webby-gen
CHANGED
|
@@ -1,5 +1,38 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
2
|
|
|
3
|
+
require 'rubygems'
|
|
4
|
+
require 'logging'
|
|
5
|
+
|
|
6
|
+
::Logging.configure {
|
|
7
|
+
logger('Webby') {
|
|
8
|
+
level :info
|
|
9
|
+
appenders 'stdout'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
logger('Webby::Journal') {
|
|
13
|
+
level :info
|
|
14
|
+
additive false
|
|
15
|
+
appenders 'journal'
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
appender('stdout') {
|
|
19
|
+
type 'Stdout'
|
|
20
|
+
layout {
|
|
21
|
+
type 'Pattern'
|
|
22
|
+
pattern "[%d] %5l: %m\n"
|
|
23
|
+
date_pattern "%H:%M:%S"
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
appender('journal') {
|
|
28
|
+
type 'Stdout'
|
|
29
|
+
layout {
|
|
30
|
+
type 'Pattern'
|
|
31
|
+
pattern "%m\n"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
3
36
|
require File.expand_path(
|
|
4
37
|
File.join(File.dirname(__FILE__), %w[.. lib webby]))
|
|
5
38
|
|
|
File without changes
|
|
@@ -1 +1,25 @@
|
|
|
1
|
-
/* The following rule is necessary to have all slides appear in print! DO NOT REMOVE IT! */
|
|
1
|
+
/* The following rule is necessary to have all slides appear in print! DO NOT REMOVE IT! */
|
|
2
|
+
.slide, ul {page-break-inside: avoid; visibility: visible !important;}
|
|
3
|
+
h1 {page-break-after: avoid;}
|
|
4
|
+
|
|
5
|
+
body {font-size: 12pt; background: white;}
|
|
6
|
+
* {color: black;}
|
|
7
|
+
|
|
8
|
+
#slide0 h1 {font-size: 200%; border: none; margin: 0.5em 0 0.25em;}
|
|
9
|
+
#slide0 h3 {margin: 0; padding: 0;}
|
|
10
|
+
#slide0 h4 {margin: 0 0 0.5em; padding: 0;}
|
|
11
|
+
#slide0 {margin-bottom: 3em;}
|
|
12
|
+
|
|
13
|
+
h1 {border-top: 2pt solid gray; border-bottom: 1px dotted silver;}
|
|
14
|
+
.extra {background: transparent !important;}
|
|
15
|
+
div.extra, pre.extra, .example {font-size: 10pt; color: #333;}
|
|
16
|
+
ul.extra a {font-weight: bold;}
|
|
17
|
+
p.example {display: none;}
|
|
18
|
+
|
|
19
|
+
#header {display: none;}
|
|
20
|
+
#footer h1 {margin: 0; border-bottom: 1px solid; color: gray; font-style: italic;}
|
|
21
|
+
#footer h2, #controls {display: none;}
|
|
22
|
+
|
|
23
|
+
/* The following rule keeps the layout stuff out of print. Remove at your own risk! */
|
|
24
|
+
.layout, .layout * {display: none !important;}
|
|
25
|
+
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Release 0.9.3
|
|
3
|
+
created_at: 2008-10-08 21:22:41.217238 -06:00
|
|
4
|
+
filter:
|
|
5
|
+
- erb
|
|
6
|
+
- textile
|
|
7
|
+
release_name: Bill Gates Alien Love Child
|
|
8
|
+
---
|
|
9
|
+
h2. <%= h(@page.title) %>
|
|
10
|
+
|
|
11
|
+
Release 0.9.3 adds several new features and fixes a few bugs. The two most significant features are a "wikiwords" filter and a special webby gem for the windows platform. See below for more information.
|
|
12
|
+
|
|
13
|
+
* 4 minor enhancements
|
|
14
|
+
** Added a "wikiwords" filter to process [[text]] as links to other pages (thanks to Paul)
|
|
15
|
+
** Added colorization to the output text (facets gem required)
|
|
16
|
+
** Replaced the Heel webserver with webrick
|
|
17
|
+
** Special windows version with windows line endings in generated files
|
|
18
|
+
* 2 bug fixes
|
|
19
|
+
** Fixed a bug on Windows where line endings were messing with meta-data
|
|
20
|
+
** The paginator was not linking correctly back to the first page from subsequent pages in a list
|
|
21
|
+
|
|
22
|
+
h3. Wiki Words
|
|
23
|
+
|
|
24
|
+
Wiki Words provide a convenient way to link to other pages in a site based on the page titles. Page titles surrounded by double brackets will be converted into a link to that particular page.
|
|
25
|
+
|
|
26
|
+
<pre>
|
|
27
|
+
<%= Webby::YAML_SEP %>
|
|
28
|
+
title: Special Report
|
|
29
|
+
created_at: 2008-10-08 21:22:41.217238 -06:00
|
|
30
|
+
filter:
|
|
31
|
+
- wikiwords
|
|
32
|
+
- textile
|
|
33
|
+
<%= Webby::YAML_SEP %>
|
|
34
|
+
h1. Special Report
|
|
35
|
+
|
|
36
|
+
This page is a special report that links to some [[Other Page]] in the site and
|
|
37
|
+
offers a little more information. You can find out more in the [[Reference]]
|
|
38
|
+
page, too.
|
|
39
|
+
</pre>
|
|
40
|
+
|
|
41
|
+
So, in the example above two links will be generated. One will link to the "Other Page" and the second will link to the "Reference" page.
|
|
42
|
+
|
|
43
|
+
h3. Windows Support
|
|
44
|
+
|
|
45
|
+
This release also fixes a few issues with webby on the windows platform. Both issues concern windows line endings versus UNIX line endings in files. The code that parses meta-data has been updated to be line ending agnostic -- so no need to use UNIX line endings in the windows world.
|
|
46
|
+
|
|
47
|
+
The second issue is a windows specific version of the webby gem. This gem has the template site files converted to the windows line ending style. So when a site is created using the webby-gen command, the resulting files should be in the native windows format.
|
data/lib/webby/apps/generator.rb
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require 'fileutils'
|
|
2
2
|
require 'optparse'
|
|
3
|
+
require 'forwardable'
|
|
3
4
|
|
|
4
5
|
module Webby::Apps
|
|
5
6
|
|
|
@@ -9,6 +10,7 @@ module Webby::Apps
|
|
|
9
10
|
#
|
|
10
11
|
|
|
11
12
|
class Generator
|
|
13
|
+
extend Forwardable
|
|
12
14
|
|
|
13
15
|
# Create a new Generator instance and run the +webby+ application given the
|
|
14
16
|
# command line _args_.
|
|
@@ -22,10 +24,34 @@ class Generator
|
|
|
22
24
|
|
|
23
25
|
# Initialize a new generator object.
|
|
24
26
|
#
|
|
25
|
-
def initialize
|
|
27
|
+
def initialize( output = $stdout, input = $stdin )
|
|
26
28
|
@options = {}
|
|
27
29
|
@site = @template = nil
|
|
28
|
-
@
|
|
30
|
+
@output, @input = output, input
|
|
31
|
+
@journal = journal
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def_delegators :@journal,
|
|
35
|
+
:exists, :create, :force, :skip, :identical
|
|
36
|
+
|
|
37
|
+
# Writes the given objects to the output destination. Each object is
|
|
38
|
+
# followed by a newline unless the object is a string with a newline
|
|
39
|
+
# already at the end.
|
|
40
|
+
#
|
|
41
|
+
def puts( *args )
|
|
42
|
+
@output.puts(*args)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
# Writes the given objects to the output destination.
|
|
46
|
+
#
|
|
47
|
+
def print( *args )
|
|
48
|
+
@output.print(*args)
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# Reads a line text frim the input source.
|
|
52
|
+
#
|
|
53
|
+
def gets
|
|
54
|
+
@input.gets
|
|
29
55
|
end
|
|
30
56
|
|
|
31
57
|
# Run the generator executing the commands specified by the user on the
|
|
@@ -60,18 +86,18 @@ class Generator
|
|
|
60
86
|
opts.on('-t', '--templates', 'list available templates') {
|
|
61
87
|
ary = templates.map {|t| ::File.basename(t)}
|
|
62
88
|
ary.delete 'webby'
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
89
|
+
puts "\nAvailable Templates"
|
|
90
|
+
puts " #{ary.join(', ')}"
|
|
91
|
+
puts
|
|
66
92
|
exit
|
|
67
93
|
}
|
|
68
94
|
|
|
69
95
|
opts.separator ''
|
|
70
96
|
opts.separator 'common options:'
|
|
71
97
|
|
|
72
|
-
opts.on( '-h', '--help', 'show this message' ) {
|
|
98
|
+
opts.on( '-h', '--help', 'show this message' ) {puts opts; exit}
|
|
73
99
|
opts.on( '--version', 'show version' ) do
|
|
74
|
-
|
|
100
|
+
puts "Webby #{::Webby::VERSION}"
|
|
75
101
|
exit
|
|
76
102
|
end
|
|
77
103
|
|
|
@@ -87,13 +113,13 @@ class Generator
|
|
|
87
113
|
|
|
88
114
|
# exit if comand line args are missing
|
|
89
115
|
if site.nil? or tmpl.nil?
|
|
90
|
-
|
|
116
|
+
puts opts
|
|
91
117
|
exit 1
|
|
92
118
|
end
|
|
93
119
|
|
|
94
120
|
templates.each {|t| self.template = t if t =~ %r/\/#{tmpl}$/}
|
|
95
121
|
if template.nil?
|
|
96
|
-
|
|
122
|
+
puts opts
|
|
97
123
|
abort "Could not find template '#{tmpl}'"
|
|
98
124
|
end
|
|
99
125
|
|
|
@@ -184,46 +210,16 @@ class Generator
|
|
|
184
210
|
end
|
|
185
211
|
return if pretend?
|
|
186
212
|
|
|
187
|
-
|
|
188
|
-
else FileUtils.cp(src, dst) end
|
|
189
|
-
end
|
|
190
|
-
|
|
191
|
-
# Copy the file from the _src_ location to the _dst_ location and
|
|
192
|
-
# transform the line endings to the windows "\r\n" format.
|
|
193
|
-
#
|
|
194
|
-
def win_line_endings( src, dst )
|
|
195
|
-
case ::File.extname(src)
|
|
196
|
-
when *%w[.png .gif .jpg .jpeg]
|
|
197
|
-
FileUtils.cp src, dst
|
|
198
|
-
else
|
|
199
|
-
::File.open(dst,'w') do |fd|
|
|
200
|
-
::File.foreach(src, "\n") do |line|
|
|
201
|
-
line.tr!("\r\n",'')
|
|
202
|
-
fd.puts line
|
|
203
|
-
end
|
|
204
|
-
end
|
|
205
|
-
end
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
%w[exists create force skip identical].each do |m|
|
|
209
|
-
class_eval "def #{m}( msg ) message('#{m}', msg); end"
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
# Print the given message and message type to stdout.
|
|
213
|
-
#
|
|
214
|
-
def message( type, msg )
|
|
215
|
-
msg = msg.sub(%r/#{site}\/?/, '')
|
|
216
|
-
return if msg.empty?
|
|
217
|
-
@stdout.puts "%13s %s" % [type, msg]
|
|
213
|
+
FileUtils.cp(src, dst)
|
|
218
214
|
end
|
|
219
215
|
|
|
220
216
|
# Prints an abort message to the screen and then exits the Ruby
|
|
221
217
|
# interpreter. A non-zero return code is used to indicate an error.
|
|
222
218
|
#
|
|
223
219
|
def abort( msg )
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
220
|
+
puts "\nAborting!"
|
|
221
|
+
puts " #{msg}"
|
|
222
|
+
puts
|
|
227
223
|
exit 1
|
|
228
224
|
end
|
|
229
225
|
|
|
@@ -254,8 +250,6 @@ class Generator
|
|
|
254
250
|
# Returns +false+ if this is not the case.
|
|
255
251
|
#
|
|
256
252
|
def identical?( src, dst )
|
|
257
|
-
# FIXME: this most likely won't work on windows machines
|
|
258
|
-
# because the line endings are modified when the site is gnerated
|
|
259
253
|
source = IO.read(src)
|
|
260
254
|
destination = IO.read(dst)
|
|
261
255
|
source == destination
|
|
@@ -265,9 +259,8 @@ class Generator
|
|
|
265
259
|
#
|
|
266
260
|
def force_file_collision?( dst )
|
|
267
261
|
dst = dst.sub(%r/#{site}\/?/, '')
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
case @stdin.gets
|
|
262
|
+
print "overwrite #{dst}? [(Y)es (n)o (q)uit] "
|
|
263
|
+
case gets
|
|
271
264
|
when %r/q/i then abort 'user asked to quit'
|
|
272
265
|
when %r/n/i then :skip
|
|
273
266
|
when %r/y/i then :force
|
data/lib/webby/apps/main.rb
CHANGED
|
@@ -12,10 +12,13 @@ class Main
|
|
|
12
12
|
self.new.run args
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
+
attr_reader :cmd_line_options
|
|
16
|
+
|
|
15
17
|
# Create a new Main webby object for building websites.
|
|
16
18
|
#
|
|
17
19
|
def initialize
|
|
18
20
|
@stdout = $stdout
|
|
21
|
+
@cmd_line_options = {}
|
|
19
22
|
end
|
|
20
23
|
|
|
21
24
|
# Runs the main webby application. The command line arguments are passed
|
|
@@ -44,6 +47,16 @@ class Main
|
|
|
44
47
|
opts.on(*options)
|
|
45
48
|
end
|
|
46
49
|
|
|
50
|
+
opts.separator ''
|
|
51
|
+
opts.separator 'autobuild options:'
|
|
52
|
+
|
|
53
|
+
opts.on('--web-server', 'Start a local web server') {
|
|
54
|
+
cmd_line_options[:use_web_server] = true
|
|
55
|
+
}
|
|
56
|
+
opts.on('--no-web-server', 'Do not start a local web server') {
|
|
57
|
+
cmd_line_options[:use_web_server] = false
|
|
58
|
+
}
|
|
59
|
+
|
|
47
60
|
opts.separator ''
|
|
48
61
|
opts.separator 'common options:'
|
|
49
62
|
|
|
@@ -98,6 +111,7 @@ class Main
|
|
|
98
111
|
def rake
|
|
99
112
|
app.init 'webby'
|
|
100
113
|
app.load_rakefile
|
|
114
|
+
load_command_line_options
|
|
101
115
|
app.top_level
|
|
102
116
|
end
|
|
103
117
|
|
|
@@ -167,6 +181,14 @@ class Main
|
|
|
167
181
|
args
|
|
168
182
|
end
|
|
169
183
|
|
|
184
|
+
# Load options from the command line into the ::Webby.site struct
|
|
185
|
+
#
|
|
186
|
+
def load_command_line_options
|
|
187
|
+
cmd_line_options.each do |key, value|
|
|
188
|
+
::Webby.site.__send__("#{key}=", value)
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
|
|
170
192
|
end # class Main
|
|
171
193
|
end # module Webby::Apps
|
|
172
194
|
|
data/lib/webby/auto_builder.rb
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
require 'directory_watcher'
|
|
2
|
+
require 'launchy'
|
|
3
|
+
require 'webrick'
|
|
2
4
|
|
|
3
5
|
module Webby
|
|
4
6
|
|
|
@@ -21,13 +23,15 @@ class AutoBuilder
|
|
|
21
23
|
self.new.run
|
|
22
24
|
end
|
|
23
25
|
|
|
26
|
+
attr_reader :logger
|
|
27
|
+
|
|
24
28
|
# call-seq:
|
|
25
29
|
# AutoBuilder.new
|
|
26
30
|
#
|
|
27
31
|
# Create a new AutoBuilder class.
|
|
28
32
|
#
|
|
29
33
|
def initialize
|
|
30
|
-
@
|
|
34
|
+
@logger = Logging::Logger[self]
|
|
31
35
|
|
|
32
36
|
@builder = Builder.new
|
|
33
37
|
@builder.load_files
|
|
@@ -39,6 +43,8 @@ class AutoBuilder
|
|
|
39
43
|
glob << File.join(::Webby.site.layout_dir, '**', '*')
|
|
40
44
|
glob << File.join(::Webby.site.content_dir, '**', '*')
|
|
41
45
|
@watcher.glob = glob
|
|
46
|
+
|
|
47
|
+
@web_server = ::Webby.site.use_web_server ? WebServer.new : nil
|
|
42
48
|
end
|
|
43
49
|
|
|
44
50
|
# call-seq:
|
|
@@ -53,15 +59,16 @@ class AutoBuilder
|
|
|
53
59
|
return if ary.empty?
|
|
54
60
|
|
|
55
61
|
ary.each do |evt|
|
|
56
|
-
|
|
62
|
+
logger.debug "changed #{evt.path}"
|
|
57
63
|
next unless test ?f, evt.path
|
|
58
64
|
next if evt.path =~ ::Webby.exclude
|
|
59
65
|
Resources.new evt.path
|
|
60
66
|
end
|
|
61
67
|
|
|
62
|
-
|
|
68
|
+
logger.info 'running the build'
|
|
69
|
+
@builder.run :load_files => false, :verbose => false
|
|
63
70
|
rescue => err
|
|
64
|
-
|
|
71
|
+
logger.error err
|
|
65
72
|
end
|
|
66
73
|
|
|
67
74
|
# call-seq:
|
|
@@ -71,14 +78,79 @@ class AutoBuilder
|
|
|
71
78
|
# Ctrl-C to stop the watcher thread.
|
|
72
79
|
#
|
|
73
80
|
def run
|
|
74
|
-
|
|
81
|
+
logger.info 'starting autobuild (Ctrl-C to stop)'
|
|
75
82
|
|
|
76
|
-
Signal.trap('INT') {
|
|
83
|
+
Signal.trap('INT') {
|
|
84
|
+
@watcher.stop
|
|
85
|
+
@web_server.stop if @web_server
|
|
86
|
+
}
|
|
77
87
|
|
|
78
88
|
@watcher.start
|
|
89
|
+
if @web_server
|
|
90
|
+
@web_server.start
|
|
91
|
+
sleep 0.25
|
|
92
|
+
Launchy.open("http://localhost:#{::Webby.site.heel_port}")
|
|
93
|
+
end
|
|
94
|
+
|
|
79
95
|
@watcher.join
|
|
96
|
+
@web_server.join if @web_server
|
|
80
97
|
end
|
|
81
98
|
|
|
99
|
+
# Wrapper class around the webrick web server.
|
|
100
|
+
#
|
|
101
|
+
class WebServer
|
|
102
|
+
|
|
103
|
+
# Create a new webrick server configured to serve pages from the output
|
|
104
|
+
# directory. Output will be directed to /dev/null.
|
|
105
|
+
#
|
|
106
|
+
def initialize
|
|
107
|
+
logger = WEBrick::Log.new(Kernel::DEV_NULL, WEBrick::Log::DEBUG)
|
|
108
|
+
access_log = [[ logger, WEBrick::AccessLog::COMBINED_LOG_FORMAT ]]
|
|
109
|
+
|
|
110
|
+
@thread = nil
|
|
111
|
+
@running = false
|
|
112
|
+
@server = WEBrick::HTTPServer.new(
|
|
113
|
+
:BindAddress => 'localhost',
|
|
114
|
+
:Port => ::Webby.site.heel_port,
|
|
115
|
+
:DocumentRoot => ::Webby.site.output_dir,
|
|
116
|
+
:FancyIndexing => true,
|
|
117
|
+
:Logger => logger,
|
|
118
|
+
:AccessLog => access_log
|
|
119
|
+
)
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
# Returns +true+ if the server is running.
|
|
123
|
+
#
|
|
124
|
+
def running?
|
|
125
|
+
@running
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Start the webrick server running in a separate thread (so we don't
|
|
129
|
+
# block forever).
|
|
130
|
+
#
|
|
131
|
+
def start
|
|
132
|
+
return if running?
|
|
133
|
+
@running = true
|
|
134
|
+
@thread = Thread.new {@server.start}
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# Stop the webrick server.
|
|
138
|
+
#
|
|
139
|
+
def stop
|
|
140
|
+
return if not running?
|
|
141
|
+
@running = false
|
|
142
|
+
@server.shutdown
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# Join on the webserver thread.
|
|
146
|
+
#
|
|
147
|
+
def join
|
|
148
|
+
return if not running?
|
|
149
|
+
@thread.join
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
end # class WebServer
|
|
153
|
+
|
|
82
154
|
end # class AutoBuilder
|
|
83
155
|
end # module Webby
|
|
84
156
|
|