webby 0.9.2 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +13 -0
- data/Manifest.txt +44 -33
- 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 +49 -0
- data/lib/webby.rb +3 -10
- 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/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 -56
- 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
|
@@ -150,48 +152,57 @@ lib/webby/tasks/build.rake
|
|
150
152
|
lib/webby/tasks/create.rake
|
151
153
|
lib/webby/tasks/deploy.rake
|
152
154
|
lib/webby/tasks/growl.rake
|
153
|
-
lib/webby/tasks/heel.rake
|
154
155
|
lib/webby/tasks/validate.rake
|
155
156
|
spec/core_ext/hash_spec.rb
|
156
157
|
spec/core_ext/string_spec.rb
|
157
158
|
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
159
|
spec/data/hooligans/bad_meta_data_1.txt
|
175
160
|
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/
|
161
|
+
spec/data/outline/basic.out
|
162
|
+
spec/data/outline/basic.txt
|
163
|
+
spec/data/outline/no_clobber.out
|
164
|
+
spec/data/outline/numbering.out
|
165
|
+
spec/data/outline/numbering_only.out
|
166
|
+
spec/data/outline/toc_range_1.out
|
167
|
+
spec/data/outline/toc_range_2.out
|
168
|
+
spec/data/outline/toc_style.out
|
169
|
+
spec/data/site/Sitefile
|
170
|
+
spec/data/site/content/_partial.txt
|
171
|
+
spec/data/site/content/css/coderay.css
|
172
|
+
spec/data/site/content/css/site.css
|
173
|
+
spec/data/site/content/css/tumblog.css
|
174
|
+
spec/data/site/content/images/tumblog/permalink.gif
|
175
|
+
spec/data/site/content/images/tumblog/rss.gif
|
176
|
+
spec/data/site/content/index.txt
|
177
|
+
spec/data/site/content/photos.txt
|
178
|
+
spec/data/site/content/tumblog/200806/the-noble-chicken/index.txt
|
179
|
+
spec/data/site/content/tumblog/200807/historical-perspectives-on-the-classic-chicken-joke/index.txt
|
180
|
+
spec/data/site/content/tumblog/200807/mad-city-chickens/index.txt
|
181
|
+
spec/data/site/content/tumblog/200807/the-wisdom-of-the-dutch/index.txt
|
182
|
+
spec/data/site/content/tumblog/200807/up-a-tree/index.txt
|
183
|
+
spec/data/site/content/tumblog/index.txt
|
184
|
+
spec/data/site/content/tumblog/rss.txt
|
185
|
+
spec/data/site/layouts/default.txt
|
186
|
+
spec/data/site/layouts/tumblog/default.txt
|
187
|
+
spec/data/site/layouts/tumblog/post.txt
|
188
|
+
spec/data/site/lib/breadcrumbs.rb
|
189
|
+
spec/data/site/lib/tumblog_helper.rb
|
190
|
+
spec/data/site/tasks/tumblog.rake
|
191
|
+
spec/data/site/templates/_partial.erb
|
192
|
+
spec/data/site/templates/atom_feed.erb
|
193
|
+
spec/data/site/templates/page.erb
|
194
|
+
spec/data/site/templates/presentation.erb
|
195
|
+
spec/data/site/templates/tumblog/conversation.erb
|
196
|
+
spec/data/site/templates/tumblog/link.erb
|
197
|
+
spec/data/site/templates/tumblog/photo.erb
|
198
|
+
spec/data/site/templates/tumblog/post.erb
|
199
|
+
spec/data/site/templates/tumblog/quote.erb
|
191
200
|
spec/spec.opts
|
192
201
|
spec/spec_helper.rb
|
193
202
|
spec/webby/apps/generator_spec.rb
|
194
203
|
spec/webby/apps/main_spec.rb
|
204
|
+
spec/webby/filters/basepath_spec.rb
|
205
|
+
spec/webby/filters/outline_spec.rb
|
195
206
|
spec/webby/filters/textile_spec.rb
|
196
207
|
spec/webby/helpers/capture_helper_spec.rb
|
197
208
|
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,49 @@
|
|
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
|
+
FIXME
|
12
|
+
|
13
|
+
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.
|
14
|
+
|
15
|
+
* 4 minor enhancements
|
16
|
+
** Added a "wikiwords" filter to process [[text]] as links to other pages (thanks to Paul)
|
17
|
+
** Added colorization to the output text (facets gem required)
|
18
|
+
** Replaced the Heel webserver with webrick
|
19
|
+
** Special windows version with windows line endings in generated files
|
20
|
+
* 2 bug fixes
|
21
|
+
** Fixed a bug on Windows where line endings were messing with meta-data
|
22
|
+
** The paginator was not linking correctly back to the first page from subsequent pages in a list
|
23
|
+
|
24
|
+
h3. Wiki Words
|
25
|
+
|
26
|
+
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.
|
27
|
+
|
28
|
+
<pre>
|
29
|
+
<%= Webby::YAML_SEP %>
|
30
|
+
title: Special Report
|
31
|
+
created_at: 2008-10-08 21:22:41.217238 -06:00
|
32
|
+
filter:
|
33
|
+
- wikiwords
|
34
|
+
- textile
|
35
|
+
<%= Webby::YAML_SEP %>
|
36
|
+
h1. Special Report
|
37
|
+
|
38
|
+
This page is a special report that links to some [[Other Page]] in the site and
|
39
|
+
offers a little more information. You can find out more in the [[Reference]]
|
40
|
+
page, too.
|
41
|
+
</pre>
|
42
|
+
|
43
|
+
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.
|
44
|
+
|
45
|
+
h3. Windows Support
|
46
|
+
|
47
|
+
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.
|
48
|
+
|
49
|
+
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.rb
CHANGED
@@ -7,18 +7,10 @@ require 'logging'
|
|
7
7
|
require 'ostruct'
|
8
8
|
require 'date'
|
9
9
|
|
10
|
-
# Configure Webby to log to STDOUT at the 'info' level
|
11
|
-
Logging::Logger['Webby'].level = :info
|
12
|
-
Logging::Logger['Webby'].add_appenders(Logging::Appender.stdout)
|
13
|
-
Logging::Appender.stdout.layout = Logging::Layouts::Pattern.new(
|
14
|
-
:pattern => "[%d] %5l: %m\n", # [date] LEVEL: message
|
15
|
-
:date_pattern => "%H:%M:%S" # date == HH:MM:SS
|
16
|
-
)
|
17
|
-
|
18
10
|
module Webby
|
19
11
|
|
20
12
|
# :stopdoc:
|
21
|
-
VERSION = '0.9.
|
13
|
+
VERSION = '0.9.3' # :nodoc:
|
22
14
|
LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
|
23
15
|
PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
|
24
16
|
YAML_SEP = '---'
|
@@ -51,7 +43,8 @@ module Webby
|
|
51
43
|
:tumblog_dir => 'tumblog',
|
52
44
|
|
53
45
|
# Items for running the heel webserver
|
54
|
-
:
|
46
|
+
:use_web_server => true,
|
47
|
+
:heel_port => 4331,
|
55
48
|
|
56
49
|
# Items used to deploy the website
|
57
50
|
:user => ENV['USER'] || ENV['USERNAME'],
|
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
|