webby 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ == 0.6.0 /
2
+
3
+ * Added support for embedded graphviz images and image maps
4
+ * Tidy can be used as a filter to format HTML and check for errors
5
+ * Simplified coderay when used with textile
6
+
1
7
  == 0.5.1 / 2007-11-29
2
8
 
3
9
  * Growl notifications now work on Leopard / Tiger
data/Manifest.txt CHANGED
@@ -30,8 +30,10 @@ data/templates/page.erb
30
30
  lib/webby.rb
31
31
  lib/webby/auto_builder.rb
32
32
  lib/webby/builder.rb
33
- lib/webby/coderay_filter.rb
34
33
  lib/webby/file.rb
34
+ lib/webby/filters/coderay.rb
35
+ lib/webby/filters/graphviz.rb
36
+ lib/webby/filters/tidy.rb
35
37
  lib/webby/main.rb
36
38
  lib/webby/pages_db.rb
37
39
  lib/webby/renderer.rb
data/data/Rakefile CHANGED
@@ -1,5 +1,4 @@
1
1
 
2
- require 'webby'
3
2
  load 'tasks/setup.rb'
4
3
 
5
4
  task :default => :build
@@ -1,13 +1,4 @@
1
1
 
2
- require 'webby'
3
-
4
- Rake::WebbyTask.new do |webby|
5
- webby.content_dir = SITE.content_dir
6
- webby.output_dir = SITE.output_dir
7
- webby.layout_dir = SITE.layout_dir
8
- webby.template_dir = SITE.template_dir
9
- webby.exclude = SITE.exclude
10
- webby.page_defaults = SITE.page_defaults
11
- end
2
+ Rake::WebbyTask.new
12
3
 
13
4
  # EOF
data/data/tasks/setup.rb CHANGED
@@ -1,8 +1,9 @@
1
1
 
2
- require 'ostruct'
2
+ require 'webby'
3
3
 
4
- SITE = OpenStruct.new
4
+ SITE = Webby.site
5
5
 
6
+ # Webby defaults
6
7
  SITE.content_dir = 'content'
7
8
  SITE.output_dir = 'output'
8
9
  SITE.layout_dir = 'layouts'
@@ -14,12 +15,18 @@ SITE.page_defaults = {
14
15
  'layout' => 'default'
15
16
  }
16
17
 
18
+ # Items used to deploy the webiste
17
19
  SITE.host = 'user@hostname.tld'
18
20
  SITE.remote_dir = '/not/a/valid/dir'
19
21
  SITE.rsync_args = %w(-av --delete)
20
22
 
23
+ # Options passed to the 'tidy' program when the tidy filter is used
24
+ SITE.tidy_options = '-indent -wrap 80'
25
+
26
+ # Load up the other rake tasks
21
27
  FileList['tasks/*.rake'].each {|task| import task}
22
28
 
29
+ # Conditional dependencies
23
30
  %w(heel).each do |lib|
24
31
  Object.instance_eval {const_set "HAVE_#{lib.upcase}", try_require(lib)}
25
32
  end
data/lib/webby.rb CHANGED
@@ -1,6 +1,7 @@
1
- # $Id: webby.rb 51 2007-11-29 06:01:26Z tim_pease $
1
+ # $Id: webby.rb 60 2007-12-04 05:05:50Z tim_pease $
2
2
 
3
3
  require 'logging'
4
+ require 'ostruct'
4
5
 
5
6
  # Configure Webby to log to STDOUT at the 'info' level
