rote 0.1.2 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -10,41 +10,7 @@ Markdown, and embedded Ruby code with RedCloth [http://redcloth.rubyforge.org/]
10
10
  and ERB [http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html]),
11
11
  layout, and general documentation / website build tasks.
12
12
 
13
- == Should I download it?
14
-
15
- I don't know. Rote offers the following major features:
16
-
17
- * Simple set-up based on page templates and sections.
18
- * ERB, Textile, and Markdown supported out of the box.
19
- * Multiple configurable layouts apply boilerplate to your pages.
20
- * 'Scoped' Ruby code support allows fine-grained control of data available across
21
- all documentation, a subset, or individual pages.
22
- * Can be used standalone (from the command-line) or from within Rake [http://rake.rubyforge.org]
23
- as a custom task library.
24
- * Supports any (text-based) format, while providing utilities and helpers for
25
- common formats (HTML at present).
26
-
27
- So, should you?
28
-
29
- == Why 'Rote'
30
-
31
- The name? I tried to come up with a combination of 'Ruby Site', but couldn't
32
- get past 'Rite' (it's already taken ;)). So, I changed a letter. I'm short on
33
- imagination you know. Oh, you mean why the system? Well, to make it easier
34
- for me to manage roscopeco.co.uk now that I've dumped all the dynamic (JEE)
35
- stuff and gone back to good old Apache sans CGI. I want something that lets
36
- me do the disconnected page rendering and some of the 'dynamic' stuff,
37
- without the dynamic stuff.
38
-
39
- If you really need a better explanation for the name, I've come up with these
40
- alternatives:
41
-
42
- * Something about 'the docs I rote'
43
- * 'Rake-Oriented Template Extensions'
44
- * 'Rote Only Talks Erb'
45
- * 'Really? Ordinary Template Enhancements?'
46
-
47
- == What else do I need?
13
+ == Prerequisites
48
14
 
49
15
  Rote uses the following (versions are as per my development environment,
50
16
  you may find you can use older versions, you may not).
@@ -53,17 +19,21 @@ you may find you can use older versions, you may not).
53
19
  * Rake 0.6.2 ('gem install rake')
54
20
  * RedCloth 3.0.4 ('gem install RedCloth')
55
21
 
56
- RubyGems (http://rubyforge.org/frs/?group_id=126) is *highly recommended*,
22
+ RubyGems [http://rubyforge.org/frs/?group_id=126] is *highly recommended*,
57
23
  and makes for not only an easier install but a cleaner library path.
58
24
  Rote is tested with Gems 0.8.11.
59
25
 
60
- == How do I install it ...
26
+ Please note that Rote is written and tested on Linux - I have no facilities
27
+ to test with, e.g. Windows, and would like to hear about any issues that affect
28
+ usage with other OSes.
29
+
30
+ == Installation ...
61
31
 
62
32
  === ... with RubyGems?
63
33
 
64
34
  If you have RubyGems, you can install Rote by simply issuing the command:
65
35
 
66
- gem install rote
36
+ gem install -r rote
67
37
 
68
38
  Which should download the latest version and install it, including
69
39
  the 'rote' wrapper script and man pages. If you experience problems,
@@ -71,7 +41,11 @@ or wish to perform an offline installation, then simply download the
71
41
  .gem file from the FRS, and execute the gem command from within the same
72
42
  directory.
73
43
 
74
- === ... using install.rb?
44
+ *Note* that the gem install currently doesn't install the man pages.
45
+ You will need to copy them to the appropriate location manually if using
46
+ this method.
47
+
48
+ === ... with install.rb?
75
49
 
76
50
  If you don't have RubyGems, you can install from one of the tarball or zip
77
51
  packages, using the following command:
@@ -79,7 +53,7 @@ packages, using the following command:
79
53
  ruby install.rb
80
54
 
81
55
  from the unpacked root directory. This will copy the libaries to the
82
- appropriate place, and set up the rote wrapper script and so on.
56
+ appropriate place, and set up the rote wrapper script, manpages, and so on.
83
57
 
84
58
  === ... in my own way?
85
59
 
@@ -100,203 +74,40 @@ the version number of your Rote installation.
100
74
 
101
75
  == How do I use it?
102
76
 
103
- === From the command-line
104
-
105
- If you are generating a standalone documentation set (i.e. not as part of
106
- some wider build) then you don't need to worry about writing a +Rakefile+ -
107
- you can use the built-in build via the +rote+ command. This works with
108
- a standard directory layout, and wraps invocation of +rake+ to handle
109
- setting up library dependencies and generation of appropriate tasks.
110
-
111
- You'll need something like the following directory layout:
112
-
113
- somesite ( <- root, this can be called whatever you like)
114
- |--> [publish.rf]
115
- |
116
- |--> doc
117
- | |--> [COMMON.rb]
118
- | |
119
- | |--> res
120
- | | |--> (resources)
121
- | |
122
- | |--> layouts
123
- | | |--> one.rhtml
124
- | | |--> two.rhtml
125
- | |
126
- | |--> pages
127
- | | |--> [COMMON.rb]
128
- | | |--> apage.txt
129
- | | |--> [apage.rb]
130
- | | |--> adir
131
- | | | |--> [COMMON.rb]
132
- | | | |--> bpage.html
133
- | | | |--> [bpage.rb]
134
-
135
- Template sources under the 'pages' directory may have any extension (except
136
- +rb+), and will be rendered to that same name under the output directory.
137
- See the section on Layouts below for details on layout name resolution.
138
- Set up a simple test site following the above layout, and then run:
139
-
140
- rote
141
-
142
- from the top-level directory (+somesite+), you should get a 'target' directory
143
- created with the (transformed) templates.
144
-
145
- Now try:
146
-
147
- rote --tasks
148
-
149
- to get a list of valid tasks, or:
150
-
151
- rote --usage
152
-
153
- for further option information.
154
-
155
- === From your +Rakefile+
156
-
157
- If you are wanting to build documentation as part of a larger build process, or
158
- commandline setup, then you'll want to get started on integrating Rote with
159
- your own (existing) +Rakefile+. Fortunately, this is very easy to do. Try
160
- something like:
161
-
162
- # Rakefile
163
- require 'rote'
164
-
165
- ws = Rote::DocTask.new(:doc) { |site|
166
- site.site_dir = 'html'
167
- site.layout_dir = 'doc/layouts'
168
-
169
- site.pages.dir = 'doc/pages'
170
- site.pages.include('**/*')
171
-
172
- site.res.dir = 'doc/res/'
173
- site.res.include('**/*.png')
174
- site.res.include('**/*.gif')
175
- site.res.include('**/*.jpg')
176
- site.res.include('**/*.css')
177
- }
178
-
179
- Save this as +Rakefile+, and fire up:
180
-
181
- rake --libdir=$ROTE_HOME/lib doc
182
-
183
- If all goes well, you should see each command and transformation output to your
184
- console as Rote runs.
185
-
186
- *Note* that it's safe to include '**/*' in the +pages+ list, since +rb+
187
- files are implicitly excluded.
188
-
189
- == Creating templates
190
-
191
- As mentioned, templates are simply text files in the doc/pages directory. The
192
- layout below that directory is retained when transforming pages, and is
193
- also used to provide simple hierarchical structure to the common page code.
194
- By default, any file with an extension other than +rb+ will be processed
195
- as a page template (with it's associated ruby source). The output will have
196
- the same filename and path, relative to the output directory.
77
+ Please see the user guide for usage information. The latest version can be
78
+ found online at http://rote.rubyforge.org/guide/ , and documentation source for
79
+ a specific release is included in the release package.
197
80
 
198
- === Template code and ERB
81
+ See above for instructions on building the documentation set.
199
82
 
200
- All templates may contain embedded Ruby code (ERB), delimited by the standard
201
- <% ... %> (for executed code) and <%= ... %> (for output) tags. Any (valid)
202
- Ruby code may be placed in the templates, and variables may be defined to
203
- allow information to be passed into templates. There are four places where
204
- you might define such variables. The following is in order of evaluation:
83
+ === A note about version numbers
205
84
 
206
- * This directory's COMMON.rb, or the parent directory's COMMON.rb if
207
- +inherit_common+ is used.
208
- * This page's ruby code, _basename_.rb
209
- * In a block passed to Page.new
210
- * In the template itself
85
+ Rote uses odd/even numbers for development/release versions. When the final
86
+ version component is odd, the package is an 'unofficial' build - generally
87
+ this means built manually from source, during development. These will never
88
+ be distributed, and there's no guarantee that any two packages with the same
89
+ development version will actually be the same. These packages will have no
90
+ corresponding CVS tag.
211
91
 
212
- When a Rote::Page instance is created, Rote looks for these, and
213
- evaluates them, in order, in the same binding as the template is later rendered
214
- in (i.e. the +Page+ instance binding). Therefore, you can define
215
- instance variables to pass data around, or even helper methods if you wish.
92
+ Even numbers always denote 'official' releases, which are released on
93
+ RubyForge and tagged as such in CVS. These packages can be trusted to exhibit
94
+ version consistency.
216
95
 
217
- === Text to HTML formatting
96
+ If you are bundling Rote with your product, please ensure you use an official
97
+ release version whenever possible. If you must use a developmental version,
98
+ please modify the package version to reflect the fact that it is a custom
99
+ build (e.g. 0.1.3-mycompany-20051021) to prevent inconsistent development
100
+ packages from escaping into the wild.
218
101
 
219
- Rote uses RedCloth (http://redcloth.rubyforge.org) to provide text to HTML
220
- formatting, supporting both Textile and Markdown. The formatting applied to a
221
- given page is controlled by that page's +format_opts+ array. Both are disabled
222
- by default - to enable formatting you must add something like the following
223
- somewhere appropriate:
102
+ === Further information
224
103
 
225
- format_opts << :textile << :markdown
226
-
227
- Although you can directly assign to +format_opts+, this isn't recommended since
228
- Ruby often interprets it as a local variable set rather than method call,
229
- resulting in much head scratching as to why your options are being ignored.
230
-
231
- Formatting is applied _after_ any ERB has been evaluated.
232
-
233
- *Note* that the options you supply are passed directly to RedCloth, so you can
234
- exercise much more control over the formatting by using the feature-specific
235
- symbols defined by RedCloth, rather than the blanket :textile and :markdown
236
- symbols.
104
+ Rote is developed by Ross Bamford (ross <at> roscopeco.co.uk). Flame him if
105
+ it breaks your day ;P
237
106
 
238
- === Layout
239
-
240
- Layouts are stored under the doc/layouts directory (by default). They may
241
- be organised into subdirectories, but this hierarchy is not connected to
242
- the hierarchy in +pages+. To apply a layout to a page, simply call the
243
- Rote::Page.layout method from code applied to that page, passing the
244
- base-name (and path, relative to +layouts+, if used). If no extension is
245
- specified, then the same extension as the page itself is assumed. Examples:
246
-
247
- layout 'one'
248
- layout 'main/wide'
249
- layout 'dark.txt'
250
- <% layout 'my' %>
251
-
252
- With that done, Rote would first render the template text (including textile)
253
- and set the Page instance variable @content_for_layout before rendering
254
- the layout (in which textile is currently not supported). The layout is
255
- responsible for inserting the rendered template where appropriate, with
256
- e.g.:
107
+ * Homepage - http://rote.rubyforge.org/
108
+ * Project - http://rubyforge.org/projects/rote
109
+ * Issues - http://rubyforge.org/tracker/?group_id=1120
110
+ * List - rote-devel@rubyforge.org
257
111
 
258
- <%= @content_for_layout %>
259
-
260
- This pattern shouldn't be unfamiliar. Again, note that Rote doesn't mandate
261
- HTML, despite the appearance from the ERB tags - any (textual) format can
262
- be templated and laid out.
263
-
264
- == Resources
265
-
266
- Of course, you're likely to have resources for your site (images, sounds, etc)
267
- and you'll need to copy them over to the target too. Such resources should be
268
- placed under 'res' (with the commandline setup) or in your specified +res+
269
- directory, and will be copied directly to the output directory after page
270
- rendering.
271
-
272
- Of course, the directory layout beneath +res+ should mirror that of the
273
- output, and will be preserved during the copy.
274
-
275
- == Publishing
276
-
277
- Rote does not provide any direct support for publishing your site at present,
278
- relying on you to configure an appropriate publish task if required, using
279
- the publishers supplied with Rake (in rake/contrib). This allows maximum
280
- flexibility, and allows Rote to concentrate on creating your documents.
281
-
282
- The command-line build will automatically look for a file in the top-level
283
- directory (above +doc+) named publish.rf. If found, this file will be
284
- evaluated by Rake, making any tasks defined within it available to your
285
- build. The most likely use case is to define task that uses an SSH directory
286
- publisher to publish via SCP.
287
-
288
- == A final note about command-line mode
289
-
290
- Currently, there isn't enough checking involved on source resources when
291
- building pages from the command-line wrapper - Basically, only templates are
292
- considered when Rake decides what to update. If you change layouts, code or
293
- resources you'll need to run:
294
-
295
- rote clean
296
-
297
- to make sure everything gets updated. It's recommended to always run upload
298
- as:
299
-
300
- rote clean upload
301
-
302
- Please note that this isn't Rake's limitation - it's mine.
112
+ As you may have guessed, Rote's hosting and development services are provided
113
+ by http://RubyForge.org .
data/Rakefile CHANGED
@@ -6,7 +6,7 @@
6
6
  # This Rakefile is heavily based on Rake's own Rakefile.
7
7
  # Portions copyright (c)2003, 2004 Jim Weirich (jim <AT> weirichhouse.org)
8
8
  #
9
- # $Id: Rakefile,v 1.4 2005/11/26 01:36:52 roscopeco Exp $
9
+ # $Id: Rakefile,v 1.6 2005/11/27 15:57:45 roscopeco Exp $
10
10
  #
11
11
 
12
12
  begin
@@ -20,7 +20,10 @@ require 'rake/clean'
20
20
  require 'rake/testtask'
21
21
  require 'rake/rdoctask'
22
22
 
23
- $: << 'lib'
23
+ # This needs to go at the front of the libpath
24
+ # Otherwise, any pre-installed rote gets found,
25
+ # and used from there.
26
+ $:[0,1] = 'lib'
24
27
  require 'rote'
25
28
 
26
29
  CLEAN.include('testdata')
@@ -172,9 +175,6 @@ else
172
175
 
173
176
  s.files = PKG_FILES.to_a
174
177
 
175
- #### Install Manpages (abuse C extension feature a bit)
176
- #s.extensions << "post-install.rb"
177
-
178
178
  #### Load-time details: library and application (you will need one or both).
179
179
 
180
180
  s.require_path = 'lib' # Use these for libraries.
@@ -208,6 +208,15 @@ else
208
208
  # s.cert_chain = [File.join(ENV['CERT_DIR'], 'gem-public_cert.pem')]
209
209
  # end
210
210
  end
211
+
212
+ # Quick fix for Ruby 1.8.3 / YAML bug
213
+ if (RUBY_VERSION == '1.8.3')
214
+ def spec.to_yaml
215
+ out = super
216
+ out = '--- ' + out unless out =~ /^---/
217
+ out
218
+ end
219
+ end
211
220
 
212
221
  package_task = Rake::GemPackageTask.new(spec) do |pkg|
213
222
  pkg.need_zip = true
data/TODO CHANGED
@@ -6,7 +6,10 @@ Send any suggestions (or test-driven patches) to:
6
6
  rosco <at> roscopeco <dot> co <dot> uk
7
7
 
8
8
  * More flexible markup rendering
9
+ * Nested layouts
9
10
  * Integration with test reports
10
11
  * Automatic navigation / TOC
12
+ * Ability to have multiple views of a section, e.g. user guide (separate
13
+ pages) and user guide (one page) generated from same source.
11
14
  * Index and glossary support
12
15
  * statistics
@@ -32,6 +32,10 @@
32
32
  </table>
33
33
 
34
34
  <div class='main' background='#c0a0c0'>
35
+ <% if @page_title %>
36
+ <h2><%= @page_title %></h2>
37
+ <% end %>
38
+
35
39
  <%= @content_for_layout %>
36
40
  </div>
37
41
 
data/doc/man/rote.1.gz ADDED
Binary file
data/doc/pages/COMMON.rb CHANGED
@@ -1,3 +1,14 @@
1
+ # Common code for every page.
2
+ #
3
+ # Instead of being executed once (as you might expect), this is evaluated
4
+ # for each Page's binding as the instance is created.
5
+ #
6
+ # At the moment, COMMON.rb code isn't automatically inherited from
7
+ # parent directories - you have to use the 'inherit_common' hack provided
8
+ # by Page to inherit from the immediate parent directory ONLY (setting
9
+ # up chains of COMMONs if you have deep nesting - Ugh!). This limitation
10
+ # will be removed very soon.
11
+
1
12
  @site_title = 'Rote'
2
13
  @base_url = 'http://rote.rubyforge.org/'
3
14
 
@@ -5,16 +16,23 @@
5
16
  layout 'page'
6
17
  format_opts << :textile
7
18
 
8
- # this is used to construct the navbar and frontpage.
19
+ # this is used to construct the navbar and frontpage. Note that we use absolute
20
+ # (root-relative) URLs here, and fix them from each page with 'link_rel'.
9
21
  @navigation = [
10
22
  {:title => 'Home',
11
23
  :url => '/index.html'},
12
24
  {:title => 'Download',
13
25
  :url => 'http://rubyforge.org/frs/?group_id=1120'},
26
+ {:title => 'User guide',
27
+ :url => '/guide/'},
14
28
  {:title => 'RDoc',
15
- :url => 'rdoc/'},
29
+ :url => '/rdoc/'},
30
+ {:title => 'Issue tracker',
31
+ :url => 'http://rubyforge.org/tracker/?group_id=1120'},
16
32
  {:title => 'Project home',
17
33
  :url => 'http://rubyforge.org/projects/rote'},
18
34
  {:title => 'Browse CVS',
19
- :url => 'http://rubyforge.org/cgi-bin/viewcvs.cgi/?cvsroot=rote'}
35
+ :url => 'http://rubyforge.org/cgi-bin/viewcvs.cgi/?cvsroot=rote'},
36
+ {:title => 'License',
37
+ :url => '/license.html'}
20
38
  ]
@@ -0,0 +1,7 @@
1
+ # This is a hack that exists currently to inherit COMMON.rb
2
+ # from above. Of course, we can still define extra stuff
3
+ # here.
4
+ #
5
+ # This will be made implicit soon.
6
+
7
+ inherit_common
@@ -0,0 +1,311 @@
1
+ <% @page_title = 'User guide' %>
2
+
3
+ *This guide is still very much under construction!*
4
+
5
+ It is assumed that you have installed Rote already. If not, please
6
+ consult the <a href="<%= link_rel '/rdoc/files/README.html' %>">README</a>
7
+ for installation instructions.
8
+
9
+ <a name='top'/>
10
+ h3. Contents
11
+
12
+ * "Getting started with Rote":#getting_started
13
+ ** "From the command-line":#getting_started_command_line
14
+ ** "From your Rakefile":#getting_started_rakefile
15
+ * "Creating templates":#create_templates
16
+ ** "Basics":#create_templates_basics
17
+ ** "Formatting":#create_templates_formatting
18
+ ** "Template code & ERB":create_templates_erb
19
+ ** "Applying layout":create_templates_layout
20
+ * "Resources":#resources
21
+ * "Publishing":#publishing
22
+
23
+ <a name='getting_started'/>
24
+ h3. Getting started with Rote
25
+
26
+ h4. Setting up a project
27
+
28
+ To get started quickly, we'll use the standard Rote directory layout, which
29
+ can be used immediately with the command-line wrapper, and fits well with
30
+ Rakefile usage too. Basically, Rote expects your documentation source to
31
+ be laid out as follows:
32
+
33
+ <code><pre>
34
+ project_root ( <- root, this can be called whatever you like)
35
+ |
36
+ |--> [publish.rf]
37
+ |
38
+ |--> doc
39
+ | |--> [COMMON.rb]
40
+ | |
41
+ | |--> res
42
+ | | |--> (resources)
43
+ | |
44
+ | |--> layouts
45
+ | | |--> one.txt
46
+ | | |--> two.html
47
+ | |
48
+ | |--> pages
49
+ | | |--> [COMMON.rb]
50
+ | | |--> apage.txt
51
+ | | |--> [apage.rb]
52
+ | | |--> adir
53
+ | | | |--> [COMMON.rb]
54
+ | | | |--> bpage.html
55
+ | | | |--> [bpage.rb]
56
+
57
+ </code></pre>
58
+
59
+ Template sources under the 'pages' directory may have any extension (except
60
+ =rb=), and will be rendered to that same name under the output directory.
61
+ See the section on Layouts below for details on layout name resolution.
62
+
63
+ Ruby source is optional, and allows you to define instance variables and
64
+ methods on a Page instance. COMMON.rb is applied to all pages in a given
65
+ directory. See "the section on templates":#create_templates for more
66
+ information on the specifics.
67
+
68
+ If you've downloaded Rote, then you can see the canonical example site by
69
+ looking in the =doc/= directory (where you'll find the source for this
70
+ site).
71
+
72
+ ["top":#top]
73
+
74
+ <a name='getting_started_command_line'/>
75
+ h4. From the command-line
76
+
77
+ If you are generating a standalone documentation set (i.e. not as part of
78
+ some wider build) then you don't need to worry about writing a =Rakefile= -
79
+ you can use the built-in build via the +rote+ command. This works with
80
+ a standard directory layout, and wraps invocation of +rake+ to handle
81
+ setting up library dependencies and generation of appropriate tasks.
82
+
83
+ The command-line wrapper expects the above layout, and requires no direct
84
+ configuration. To generate an entire documentation set, simply run:
85
+
86
+ <pre><code> rote</code></pre>
87
+
88
+ from the top-level directory (=project= in the example above), you should get
89
+ a 'html' directory created with the (transformed) templates, and any
90
+ resources should be copied as necessary.
91
+
92
+ Being based on Rake, Rote supports last-modified checking, and provides an
93
+ individual file task for each page in your doc set. For example, running
94
+ the 'rote' command again with no options will cause it to exit almost
95
+ immediately, since all output is up to date. If you change a file, and run
96
+ rote again, then just that file will be updated. There are a few caveats
97
+ with this (see "the notes section":#final_notes).
98
+
99
+ The file tasks are named for the target files, so for example to generate
100
+ just the top-level index.html (regardless of whether it's been modified)
101
+ you'd run:
102
+
103
+ <pre><code> rote html/index.html</code></pre>
104
+
105
+ The =clean= task supports deleting all output files to start from scratch:
106
+
107
+ <pre><code> rote clean</code></pre>
108
+
109
+ Of course, multiple file or task names (or a mixture) can be specified.
110
+ You can get a list of valid tasks in the current context with:
111
+
112
+ <pre><code> rote --tasks</code></pre>
113
+
114
+ Further command-line usage information is available with:
115
+
116
+ <pre><code> rote --usage</code></pre>
117
+
118
+ and Unix installations performed with =install.rb= should also make a
119
+ manpage available for the =rote= command.
120
+
121
+ ["top":#top]
122
+
123
+ <a name='getting_started_rakefile'/>
124
+ h4. From your +Rakefile+
125
+
126
+ If you are wanting to build documentation as part of a larger build process, or
127
+ commandline setup, then you'll want to get started on integrating Rote with
128
+ your own (existing) +Rakefile+. Fortunately, this is very easy to do. Try
129
+ something like:
130
+
131
+ <pre><code>
132
+ # Rakefile
133
+ require 'rote'
134
+
135
+ ws = Rote::DocTask.new(:doc) { |site|
136
+ site.site_dir = 'html'
137
+ site.layout_dir = 'doc/layouts'
138
+
139
+ site.pages.dir = 'doc/pages'
140
+ site.pages.include('**/*')
141
+
142
+ site.res.dir = 'doc/res/'
143
+ site.res.include('**/*.png')
144
+ site.res.include('**/*.gif')
145
+ site.res.include('**/*.jpg')
146
+ site.res.include('**/*.css')
147
+ }
148
+
149
+ </code></pre>
150
+
151
+ Save this as =Rakefile=, and fire up:
152
+
153
+ <pre><code> rake doc</code></pre>
154
+
155
+ If all goes well, you should see each command and transformation output to your
156
+ console as Rote runs.
157
+
158
+ *Note* that it's safe to include '**/*' in the +pages+ list, since +rb+
159
+ files are implicitly excluded.
160
+
161
+ ["top":#top]
162
+
163
+ <a name='create_templates'/>
164
+ h3. Creating templates
165
+
166
+ <a name='create_templates_basics'/>
167
+ h4. The basics
168
+
169
+ As mentioned, templates are simply text files in the =doc/pages= directory. The
170
+ layout below that directory is retained when transforming pages, and is
171
+ also used to provide simple hierarchical structure to the common page code.
172
+
173
+ By default, any file with an extension other than =rb= will be processed
174
+ as a page template (with it's associated ruby source). The output will have
175
+ the same filename and path, relative to the output directory.
176
+
177
+ ["top":#top]
178
+
179
+ <a name='create_templates_formatting'/>
180
+ h4. Applying formatting
181
+
182
+ If you're generating HTML, you'll probably want to use some plaintext
183
+ formatting, rather than writing HTML by hand. Rote uses
184
+ "RedCloth":http://redcloth.rubyforge.org to provide text to HTML formatting,
185
+ supporting both Textile and Markdown. The formatting applied to a given page is
186
+ controlled by that page's +format_opts+ array. Both are disabled by default - to
187
+ enable formatting you must add something like the following somewhere appropriate:
188
+
189
+ <pre><code> format_opts << :textile << :markdown</code></pre>
190
+
191
+ This can be done in page code, COMMON.rb, or even inside the template itself.
192
+ See "the section on template code":#create_templates_erb for more information
193
+ on adding code to your templates.
194
+
195
+ *Some additional notes on formatting*
196
+
197
+ * Although you can directly assign to +format_opts+, this isn't recommended
198
+ since Ruby often interprets it as a local variable set rather than method call,
199
+ resulting in much head scratching as to why your options are being ignored.
200
+
201
+ * Note that *Formatting is applied _after_ any ERB has been evaluated.*
202
+
203
+ * that the options you supply are passed directly to RedCloth, so you can
204
+ exercise much more control over the formatting by using the feature-specific
205
+ symbols defined by RedCloth, rather than the blanket :textile and :markdown
206
+ symbols.
207
+
208
+ ["top":#top]
209
+
210
+ <a name='create_templates_erb'/>
211
+ h4. Template code and ERB
212
+
213
+ All templates may contain embedded Ruby code (ERB), delimited by the standard
214
+ &lt;% ... %&gt; (for executed code) and &lt;%= ... %&gt; (for output) tags. Any
215
+ (valid) Ruby code may be placed in the templates, and variables may be defined to
216
+ allow information to be passed into templates. There are four places where
217
+ you might define such variables. The following is in order of evaluation:
218
+
219
+ * This directory's COMMON.rb, or the parent directory's COMMON.rb if
220
+ =inherit_common= is used.
221
+ * This page's ruby code, _basename_.rb
222
+ * In a block passed to Page.new
223
+ * In the template itself
224
+
225
+ When a =Rote::Page= instance is created, Rote looks for these, and if found
226
+ evaluates them, in order, in the same binding as the template is later rendered
227
+ in (i.e. the =Page= instance binding). Therefore, you can define
228
+ instance variables to pass data around, or even helper methods if you wish.
229
+
230
+ ["top":#top]
231
+
232
+ <a name='create_templates_layout'/>
233
+ h4. Layout
234
+
235
+ Layouts are stored under the =doc/layouts= directory (by default). They may
236
+ be organised into subdirectories, but this hierarchy is not connected to
237
+ the hierarchy in =pages=. To apply a layout to a page, simply call the
238
+ =Rote::Page.layout= method from code applied to that page, passing the
239
+ base-name (and path, relative to =layouts=, if used). If no extension is
240
+ specified, then the same extension as the page itself is assumed. Examples:
241
+
242
+ <code><pre>
243
+ layout 'one'
244
+ layout 'main/wide'
245
+ layout 'dark.txt'
246
+ &lt;% layout 'my' %&gt;
247
+ </code></pre>
248
+
249
+ With that done, Rote would first render the template text (including textile)
250
+ and set the Page instance variable =@content_for_layout= before rendering
251
+ the layout (in which textile is currently not supported). The layout is
252
+ responsible for inserting the rendered template where appropriate, with
253
+ e.g.:
254
+
255
+ <code><pre> &lt;%= @content_for_layout %&gt;</code></pre>
256
+
257
+ This pattern shouldn't be unfamiliar. Again, note that Rote doesn't mandate
258
+ HTML, despite the appearance from the ERB tags - any (textual) format can
259
+ be templated and laid out.
260
+
261
+ ["top":#top]
262
+
263
+ <a name='resources'/>
264
+ h3. Resources
265
+
266
+ Of course, you're likely to have resources for your site (images, sounds, etc)
267
+ and you'll need to copy them over to the target too. Such resources should be
268
+ placed under 'res' (with the commandline setup) or in your specified +res+
269
+ directory, and will be copied directly to the output directory after page
270
+ rendering.
271
+
272
+ As you'd expect, the directory layout beneath =res= should mirror that of the
273
+ output, and will be preserved during the copy.
274
+
275
+ ["top":#top]
276
+
277
+ <a name='publishing'/>
278
+ h3. Publishing
279
+
280
+ Rote does not provide any direct support for publishing your site at present,
281
+ relying on you to configure an appropriate publish task if required, using
282
+ the publishers supplied with Rake (in =rake/contrib=), or your own. This
283
+ allows maximum flexibility, and allows Rote to concentrate on creating your
284
+ documents.
285
+
286
+ The command-line build will automatically look for a file in the top-level
287
+ directory (above =doc=) named =publish.rf=. If found, this file will be
288
+ evaluated by Rake, making any tasks defined within it available to your
289
+ build. The most likely use case is to define a task that uses an SSH directory
290
+ publisher to publish via SCP.
291
+
292
+ ["top":#top]
293
+
294
+ <a name='final_notes'/>
295
+ h3. Final notes
296
+
297
+ Currently, there isn't enough checking involved on source resources when
298
+ building pages - Basically, only templates are considered when Rake decides
299
+ what to update. If you change layouts, code or resources you'll need to run:
300
+
301
+ <pre><code> rote clean</code></pre>
302
+
303
+ to make sure everything gets updated. It's recommended to always run upload
304
+ as:
305
+
306
+ <pre><code> rote clean upload</code></pre>
307
+
308
+ Please note that this isn't Rake's limitation - it's mine. It will be fixed
309
+ in a later version of Rote.
310
+
311
+ ["top":#top]
data/doc/pages/index.html CHANGED
@@ -1,5 +1,3 @@
1
- h2. Rote - A static website build tool for Ruby
2
-
3
1
  *Rote is a simple page-based template system that was written to make it
4
2
  easier to author and maintain non-dynamic websites and
5
3
  offline documentation.* Rote provides a simple commandline or
@@ -9,12 +7,6 @@ rendering (optionally supporting Textile and Markdown with
9
7
  "ERB":http://www.ruby-doc.org/stdlib/libdoc/erb/rdoc/classes/ERB.html), layout,
10
8
  and general documentation / website build tasks.
11
9
 
12
- Rote is somewhat similar to (though simpler than)
13
- "WebGen":http://webgen.rubyforge.org , which provides a richer environment
14
- geared more toward websites and content publishing (whereas Rote's
15
- implementation as an extension to Rake reflects a bias toward software
16
- documentation).
17
-
18
10
  h3. Features
19
11
 
20
12
  Rote offers the following major features:
@@ -29,44 +21,31 @@ Rote offers the following major features:
29
21
  * Supports any (text-based) format, while providing utilities and helpers for
30
22
  common formats (HTML at present).
31
23
 
32
- h3. So where is it?
24
+ Rote is somewhat similar to (though simpler than)
25
+ "WebGen":http://webgen.rubyforge.org , which provides a richer environment
26
+ geared more toward websites and content publishing (whereas Rote's
27
+ implementation as an extension to Rake reflects a bias toward software
28
+ documentation).
29
+
30
+ See the "User guide":<%= link_rel '/guide' %> and "RDoc":<%= link_rel '/rdoc' %> for usage information.
33
31
 
34
- The first release of Rote can be downloaded from "Our FRS on RubyForge":http://rubyforge.org/frs/?group_id=1120 .
35
- It should be also available as a RubyGem (rote-0.1.0) in the usual way.
36
- The "README":rdoc/files/README.html has the most comprehensive user guide at the moment. Obviously, this
37
- site is still under construction too.
32
+ h3. Download?
38
33
 
39
- You can also grab the latest code from "CVS":http://rubyforge.org/cgi-bin/viewcvs.cgi/?cvsroot=rote.
34
+ You can get Rote via "RubyGems":http://rubyforge.org/projects/rubygems if you have it:
40
35
 
41
- Please note that Rote is still pretty new, and while this first release is fairly functional, it's
42
- also still shiny and new, and liable to break down, destroy data, and run away with your spouse if
43
- given half a chance. Check out the "Project page on Rubyforge":http://rubyforge.org/projects/rote
44
- for everything you need to get going with the CVS version.
36
+ * <strong><code>gem install -r rote</code></strong>
37
+
38
+ Alternatively, you can download tarball / zip packages from:
45
39
 
46
- h3. Licence
40
+ * <strong>"http://rubyforge.org/frs/?group_id=1120":http://rubyforge.org/frs/?group_id=1120</strong>
47
41
 
48
- <ul>
49
- <pre>
50
- <code>
51
- Copyright (c) 2005 Ross Bamford (and contributors)
42
+ You can also grab the latest code from "CVS":http://rubyforge.org/cgi-bin/viewcvs.cgi/?cvsroot=rote.
52
43
 
53
- Permission is hereby granted, free of charge, to any person obtaining a copy of
54
- this software and associated documentation files (the "Software"), to deal in
55
- the Software without restriction, including without limitation the rights to
56
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
57
- of the Software, and to permit persons to whom the Software is furnished to do
58
- so, subject to the following conditions:
44
+ h4. From CVS
59
45
 
60
- The above copyright notice and this permission notice shall be included in all
61
- copies or substantial portions of the Software.
46
+ A link to the latest stable release can be found from the "project page":http://rubyforge.org/projects/rote .
62
47
 
63
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
64
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
65
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
66
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
67
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
68
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
69
- SOFTWARE.
70
- </code>
71
- </pre>
72
- </ul>
48
+ Please note that Rote is still pretty new, and while currently fairly functional, it's
49
+ also still shiny and new, and liable to break down, destroy data, and run away with your spouse if
50
+ given half a chance. Sound like fun? Then check out the "Project page on Rubyforge":http://rubyforge.org/projects/rote
51
+ for everything you need to get going with the CVS version!
data/doc/pages/index.rb CHANGED
@@ -1,4 +1,8 @@
1
- # the default
2
- #layout 'page'
3
-
4
- @page_title = 'Welcome!'
1
+ # Page code for 'index.html'
2
+ #
3
+ # In practice, for something this simple you'd usually go with setting
4
+ # the var directly in the template, e.g.
5
+ #
6
+ # <% @page_title = 'Welcome!' %>
7
+ #
8
+ @page_title = 'Welcome!'
@@ -0,0 +1,27 @@
1
+ <% @page_title = 'Licence' %>
2
+
3
+ <ul>
4
+ <pre>
5
+ <code>
6
+ Copyright (c) 2005 Ross Bamford (and contributors)
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
9
+ this software and associated documentation files (the "Software"), to deal in
10
+ the Software without restriction, including without limitation the rights to
11
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12
+ of the Software, and to permit persons to whom the Software is furnished to do
13
+ so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in all
16
+ copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ SOFTWARE.
25
+ </code>
26
+ </pre>
27
+ </ul>
data/install.rb CHANGED
@@ -85,5 +85,27 @@ for fn in files
85
85
  File::install(File.join('lib', fn), File.join($sitedir, fn), 0644, true)
86
86
  end
87
87
 
88
+ $mandir = CONFIG['mandir']
89
+ unless (!$mandir || CONFIG["target_os"] =~ /mswin/i) # manpages not doable on windows?
90
+ files = Dir.chdir('doc/man') { Dir['*.gz'] }
91
+ for fn in files
92
+ # maybe in locale dir
93
+ fdn = File.dirname(fn)
94
+ target_dir = $mandir
95
+ target_dir = File.join(target_dir, fdn) unless fdn == '.'
96
+
97
+ fbn = File.basename(fn)
98
+ if (fbn =~ /\.([0-9]*)(\.gz)?$/)
99
+ target_dir = File.join(target_dir,"man#{$~[1]}")
100
+ end
101
+
102
+ if ! File.exist?(target_dir)
103
+ File.makedirs(target_dir)
104
+ end
105
+
106
+ File::install(File.join('doc/man', fn), File.join(target_dir, fbn), 0644, true)
107
+ end
108
+ end
109
+
88
110
  # and the executable
89
111
  installBIN("bin/rote", "rote")
data/lib/rote.rb CHANGED
@@ -28,7 +28,7 @@ require_gem 'rake'
28
28
  require 'rote/rotetasks'
29
29
 
30
30
  # Master Rote version. Manage this from the Rake release support.
31
- ROTEVERSION = '0.1.2'
31
+ ROTEVERSION = '0.1.6'
32
32
 
33
33
  #####
34
34
  ## *Rote* is a Rake (http://rake.rubyforge.org) based build tool for page-based
@@ -1,5 +1,9 @@
1
1
  module Rote
2
2
 
3
+
4
+ # TODO untested
5
+
6
+
3
7
  # An extension to the Rake +FileList+ class that allows a root
4
8
  # directory to be specified.
5
9
  class DirectoryFileList < FileList
@@ -8,17 +12,17 @@ module Rote
8
12
  # patterns. You may also pass a block to perform additional
9
13
  # configuration (e.g. if you have a lot of includes/excludes
10
14
  # or just don't like arguments for whatever reason).
11
- def initialize(basedir = '.', *patterns)
12
- dir=(basedir)
15
+ def initialize(basedir = '.', *patterns)
13
16
  super(*patterns)
17
+ self.dir = basedir
14
18
  end
15
19
 
16
20
  # The root directory from which this filelist matches. All patterns
17
21
  # are considered relative to this directory.
18
- attr_accessor :dir
22
+ attr_reader :dir
19
23
  def dir=(newdir)
20
24
  newdir = newdir.sub(/\/$/,'')
21
- sub!(/^#{@dir}/,newdir)
25
+ self.sub!(/^#{@dir}/,newdir) unless self.empty?
22
26
  @dir = newdir
23
27
  end
24
28
 
data/lib/rote/page.rb CHANGED
@@ -33,7 +33,7 @@ module Rote
33
33
  # The default is [], which means 'No formatting'. This setting
34
34
  # does not affect ERB rendering (which is always performed, before
35
35
  # any formatting).
36
- attr_accessor :format_opts
36
+ attr_reader :format_opts
37
37
  def format_opts=(opts)
38
38
  if !opts.nil? && opts.respond_to?(:to_ary)
39
39
  @format_opts = opts
@@ -91,8 +91,10 @@ module Rote
91
91
  def define_page_tasks
92
92
 
93
93
  # define a task for each page
94
+ realpages = FileList[]
94
95
  pages.each { |fn|
95
96
  unless File.directory?(fn) # make dirs only as needed
97
+ realpages << fn
96
98
  tfn = fn.sub(/#{pages.dir}/, output_dir)
97
99
 
98
100
  desc "#{fn} => #{tfn}" if show_page_tasks?
@@ -109,7 +111,7 @@ module Rote
109
111
 
110
112
  # this is pretty convenient ;]
111
113
  desc "Render all documentation pages"
112
- task "#{name}-pages" => pages.sub(/#{pages.dir}/, output_dir)
114
+ task "#{name}-pages" => realpages.sub(/#{pages.dir}/, output_dir)
113
115
  end
114
116
 
115
117
  def define_main_tasks
metadata CHANGED
@@ -1,10 +1,10 @@
1
- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: rote
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.2
7
- date: 2005-11-26 00:00:00 +00:00
6
+ version: 0.1.6
7
+ date: 2005-11-28 00:00:00 +00:00
8
8
  summary: Adds template-based doc support to Rake.
9
9
  require_paths:
10
10
  - lib
@@ -61,6 +61,7 @@ files:
61
61
  - doc/res
62
62
  - doc/jamis.rb
63
63
  - doc/pages
64
+ - doc/man
64
65
  - doc/layouts
65
66
  - doc/res/images
66
67
  - doc/res/stylesheets
@@ -78,7 +79,12 @@ files:
78
79
  - doc/res/stylesheets/normal.css
79
80
  - doc/pages/COMMON.rb
80
81
  - doc/pages/index.html
82
+ - doc/pages/guide
83
+ - doc/pages/license.html
81
84
  - doc/pages/index.rb
85
+ - doc/pages/guide/COMMON.rb
86
+ - doc/pages/guide/index.html
87
+ - doc/man/rote.1.gz
82
88
  - doc/layouts/page.html
83
89
  test_files: []
84
90