Shazburg-webby 0.9.0

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.
Files changed (172) hide show
  1. data/History.txt +176 -0
  2. data/Manifest.txt +171 -0
  3. data/README.txt +92 -0
  4. data/Rakefile +54 -0
  5. data/bin/webby +8 -0
  6. data/bin/webby-gen +8 -0
  7. data/examples/blog/Sitefile +7 -0
  8. data/examples/blog/tasks/blog.rake +72 -0
  9. data/examples/blog/templates/atom_feed.erb +40 -0
  10. data/examples/blog/templates/blog/month.erb +22 -0
  11. data/examples/blog/templates/blog/post.erb +16 -0
  12. data/examples/blog/templates/blog/year.erb +22 -0
  13. data/examples/presentation/Sitefile +10 -0
  14. data/examples/presentation/content/css/uv/twilight.css +137 -0
  15. data/examples/presentation/content/presentation/_sample_code.txt +10 -0
  16. data/examples/presentation/content/presentation/index.txt +63 -0
  17. data/examples/presentation/content/presentation/s5/blank.gif +0 -0
  18. data/examples/presentation/content/presentation/s5/bodybg.gif +0 -0
  19. data/examples/presentation/content/presentation/s5/framing.css +23 -0
  20. data/examples/presentation/content/presentation/s5/iepngfix.htc +42 -0
  21. data/examples/presentation/content/presentation/s5/opera.css +7 -0
  22. data/examples/presentation/content/presentation/s5/outline.css +15 -0
  23. data/examples/presentation/content/presentation/s5/pretty.css +86 -0
  24. data/examples/presentation/content/presentation/s5/print.css +1 -0
  25. data/examples/presentation/content/presentation/s5/s5-core.css +9 -0
  26. data/examples/presentation/content/presentation/s5/slides.css +3 -0
  27. data/examples/presentation/content/presentation/s5/slides.js +553 -0
  28. data/examples/presentation/layouts/presentation.txt +43 -0
  29. data/examples/presentation/templates/_code_partial.erb +13 -0
  30. data/examples/presentation/templates/presentation.erb +40 -0
  31. data/examples/tumblog/Sitefile +9 -0
  32. data/examples/tumblog/content/css/tumblog.css +308 -0
  33. data/examples/tumblog/content/images/tumblog/permalink.gif +0 -0
  34. data/examples/tumblog/content/images/tumblog/rss.gif +0 -0
  35. data/examples/tumblog/content/tumblog/200806/the-noble-chicken/index.txt +12 -0
  36. data/examples/tumblog/content/tumblog/200807/historical-perspectives-on-the-classic-chicken-joke/index.txt +12 -0
  37. data/examples/tumblog/content/tumblog/200807/mad-city-chickens/index.txt +10 -0
  38. data/examples/tumblog/content/tumblog/200807/the-wisdom-of-the-dutch/index.txt +11 -0
  39. data/examples/tumblog/content/tumblog/200807/up-a-tree/index.txt +13 -0
  40. data/examples/tumblog/content/tumblog/index.txt +37 -0
  41. data/examples/tumblog/content/tumblog/rss.txt +37 -0
  42. data/examples/tumblog/layouts/tumblog/default.txt +44 -0
  43. data/examples/tumblog/layouts/tumblog/post.txt +15 -0
  44. data/examples/tumblog/lib/tumblog_helper.rb +32 -0
  45. data/examples/tumblog/tasks/tumblog.rake +30 -0
  46. data/examples/tumblog/templates/atom_feed.erb +40 -0
  47. data/examples/tumblog/templates/tumblog/conversation.erb +12 -0
  48. data/examples/tumblog/templates/tumblog/link.erb +10 -0
  49. data/examples/tumblog/templates/tumblog/photo.erb +13 -0
  50. data/examples/tumblog/templates/tumblog/post.erb +12 -0
  51. data/examples/tumblog/templates/tumblog/quote.erb +11 -0
  52. data/examples/webby/Sitefile +19 -0
  53. data/examples/webby/content/css/background.gif +0 -0
  54. data/examples/webby/content/css/blueprint/print.css +76 -0
  55. data/examples/webby/content/css/blueprint/screen.css +696 -0
  56. data/examples/webby/content/css/coderay.css +96 -0
  57. data/examples/webby/content/css/site.css +184 -0
  58. data/examples/webby/content/css/uv/twilight.css +137 -0
  59. data/examples/webby/content/index.txt +37 -0
  60. data/examples/webby/content/manual/index.txt +430 -0
  61. data/examples/webby/content/reference/index.txt +202 -0
  62. data/examples/webby/content/release-notes/rel-0-9-0/index.txt +73 -0
  63. data/examples/webby/content/robots.txt +6 -0
  64. data/examples/webby/content/script/jquery.corner.js +152 -0
  65. data/examples/webby/content/script/jquery.js +31 -0
  66. data/examples/webby/content/sitemap.txt +31 -0
  67. data/examples/webby/content/tips_and_tricks/index.txt +96 -0
  68. data/examples/webby/content/tutorial/index.txt +131 -0
  69. data/examples/webby/layouts/default.txt +55 -0
  70. data/examples/webby/templates/page.erb +10 -0
  71. data/examples/website/Sitefile +7 -0
  72. data/examples/website/content/css/blueprint/License.txt +21 -0
  73. data/examples/website/content/css/blueprint/Readme.txt +100 -0
  74. data/examples/website/content/css/blueprint/compressed/print.css +76 -0
  75. data/examples/website/content/css/blueprint/compressed/screen.css +696 -0
  76. data/examples/website/content/css/blueprint/lib/forms.css +45 -0
  77. data/examples/website/content/css/blueprint/lib/grid.css +193 -0
  78. data/examples/website/content/css/blueprint/lib/grid.png +0 -0
  79. data/examples/website/content/css/blueprint/lib/ie.css +30 -0
  80. data/examples/website/content/css/blueprint/lib/reset.css +39 -0
  81. data/examples/website/content/css/blueprint/lib/typography.css +116 -0
  82. data/examples/website/content/css/blueprint/plugins/buttons/Readme +31 -0
  83. data/examples/website/content/css/blueprint/plugins/buttons/buttons.css +97 -0
  84. data/examples/website/content/css/blueprint/plugins/buttons/icons/cross.png +0 -0
  85. data/examples/website/content/css/blueprint/plugins/buttons/icons/key.png +0 -0
  86. data/examples/website/content/css/blueprint/plugins/buttons/icons/tick.png +0 -0
  87. data/examples/website/content/css/blueprint/plugins/css-classes/Readme +14 -0
  88. data/examples/website/content/css/blueprint/plugins/css-classes/css-classes.css +24 -0
  89. data/examples/website/content/css/blueprint/plugins/fancy-type/Readme +22 -0
  90. data/examples/website/content/css/blueprint/plugins/fancy-type/fancy-type-compressed.css +5 -0
  91. data/examples/website/content/css/blueprint/plugins/fancy-type/fancy-type.css +74 -0
  92. data/examples/website/content/css/blueprint/print.css +68 -0
  93. data/examples/website/content/css/blueprint/screen.css +22 -0
  94. data/examples/website/content/css/coderay.css +111 -0
  95. data/examples/website/content/css/site.css +67 -0
  96. data/examples/website/content/index.txt +19 -0
  97. data/examples/website/layouts/default.txt +58 -0
  98. data/examples/website/lib/breadcrumbs.rb +28 -0
  99. data/examples/website/templates/_partial.erb +10 -0
  100. data/examples/website/templates/page.erb +18 -0
  101. data/examples/website/templates/presentation.erb +40 -0
  102. data/lib/webby.rb +227 -0
  103. data/lib/webby/apps.rb +12 -0
  104. data/lib/webby/apps/generator.rb +283 -0
  105. data/lib/webby/apps/main.rb +221 -0
  106. data/lib/webby/auto_builder.rb +83 -0
  107. data/lib/webby/builder.rb +183 -0
  108. data/lib/webby/core_ext/enumerable.rb +11 -0
  109. data/lib/webby/core_ext/hash.rb +28 -0
  110. data/lib/webby/core_ext/kernel.rb +21 -0
  111. data/lib/webby/core_ext/string.rb +163 -0
  112. data/lib/webby/core_ext/time.rb +9 -0
  113. data/lib/webby/filters.rb +91 -0
  114. data/lib/webby/filters/basepath.rb +97 -0
  115. data/lib/webby/filters/erb.rb +9 -0
  116. data/lib/webby/filters/haml.rb +18 -0
  117. data/lib/webby/filters/markdown.rb +16 -0
  118. data/lib/webby/filters/outline.rb +308 -0
  119. data/lib/webby/filters/sass.rb +17 -0
  120. data/lib/webby/filters/slides.rb +56 -0
  121. data/lib/webby/filters/textile.rb +16 -0
  122. data/lib/webby/filters/tidy.rb +76 -0
  123. data/lib/webby/helpers.rb +30 -0
  124. data/lib/webby/helpers/capture_helper.rb +141 -0
  125. data/lib/webby/helpers/coderay_helper.rb +69 -0
  126. data/lib/webby/helpers/graphviz_helper.rb +136 -0
  127. data/lib/webby/helpers/tag_helper.rb +65 -0
  128. data/lib/webby/helpers/tex_img_helper.rb +133 -0
  129. data/lib/webby/helpers/ultraviolet_helper.rb +63 -0
  130. data/lib/webby/helpers/url_helper.rb +235 -0
  131. data/lib/webby/link_validator.rb +152 -0
  132. data/lib/webby/renderer.rb +379 -0
  133. data/lib/webby/resources.rb +96 -0
  134. data/lib/webby/resources/db.rb +251 -0
  135. data/lib/webby/resources/file.rb +221 -0
  136. data/lib/webby/resources/layout.rb +63 -0
  137. data/lib/webby/resources/page.rb +118 -0
  138. data/lib/webby/resources/partial.rb +79 -0
  139. data/lib/webby/resources/resource.rb +160 -0
  140. data/lib/webby/resources/static.rb +52 -0
  141. data/lib/webby/stelan/mktemp.rb +135 -0
  142. data/lib/webby/stelan/paginator.rb +150 -0
  143. data/lib/webby/stelan/spawner.rb +339 -0
  144. data/lib/webby/tasks/build.rake +27 -0
  145. data/lib/webby/tasks/create.rake +22 -0
  146. data/lib/webby/tasks/deploy.rake +22 -0
  147. data/lib/webby/tasks/growl.rake +15 -0
  148. data/lib/webby/tasks/heel.rake +28 -0
  149. data/lib/webby/tasks/validate.rake +19 -0
  150. data/spec/core_ext/hash_spec.rb +47 -0
  151. data/spec/core_ext/string_spec.rb +110 -0
  152. data/spec/core_ext/time_spec.rb +19 -0
  153. data/spec/spec.opts +1 -0
  154. data/spec/spec_helper.rb +14 -0
  155. data/spec/webby/apps/generator_spec.rb +111 -0
  156. data/spec/webby/apps/main_spec.rb +75 -0
  157. data/spec/webby/helpers/capture_helper_spec.rb +56 -0
  158. data/spec/webby/resources/file_spec.rb +104 -0
  159. data/spec/webby/resources_spec.rb +17 -0
  160. data/tasks/ann.rake +81 -0
  161. data/tasks/bones.rake +21 -0
  162. data/tasks/gem.rake +126 -0
  163. data/tasks/git.rake +41 -0
  164. data/tasks/manifest.rake +49 -0
  165. data/tasks/notes.rake +28 -0
  166. data/tasks/post_load.rake +39 -0
  167. data/tasks/rdoc.rake +51 -0
  168. data/tasks/rubyforge.rake +57 -0
  169. data/tasks/setup.rb +268 -0
  170. data/tasks/spec.rake +55 -0
  171. data/tasks/website.rake +38 -0
  172. metadata +287 -0
