webby 0.8.4 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (165) hide show
  1. data/History.txt +19 -0
  2. data/Manifest.txt +104 -91
  3. data/README.txt +27 -45
  4. data/Rakefile +4 -5
  5. data/bin/webby +2 -1
  6. data/bin/webby-gen +8 -0
  7. data/{data/Rakefile → examples/blog/Sitefile} +0 -2
  8. data/examples/{webby → blog}/tasks/blog.rake +5 -4
  9. data/{data → examples/blog}/templates/atom_feed.erb +10 -11
  10. data/{data → examples/blog}/templates/blog/month.erb +1 -1
  11. data/{data → examples/blog}/templates/blog/post.erb +1 -0
  12. data/{data → examples/blog}/templates/blog/year.erb +1 -1
  13. data/examples/presentation/{Rakefile → Sitefile} +0 -4
  14. data/examples/presentation/content/{_sample_code.txt → presentation/_sample_code.txt} +0 -0
  15. data/examples/presentation/content/{index.txt → presentation/index.txt} +0 -0
  16. data/{data/content → examples/presentation/content/presentation}/s5/blank.gif +0 -0
  17. data/{data/content → examples/presentation/content/presentation}/s5/bodybg.gif +0 -0
  18. data/{data/content → examples/presentation/content/presentation}/s5/framing.css +0 -0
  19. data/{data/content → examples/presentation/content/presentation}/s5/iepngfix.htc +0 -0
  20. data/{data/content → examples/presentation/content/presentation}/s5/opera.css +0 -0
  21. data/{data/content → examples/presentation/content/presentation}/s5/outline.css +0 -0
  22. data/{data/content → examples/presentation/content/presentation}/s5/pretty.css +0 -0
  23. data/{data/content → examples/presentation/content/presentation}/s5/print.css +0 -0
  24. data/{data/content → examples/presentation/content/presentation}/s5/s5-core.css +0 -0
  25. data/{data/content → examples/presentation/content/presentation}/s5/slides.css +0 -0
  26. data/{data/content → examples/presentation/content/presentation}/s5/slides.js +0 -0
  27. data/examples/presentation/layouts/{presentation.rhtml → presentation.txt} +3 -3
  28. data/examples/presentation/templates/{_partial.erb → _code_partial.erb} +0 -0
  29. data/examples/tumblog/Sitefile +9 -0
  30. data/examples/tumblog/content/css/tumblog.css +308 -0
  31. data/examples/tumblog/content/images/tumblog/permalink.gif +0 -0
  32. data/examples/tumblog/content/images/tumblog/rss.gif +0 -0
  33. data/examples/tumblog/content/tumblog/200806/the-noble-chicken/index.txt +12 -0
  34. data/examples/tumblog/content/tumblog/200807/historical-perspectives-on-the-classic-chicken-joke/index.txt +12 -0
  35. data/examples/tumblog/content/tumblog/200807/mad-city-chickens/index.txt +10 -0
  36. data/examples/tumblog/content/tumblog/200807/the-wisdom-of-the-dutch/index.txt +11 -0
  37. data/examples/tumblog/content/tumblog/200807/up-a-tree/index.txt +13 -0
  38. data/examples/tumblog/content/tumblog/index.txt +37 -0
  39. data/examples/tumblog/content/tumblog/rss.txt +37 -0
  40. data/examples/tumblog/layouts/tumblog/default.txt +44 -0
  41. data/examples/tumblog/layouts/tumblog/post.txt +15 -0
  42. data/examples/tumblog/lib/tumblog_helper.rb +32 -0
  43. data/examples/tumblog/tasks/tumblog.rake +30 -0
  44. data/examples/tumblog/templates/atom_feed.erb +40 -0
  45. data/examples/tumblog/templates/tumblog/conversation.erb +12 -0
  46. data/examples/tumblog/templates/tumblog/link.erb +10 -0
  47. data/examples/tumblog/templates/tumblog/photo.erb +13 -0
  48. data/examples/tumblog/templates/tumblog/post.erb +12 -0
  49. data/examples/tumblog/templates/tumblog/quote.erb +11 -0
  50. data/examples/webby/{Rakefile → Sitefile} +2 -2
  51. data/examples/webby/content/communicate/index.txt +28 -0
  52. data/examples/webby/content/css/background.gif +0 -0
  53. data/examples/webby/content/css/site.css +52 -20
  54. data/examples/webby/content/index.txt +7 -8
  55. data/examples/webby/content/learn/index.txt +28 -0
  56. data/examples/webby/content/reference/index.txt +3 -1
  57. data/examples/webby/content/release-notes/rel-0-9-0/index.txt +73 -0
  58. data/examples/webby/content/sitemap.txt +31 -0
  59. data/examples/webby/content/tips_and_tricks/index.txt +1 -1
  60. data/examples/webby/content/tutorial/index.txt +17 -17
  61. data/examples/webby/content/{manual → user-manual}/index.txt +53 -50
  62. data/examples/webby/layouts/{default.rhtml → default.txt} +8 -15
  63. data/examples/webby/templates/page.erb +1 -1
  64. data/examples/website/Sitefile +7 -0
  65. data/{data → examples/website}/content/css/blueprint/License.txt +0 -0
  66. data/{data → examples/website}/content/css/blueprint/Readme.txt +0 -0
  67. data/{data → examples/website}/content/css/blueprint/compressed/print.css +0 -0
  68. data/{data → examples/website}/content/css/blueprint/compressed/screen.css +0 -0
  69. data/{data → examples/website}/content/css/blueprint/lib/forms.css +0 -0
  70. data/{data → examples/website}/content/css/blueprint/lib/grid.css +0 -0
  71. data/{data → examples/website}/content/css/blueprint/lib/grid.png +0 -0
  72. data/{data → examples/website}/content/css/blueprint/lib/ie.css +0 -0
  73. data/{data → examples/website}/content/css/blueprint/lib/reset.css +0 -0
  74. data/{data → examples/website}/content/css/blueprint/lib/typography.css +0 -0
  75. data/{data → examples/website}/content/css/blueprint/plugins/buttons/Readme +0 -0
  76. data/{data → examples/website}/content/css/blueprint/plugins/buttons/buttons.css +0 -0
  77. data/{data → examples/website}/content/css/blueprint/plugins/buttons/icons/cross.png +0 -0
  78. data/{data → examples/website}/content/css/blueprint/plugins/buttons/icons/key.png +0 -0
  79. data/{data → examples/website}/content/css/blueprint/plugins/buttons/icons/tick.png +0 -0
  80. data/{data → examples/website}/content/css/blueprint/plugins/css-classes/Readme +0 -0
  81. data/{data → examples/website}/content/css/blueprint/plugins/css-classes/css-classes.css +0 -0
  82. data/{data → examples/website}/content/css/blueprint/plugins/fancy-type/Readme +0 -0
  83. data/{data → examples/website}/content/css/blueprint/plugins/fancy-type/fancy-type-compressed.css +0 -0
  84. data/{data → examples/website}/content/css/blueprint/plugins/fancy-type/fancy-type.css +0 -0
  85. data/{data → examples/website}/content/css/blueprint/print.css +0 -0
  86. data/{data → examples/website}/content/css/blueprint/screen.css +0 -0
  87. data/{data → examples/website}/content/css/coderay.css +0 -0
  88. data/{data → examples/website}/content/css/site.css +0 -0
  89. data/{data → examples/website}/content/index.txt +2 -1
  90. data/{data/layouts/default.rhtml → examples/website/layouts/default.txt} +1 -1
  91. data/{data → examples/website}/lib/breadcrumbs.rb +0 -0
  92. data/{data → examples/website}/templates/_partial.erb +0 -0
  93. data/{data → examples/website}/templates/page.erb +0 -0
  94. data/{data → examples/website}/templates/presentation.erb +0 -0
  95. data/lib/webby/apps/generator.rb +283 -0
  96. data/lib/webby/apps/main.rb +221 -0
  97. data/lib/webby/apps.rb +12 -0
  98. data/lib/webby/builder.rb +8 -10
  99. data/lib/webby/core_ext/enumerable.rb +11 -0
  100. data/lib/webby/{utils.rb → core_ext/hash.rb} +2 -26
  101. data/lib/webby/core_ext/kernel.rb +21 -0
  102. data/lib/webby/core_ext/string.rb +163 -0
  103. data/lib/webby/core_ext/time.rb +9 -0
  104. data/lib/webby/filters/haml.rb +13 -5
  105. data/lib/webby/filters/markdown.rb +12 -4
  106. data/lib/webby/filters/outline.rb +3 -2
  107. data/lib/webby/filters/sass.rb +12 -4
  108. data/lib/webby/filters/textile.rb +12 -4
  109. data/lib/webby/filters/tidy.rb +10 -8
  110. data/lib/webby/filters.rb +2 -0
  111. data/lib/webby/helpers/graphviz_helper.rb +1 -2
  112. data/lib/webby/helpers/tex_img_helper.rb +6 -10
  113. data/lib/webby/renderer.rb +5 -3
  114. data/lib/webby/resources/layout.rb +1 -1
  115. data/lib/webby/resources/page.rb +1 -1
  116. data/lib/webby/resources/resource.rb +13 -3
  117. data/lib/webby/resources.rb +16 -0
  118. data/{data → lib/webby}/tasks/build.rake +0 -0
  119. data/{examples/presentation → lib/webby}/tasks/create.rake +1 -1
  120. data/{data → lib/webby}/tasks/deploy.rake +0 -0
  121. data/{examples → lib}/webby/tasks/growl.rake +4 -1
  122. data/{data → lib/webby}/tasks/heel.rake +0 -0
  123. data/{data → lib/webby}/tasks/validate.rake +0 -0
  124. data/lib/webby.rb +11 -5
  125. data/spec/core_ext/hash_spec.rb +47 -0
  126. data/spec/core_ext/string_spec.rb +110 -0
  127. data/spec/core_ext/time_spec.rb +19 -0
  128. data/spec/webby/apps/generator_spec.rb +111 -0
  129. data/spec/webby/apps/main_spec.rb +75 -0
  130. data/spec/webby/helpers/capture_helper_spec.rb +1 -1
  131. data/spec/webby/resources_spec.rb +17 -0
  132. data/tasks/gem.rake +10 -2
  133. data/tasks/git.rake +41 -0
  134. data/tasks/rubyforge.rake +2 -2
  135. data/tasks/website.rake +38 -38
  136. metadata +125 -98
  137. data/data/tasks/blog.rake +0 -71
  138. data/data/tasks/create.rake +0 -22
  139. data/data/tasks/growl.rake +0 -12
  140. data/data/tasks/setup.rb +0 -17
  141. data/examples/presentation/content/s5/blank.gif +0 -0
  142. data/examples/presentation/content/s5/bodybg.gif +0 -0
  143. data/examples/presentation/content/s5/framing.css +0 -23
  144. data/examples/presentation/content/s5/iepngfix.htc +0 -42
  145. data/examples/presentation/content/s5/opera.css +0 -7
  146. data/examples/presentation/content/s5/outline.css +0 -15
  147. data/examples/presentation/content/s5/pretty.css +0 -86
  148. data/examples/presentation/content/s5/print.css +0 -1
  149. data/examples/presentation/content/s5/s5-core.css +0 -9
  150. data/examples/presentation/content/s5/slides.css +0 -3
  151. data/examples/presentation/content/s5/slides.js +0 -553
  152. data/examples/presentation/tasks/blog.rake +0 -71
  153. data/examples/presentation/tasks/build.rake +0 -27
  154. data/examples/presentation/tasks/deploy.rake +0 -22
  155. data/examples/presentation/tasks/growl.rake +0 -12
  156. data/examples/presentation/tasks/heel.rake +0 -28
  157. data/examples/presentation/tasks/setup.rb +0 -17
  158. data/examples/presentation/tasks/validate.rake +0 -19
  159. data/examples/webby/tasks/build.rake +0 -27
  160. data/examples/webby/tasks/create.rake +0 -22
  161. data/examples/webby/tasks/deploy.rake +0 -22
  162. data/examples/webby/tasks/heel.rake +0 -28
  163. data/examples/webby/tasks/setup.rb +0 -17
  164. data/examples/webby/tasks/validate.rake +0 -19
  165. data/lib/webby/main.rb +0 -227