6
7
  Logging::Appender.stdout.layout = Logging::Layouts::Pattern.new(
@@ -13,7 +14,7 @@ Logging::Logger['Webby'].level = :info
13
14
 
14
15
  module Webby
15
16
 
16
- VERSION = '0.5.1' # :nodoc:
17
+ VERSION = '0.6.0' # :nodoc:
17
18
 
18
19
  # Path to the Webby package
19
20
  PATH = ::File.expand_path(::File.join(::File.dirname(__FILE__), '..'))
@@ -37,30 +38,27 @@ module Webby
37
38
  end
38
39
 
39
40
  # call-seq:
40
- # Webby.config => hash
41
+ # Webby.site => struct
41
42
  #
42
- # Returns the configuration hash for the Webby application.
43
+ # Returns a struct containing the configuration parameters for the
44
+ # Webby site. These defaults should be overridden as needed in the
45
+ # site specific Rakefile.
43
46
  #
44
- def self.config
45
- @config ||= {
46
- 'output_dir' => 'output',
47
- 'content_dir' => 'content',
48
- 'layout_dir' => 'layouts',
49
- 'template_dir' => 'templates',
50
- 'exclude' => %w(tmp$ bak$ ~$ CVS \.svn)
51
- }
52
- end
53
-
54
- # call-seq:
55
- # Webby.page_defaults => hash
56
- #
57
- # Returns the page defaults hash used for page resource objects.
58
- #
59
- def self.page_defaults
60
- @page_defaults ||= {
47
+ def self.site
48
+ return @site if defined? @site
49
+
50
+ @site = OpenStruct.new
51
+ @site.output_dir = 'output'
52
+ @site.content_dir = 'content'
53
+ @site.layout_dir = 'layouts'
54
+ @site.template_dir = 'templates'
55
+ @site.exclude = %w(tmp$ bak$ ~$ CVS \.svn)
56
+ @site.page_defaults = {
61
57
  'extension' => 'html',
62
58
  'layout' => 'default'
63
59
  }
60
+
61
+ @site
64
62
  end
65
63
 
66
64
  # call-seq
@@ -71,7 +69,7 @@ module Webby
71
69
  # also used to exclude layouts.
72
70
  #
73
71
  def self.exclude
74
- @exclude ||= Regexp.new(config['exclude'].join('|'))
72
+ @exclude ||= Regexp.new(site.exclude.join('|'))
75
73
  end
76
74
 
77
75
  # call-seq:
@@ -82,7 +80,7 @@ module Webby
82
80
  # modification time of the file is important.
83
81
  #
84
82
  def self.cairn
85
- @cairn ||= File.join(config['output_dir'], '.cairn')
83
+ @cairn ||= File.join(site.output_dir, '.cairn')
86
84
  end
87
85
 
88
86
  end # module Webby
@@ -1,4 +1,4 @@
1
- # $Id: auto_builder.rb 40 2007-10-14 03:54:36Z tim_pease $
1
+ # $Id: auto_builder.rb 60 2007-12-04 05:05:50Z tim_pease $
2
2
 
3
3
  require 'directory_watcher'
4
4
 
@@ -34,8 +34,8 @@ class AutoBuilder
34
34
  @watcher.add_observer self
35
35
 
36
36
  glob = []
37
- glob << File.join(::Webby.config['layout_dir'], '**', '*')
38
- glob << File.join(::Webby.config['content_dir'], '**', '*')
37
+ glob << File.join(::Webby.site.layout_dir, '**', '*')
38
+ glob << File.join(::Webby.site.content_dir, '**', '*')
39
39
  @watcher.glob = glob
40
40
  end
41
41
 
data/lib/webby/builder.rb CHANGED
@@ -1,4 +1,4 @@
1
- # $Id: builder.rb 46 2007-11-27 03:31:29Z tim_pease $
1
+ # $Id: builder.rb 60 2007-12-04 05:05:50Z tim_pease $
2
2
 
3
3
  require 'find'
4
4
  require 'fileutils'
@@ -150,7 +150,7 @@ class Builder
150
150
 
151
151
  %w(output_dir layout_dir content_dir).each do |key|
152
152
  self.class_eval <<-CODE
153
- def #{key}( ) ::Webby.config['#{key}'] end
153
+ def #{key}( ) ::Webby.site.#{key} end
154
154
  CODE
155
155
  end
156
156
 
@@ -1,12 +1,13 @@
1
- # $Id: coderay_filter.rb 27 2007-09-18 18:09:25Z tim_pease $
1
+ # $Id: coderay.rb 58 2007-12-02 23:59:27Z tim_pease $
2
2
 
3
3
  require 'enumerator'
4
4
  require 'hpricot'
5
5
  try_require 'coderay'
6
6
 
7
7
  module Webby
8
+ module Filters
8
9
 
9
- # The CodeRayFilter applies syntax highlighting to source code embedded in a
10
+ # The CodeRay applies syntax highlighting to source code embedded in a
10
11
  # webpage. The CodeRay highlighting engine is used for the HTML markup of
11
12
  # the source code. A set of <coderay>...</coderay> tags is used to denote
12
13
  # which sections of the page should be highlighted.
@@ -21,7 +22,7 @@ module Webby
21
22
  # end
22
23
  # </coderay>
23
24
  #
24
- # The supported CodeRay options are the following:
25
+ # The supported CodeRay options are the following:
25
26
  #
26
27
  # lang : the language to highlight (ruby, c, html, ...)
27
28
  # line_numbers : include line nubers in 'table', 'inline',
@@ -30,15 +31,16 @@ module Webby
30
31
  # bold_every : make every n-th number appear bold
31
32
  # tab_width : convert tab characters to n spaces
32
33
  #
33
- class CodeRayFilter
34
+ class CodeRay
34
35
 
35
36
  # call-seq:
36
- # CodeRayFilter.new( string )
37
+ # CodeRay.new( string, filters = nil )
37
38
  #
38
39
  # Creates a new CodeRay filter that will operate on the given _string_.
39
40
  #
40
- def initialize( str )
41
+ def initialize( str, filters = nil )
41
42
  @str = str
43
+ @filters = filters
42
44
  end
43
45
 
44
46
  # call-seq:
@@ -66,15 +68,25 @@ class CodeRayFilter
66
68
 
67
69
  #cr.swap(CodeRay.scan(text, lang).html(opts).div)
68
70
  out = "<div class=\"CodeRay\"><pre>\n"
69
- out << CodeRay.scan(text, lang).html(opts)
71
+ out << ::CodeRay.scan(text, lang).html(opts)
70
72
  out << "\n</pre></div>"
73
+
74
+ @filters.each do |f|
75
+ case f
76
+ when 'textile'
77
+ out.insert 0, "<notextile>\n"
78
+ out << "\n</notextile>"
79
+ end
80
+ end unless @filters.nil?
81
+
71
82
  cr.swap out
72
83
  end
73
84
 
74
85
  doc.to_html
75
86
  end
76
87
 
77
- end # class CodeRayFilter
88
+ end # class CodeRay
89
+ end # module Filters
78
90
  end # module Webby
79
91
 
80
92
  # EOF
@@ -0,0 +1,175 @@
1
+ # $Id: graphviz.rb 61 2007-12-04 05:48:23Z tim_pease $
2
+
3
+ require 'hpricot'
4
+ require 'fileutils'
5
+ require 'tempfile'
6
+
7
+ module Webby
8
+ module Filters
9
+
10
+ # The Graphviz filter processes DOT scripts in a webpage and replaces them
11
+ # with generated image files. A set of <graphviz>...</graphviz> tags is
12
+ # used to denote which section(s) of the page contains DOT scripts.
13
+ #
14
+ # Options can be passed to the Graphviz filter using attributes in the
15
+ # <graphviz> tag.
16
+ #
17
+ # <graphviz path="images" type="gif" cmd="dot">
18
+ # digraph graph_1 {
19
+ # graph [URL="default.html"]
20
+ # a [URL="a.html"]
21
+ # b [URL="b.html"]
22
+ # c [URL="c.html"]
23
+ # a -> b -> c
24
+ # a -> c
25
+ # }
26
+ # </graphviz>
27
+ #
28
+ # If the DOT script contains *URL* or *href* statements on any of the nodes
29
+ # or edges, then an image map will be generated and the image will be
30
+ # "clikcable" in the webpage. If *URL* or *href* statements do not appear in
31
+ # the DOT script, then a regular image will be inserted into the webpage.
32
+ #
33
+ # The image is inserted into the page using an HTML <img /> tag. A
34
+ # corresponding <map>...</map> element will be inserted if needed.
35
+ #
36
+ # The supported Graphviz options are the following:
37
+ #
38
+ # path : where generated images will be stored
39
+ # [default is "/"]
40
+ # type : the type of image to generate (png, jpeg, gif)
41
+ # [default is png]
42
+ # cmd : the Graphviz command to use when generating images
43
+ # (dot, neato, twopi, circo, fdp) [default is dot]
44
+ #
45
+ # the following options are passed as-is to the generated <img /> tag
46
+ # style : CSS styles to apply to the <img />
47
+ # class : CSS class to apply to the <img />
48
+ # id : HTML identifier
49
+ # alt : alternate text for the <img />
50
+ #
51
+ class Graphviz
52
+
53
+ class Error < StandardError; end # :nodoc:
54
+
55
+ # call-seq:
56
+ # Graphviz.new( string, filters = nil )
57
+ #
58
+ # Creates a new Graphviz filter that will operate on the given _string_.
59
+ # The optional _filters_ describe filters that will be applied to the
60
+ # output string returned by the Graphviz filter.
61
+ #
62
+ def initialize( str, filters = nil )
63
+ @log = ::Logging::Logger[self]
64
+ @str = str
65
+ @filters = filters
66
+
67
+ # create a temporary file for holding any error messages
68
+ # from the graphviz program
69
+ @err = Tempfile.new('graphviz_err')
70
+ @err.close
71
+ end
72
+
73
+ # call-seq:
74
+ # to_html => string
75
+ #
76
+ # Process the original text string passed to the filter when it was
77
+ # created and output HTML formatted text. Any text between
78
+ # <graphviz>...</graphviz> tags will have the contained DOT syntax
79
+ # converted into an image and then included into the resulting HTML text.
80
+ #
81
+ def to_html
82
+ doc = Hpricot(@str)
83
+ doc.search('//graphviz') do |gviz|
84
+
85
+ text = gviz.inner_html.strip # the DOT script to process
86
+ path = gviz['path']
87
+ cmd = gviz['cmd'] || 'dot'
88
+ type = gviz['type'] || 'png'
89
+
90
+ %x[#{cmd} -V 2>&1]
91
+ unless 0 == $?.exitstatus
92
+ raise NameError, "'#{cmd}' not found on the path"
93
+ end
94
+
95
+ # pull the name of the graph|digraph out of the DOT script
96
+ name = text.match(%r/\A\s*(?:strict\s+)?(?:di)?graph\s+([A-Za-z_][A-Za-z0-9_]*)\s+\{/o)[1]
97
+
98
+ # see if the user includes any URL or href attributes
99
+ # if so, then we need to create an imagemap
100
+ usemap = text.match(%r/(?:URL|href)\s*=/o) != nil
101
+
102
+ # generate the image filename based on the path, graph name, and type
103
+ # of image to generate
104
+ image_fn = path.nil? ? name.dup : File.join(path, name)
105
+ image_fn << '.' << type
106
+
107
+ # create the HTML img tag
108
+ out = "<img src=\"#{image_fn}\""
109
+
110
+ %w[class style id alt].each do |attr|
111
+ next if gviz[attr].nil?
112
+ out << " %s=\"%s\"" % [attr, gviz[attr]]
113
+ end
114
+
115
+ out << " usemap=\"#{name}\"" if usemap
116
+ out << " />\n"
117
+
118
+ # generate the image map if needed
119
+ if usemap
120
+ IO.popen("#{cmd} -Tcmapx 2> #{@err.path}", 'r+') do |io|
121
+ io.write text
122
+ io.close_write
123
+ out << io.read
124
+ end
125
+ error_check
126
+ end
127
+
128
+ # generate the image using graphviz -- but first ensure that the
129
+ # path exists
130
+ out_dir = ::Webby.site.output_dir
131
+ out_file = File.join(out_dir, image_fn)
132
+ FileUtils.mkpath(File.join(out_dir, path)) unless path.nil?
133
+ cmd = "#{cmd} -T#{type} -o #{out_file} 2> #{@err.path}"
134
+
135
+ IO.popen(cmd, 'w') {|io| io.write text}
136
+ error_check
137
+
138
+ # see if we need to put some guards around the output
139
+ # (specifically for textile)
140
+ @filters.each do |f|
141
+ case f
142
+ when 'textile'
143
+ out.insert 0, "<notextile>\n"
144
+ out << "\n</notextile>"
145
+ end
146
+ end unless @filters.nil?
147
+
148
+ gviz.swap out
149
+ end
150
+
151
+ doc.to_html
152
+ end
153
+
154
+
155
+ private
156
+
157
+ # call-seq:
158
+ # error_check
159
+ #
160
+ # Check the temporary error file to see if it contains any error messages
161
+ # from the graphviz program. If it is not empty, then read the contents
162
+ # and log an error message and raise an exception.
163
+ #
164
+ def error_check
165
+ if File.size(@err.path) != 0
166
+ @log.error File.read(@err.path).strip
167
+ raise Error
168
+ end
169
+ end
170
+
171
+ end # class Graphviz
172
+ end # module Filters
173
+ end # module Webby
174
+
175
+ # EOF
@@ -0,0 +1,71 @@
1
+ # $Id: tidy.rb 61 2007-12-04 05:48:23Z tim_pease $
2
+
3
+ require 'fileutils'
4
+ require 'tempfile'
5
+
6
+ module Webby
7
+ module Filters
8
+
9
+ # The Tidy filter is used to process HTML (or XHTML) through the _tidy_
10
+ # program and outpu nicely formatted and correct HTML (or XHTML).
11
+ #
12
+ # Options can be passed to the _tidy_ program via the
13
+ # <code>Webby.site</code> struct. Setting the +tidy_options+ to the string
14
+ # of desired options will do the trick.
15
+ #
16
+ # From a project's Rakefile, include the following line (or one that's more
17
+ # to your liking):
18
+ #
19
+ # SITE.tidy_options = "-indent -wrap 80 -utf8"
20
+ #
21
+ class Tidy
22
+
23
+ class Error < StandardError; end # :nodoc:
24
+
25
+ # call-seq:
26
+ # Tidy.new( html )
27
+ #
28
+ # Create a new filter that will process the given _html_ through the tidy
29
+ # program.
30
+ #
31
+ def initialize( str )
32
+ @log = ::Logging::Logger[self]
33
+ @str = str
34
+
35
+ # create a temporary file for holding any error messages
36
+ # from the tidy program
37
+ @err = Tempfile.new('tidy_err')
38
+ @err.close
39
+ end
40
+
41
+ # call-seq:
42
+ # process => formatted html
43
+ #
44
+ # Process the original HTML text string passed to the filter when it was
45
+ # created and output Tidy formatted HTML or XHTML.
46
+ #
47
+ def process
48
+ %x[tidy -v 2>&1]
49
+ unless 0 == $?.exitstatus
50
+ raise NameError, "'tidy' not found on the path"
51
+ end
52
+
53
+ cmd = "tidy %s -q -f #{@err.path}" % ::Webby.site.tidy_options
54
+ out = IO.popen(cmd, 'r+') do |tidy|
55
+ tidy.write @str
56
+ tidy.close_write
57
+ tidy.read
58
+ end
59
+
60
+ if File.size(@err.path) != 0
61
+ @log.warn File.read(@err.path).strip
62
+ end
63
+
64
+ return out
65
+ end
66
+
67
+ end # class Tidy
68
+ end # module Filters
69
+ end # module Webby
70
+
71
+ # EOF
@@ -1,4 +1,4 @@
1
- # $Id: renderer.rb 51 2007-11-29 06:01:26Z tim_pease $
1
+ # $Id: renderer.rb 61 2007-12-04 05:48:23Z tim_pease $
2
2
 
3
3
  require 'erb'
4
4
  try_require 'bluecloth'
@@ -160,8 +160,9 @@ class Renderer
160
160
  #
161
161
  def markdown_filter( str )
162
162
  BlueCloth.new(str).to_html
163
- rescue NameError
163
+ rescue NameError => err
164
164
  @log.error 'markdown filter failed (BlueCloth not installed?)'
165
+ @log.debug err
165
166
  exit
166
167
  end
167
168
 
@@ -169,17 +170,57 @@ class Renderer
169
170
  #
170
171
  def textile_filter( str )
171
172
  RedCloth.new(str).to_html
172
- rescue NameError
173
+ rescue NameError => err
173
174
  @log.error 'textile filter failed (RedCloth not installed?)'
175
+ @log.debug err
174
176
  exit
175
177
  end
176
178
 
177
179
  # Render text via the CodeRay syntax highlighter library.
178
180
  #
179
181
  def coderay_filter( str )
180
- CodeRayFilter.new(str).to_html
181
- rescue NameError
182
+ filters = nil
183
+
184
+ if Array === @page.filter
185
+ idx = @page.filter.index('coderay') + 1
186
+ filters = @page.filter.slice(idx..-1)
187
+ end
188
+
189
+ Filters::CodeRay.new(str, filters).to_html
190
+ rescue NameError => err
182
191
  @log.error 'coderay filter failed (CodeRay not installed?)'
192
+ @log.debug err
193
+ exit
194
+ end
195
+
196
+ # Render text into iamges via the Graphviz programs.
197
+ #
198
+ def graphviz_filter( str )
199
+ filters = nil
200
+
201
+ if Array === @page.filter
202
+ idx = @page.filter.index('graphviz') + 1
203
+ filters = @page.filter.slice(idx..-1)
204
+ end
205
+
206
+ Filters::Graphviz.new(str, filters).to_html
207
+ rescue NameError => err
208
+ @log.error 'graphviz filter failed (Graphviz not installed?)'
209
+ @log.debug err
210
+ exit
211
+ rescue Filters::Graphviz::Error
212
+ exit
213
+ end
214
+
215
+ # Render html into html/xhtml via the Tidy program
216
+ #
217
+ def tidy_filter( str )
218
+ Filters::Tidy.new(str).process
219
+ rescue NameError => err
220
+ @log.error 'tidy filter failed (Tidy not installed?)'
221
+ @log.debug err
222
+ exit
223
+ rescue Filters::Tidy::Error
183
224
  exit
184
225
  end
185
226
 
@@ -190,8 +231,9 @@ class Renderer
190
231
  opts[:locals] ||= {}
191
232
  opts[:locals].merge!({:page => @page, :pages => @pages})
192
233
  Haml::Engine.new(str, opts).to_html
193
- rescue NameError
234
+ rescue NameError => err
194
235
  @log.error 'haml filter failed (Haml not installed?)'
236
+ @log.debug err
195
237
  exit
196
238
  end
197
239
 
@@ -200,8 +242,9 @@ class Renderer
200
242
  def sass_filter( str )
201
243
  opts = @page.sass_options || {}
202
244
  Sass::Engine.new(str, opts).render
203
- rescue NameError
245
+ rescue NameError => err
204
246
  @log.error 'sass filter failed (Haml not installed?)'
247
+ @log.debug err
205
248
  exit
206
249
  end
207
250
 
@@ -1,4 +1,4 @@
1
- # $Id: resource.rb 51 2007-11-29 06:01:26Z tim_pease $
1
+ # $Id: resource.rb 61 2007-12-04 05:48:23Z tim_pease $
2
2
 
3
3
  module Webby
4
4
 
@@ -77,7 +77,7 @@ class Resource
77
77
  @have_mdata = !@mdata.nil?
78
78
 
79
79
  @mdata ||= {}
80
- @mdata = ::Webby.page_defaults.merge(@mdata) if is_page?
80
+ @mdata = ::Webby.site.page_defaults.merge(@mdata) if is_page?
81
81
  @mdata.sanitize!
82
82
 
83
83
  self.class.pages << self if is_page? or is_static?
@@ -147,7 +147,7 @@ class Resource
147
147
  @dest = if @mdata.has_key? 'destination' then @mdata['destination']
148
148
  else File.join(dir, filename) end
149
149
 
150
- @dest = File.join(::Webby.config['output_dir'], @dest)
150
+ @dest = File.join(::Webby.site.output_dir, @dest)
151
151
  @dest << @number.to_s if @number
152
152
  @dest << '.'
153
153
  @dest << extension
@@ -155,17 +155,17 @@ class Resource
155
155
  end
156
156
 
157
157
  # call-seq
158
- # href => string or nil
158
+ # url => string or nil
159
159
  #
160
- # Returns a string suitable for use as an href linking to this page. Nil
160
+ # Returns a string suitable for use as a URL linking to this page. Nil
161
161
  # is returned for layouts.
162
162
  #
163
- def href
163
+ def url
164
164
  return nil if is_layout?
165
- return @href if defined? @href and @href
165
+ return @url if defined? @url and @url
166
166
 
167
- @href = destination.sub(::Webby.config['output_dir'], '')
168
- @href
167
+ @url = destination.sub(::Webby.site.output_dir, '')
168
+ @url
169
169
  end
170
170
 
171
171
  # call-seq:
@@ -212,7 +212,7 @@ class Resource
212
212
  #
213
213
  def is_layout?
214
214
  @is_layout ||=
215
- !(%r/\A(?:\.\/|\/)?#{::Webby.config['layout_dir']}\//o =~ @path).nil?
215
+ !(%r/\A(?:\.\/|\/)?#{::Webby.site.layout_dir}\//o =~ @path).nil?
216
216
  end
217
217
 
218
218
  # call-seq:
@@ -1,4 +1,4 @@
1
- # $Id: webby_task.rb 15 2007-08-25 19:05:39Z tim_pease $
1
+ # $Id: webby_task.rb 60 2007-12-04 05:05:50Z tim_pease $
2
2
 
3
3
  begin
4
4
  require 'rake'
@@ -33,24 +33,6 @@ module Rake
33
33
  #
34
34
  class WebbyTask < TaskLib
35
35
 
36
- # Define a setter and getter for each key in the Webby configuration hash
37
- ::Webby.config.keys.each do |key|
38
- self.class_eval do
39
- define_method(key) {::Webby.config[key]}
40
- define_method(key+'=') {|val| ::Webby.config[key] = val}
41
- end
42
- end
43
-
44
- # Global page attributes
45
- def page_defaults
46
- ::Webby.page_defaults
47
- end
48
-
49
- # Merge the given _hash_ with the page defaults hash
50
- def page_defaults=( hash )
51
- ::Webby.page_defaults.merge! hash
52
- end
53
-
54
36
  # call-seq:
55
37
  # WebbyTask.new {|self| block}
56
38
  #
@@ -92,15 +74,15 @@ class WebbyTask < TaskLib
92
74
  # task for creating a new page based on that template.
93
75
  #
94
76
  def define_create_tasks
95
- FileList["#{template_dir}/*"].each do |template|
77
+ FileList["#{::Webby.site.template_dir}/*"].each do |template|
96
78
  name = template.pathmap '%n'
97
79
 
98
- desc "create a new #{name} page"
80
+ desc "create a new #{name}"
99
81
  task name do |t|
100
82
  raise "Usage: rake #{t.name} path" unless ARGV.length == 2
101
83
 
102
84
  page = t.application.top_level_tasks.pop
103
- page = File.join(content_dir, page)
85
+ page = File.join(::Webby.site.content_dir, page)
104
86
  page << '.txt' if File.extname(page).empty?
105
87
 
106
88
  ::Webby::Builder.create page, :from => template
data/website/Rakefile CHANGED
@@ -1,5 +1,4 @@
1
1
 
2
- require 'webby'
3
2
  load 'tasks/setup.rb'
4
3
 
5
4
  task :default => :build
@@ -15,8 +15,10 @@ gem install webby
15
15
 
16
16
  h2. Features
17
17
 
18
- * choose your templating language: *eRuby*, *Textile*, *Markdown*, *HAML*
18
+ * choose your templating language: *eRuby*, *Textile*, *Markdown*, *HAML*, *SASS*
19
19
  * support for "CodeRay":http://coderay.rubychan.de/ syntax highlighting
20
+ * embeddable DOT scripts for "Graphviz":http://www.graphviz.org/ graphs
21
+ * automatically clean up generated content using "Tidy":http://tidy.sourceforge.net/
20
22
  * quick and speedy - only builds pages that have changed
21
23
  * deploy anywhere - it's just HTML, no special server stuff required
22
24
  * happy "rake":http://docs.rubyrake.org/ tasks for deploying your website to a server
@@ -3,19 +3,46 @@ title: Manual
3
3
  created_at: Wed Aug 29 08:57:00 -0600 2007
4
4
  filter:
5
5
  - coderay
6
+ - graphviz
6
7
  - textile
7
8
  ---
9
+ <graphviz path="images" alt="test image">
10
+ digraph my_graph {
11
+ // order all the nodes from Left to Right
12
+ rankdir=LR;
13
+
14
+ // defaults for each node in the graph
15
+ node [shape=rect,
16
+ style=filled,
17
+ fillcolor="#99CCCC",
18
+ fontname="Verdana",
19
+ fontsize=10];
20
+
21
+ // defaults for each edge in the graph
22
+ edge [fontname="Verdana", fontsize=8];
23
+
24
+ // the graph
25
+ a [URL="/index.html", label="Home"];
26
+ b [URL="/download.html", label="Download"];
27
+ c [URL="/tutorial.html", label="Tutorial"];
28
+ d [label="Manual", fillcolor="#6699CC"];
29
+ e [URL="/tips_and_tricks.html", label="Tips &\nTricks"];
30
+
31
+ a -> b -> c;
32
+ c -> d -> e;
33
+ a -> c [URL="http://www.google.com" label="skipping\ndownload"];
34
+ }
35
+ </graphviz>
36
+
8
37
  h2. To-Do
9
38
 
10
39
  The Webby user's manual goes here.
11
40
 
12
- <notextile>
13
41
  <coderay lang="ruby">
14
42
  def method( blah )
15
43
  blah.upcase
16
44
  end
17
45
  </coderay>
18
- </notextile>
19
46
 
20
47
  directory structure
21
48
  * content
@@ -15,8 +15,6 @@ h2(#toc_cr){clear:none}. CodeRay
15
15
 
16
16
  To include "CodeRay":http://coderay.rubychan.de/ syntax highlighting support in a page you need to have the @coderay@ gem installed, and you need to include the CodeRay stylesheet in your layout. The following example shows a page that uses CodeRay syntax highlighting combined with Textile markup.
17
17
 
18
- Note how the @coderay@ block is enclosed by a @notextile@ block. This ensures that the Textile filter does not clobber the generated syntax highlighting.
19
-
20
18
  <pre class="code">
21
19
  ---
22
20
  title: CodeRay Example
@@ -30,8 +28,7 @@ h2. <%= h(@page.title) %>
30
28
  This is the @render_page@ function from the Webby static website generation
31
29
  system. It is used to render a page by applying the specified filters in
32
30
  succession to the page contents.
33
-
34
- <notextile>&lt;notextile&gt;
31
+ <notextile>
35
32
  &lt;coderay lang="ruby" line_numbers="inline"&gt;
36
33
  # call-seq:
37
34
  # render_page => string
@@ -50,7 +47,6 @@ def render_page
50
47
  str
51
48
  end
52
49
  &lt;/coderay&gt;
53
- &lt;/notextile&gt;</notextile>
54
- </pre>
50
+ </notextile></pre>
55
51
 
56
- There are more options that can be passed to the CodeRay syntax highlighter than those shown in the example above. Take a look at the RDoc documentation for the "CodeRayFilter":http://webby.rubyforge.org/rdoc/classes/Webby/CodeRayFilter.html class for more information.
52
+ There are more options that can be passed to the CodeRay syntax highlighter than those shown in the example above. Take a look at the RDoc documentation for the "CodeRay Filter":http://webby.rubyforge.org/rdoc/classes/Webby/CodeRayFilter.html class for more information.
@@ -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>
@@ -1,13 +1,4 @@
1
1
 
2
- require 'webby'
3
-
4
- Rake::WebbyTask.new do |webby|
5
- webby.content_dir = SITE.content_dir
6
- webby.output_dir = SITE.output_dir
7
- webby.layout_dir = SITE.layout_dir
8
- webby.template_dir = SITE.template_dir
9
- webby.exclude = SITE.exclude
10
- webby.page_defaults = SITE.page_defaults
11
- end
2
+ Rake::WebbyTask.new
12
3
 
13
4
  # EOF
@@ -1,8 +1,9 @@
1
1
 
2
- require 'ostruct'
2
+ require 'webby'
3
3
 
4
- SITE = OpenStruct.new
4
+ SITE = Webby.site
5
5
 
6
+ # Webby defaults
6
7
  SITE.content_dir = 'content'
7
8
  SITE.output_dir = 'output'
8
9
  SITE.layout_dir = 'layouts'
@@ -14,12 +15,18 @@ SITE.page_defaults = {
14
15
  'layout' => 'default'
15
16
  }
16
17
 
18
+ # Items used to deploy the webiste
17
19
  SITE.host = 'user@hostname.tld'
18
20
  SITE.remote_dir = '/not/a/valid/dir'
19
21
  SITE.rsync_args = %w(-av --delete)
20
22
 
23
+ # Options passed to the 'tidy' program when the tidy filter is used
24
+ SITE.tidy_options = '-indent -wrap 80'
25
+
26
+ # Load up the other rake tasks
21
27
  FileList['tasks/*.rake'].each {|task| import task}
22
28
 
29
+ # Conditional dependencies
23
30
  %w(heel).each do |lib|
24
31
  Object.instance_eval {const_set "HAVE_#{lib.upcase}", try_require(lib)}
25
32
  end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
3
3
  specification_version: 1
4
4
  name: webby
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.5.1
7
- date: 2007-11-29 00:00:00 -07:00
6
+ version: 0.6.0
7
+ date: 2007-12-04 00:00:00 -07:00
8
8
  summary: static website creation and management
9
9
  require_paths:
10
10
  - lib
@@ -61,8 +61,10 @@ files:
61
61
  - lib/webby.rb
62
62
  - lib/webby/auto_builder.rb
63
63
  - lib/webby/builder.rb
64
- - lib/webby/coderay_filter.rb
65
64
  - lib/webby/file.rb
65
+ - lib/webby/filters/coderay.rb
66
+ - lib/webby/filters/graphviz.rb
67
+ - lib/webby/filters/tidy.rb
66
68
  - lib/webby/main.rb
67
69
  - lib/webby/pages_db.rb
68
70
  - lib/webby/renderer.rb