@@ -0,0 +1,430 @@
1
+ ---
2
+ title: Manual
3
+ created_at: 2007-08-29 08:57:00.000000 -06:00
4
+ filter:
5
+ - erb
6
+ - textile
7
+ - outline
8
+ ---
9
+ <div class="toc push-1">
10
+
11
+ p(title). Table of Contents
12
+
13
+ <toc />
14
+ </div>
15
+
16
+ h2. Introduction
17
+
18
+ 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
+
20
+ p(TODO). make a better picture using omnigraffle
21
+
22
+ <% graphviz :path => "images", :alt => "Webby Overview" do %>
23
+ digraph overview {
24
+ rankdir = LR;
25
+ edge [fontname="Verdana", fontsize=8];
26
+ node [fontname="Verdana", fontsize=10];
27
+
28
+ layout [label="Layout",color="#BBBBBB",style=filled];
29
+ p1 [label="Page 1",color=red];
30
+ h1 [label="HTML 1",color=red];
31
+ p2 [label="Page 2",color=green];
32
+ h2 [label="HTML 2",color=green];
33
+ p3 [label="Page 3",color=blue];
34
+ h3 [label="HTML 3",color=blue];
35
+
36
+ p1 -> layout -> h1 [color=red];
37
+ p2 -> layout -> h2 [color=green];
38
+ p3 -> layout -> h3 [color=blue];
39
+ }
40
+ <% end %>
41
+
42
+ The diagram above shows the basic concept of how Webby works. Changing the layout file will result in changes to every generated HTML file. Changes to a single page will result in changes only to the HTML file corresponding to that particular page.
43
+
44
+ Webby does not limit the output to HTML. Webby can be used to generate XML files for RSS or Atom news feeds, CSS files for styling web pages, or any other type of text file that you can think of.
45
+
46
+ h3. Requirements
47
+
48
+ Webby is written in the Ruby programming language. To install and run Webby you will need the following applications installed on your system:
49
+
50
+ * "Ruby":http://ruby-lang.org
51
+ * "RubyGems":http://rubygems.org/read/chapter/3
52
+
53
+ h3. Installation
54
+
55
+ Webby is easily installed as a Ruby gem. From a command prompt type in the following:
56
+
57
+ pre. sudo gem install webby
58
+
59
+ This will install Webby and all its required dependencies.
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 _hpricot_ gem when prompted.
62
+
63
+ 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
+
65
+ * RedCloth
66
+ * rdiscount
67
+ * haml
68
+ * coderay
69
+ * ultraviolet
70
+
71
+ 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.
72
+
73
+ h3. Running Webby
74
+
75
+ p(TODO). update to reflect the two commands webby-gen and webby
76
+
77
+ When Webby is installed a command line program, @webby@, is installed alongside the gem. This program is used to create a new Webby site folder and files, and it is used within the site folder to generate the final site output from the content and layouts. Type in @webby --help@ on the command line will show you the options this program supports.
78
+
79
+ <pre>
80
+ webby --help
81
+
82
+ Usage: webby [options] task [task args]
83
+
84
+ -D, --describe [PATTERN] describe the tasks (matching optional PATTERN), then exit
85
+ -P, --prereqs display the tasks and dependencies, then exit
86
+ -T, --tasks [PATTERN] display the tasks (matching optional PATTERN) with descriptions, then exit
87
+ -t, --trace turn on invoke/execute tracing, enable full backtrace
88
+
89
+ common options:
90
+ -h, --help show this message
91
+ --version show version
92
+ </pre>
93
+
94
+ In this mode the @webby@ command is 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:
95
+
96
+ pre. webby -T
97
+
98
+ The second mode of the @webby@ program is used less often but it is no less important. This is the *generate* mode, and it is used to create a new Webby site folder and files. Type in @webby-gen --help@ on the command to see how the program is used.
99
+
100
+ <pre>
101
+ webby-gen --help
102
+
103
+ Usage: webby-gen [options] template site
104
+
105
+ -f, --force overwrite files that already exist
106
+ -s, --skip skip files that already exist
107
+ -u, --update update rake tasks for the site
108
+ -p, --pretend run but do not make any changes
109
+
110
+ -t, --templates list available templates
111
+
112
+ common options:
113
+ -h, --help show this message
114
+ --version show version
115
+ </pre>
116
+
117
+ 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:
118
+
119
+ pre. webby-gen --templates
120
+
121
+ h2. Getting Started
122
+
123
+ p(TODO). have a little box on the left with a list of prerequisites for doing this section ??
124
+
125
+ p(TODO). start here with a section on creating a new blog, modifying pages, creating pages, new layouts, and provide links to more in depth coverage later in the manual
126
+
127
+
128
+ h2. Working With Resources
129
+
130
+ 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:
131
+
132
+ * Files
133
+ * Pages
134
+ * Layouts
135
+
136
+ Files are the simplest resource to handle. They are copied, unchanged, from the content folder to the output folder. Files include resources such as images, CSS stylesheets, and so forth. A file will be copied from its location in the content folder to its corresponding location in the output folder -- i.e. a file located at @content/some/folder/image.jpg@ would be copied to @output/some/folder/image.jpg@.
137
+
138
+ Files will only be found in the _content_ folder. The _layouts_ folder is reserved solely for layouts.
139
+
140
+ h3(#pages). Pages
141
+
142
+ Pages are found in the _content_ folder along with regular files. Pages contain *meta-data* at the top of the file; this is what differentiates a page from a regular file. The meta-data is a section of "YAML":http://www.yaml.org/spec/1.1/ formatted text that describes various properties and attributes of the page. These attributes are used by Webby to determine how the page will be processed by the filter engine.
143
+
144
+ Let's look at an example page.
145
+
146
+ <pre>
147
+ ---
148
+ title: Lorem Ipsum
149
+ created_at: Wed Aug 29 08:57:00 -0600 2007
150
+ filter:
151
+ - erb
152
+ - textile
153
+ ---
154
+ h2. <%%= @page.title %>
155
+
156
+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc congue ipsum
157
+ vestibulum libero. Aenean vitae justo. Nam eget tellus. Etiam convallis, est eu
158
+ lobortis mattis, lectus tellus tempus felis, a ultricies erat ipsum at metus.
159
+ </pre>
160
+
161
+ 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.
162
+
163
+ 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.
164
+
165
+ <pre>
166
+ <h2>Lorem Ipsum</h2>
167
+
168
+ <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc congue ipsum
169
+ vestibulum libero. Aenean vitae justo. Nam eget tellus. Etiam convallis, est eu
170
+ lobortis mattis, lectus tellus tempus felis, a ultricies erat ipsum at metus.</p>
171
+ </pre>
172
+
173
+ 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.
174
+
175
+ 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.
176
+
177
+ h4. Page Attributes
178
+
179
+ Attribute identifiers cannot contain spaces; they must be separated from their values by a colon. Other than that, you are free to define as many attributes as you like. Aside from defining values that can be rendered into a page, attributes are also used to find other pages in the site. Finding and linking to other pages is discussed in the "ERB Filter":#erbfilter section.
180
+
181
+ There are a few attributes that control when, where, and how pages are rendered. These are listed below with a brief description of how the attribute affects the system.
182
+
183
+ * *destination* -- Defines the path in the output directory where the rendered page should be stored.
184
+ * *dirty* -- The dirty flag is used to determine whether the page should rendered or not. Normally this is automatically determined by the filter engine, but it can be overridden by setting this attribute. If the dirty flag is set to _true_ then the page will always be rendered. If the dirty flag is set to _false_ then the page will never be rendered.
185
+ * *extension* -- Defines the extension that will be appended to the filename of the rendered page in the output folder. The extension is determined by looking at the following:
186
+ ** the meta-data of the current page for an @extension@ attribute
187
+ ** the meta-data of layout file of the current page for an @extension@ attribute
188
+ ** the extension of this page file in the _content_ folder
189
+ * *filter* -- Defines the list of filters that will be applied to the contents of this page. If left blank, then the default filter will be applied to the page contents.
190
+ * *layout* -- Defines the layout that the page contents will be rendered into. The default layout will be used if this attribute is not defined. The value of @nil@ should be specified if the page should not be rendered into any layout.
191
+
192
+ The following attributes are defined for each page in the content folder. These attributes cannot be changed in the page's meta-data section. However, they are available to the ERB filter when rendering the contents of a page.
193
+
194
+ * *path* -- The full path to the file in the _content_ folder
195
+ * *dir* -- The relative directory in the output folder where the page will be rendered
196
+ * *filename* -- The name of the file in the _content_ folder excluding any path information
197
+ * *ext* -- The extension of the file in the _content_ folder
198
+ * *mtime* -- The modification time of the file in the _content_ folder
199
+ * *number* -- Reserved variable used for multi-page content
200
+ * *url* -- A URL suitable for creating a link to the page
201
+ * *render* -- Returns the contents of the page as rendered by the Webby filter engine
202
+
203
+ h4. Page Filters
204
+
205
+ Filters operate on the content of a page by transforming the text of the content section according to the rules of the individual filter. Some filters transform simplified markup into true HTML syntax; examples of these are the Textile filter and the Markdown filter. Other filters will rewrite URLs (basepath filter) or clean up the generated HTML (tidy filter). All the filters are discussed in detail in the "Filters":#filters section of this document.
206
+
207
+ h3. Layouts
208
+
209
+ Layouts provide the basic framework for a page -- the header, the footer, the navigation. They provide a consistent look and feel across all pages in the website. Individual pages contain just the content for that particular page.
210
+
211
+ <% graphviz :path => "images", :class => "push-0", :alt => "layout diagram" do %>
212
+ digraph layout_graph {
213
+ rankdir = LR;
214
+ edge [fontname="Verdana", fontsize=8];
215
+ node [fontname="Verdana", fontsize=10];
216
+
217
+ page -> layout [label="rendered\ninto"];
218
+ layout -> HTML [label="results\nin"];
219
+ }
220
+ <% end %>
221
+
222
+ The diagram to the right shows a typical page rendering process. The content of a page is rendered by the Webby filter engine. The rendered content is inserted into the layout specified by the page; the content insertion occurs as the layout is being rendered. The result is the HTML that is stored in the _output_ folder.
223
+
224
+ Layouts are treated exactly as pages are treated with one exception -- the layout has access to the rendered contents of another page in site. The content of the page being rendered is made available to the layout via the @@content@ variable accessible from the ERB filter.
225
+
226
+ <pre>
227
+ ---
228
+ extension: html
229
+ filter: erb
230
+ ---
231
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-us">
232
+ <head>
233
+ <title><%= @page.title %></title>
234
+ </head>
235
+ <body>
236
+ <%%= @content %>
237
+ </body>
238
+ </html>
239
+ </pre>
240
+
241
+ The example above shows a very simple layout. The content for the current page being rendered will be inserted between the HTML body tags.
242
+
243
+ Along with the @@content@ variable, all the attributes of the current page being rendered are also accessible in the layout. The page title is inserted into the HTML title tags. But again, any page attribute can be accessed within the layout via the @@page@ variable.
244
+
245
+ h2(#filters). Filters
246
+
247
+ Filters are used in Webby to transform the text of pages and layouts. The filters applied to a page are defined in the meta-data of the page. The filters are used to transform different parts of the page contents resulting in HTML syntax, images, highlighted code, etc. Filters apply equally to pages and to layouts -- that is, pages and layouts are treated in the same manner by filters.
248
+
249
+ This section will look at the various filters provided by Webby, what those filters do, and how they should be used. Enjoy!
250
+
251
+ h3(#erbfilter). ERB
252
+
253
+ "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.
254
+
255
+ 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.
256
+
257
+ <pre><notextile>
258
+ The title of this page is "&lt;%= @page.title" %&gt;".
259
+ </notextile></pre>
260
+
261
+ <pre>
262
+ The title of this page is "<%= @page.title %>".
263
+ </pre>
264
+
265
+ <div class="label">Usage</div>
266
+ <div class="desc">
267
+ Include "erb" in the filter list of the page or layout that contains ERB formatting.
268
+ </div>
269
+
270
+ <div class="label">Options</div>
271
+ <div class="desc">
272
+ none
273
+ </div>
274
+
275
+ <div class="label">Require</div>
276
+ <div class="desc">
277
+ none
278
+ </div>
279
+
280
+ h3. Textile
281
+
282
+ "Textile":http://en.wikipedia.org/wiki/Textile_%28markup_language%29 is a lightweight markup language originally developed by Dean Allen and billed as a "humane Web text generator". The textile filter converts Textile formatted text into valid, well-formed XHTML.
283
+
284
+ 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>.
285
+
286
+ 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.
287
+
288
+ <div class="label">Usage</div>
289
+ <div class="desc">
290
+ Include "textile" in the filter list of the page or layout that contains Textile formatting
291
+ </div>
292
+
293
+ <div class="label">Options</div>
294
+ <div class="desc">
295
+ none
296
+ </div>
297
+
298
+ <div class="label">Require</div>
299
+ <div class="desc">
300
+ The *RedCloth* gem must be installed on your system in order to use the textile filter.
301
+ </div>
302
+
303
+ fn1(fn){clear:both}. Please don't ask. Why is very smart, he wrote the Ruby code that handles Textile markup, and the code is very solid. Enjoy the benefits of his work.
304
+
305
+ h3. Markdown
306
+
307
+ "Markdown":http://daringfireball.net/projects/markdown/ is a lightweight markup language created by John Gruber. It allows you to write using an easy-to-read, easy-to-write plain text format. From the Markdown web page:
308
+
309
+ bq. The overriding design goal for Markdown's formatting syntax is to make it as readable as possible. The idea is that a Markdown-formatted document should be publishable as-is, as plain text, without looking like it's been marked up with tags or formatting instructions. While Markdown's syntax has been influenced by several existing text-to-HTML filters, the single biggest source of inspiration for Markdown's syntax is the format of plain text email.
310
+
311
+ The markdown 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.
312
+
313
+ <div class="label">Usage</div>
314
+ <div class="desc">
315
+ Include "markdown" in the filter list of the page or layout that contains Markdown formatting.
316
+ </div>
317
+
318
+ <div class="label">Options</div>
319
+ <div class="desc">
320
+ none
321
+ </div>
322
+
323
+ <div class="label">Require</div>
324
+ <div class="desc">
325
+ The *BlueCloth* gem must be installed on your system in order to use the markdown filter.
326
+ </div>
327
+
328
+ h3. HAML & SASS
329
+
330
+ "HAML":http://haml.hamptoncatlin.com/ is a markup language created by Hampton Catlin that's used to cleanly and simply describe the XHTML of any web document without the use of inline code. SASS is the equivalent for CSS documents. From the HAML website:
331
+
332
+ bq. "HAML":http://haml.hamptoncatlin.com/docs/haml and "SASS":http://haml.hamptoncatlin.com/docs/sass are templating engines for the two most common types of documents on the web: HTML and CSS, respectively. They are designed to make it both easier and more pleasant to code HTML and CSS documents, by eliminating redundancy, reflecting the underlying structure that the document represents, and providing elegant, easily understandable, and powerful syntax.
333
+
334
+ Both the haml and the sass filter will operate on all the contents of a page or layout. Given that fact, these should be one of the last filters applied to the page.
335
+
336
+ <div class="label">Usage</div>
337
+ <div class="desc">
338
+ Include "haml" in the filter list of the page or layout that contains HAML formatting. Include "sass" in the filter list of the page that contains SASS formatting (this should be a CSS page).
339
+ </div>
340
+
341
+ <div class="label">Options</div>
342
+ <div class="desc">
343
+
344
+ Options are passed to the haml filter by setting the "haml_options" in the page meta-data -- the hash of options defined under the "haml_options" attribute will be passed to the haml filter engine when it is run. Please refer to the HAML documentation for the list of available options.
345
+
346
+ p(last). Options are passed to the sass filter by setting the "sass_options" in the page meta-data -- the hash of options defined under the "sass_options" attribute will be passed to the sass filter engine when it is run. Please refer to the SASS documentation for the list of available options.
347
+
348
+ </div>
349
+
350
+ <div class="label">Require</div>
351
+ <div class="desc">
352
+ The @haml@ gem must be installed on your system in order to use the haml filter or the sass filter.
353
+ </div>
354
+
355
+ h3. Outline
356
+
357
+ The Outline filter is used to insert outline numbering into HTML heading tags (h1, h2, h3, etc.) and to generate a table of contents based on the heading tags. The table of contents is inserted into the page at the location of the @<toc />@ tag. If there is no @<toc />@ tag, then a table of contents will not be created but outline numbering will still take place.
358
+
359
+ If a table of contents is desired without outline numbers being inserted into the heading tags, this can be specified in the attibutes of the @<toc />@ tag itself.
360
+
361
+ <pre>
362
+ <toc numbering="off" />
363
+ </pre>
364
+
365
+ This will generate a table of contents, but not insert outline numbering into the heading tags. The full list of "TOC attributes":/rdoc/classes/Webby/Filters/Outline.html can be found in the source documentation.
366
+
367
+ The Outline filter will only work on valid HTML or XHTML pages. Therefore it should be used after any markup langauge filters (textile, markdown, etc.).
368
+
369
+ h3. BasePath
370
+
371
+ The basepath filter is used to rewrite the base path location for all URLs in a page. This is useful for the times when the publish location of the website is no at the root of the web server -- @http://your.website.com/path/to/your/site@ for example. This allows pages and resources (images, javascript, stylesheets, etc.) to be referenced from the root of the Webby web server for easy development, but the paths of these resources can easily be changed by the basepath filter when the website is being deployed.
372
+
373
+ The basepath filter only works on HTML/XHTML text, and therefore, it should be one of the last (if not the last) filter applied to your content. It is recommended to only include the basepath filter in your layout(s). The basepath filter should appear before the tidy filter.
374
+
375
+ <div class="label">Usage</div>
376
+ <div class="desc">
377
+
378
+ 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.
379
+
380
+ <pre style="margin-bottom:0">
381
+ $ webby rebuild BASE='http://your.website.com/path/to/your/site'
382
+ </pre>
383
+ </div>
384
+
385
+ <div class="label">Options</div>
386
+ <div class="desc">
387
+
388
+ Options can be passed to the basepath filter by specifying them in the project _Rakefile_.
389
+
390
+ <pre style="margin-bottom:0">
391
+ SITE.xpaths << '/html/body//img[@usemap]'
392
+ SITE.base = 'http://webby.rubyforge.org'
393
+ </pre>
394
+ </div>
395
+
396
+ <div class="label">Require</div>
397
+ <div class="desc">
398
+ none
399
+ </div>
400
+
401
+ h3(#tidy). Tidy
402
+
403
+ "Tidy":http://www.w3.org/People/Raggett/tidy/ is a useful application for cleaning up and detecting errors in XHTML text. The tidy filter will run your XHTML code through the tidy program and report any errors in the build log. From the HTML Tidy website:
404
+
405
+ bq. When editing HTML it's easy to make mistakes. Wouldn't it be nice if there was a simple way to fix these mistakes automatically and tidy up sloppy editing into nicely layed out markup? Well now there is! Dave Raggett's HTML TIDY is a free utility for doing just that. Tidy is able to fix up a wide range of problems and to bring to your attention things that you need to work on yourself. Each item found is listed with the line number and column so that you can see where the problem lies in your markup. Tidy won't generate a cleaned up version when there are problems that it can't be sure of how to handle. These are logged as "errors" rather than "warnings".
406
+
407
+ The tidy program only works on HTML/XHTML text, and therefore, tidy should be one of the last (if not the last) filter applied to your content. It is recommended to only include the tidy filter in your layout(s).
408
+
409
+ <div class="label">Usage</div>
410
+ <div class="desc">
411
+ Include "tidy" as the last item in the filter list of your layout(s).
412
+ </div>
413
+
414
+ <div class="label">Options</div>
415
+ <div class="desc">
416
+
417
+ Options can be passed to the tidy program by specifying them in the project _Rakefile_. These are the command line options that will be passed to the tidy program when it is run.
418
+
419
+ <pre style="margin-bottom:0">
420
+ SITE.tidy_options = '-indent -wrap 80'
421
+ </pre>
422
+ </div>
423
+
424
+ <div class="label">Require</div>
425
+ <div class="desc">
426
+ The HTML Tidy application must be installed on your system, and the @tidy@ executable must be available on the path.
427
+ </div>
428
+
429
+ h2. Using Rake
430
+
@@ -0,0 +1,202 @@
1
+ ---
2
+ title: Reference
3
+ created_at: 2008-03-04 22:00:08.439182 -07:00
4
+ filter:
5
+ - erb
6
+ - textile
7
+ - outline
8
+ content_for_head: |
9
+ <link rel="stylesheet" href="/css/coderay.css" type="text/css" media="screen, projection" />
10
+ <link rel="stylesheet" href="/css/uv/twilight.css" type="text/css" media="screen, projection" />
11
+ ---
12
+ <div class="toc push-1">
13
+
14
+ p(title). Table of Contents
15
+
16
+ <toc />
17
+ </div>
18
+
19
+ h3. Resources
20
+
21
+ Resources are the files that are found in the _content_ and _layouts_ folders of a webby site. They come in the following four flavors:
22
+
23
+ * *Pages* -- contain meta-data at the top of the file, are found in the content folder, and are processed by the Webby filter engine
24
+ * *Files* -- are found in the content folder and copied "as is" to the output folder
25
+ * *Partials* -- contain snippets of text that can be used in multiple locations; partial filenames begin with an underscore are are _not_ copied to the output folder
26
+ * *Layouts* -- are found in the layout folder and provide the basic framework of the webpage - the header, the footer, the navigation
27
+
28
+ h3. Attributes
29
+
30
+ Attributes are defined in the meta-data section of pages and layouts.
31
+
32
+ <div class="label">destination</div>
33
+ <div class="desc">
34
+ Defines the path in the output directory where the rendered page should be stored.
35
+ </div>
36
+
37
+ <div class="label">dirty</div>
38
+ <div class="desc">
39
+ The dirty flag is used to determine whether the page should rendered or not. Normally this is automatically determined by the filter engine, but it can be overridden by setting this attribute. If the dirty flag is set to _true_ then the page will always be rendered. If the dirty flag is set to _false_ then the page will never be rendered.
40
+ </div>
41
+
42
+ <div class="label">extension</div>
43
+ <div class="desc">
44
+ Defines the extension that will be appended to the filename of the rendered page in the output folder. The extension is determined by looking at the following:
45
+
46
+ * the meta-data of the current page for an @extension@ attribute
47
+ * the meta-data of layout file of the current page for an @extension@ attribute
48
+ * the extension of this page file in the _content_ folder
49
+
50
+ </div>
51
+
52
+ <div class="label">filter</div>
53
+ <div class="desc">
54
+ Defines the list of filters that will be applied to the contents of this page. If left blank, then the default filter will be applied to the page contents.
55
+ </div>
56
+
57
+ <div class="label">layout</div>
58
+ <div class="desc">
59
+ Defines the layout that the page contents will be rendered into. The default layout will be used if this attribute is not defined. The value of @nil@ should be specified if the page should not be rendered into any layout.
60
+ </div>
61
+
62
+ The following attributes are defined for each page in the content folder. These attributes cannot be changed in the page's meta-data section. However, they are available to the ERB filter when rendering the contents of a page.
63
+
64
+ <div class="label">path</div>
65
+ <div class="desc">
66
+ The full path to the file in the _content_ folder
67
+ </div>
68
+
69
+ <div class="label">dir</div>
70
+ <div class="desc">
71
+ The relative directory in the output folder where the page will be rendered
72
+ </div>
73
+
74
+ <div class="label">filename </div>
75
+ <div class="desc">
76
+ The name of the file in the _content_ folder excluding any path information and extension
77
+ </div>
78
+
79
+ <div class="label">ext</div>
80
+ <div class="desc">
81
+ The extension of the file in the _content_ folder
82
+ </div>
83
+
84
+ <div class="label">mtime</div>
85
+ <div class="desc">
86
+ The modification time of the file in the _content_ folder
87
+ </div>
88
+
89
+ <div class="label">number</div>
90
+ <div class="desc">
91
+ Reserved variable used for multi-page content
92
+ </div>
93
+
94
+ <div class="label">url</div>
95
+ <div class="desc">
96
+ A URL suitable for creating a link to the page
97
+ </div>
98
+
99
+ <div class="label">render</div>
100
+ <div class="desc">
101
+ Returns the contents of the page as rendered by the Webby filter engine
102
+ </div>
103
+
104
+ h3. Filters
105
+
106
+ h3. ERB Variables & Methods
107
+
108
+ h4. coderay
109
+
110
+ The coderay method is used to generate syntax highlighting on a block of code. You will need to have the coderay gem installed on your system, and you will need to include the coderay CSS stylesheet in your pages for the syntax highlighting markup to take effect.
111
+
112
+ The full list of "coderay options":/rdoc/classes/Webby/Helpers/CodeRayHelper.html can be found in the source documentation.
113
+
114
+ <pre>
115
+ <%% coderay :lang => 'ruby', :line_numbers => 'inline' do -%>
116
+ class Object
117
+ def returning( r )
118
+ yield r if block_given?
119
+ r
120
+ end
121
+ end
122
+ <%% end -%>
123
+ </pre>
124
+
125
+ <% coderay :lang => "ruby", :line_numbers => "inline" do -%>
126
+ class Object
127
+ def returning( r )
128
+ yield r if block_given?
129
+ r
130
+ end
131
+ end
132
+ <% end -%>
133
+
134
+
135
+ h4. graphviz
136
+
137
+ The graphviz method is used to convert a DOT script into an image and insert the image into the page. If the DOT script contains URL references, then an image map will also be generated. The resulting image will then have "clickable" regions that link to the URLs specified.
138
+
139
+ "Graphviz":http://www.graphviz.org/ needs to be installed on your system in order to use the graphviz method. The full list of "graphviz options":/rdoc/classes/Webby/Helpers/GraphvizHelper.html can be found in the source documentation.
140
+
141
+ <pre>
142
+ <%% graphviz :path => 'images', :alt => 'hello world graph' do -%>
143
+ digraph hello_world {
144
+ rankdir = LR;
145
+ Hello -> World;
146
+ }
147
+ <%% end -%>
148
+ </pre>
149
+
150
+ <% graphviz :path => "images", :alt => "hello world graph" do -%>
151
+ digraph hello_world {
152
+ rankdir = LR;
153
+ Hello -> World;
154
+ }
155
+ <% end -%>
156
+
157
+
158
+ h4. tex2img
159
+
160
+ The tex2img method is used to convert a LaTeX script into an image and insert the image into the page. "LaTeX":http://www.latex-project.org/ and "ImageMagick":http://www.imagemagick.org/script/index.php need to be instaled on your system in order to use the tex2img maethod.
161
+
162
+ The full list of "tex2img options":/rdoc/classes/Webby/Helpers/TexImgHelper.html can be found in the source documentation.
163
+
164
+ <pre>
165
+ <%% tex2img 'wave_eq', :path => 'images', :alt => 'wave equation' do -%>
166
+ $\psi_{tot}(x,-t_0,r) = \frac{1}{(2\pi)^2} \int\!\!\!\int
167
+ \tilde\Psi_{tot}\left(k_x,\frac{c}{2}\sqrt{k_x^2 + k_r^2},r=0\right)$
168
+ <%% end -%>
169
+ </pre>
170
+
171
+ <% tex2img 'wave_eq', :path => 'images', :alt => 'wave equation' do -%>
172
+ $\psi_{tot}(x,-t_0,r) = \frac{1}{(2\pi)^2} \int\!\!\!\int
173
+ \tilde\Psi_{tot}\left(k_x,\frac{c}{2}\sqrt{k_x^2 + k_r^2},r=0\right)$
174
+ <% end -%>
175
+
176
+
177
+ h4. uv
178
+
179
+ The uv method is used to generate syntax highlighting on a block of code. You will need to have the "Ultraviolet":http://ultraviolet.rubyforge.org/ gem installed on your system, and you will need to include the desired CSS stylesheet in your pages for the syntax highlighting markup to take effect.
180
+
181
+ The full list of "ultraviolet options":/rdoc/classes/Webby/Helpers/UltraVioletHelper.html can be found in the source documentation.
182
+
183
+ <pre>
184
+ <%% uv :lang => "ruby", :line_numbers => true do -%>
185
+ # Initializer for the class.
186
+ def initialize( string )
187
+ @str = string
188
+ end
189
+ <%% end -%>
190
+ </pre>
191
+
192
+ <% uv :lang => "ruby", :line_numbers => true, :theme => 'twilight' do -%>
193
+ # Initializer for the class.
194
+ def initialize( string )
195
+ @str = string
196
+ end
197
+ <% end -%>
198
+
199
+
200
+ h3. Rake Tasks
201
+
202
+ h3. Site Defaults