@@ -1,6 +1,6 @@
1
1
  ---
2
- title: Manual
3
- created_at: Wed Aug 29 08:57:00 -0600 2007
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 need for a simple way to build and manage small websites. The desire was for 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.
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 in the following:
55
+ Webby is easily installed as a Ruby gem. From a command prompt type the following:
54
56
 
55
- <pre>
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
- <pre>
66
- sudo gem install -y RedCloth
67
- sudo gem install -y BlueCloth
68
- sudo gem install -y haml
69
- sudo gem install -y coderay
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 created pretty graphs and pictures. Where external programs are required, they will be duly noted in the manual.
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 the Webby gem is installed it also installs a @webby@ executable program. This program is used to create a new website and to update the associated rake tasks when a new version of Webby is released. Typing in @webby --help@ will show you the options this program supports. After you create a website, though, the webby command will not be needed.
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
- $ webby --help
76
+ webby --help
81
77
 
82
- Usage: webby [options] site
78
+ Usage: webby [options] task [task args]
83
79
 
84
- -u, --update update the rake tasks for the site
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 day to day tasks of working with a webiste - creating pages, building the website, deploying changes to the server - are handled by the "Rake":http://docs.rubyrake.org/ application, a Ruby version of the more famous *make* program. Several rake tasks are provided by default. You are free to create others to make developing and deploying your website easier. To see the current list of rake tasks type in @rake -T@.
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
- $ rake -T
96
-
97
- rake autobuild # Continuously build the website
98
- rake build # Build the website
99
- rake clobber # Delete the website
100
- rake create:page # Create a new page
101
- rake create:partial # Create a new partial
102
- rake deploy # deploy the website to Rubyforge
103
- rake deploy:rsync # Deploy to the server using rsync
104
- rake deploy:ssh # Deploy to the server using ssh
105
- rake growl # Send log events to Growl (Mac OS X only)
106
- rake heel:start # Start the heel server to view website (not for Windows)
107
- rake heel:stop # Stop the heel server
108
- rake rebuild # Rebuild the website
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 -- 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.
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 <code><%= @page.title %></code>. All page attributes can be accessed using the <code>@page.attribute</code> syntax within an ERB block. This will be discussed in greater detail in the "ERB Filter":#erbfilter section.
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, <code><notextile>&lt;%= ruby code %&gt;</notextile></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.
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><notextile>
244
- The title of this page is "&lt;%= @page.title" %&gt;".
245
- </notextile></pre>
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 <code><notextile>&lt;notextile&gt;...&lt;/notextile&gt;</notextile></code> tags.
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 *BlueCloth* gem must be installed on your system in order to use the markdown filter.
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 @haml@ gem must be installed on your system in order to use the haml filter or the sass filter.
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
- $ rake rebuild BASE='http://your.website.com/path/to/your/site'
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-20 prepend-1 append-3 first last" id="header">
30
- <h1>Webby &#9775; <%= 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
- ><li><%= link_to_page_unless_current 'Home' %></li
36
- ><li><%= link_to_page_unless_current 'Tutorial' %></li
37
- ><li><%= link_to_page_unless_current 'Manual' %></li
38
- ><li><%= link_to_page_unless_current 'Reference' %></li
39
- ><li><%= link_to_page_unless_current 'Tips & Tricks' %></li
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-16 append-3 last">
37
+ <div class="column span-17 prepend-4 append-3 last">
45
38
  <%= @content %>
46
39
  </div>
47
40
 
48
- <div class="column span-20 prepend-1 append-3 first last" id="footer">
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>
@@ -5,6 +5,6 @@ filter:
5
5
  - erb
6
6
  - textile
7
7
  ---
8
- p(title). <%%= h(@page.title) %>
8
+ h1. <%%= h(@page.title) %>
9
9
 
10
10
  You can read more about textile "here":http://whytheluckystiff.net/ruby/redcloth/
@@ -0,0 +1,7 @@
1
+
2
+ task :default => :build
3
+
4
+ desc 'deploy the site to the webserver'
5
+ task :deploy => [:build, 'deploy:rsync']
6
+
7
+ # EOF
File without changes
File without changes
@@ -1,5 +1,6 @@
1
1
  ---
2
- title: Home Page
2
+ title: Home Page
3
+ created_at: 2008-08-02 14:06:40.000000 -06:00
3
4
  filter:
4
5
  - erb
5
6
  - textile
@@ -3,7 +3,7 @@ extension: html
3
3
  filter: erb
4
4
  ---
5
5
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
6
- "DTD/xhtml1-strict.dtd">
6
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
7
7
 
8
8
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-us">
9
9
  <head>
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