webby 0.8.4 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,6 +1,6 @@
|
|
1
1
|
---
|
2
|
-
title: Manual
|
3
|
-
created_at:
|
2
|
+
title: User Manual
|
3
|
+
created_at: 2007-08-29 08:57:00.000000 -06:00
|
4
4
|
filter:
|
5
5
|
- erb
|
6
6
|
- textile
|
@@ -10,12 +10,14 @@ filter:
|
|
10
10
|
|
11
11
|
p(title). Table of Contents
|
12
12
|
|
13
|
-
<toc />
|
13
|
+
<toc toc_range="h2-h6" />
|
14
14
|
</div>
|
15
15
|
|
16
|
+
h1. <%= h(@page.title) %>
|
17
|
+
|
16
18
|
h2. Introduction
|
17
19
|
|
18
|
-
Webby was created out of the
|
20
|
+
Webby was created out of the desire for a simple way to build and manage small websites. The goal was a system that could take files written in plain text, combine them with a layout file and produce web pages. In this system, a single page can be written quickly without the need for HTML markup; the look and feel of the entire site can be changed by modifying the site layout file.
|
19
21
|
|
20
22
|
<% graphviz :path => "images", :alt => "Webby Overview" do %>
|
21
23
|
digraph overview {
|
@@ -50,67 +52,68 @@ Webby is written in the Ruby programming language. To install and run Webby you
|
|
50
52
|
|
51
53
|
h3. Installation
|
52
54
|
|
53
|
-
Webby is easily installed as a Ruby gem. From a command prompt type
|
55
|
+
Webby is easily installed as a Ruby gem. From a command prompt type the following:
|
54
56
|
|
55
|
-
|
56
|
-
sudo gem install -y webby
|
57
|
-
</pre>
|
57
|
+
pre. sudo gem install webby
|
58
58
|
|
59
59
|
This will install Webby and all its required dependencies.
|
60
60
|
|
61
|
-
bq. For those users installing Webby on the Windows platform, please omit the @sudo@ portion of the above command. You will also need to specify the *mswin32* versions of the _mongrel_ and _hpricot_ gems when prompted.
|
62
|
-
|
63
61
|
To make use of all the features Webby has to offer, the following gems should also be installed. These gems provide different ways to transform text into HTML or CSS.
|
64
62
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
sudo gem install -y ultraviolet
|
71
|
-
</pre>
|
63
|
+
* RedCloth
|
64
|
+
* rdiscount
|
65
|
+
* haml
|
66
|
+
* coderay
|
67
|
+
* ultraviolet
|
72
68
|
|
73
|
-
Webby can also use a few other programs to clean up generated HTML and to
|
69
|
+
Webby can also use a few other programs to clean up generated HTML and to create pretty graphs and pictures. Where external programs are required, they will be duly noted in the manual.
|
74
70
|
|
75
71
|
h3. Running Webby
|
76
72
|
|
77
|
-
When
|
73
|
+
When Webby is installed, two command line programs are installed alongside the gem: @webby@ and @webby-gen@. The latter program is used to create a new Webby site folder and files. The former program is used within the site folder to generate the final site output from the content and layouts. Type @webby --help@ on the command line to see the options this program supports.
|
78
74
|
|
79
75
|
<pre>
|
80
|
-
|
76
|
+
webby --help
|
81
77
|
|
82
|
-
Usage: webby [options]
|
78
|
+
Usage: webby [options] task [task args]
|
83
79
|
|
84
|
-
-
|
80
|
+
-D, --describe [PATTERN] describe the tasks (matching optional PATTERN), then exit
|
81
|
+
-P, --prereqs display the tasks and dependencies, then exit
|
82
|
+
-T, --tasks [PATTERN] display the tasks (matching optional PATTERN) with descriptions, then exit
|
83
|
+
-t, --trace turn on invoke/execute tracing, enable full backtrace
|
85
84
|
|
86
85
|
common options:
|
87
86
|
-h, --help show this message
|
88
87
|
--version show version
|
89
88
|
</pre>
|
90
89
|
|
90
|
+
The @webby@ program is actually a smart wrapper around "Rake":http://docs.rubyrake.org/. It is used to run the tasks that will create new pages, build the output products, and deploy the site to a server. The list of available tasks can be seen by typing the following command in a Webby site folder:
|
91
|
+
|
92
|
+
pre. webby -T
|
91
93
|
|
92
|
-
The
|
94
|
+
The second program, @webby-gen@, is used less often but it is no less important. This is the *generate* command, and it is used to create a new Webby site folder and files. Type @webby-gen --help@ on the command line to see how the program is used.
|
93
95
|
|
94
96
|
<pre>
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
rake
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
rake validate # Alias to validate:internal
|
110
|
-
rake validate:external # Validate hyperlinks (include external sites)
|
111
|
-
rake validate:internal # Validate hyperlinks (exclude exteranl sites)
|
97
|
+
webby-gen --help
|
98
|
+
|
99
|
+
Usage: webby-gen [options] template site
|
100
|
+
|
101
|
+
-f, --force overwrite files that already exist
|
102
|
+
-s, --skip skip files that already exist
|
103
|
+
-u, --update update rake tasks for the site
|
104
|
+
-p, --pretend run but do not make any changes
|
105
|
+
|
106
|
+
-t, --templates list available templates
|
107
|
+
|
108
|
+
common options:
|
109
|
+
-h, --help show this message
|
110
|
+
--version show version
|
112
111
|
</pre>
|
113
112
|
|
113
|
+
The Webby generate command will create a new site folder (or update an existing site folder) using files from the desired template type. Each template is a collection of files that can be used as the starting point for a Webby project. You can see the list of available templates:
|
114
|
+
|
115
|
+
pre. webby-gen --templates
|
116
|
+
|
114
117
|
h2. Working With Resources
|
115
118
|
|
116
119
|
A resource is any file that is found in the _content_ or _layouts_ folders. Resources are either copied to the output folder or they are processed through the Webby filter engine to generate an output file. Resources fall into one of three types:
|
@@ -144,7 +147,7 @@ vestibulum libero. Aenean vitae justo. Nam eget tellus. Etiam convallis, est eu
|
|
144
147
|
lobortis mattis, lectus tellus tempus felis, a ultricies erat ipsum at metus.
|
145
148
|
</pre>
|
146
149
|
|
147
|
-
The page meta-data is contained in the first section
|
150
|
+
The page meta-data is contained in the first section. It is located between the two @---@ lines. The page meta-data will not be present in the generated HTML file. Only the page content (the text below the second @---@ line) will be rendered into the final HTML file. The meta-data defines a collection of attributes that (1) are made available to the various Webby filters and (2) provide instructions to the Webby filter engine itself.
|
148
151
|
|
149
152
|
Three attributes are defined in the above example: @title@, @created_at@, and @filter@. The first attribute, @title@, is associated with the value "Lorem Ipsum". This attribute is used in the first line of the page content to render the title using a combination of the ERB and Textile filters (more can be read in the "Filters":#filters section of this manual). The example page above will result in the following snippet of HTML code.
|
150
153
|
|
@@ -156,7 +159,7 @@ vestibulum libero. Aenean vitae justo. Nam eget tellus. Etiam convallis, est eu
|
|
156
159
|
lobortis mattis, lectus tellus tempus felis, a ultricies erat ipsum at metus.</p>
|
157
160
|
</pre>
|
158
161
|
|
159
|
-
You can see that the value of the @title@ attribute was substituted for the ERB snippet
|
162
|
+
You can see that the value of the @title@ attribute was substituted for the ERB snippet @<%%= @page.title %>@. All page attributes can be accessed using the @@page.attribute@ syntax within an ERB block. This will be discussed in greater detail in the "ERB Filter":#erbfilter section.
|
160
163
|
|
161
164
|
The last attribute in the meta-data section is the @filter@ attribute. The value for this attribute is a list of filters that will be applied to the page contents. The filters will be applied in the order they are specified. For the example page this would be the ERB filter followed by the Textile filter.
|
162
165
|
|
@@ -238,11 +241,11 @@ h3(#erbfilter). ERB
|
|
238
241
|
|
239
242
|
"ERB":http://ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html provides an easy to use but powerful templating system for Ruby. Using ERB, Ruby code can be added to any plain text document for the purposes of generating document information details and/or flow control. Much of the functionality Webby has to offer is made available through the erb filter. ERB does not place any limitations on the content of the page, so it is recommended to use the erb filter with another filter that simplifies the HTML markup -- Textile is my favorite, but Markdown and HAML support are provided in Webby, as well. Chose the markup language that suits your style.
|
240
243
|
|
241
|
-
Some examples of ERB have already been seen in the "pages":#pages section of this document. Ruby code is placed between ERB delimiters,
|
244
|
+
Some examples of ERB have already been seen in the "pages":#pages section of this document. Ruby code is placed between ERB delimiters, @<%%= ruby code %>@ somewhere in the content section of your page or layout. The erb filter executes that code and inserts the results into the page. Webby provides quite a few features that are accessed via ERB. Page attributes are one feature, and "helper methods":#helpermethods are another that are discussed elsewhere in this manual.
|
242
245
|
|
243
|
-
<pre
|
244
|
-
The title of this page is "
|
245
|
-
</
|
246
|
+
<pre>
|
247
|
+
The title of this page is "<%%= @page.title" %>".
|
248
|
+
</pre>
|
246
249
|
|
247
250
|
<pre>
|
248
251
|
The title of this page is "<%= @page.title %>".
|
@@ -269,7 +272,7 @@ h3. Textile
|
|
269
272
|
|
270
273
|
A complete textile reference is beyond the scope of this document. Please refer to the "Textile reference":http://hobix.com/textile/ compiled by _why the luck stiff_ <sup><a href="#fn1">1</a></sup>.
|
271
274
|
|
272
|
-
The textile filter will operate on all the contents of a page or layout. Given that fact, it should be one of the last filters applied to the page. You can prevent a section of the page from being processed by the textile filter by surrounding it with
|
275
|
+
The textile filter will operate on all the contents of a page or layout. Given that fact, it should be one of the last filters applied to the page. You can prevent a section of the page from being processed by the textile filter by surrounding it with @<notextile>...</notextile>@ tags.
|
273
276
|
|
274
277
|
<div class="label">Usage</div>
|
275
278
|
<div class="desc">
|
@@ -308,7 +311,7 @@ none
|
|
308
311
|
|
309
312
|
<div class="label">Require</div>
|
310
313
|
<div class="desc">
|
311
|
-
The *
|
314
|
+
The *rdiscount* gem must be installed on your system in order to use the markdown filter.
|
312
315
|
</div>
|
313
316
|
|
314
317
|
h3. HAML & SASS
|
@@ -335,7 +338,7 @@ p(last). Options are passed to the sass filter by setting the "sass_options" in
|
|
335
338
|
|
336
339
|
<div class="label">Require</div>
|
337
340
|
<div class="desc">
|
338
|
-
The
|
341
|
+
The *haml* gem must be installed on your system in order to use the haml filter or the sass filter.
|
339
342
|
</div>
|
340
343
|
|
341
344
|
h3. Outline
|
@@ -364,7 +367,7 @@ The basepath filter only works on HTML/XHTML text, and therefore, it should be o
|
|
364
367
|
Include "basepath" in the filter list of your layout(s). Specify the new base path to use either as a command line argument or as an option configured in the _Rakefile_. The base path specified on the command line takes precedence over the base path specified in the Rakefile.
|
365
368
|
|
366
369
|
<pre style="margin-bottom:0">
|
367
|
-
$
|
370
|
+
$ webby rebuild BASE='http://your.website.com/path/to/your/site'
|
368
371
|
</pre>
|
369
372
|
</div>
|
370
373
|
|
@@ -3,7 +3,6 @@ extension: html
|
|
3
3
|
filter:
|
4
4
|
- erb
|
5
5
|
- basepath
|
6
|
-
- tidy
|
7
6
|
---
|
8
7
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
9
8
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
@@ -26,26 +25,20 @@ filter:
|
|
26
25
|
|
27
26
|
<div class="container">
|
28
27
|
|
29
|
-
<div class="column span-
|
30
|
-
<h1>Webby ☯ <%= h(@page.title) %></h1>
|
31
|
-
</div>
|
32
|
-
|
33
|
-
<div class="column span-4 prepend-1 first" id="navigation">
|
28
|
+
<div class="column span-17 prepend-4 append-3 first last" id="header">
|
34
29
|
<ul
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
><li><a href="http://groups.google.com/group/webby-forum">Forum</a></li
|
41
|
-
></ul>
|
30
|
+
><li><%= link_to_page('Learn') %></li
|
31
|
+
><li><%= link_to_page('Communicate') %></a></li
|
32
|
+
></ul>
|
33
|
+
<h1><a href="/">Webby</a></h1>
|
34
|
+
<p>- ascii alchemy</p>
|
42
35
|
</div>
|
43
36
|
|
44
|
-
<div class="column span-
|
37
|
+
<div class="column span-17 prepend-4 append-3 last">
|
45
38
|
<%= @content %>
|
46
39
|
</div>
|
47
40
|
|
48
|
-
<div class="column span-
|
41
|
+
<div class="column span-21 prepend-2 append-1 first last" id="footer">
|
49
42
|
<hr />
|
50
43
|
<p>This website was created with <a href="http://webby.rubyforge.org">Webby</a><br />
|
51
44
|
Webby is released under the MIT license</p>
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/{data → examples/website}/content/css/blueprint/plugins/fancy-type/fancy-type-compressed.css
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,283 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'optparse'
|
3
|
+
|
4
|
+
module Webby::Apps
|
5
|
+
|
6
|
+
# webby gen template site => creates the tmplate
|
7
|
+
# webby gen -h / --help
|
8
|
+
# webby gen => same as --help
|
9
|
+
#
|
10
|
+
|
11
|
+
class Generator
|
12
|
+
|
13
|
+
# Create a new Generator instance and run the +webby+ application given the
|
14
|
+
# command line _args_.
|
15
|
+
#
|
16
|
+
def self.run( args )
|
17
|
+
self.new.run args
|
18
|
+
end
|
19
|
+
|
20
|
+
attr_accessor :template, :site
|
21
|
+
attr_reader :options
|
22
|
+
|
23
|
+
# Initialize a new generator object.
|
24
|
+
#
|
25
|
+
def initialize
|
26
|
+
@options = {}
|
27
|
+
@site = @template = nil
|
28
|
+
@stdout, @stdin = $stdout, $stdin
|
29
|
+
end
|
30
|
+
|
31
|
+
# Run the generator executing the commands specified by the user on the
|
32
|
+
# command line.
|
33
|
+
#
|
34
|
+
def run( args )
|
35
|
+
parse args
|
36
|
+
create_site
|
37
|
+
end
|
38
|
+
|
39
|
+
# Parse out the command line options found in the args array.
|
40
|
+
#
|
41
|
+
def parse( args )
|
42
|
+
opts = OptionParser.new
|
43
|
+
opts.banner = 'Usage: webby-gen [options] template site'
|
44
|
+
|
45
|
+
opts.separator ''
|
46
|
+
opts.separator 'The webby-gen command is used to generate a site from a standard template.'
|
47
|
+
opts.separator 'A new site can be created, or an existing site can be added to or updated.'
|
48
|
+
|
49
|
+
opts.separator ''
|
50
|
+
opts.on('-f', '--force',
|
51
|
+
'overwrite files that already exist') {options[:collision] = :force}
|
52
|
+
opts.on('-s', '--skip',
|
53
|
+
'skip files that already exist') {options[:collision] = :skip}
|
54
|
+
opts.on('-u', '--update',
|
55
|
+
'update rake tasks for the site') {options[:update] = true}
|
56
|
+
opts.on('-p', '--pretend',
|
57
|
+
'run but do not make any changes') {options[:pretend] = true}
|
58
|
+
|
59
|
+
opts.separator ''
|
60
|
+
opts.on('-t', '--templates', 'list available templates') {
|
61
|
+
ary = templates.map {|t| ::File.basename(t)}
|
62
|
+
ary.delete 'webby'
|
63
|
+
@stdout.puts "\nAvailable Templates"
|
64
|
+
@stdout.puts " #{ary.join(', ')}"
|
65
|
+
@stdout.puts
|
66
|
+
exit
|
67
|
+
}
|
68
|
+
|
69
|
+
opts.separator ''
|
70
|
+
opts.separator 'common options:'
|
71
|
+
|
72
|
+
opts.on( '-h', '--help', 'show this message' ) {@stdout.puts opts; exit}
|
73
|
+
opts.on( '--version', 'show version' ) do
|
74
|
+
@stdout.puts "Webby #{::Webby::VERSION}"
|
75
|
+
exit
|
76
|
+
end
|
77
|
+
|
78
|
+
# parse the command line arguments
|
79
|
+
opts.parse! args
|
80
|
+
tmpl, @site = args
|
81
|
+
|
82
|
+
# if no site was given, see if there is a Sitefile in the current
|
83
|
+
# directory
|
84
|
+
if site.nil?
|
85
|
+
self.site = '.' if test(?f, 'Sitefile')
|
86
|
+
end
|
87
|
+
|
88
|
+
# exit if comand line args are missing
|
89
|
+
if site.nil? or tmpl.nil?
|
90
|
+
@stdout.puts opts
|
91
|
+
exit 1
|
92
|
+
end
|
93
|
+
|
94
|
+
templates.each {|t| self.template = t if t =~ %r/\/#{tmpl}$/}
|
95
|
+
if template.nil?
|
96
|
+
@stdout.puts opts
|
97
|
+
abort "Could not find template '#{tmpl}'"
|
98
|
+
end
|
99
|
+
|
100
|
+
nil
|
101
|
+
end
|
102
|
+
|
103
|
+
# Returns +true+ if we are only going to pretend to do something. All the
|
104
|
+
# output messages will be written, but no changes will be made on the
|
105
|
+
# disc.
|
106
|
+
#
|
107
|
+
def pretend?
|
108
|
+
options[:pretend] == true
|
109
|
+
end
|
110
|
+
|
111
|
+
# Returns an array of available site templates.
|
112
|
+
#
|
113
|
+
def templates
|
114
|
+
Dir.glob(::Webby.path('examples') / '*').sort
|
115
|
+
end
|
116
|
+
|
117
|
+
# Create the site from the template specified by the user.
|
118
|
+
#
|
119
|
+
def create_site
|
120
|
+
files = site_files
|
121
|
+
|
122
|
+
# in update mode we only want to update the tasks directory
|
123
|
+
if options[:update]
|
124
|
+
FileUtils.mkdir_p site unless pretend?
|
125
|
+
mkdir 'tasks'
|
126
|
+
files['tasks'].sort.each {|file| cp file}
|
127
|
+
else
|
128
|
+
dirs = files.keys.concat %w[content layouts lib tasks templates]
|
129
|
+
dirs.sort!
|
130
|
+
dirs.uniq!
|
131
|
+
|
132
|
+
# create the directories first
|
133
|
+
dirs.each do |dir|
|
134
|
+
next if dir =~ %r/^output\/.*$/
|
135
|
+
mkdir dir
|
136
|
+
end
|
137
|
+
|
138
|
+
# and the create the files under each directory
|
139
|
+
dirs.each do |dir|
|
140
|
+
next if dir =~ %r/^output(\/.*)?$/
|
141
|
+
files[dir].sort.each {|file| cp file}
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
# Make a directory in the user specified site location. A message will be
|
147
|
+
# displayed to the screen indicating tha the directory is being created.
|
148
|
+
#
|
149
|
+
def mkdir( dir )
|
150
|
+
dir = dir.empty? ? site : site / dir
|
151
|
+
if test ?d, dir
|
152
|
+
exists dir
|
153
|
+
else
|
154
|
+
create dir
|
155
|
+
FileUtils.mkdir_p dir unless pretend?
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
# Copy a file from the template location to the user specified site
|
160
|
+
# location. A message will be displayed to the screen indicating tha the
|
161
|
+
# file is being created.
|
162
|
+
#
|
163
|
+
def cp( file )
|
164
|
+
src = template / file
|
165
|
+
dst = site / file
|
166
|
+
|
167
|
+
if test(?e, dst)
|
168
|
+
if identical?(src, dst)
|
169
|
+
identical(dst)
|
170
|
+
return
|
171
|
+
end
|
172
|
+
|
173
|
+
choice = case options[:collision]
|
174
|
+
when :force then :force
|
175
|
+
when :skip then :skip
|
176
|
+
else force_file_collision?( dst ) end
|
177
|
+
|
178
|
+
case choice
|
179
|
+
when :force then force(dst)
|
180
|
+
when :skip then skip(dst); return
|
181
|
+
else raise "Invalid collision choice: #{choice.inspect}" end
|
182
|
+
else
|
183
|
+
create(dst)
|
184
|
+
end
|
185
|
+
return if pretend?
|
186
|
+
|
187
|
+
if WINDOWS then win_line_endings(src, dst)
|
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]
|
218
|
+
end
|
219
|
+
|
220
|
+
# Prints an abort message to the screen and then exits the Ruby
|
221
|
+
# interpreter. A non-zero return code is used to indicate an error.
|
222
|
+
#
|
223
|
+
def abort( msg )
|
224
|
+
@stdout.puts "\nAborting!"
|
225
|
+
@stdout.puts " #{msg}"
|
226
|
+
@stdout.puts
|
227
|
+
exit 1
|
228
|
+
end
|
229
|
+
|
230
|
+
# Iterates over all the files in the template directory and stores them in
|
231
|
+
# a hash.
|
232
|
+
#
|
233
|
+
def site_files
|
234
|
+
exclude = %r/tmp$|bak$|~$|CVS|\.svn/o
|
235
|
+
|
236
|
+
rgxp = %r/\A#{template}\/?/o
|
237
|
+
paths = Hash.new {|h,k| h[k] = []}
|
238
|
+
|
239
|
+
Find.find(template) do |p|
|
240
|
+
next if exclude =~ p
|
241
|
+
|
242
|
+
if test(?d, p)
|
243
|
+
paths[p.sub(rgxp, '')]
|
244
|
+
next
|
245
|
+
end
|
246
|
+
dir = ::File.dirname(p).sub(rgxp, '')
|
247
|
+
paths[dir] << p.sub(rgxp, '')
|
248
|
+
end
|
249
|
+
|
250
|
+
paths
|
251
|
+
end
|
252
|
+
|
253
|
+
# Returns +true+ if the source file is identical to the destination file.
|
254
|
+
# Returns +false+ if this is not the case.
|
255
|
+
#
|
256
|
+
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
|
+
source = IO.read(src)
|
260
|
+
destination = IO.read(dst)
|
261
|
+
source == destination
|
262
|
+
end
|
263
|
+
|
264
|
+
# Ask the user what to do about the file collision.
|
265
|
+
#
|
266
|
+
def force_file_collision?( dst )
|
267
|
+
dst = dst.sub(%r/#{site}\/?/, '')
|
268
|
+
@stdout.print "overwrite #{dst}? [(Y)es (n)o (q)uit] "
|
269
|
+
@stdout.flush
|
270
|
+
case @stdin.gets
|
271
|
+
when %r/q/i then abort 'user asked to quit'
|
272
|
+
when %r/n/i then :skip
|
273
|
+
when %r/y/i then :force
|
274
|
+
when %r/\s*/ then :force
|
275
|
+
else force_file_collision?(dst) end
|
276
|
+
rescue
|
277
|
+
retry
|
278
|
+
end
|
279
|
+
|
280
|
+
end # class Generator
|
281
|
+
end # module Webby::Apps
|
282
|
+
|
283
|
+
# EOF
|