webby 0.8.2 → 0.8.3
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.
- data/History.txt +20 -0
- data/Manifest.txt +46 -2
- data/Rakefile +4 -3
- data/bin/webby +1 -1
- data/data/Rakefile +0 -1
- data/data/content/css/blueprint/plugins/buttons/icons/cross.png +0 -0
- data/data/content/css/blueprint/plugins/buttons/icons/key.png +0 -0
- data/data/content/css/blueprint/plugins/buttons/icons/tick.png +0 -0
- data/data/content/s5/blank.gif +0 -0
- data/data/content/s5/bodybg.gif +0 -0
- data/data/content/s5/framing.css +23 -0
- data/data/content/s5/iepngfix.htc +42 -0
- data/data/content/s5/opera.css +7 -0
- data/data/content/s5/outline.css +15 -0
- data/data/content/s5/pretty.css +86 -0
- data/data/content/s5/print.css +1 -0
- data/data/content/s5/s5-core.css +9 -0
- data/data/content/s5/slides.css +3 -0
- data/data/content/s5/slides.js +553 -0
- data/data/lib/breadcrumbs.rb +0 -0
- data/data/tasks/blog.rake +71 -0
- data/data/tasks/build.rake +27 -0
- data/data/tasks/create.rake +19 -1
- data/data/tasks/deploy.rake +2 -2
- data/data/tasks/setup.rb +4 -1
- data/data/templates/atom_feed.erb +20 -13
- data/data/templates/page.erb +1 -1
- data/data/templates/presentation.erb +40 -0
- data/examples/presentation/Rakefile +14 -0
- data/examples/presentation/content/_sample_code.txt +10 -0
- data/examples/presentation/content/css/uv/twilight.css +137 -0
- data/examples/presentation/content/index.txt +63 -0
- data/examples/presentation/content/s5/blank.gif +0 -0
- data/examples/presentation/content/s5/bodybg.gif +0 -0
- data/examples/presentation/content/s5/framing.css +23 -0
- data/examples/presentation/content/s5/iepngfix.htc +42 -0
- data/examples/presentation/content/s5/opera.css +7 -0
- data/examples/presentation/content/s5/outline.css +15 -0
- data/examples/presentation/content/s5/pretty.css +86 -0
- data/examples/presentation/content/s5/print.css +1 -0
- data/examples/presentation/content/s5/s5-core.css +9 -0
- data/examples/presentation/content/s5/slides.css +3 -0
- data/examples/presentation/content/s5/slides.js +553 -0
- data/examples/presentation/layouts/presentation.rhtml +43 -0
- data/examples/presentation/tasks/blog.rake +71 -0
- data/examples/presentation/tasks/build.rake +27 -0
- data/examples/presentation/tasks/create.rake +22 -0
- data/examples/presentation/tasks/deploy.rake +22 -0
- data/examples/presentation/tasks/growl.rake +12 -0
- data/examples/presentation/tasks/heel.rake +28 -0
- data/examples/presentation/tasks/setup.rb +17 -0
- data/examples/presentation/tasks/validate.rake +19 -0
- data/examples/presentation/templates/_partial.erb +13 -0
- data/examples/presentation/templates/presentation.erb +40 -0
- data/examples/webby/Rakefile +3 -2
- data/examples/webby/content/css/blueprint/screen.css +1 -1
- data/examples/webby/content/css/coderay.css +0 -15
- data/examples/webby/content/css/site.css +18 -13
- data/examples/webby/content/css/uv/twilight.css +137 -0
- data/examples/webby/content/index.txt +6 -10
- data/examples/webby/content/manual/index.txt +83 -122
- data/examples/webby/content/reference/index.txt +161 -16
- data/examples/webby/content/script/jquery.js +1 -1
- data/examples/webby/content/tips_and_tricks/index.txt +1 -1
- data/examples/webby/content/tutorial/index.txt +1 -1
- data/examples/webby/layouts/default.rhtml +2 -7
- data/examples/webby/tasks/blog.rake +71 -0
- data/examples/webby/tasks/build.rake +27 -0
- data/examples/webby/tasks/create.rake +19 -1
- data/examples/webby/tasks/deploy.rake +2 -2
- data/examples/webby/tasks/setup.rb +4 -20
- data/examples/webby/templates/page.erb +1 -1
- data/lib/webby.rb +30 -5
- data/lib/webby/auto_builder.rb +0 -2
- data/lib/webby/builder.rb +51 -5
- data/lib/webby/filters.rb +3 -3
- data/lib/webby/filters/basepath.rb +7 -7
- data/lib/webby/filters/erb.rb +0 -2
- data/lib/webby/filters/haml.rb +0 -2
- data/lib/webby/filters/markdown.rb +0 -2
- data/lib/webby/filters/outline.rb +43 -2
- data/lib/webby/filters/sass.rb +0 -2
- data/lib/webby/filters/slides.rb +56 -0
- data/lib/webby/filters/textile.rb +0 -2
- data/lib/webby/filters/tidy.rb +0 -2
- data/lib/webby/helpers.rb +0 -2
- data/lib/webby/helpers/capture_helper.rb +141 -0
- data/lib/webby/helpers/coderay_helper.rb +5 -16
- data/lib/webby/helpers/graphviz_helper.rb +6 -18
- data/lib/webby/helpers/tag_helper.rb +0 -2
- data/lib/webby/helpers/tex_img_helper.rb +5 -16
- data/lib/webby/helpers/ultraviolet_helper.rb +11 -22
- data/lib/webby/helpers/url_helper.rb +2 -4
- data/lib/webby/link_validator.rb +0 -2
- data/lib/webby/main.rb +0 -2
- data/lib/webby/renderer.rb +163 -37
- data/lib/webby/resources.rb +0 -2
- data/lib/webby/resources/db.rb +37 -27
- data/lib/webby/resources/file.rb +0 -2
- data/lib/webby/resources/layout.rb +0 -2
- data/lib/webby/resources/page.rb +4 -9
- data/lib/webby/resources/partial.rb +1 -3
- data/lib/webby/resources/resource.rb +10 -2
- data/lib/webby/resources/static.rb +0 -2
- data/lib/webby/stelan/mktemp.rb +0 -2
- data/lib/webby/stelan/spawner.rb +0 -2
- data/lib/webby/utils.rb +0 -2
- data/spec/spec_helper.rb +1 -4
- data/spec/webby/helpers/capture_helper_spec.rb +56 -0
- data/spec/webby/resources/file_spec.rb +0 -1
- data/tasks/ann.rake +7 -4
- data/tasks/bones.rake +2 -2
- data/tasks/gem.rake +26 -14
- data/tasks/notes.rake +11 -5
- data/tasks/post_load.rake +4 -2
- data/tasks/rdoc.rake +4 -2
- data/tasks/rubyforge.rake +3 -3
- data/tasks/setup.rb +24 -9
- data/tasks/spec.rake +1 -1
- data/tasks/website.rake +1 -1
- metadata +51 -7
- data/lib/webby/webby_task.rb +0 -134
- data/tasks/svn.rake +0 -45
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# $Id: url_helper.rb 192 2008-03-08 16:27:29Z tim_pease $
|
|
2
|
-
|
|
3
1
|
module Webby::Helpers
|
|
4
2
|
|
|
5
3
|
#
|
|
@@ -67,7 +65,7 @@ module UrlHelper
|
|
|
67
65
|
url_opts = opts.delete(:url)
|
|
68
66
|
|
|
69
67
|
p = @pages.find(opts)
|
|
70
|
-
raise Webby::
|
|
68
|
+
raise ::Webby::Error,
|
|
71
69
|
"could not find requested page: #{opts.inspect}" if p.nil?
|
|
72
70
|
|
|
73
71
|
self.url_for(p, url_opts)
|
|
@@ -221,7 +219,7 @@ module UrlHelper
|
|
|
221
219
|
p = @pages.find(opts)
|
|
222
220
|
end
|
|
223
221
|
|
|
224
|
-
raise Webby::
|
|
222
|
+
raise ::Webby::Error,
|
|
225
223
|
"could not find requested page: #{opts.inspect}" if p.nil?
|
|
226
224
|
|
|
227
225
|
name = p.title || p.filename if name.nil?
|
data/lib/webby/link_validator.rb
CHANGED
data/lib/webby/main.rb
CHANGED
data/lib/webby/renderer.rb
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# $Id: renderer.rb 192 2008-03-08 16:27:29Z tim_pease $
|
|
2
|
-
|
|
3
1
|
# Equivalent to a header guard in C/C++
|
|
4
2
|
# Used to prevent the spec helper from being loaded more than once
|
|
5
3
|
unless defined? ::Webby::Renderer
|
|
@@ -64,52 +62,92 @@ class Renderer
|
|
|
64
62
|
@content = nil
|
|
65
63
|
@config = ::Webby.site
|
|
66
64
|
|
|
65
|
+
@_bindings = []
|
|
66
|
+
@_content_for = {}
|
|
67
67
|
@log = Logging::Logger[self]
|
|
68
68
|
end
|
|
69
69
|
|
|
70
70
|
# call-seq:
|
|
71
|
-
#
|
|
71
|
+
# render( resource = nil, opts = {} ) => string
|
|
72
72
|
#
|
|
73
|
-
#
|
|
74
|
-
#
|
|
73
|
+
# Render the given resource (a page or a partial) and return the results
|
|
74
|
+
# as a string. If a resource is not given, then the options hash should
|
|
75
|
+
# contain the name of a partial to render (:partial => 'name').
|
|
75
76
|
#
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
77
|
+
# When a partial name is given, the partial is found by looking in the
|
|
78
|
+
# directory of the current page being rendered. Otherwise, the full path
|
|
79
|
+
# to the partial can be given.
|
|
80
|
+
#
|
|
81
|
+
# If a :guard option is given as true, then the resulting string will be
|
|
82
|
+
# protected from processing by subsequent filters. Currently this only
|
|
83
|
+
# protects against the textile filter.
|
|
84
|
+
#
|
|
85
|
+
# When rendering partials, local variables can be passed to the partial by
|
|
86
|
+
# setting them in hash passed as the :locals option.
|
|
87
|
+
#
|
|
88
|
+
# ==== Options
|
|
89
|
+
# :partial<String>::
|
|
90
|
+
# The partial to render
|
|
91
|
+
# :locals<Hash>::
|
|
92
|
+
# Locals values to define when rendering a partial
|
|
93
|
+
# :guard<Boolean>::
|
|
94
|
+
# Prevents the resulting string from being processed by subsequent
|
|
95
|
+
# filters (only textile for now)
|
|
96
|
+
#
|
|
97
|
+
# ==== Returns
|
|
98
|
+
# A string that is the rendered page or partial.
|
|
99
|
+
#
|
|
100
|
+
# ==== Examples
|
|
101
|
+
# # render the partial "foo" using the given local variables
|
|
102
|
+
# render( :partial => "foo", :locals => {:bar => "value for bar"} )
|
|
103
|
+
#
|
|
104
|
+
# # find another page and render it into this page and protect the
|
|
105
|
+
# # resulting contents from further filters
|
|
106
|
+
# page = @pages.find( :title => "Chicken Coop" )
|
|
107
|
+
# render( page, :guard => true )
|
|
108
|
+
#
|
|
109
|
+
# # find a partial and render it using the given local variables
|
|
110
|
+
# partial = @partials.find( :filename => "foo", :in_directory => "/path" )
|
|
111
|
+
# render( partial, :locals => {:baz => "baztastic"} )
|
|
112
|
+
#
|
|
113
|
+
def render( *args )
|
|
114
|
+
opts = Hash === args.last ? args.pop : {}
|
|
115
|
+
resource = args.first
|
|
116
|
+
resource = _find_partial(opts[:partial]) if resource.nil?
|
|
117
|
+
|
|
118
|
+
str = case resource
|
|
119
|
+
when Resources::Page
|
|
120
|
+
::Webby::Renderer.new(resource)._render_page
|
|
121
|
+
when Resources::Partial
|
|
122
|
+
_render_partial(resource, opts)
|
|
123
|
+
else
|
|
124
|
+
raise ::Webby::Error, "expecting a page or a partial but got '#{resource.class.name}'"
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
str = _guard(str) if opts[:guard]
|
|
128
|
+
str
|
|
80
129
|
end
|
|
81
130
|
|
|
82
131
|
# call-seq:
|
|
83
|
-
#
|
|
132
|
+
# render_page => string
|
|
84
133
|
#
|
|
85
|
-
#
|
|
86
|
-
#
|
|
134
|
+
# This method is being deprecated. It is being made internal to the
|
|
135
|
+
# framework and really shouldn't be used anymore.
|
|
87
136
|
#
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
137
|
+
def render_page
|
|
138
|
+
Webby.deprecated "render_page", "this method is being made internal to the framework"
|
|
139
|
+
_render_page
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
# call-seq:
|
|
143
|
+
# render_partial( partial, :locals => {} ) => string
|
|
92
144
|
#
|
|
93
|
-
#
|
|
94
|
-
# method of the <tt>@partials</tt> database hash. Please refer to
|
|
95
|
-
# Webby::Resources::DB#find method for more information.
|
|
145
|
+
# This method is being deprecated. Please use the +render+ method instead.
|
|
96
146
|
#
|
|
97
147
|
def render_partial( part, opts = {} )
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
p = Resources.partials.find(
|
|
102
|
-
:filename => fn, :in_directory => @page.dir ) rescue nil
|
|
103
|
-
p ||= Resources.partials.find(:filename => fn)
|
|
104
|
-
raise ::Webby::Error, "could not find partial '#{part}'" if p.nil?
|
|
105
|
-
p
|
|
106
|
-
when ::Webby::Resources::Partial
|
|
107
|
-
part
|
|
108
|
-
else raise ::Webby::Error, "expecting a partial or a partial name" end
|
|
109
|
-
|
|
110
|
-
_track_rendering(part.path) {
|
|
111
|
-
Filters.process(self, part, ::Webby::Resources::File.read(part.path))
|
|
112
|
-
}
|
|
148
|
+
Webby.deprecated "render_partial", "it is being replaced by the Renderer#render() method"
|
|
149
|
+
opts[:partial] = part
|
|
150
|
+
render opts
|
|
113
151
|
end
|
|
114
152
|
|
|
115
153
|
# call-seq:
|
|
@@ -140,11 +178,34 @@ class Renderer
|
|
|
140
178
|
# Returns the current binding for the renderer.
|
|
141
179
|
#
|
|
142
180
|
def get_binding
|
|
143
|
-
|
|
181
|
+
@_bindings.last
|
|
144
182
|
end
|
|
145
183
|
|
|
184
|
+
# call-seq:
|
|
185
|
+
# _render_page => string
|
|
186
|
+
#
|
|
187
|
+
# Apply the desired filters to the page. The filters to apply are
|
|
188
|
+
# determined from the page's meta-data.
|
|
189
|
+
#
|
|
190
|
+
def _render_page
|
|
191
|
+
_track_rendering(@page.path) {
|
|
192
|
+
Filters.process(self, @page, ::Webby::Resources::File.read(@page.path))
|
|
193
|
+
}
|
|
194
|
+
end
|
|
146
195
|
|
|
147
|
-
|
|
196
|
+
# call-seq:
|
|
197
|
+
# _render_partial( partial, :locals => {} ) => string
|
|
198
|
+
#
|
|
199
|
+
# Render the given _partial_ into the current page. The :locals are a hash
|
|
200
|
+
# of key / value pairs that will be set as local variables in the scope of
|
|
201
|
+
# the partial when it is rendered.
|
|
202
|
+
#
|
|
203
|
+
def _render_partial( part, opts = {} )
|
|
204
|
+
_track_rendering(part.path) {
|
|
205
|
+
_configure_locals(opts[:locals])
|
|
206
|
+
Filters.process(self, part, ::Webby::Resources::File.read(part.path))
|
|
207
|
+
}
|
|
208
|
+
end
|
|
148
209
|
|
|
149
210
|
# call-seq:
|
|
150
211
|
# _layout_page => string
|
|
@@ -155,7 +216,7 @@ class Renderer
|
|
|
155
216
|
# page's meta-data.
|
|
156
217
|
#
|
|
157
218
|
def _layout_page
|
|
158
|
-
@content =
|
|
219
|
+
@content = _render_page
|
|
159
220
|
|
|
160
221
|
_track_rendering(@page.path) {
|
|
161
222
|
_render_layout_for(@page)
|
|
@@ -182,6 +243,7 @@ class Renderer
|
|
|
182
243
|
# a layout, then this method returns immediately.
|
|
183
244
|
#
|
|
184
245
|
def _render_layout_for( res )
|
|
246
|
+
return unless res.layout
|
|
185
247
|
lyt = Resources.layouts.find :filename => res.layout
|
|
186
248
|
return if lyt.nil?
|
|
187
249
|
|
|
@@ -228,6 +290,7 @@ class Renderer
|
|
|
228
290
|
def _track_rendering( path )
|
|
229
291
|
loop_error = @@stack.include? path
|
|
230
292
|
@@stack << path
|
|
293
|
+
@_bindings << _binding
|
|
231
294
|
|
|
232
295
|
if loop_error
|
|
233
296
|
msg = "rendering loop detected for '#{path}'\n"
|
|
@@ -239,8 +302,71 @@ class Renderer
|
|
|
239
302
|
yield
|
|
240
303
|
ensure
|
|
241
304
|
@@stack.pop if path == @@stack.last
|
|
305
|
+
@_bindings.pop
|
|
306
|
+
end
|
|
307
|
+
|
|
308
|
+
# call-seq:
|
|
309
|
+
# _configure_locals( locals )
|
|
310
|
+
#
|
|
311
|
+
# Configure local variables in the scope of the current binding returned
|
|
312
|
+
# by the +get_binding+ method. The _locals_ should be given as a hash of
|
|
313
|
+
# name / value pairs.
|
|
314
|
+
#
|
|
315
|
+
def _configure_locals( locals )
|
|
316
|
+
return if locals.nil?
|
|
317
|
+
|
|
318
|
+
locals.each do |k,v|
|
|
319
|
+
Thread.current[:value] = v
|
|
320
|
+
definition = "#{k} = Thread.current[:value]"
|
|
321
|
+
eval(definition, get_binding)
|
|
322
|
+
end
|
|
323
|
+
end
|
|
324
|
+
|
|
325
|
+
# Attempts to locate a partial by name. If only the partial name is given,
|
|
326
|
+
# then the current directory of the page being rendered is searched for
|
|
327
|
+
# the partial. If a full path is given, then the partial is searched for
|
|
328
|
+
# in that directory.
|
|
329
|
+
#
|
|
330
|
+
# Raies a Webby::Error if the partial could not be found.
|
|
331
|
+
#
|
|
332
|
+
def _find_partial( part )
|
|
333
|
+
case part
|
|
334
|
+
when String
|
|
335
|
+
part_dir = ::File.dirname(part)
|
|
336
|
+
part_dir = @page.dir if part_dir == '.'
|
|
337
|
+
|
|
338
|
+
part_fn = ::File.basename(part)
|
|
339
|
+
part_fn = '_' + part_fn unless part_fn =~ %r/^_/
|
|
340
|
+
|
|
341
|
+
p = Resources.partials.find(
|
|
342
|
+
:filename => part_fn, :in_directory => part_dir ) rescue nil
|
|
343
|
+
raise ::Webby::Error, "could not find partial '#{part}'" if p.nil?
|
|
344
|
+
p
|
|
345
|
+
when ::Webby::Resources::Partial
|
|
346
|
+
part
|
|
347
|
+
else raise ::Webby::Error, "expecting a partial or a partial name" end
|
|
242
348
|
end
|
|
243
349
|
|
|
350
|
+
# This method will put filter guards around the given input string. This
|
|
351
|
+
# will protect the string from being processed by any remaining filters
|
|
352
|
+
# (specifically the textile filter).
|
|
353
|
+
#
|
|
354
|
+
# The string is returned unchanged if there are no remaining filters to
|
|
355
|
+
# guard against.
|
|
356
|
+
#
|
|
357
|
+
def _guard( str )
|
|
358
|
+
return str unless @_cursor
|
|
359
|
+
|
|
360
|
+
if @_cursor.remaining_filters.include? 'textile'
|
|
361
|
+
str = "<notextile>\n%s\n</notextile>" % str
|
|
362
|
+
end
|
|
363
|
+
str
|
|
364
|
+
end
|
|
365
|
+
|
|
366
|
+
# Returns the binding in the scope of this Renderer object.
|
|
367
|
+
#
|
|
368
|
+
def _binding() binding end
|
|
369
|
+
|
|
244
370
|
end # class Renderer
|
|
245
371
|
end # module Webby
|
|
246
372
|
|
data/lib/webby/resources.rb
CHANGED
data/lib/webby/resources/db.rb
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# $Id: db.rb 169 2008-02-24 03:59:37Z tim_pease $
|
|
2
|
-
|
|
3
1
|
module Webby::Resources
|
|
4
2
|
|
|
5
3
|
# A rudimentary "database" for holding resource objects and finding them.
|
|
@@ -51,19 +49,24 @@ class DB
|
|
|
51
49
|
# Iterate over each resource in the database and pass it to the given
|
|
52
50
|
# block.
|
|
53
51
|
#
|
|
54
|
-
def each( &
|
|
52
|
+
def each( &block )
|
|
55
53
|
keys = @db.keys.sort
|
|
56
54
|
keys.each do |k|
|
|
57
|
-
@db[k].sort.each(&
|
|
55
|
+
@db[k].sort.each(&block)
|
|
58
56
|
end
|
|
59
57
|
self
|
|
60
58
|
end
|
|
61
59
|
|
|
62
60
|
# call-seq:
|
|
63
|
-
# find( opts = {} ) => resource or nil
|
|
64
|
-
# find( opts = {} ) {|resource| block} => resource or nil
|
|
61
|
+
# find( limit = nil, opts = {} ) => resource or nil
|
|
62
|
+
# find( limit = nil, opts = {} ) {|resource| block} => resource or nil
|
|
65
63
|
#
|
|
66
64
|
# Find a specific resource or collection of resources in the pages database.
|
|
65
|
+
# The first resource found will be returned if the _limit_ is nil. If the
|
|
66
|
+
# _limit_ is an integer, then up to that number of resources will be
|
|
67
|
+
# returned as an array. If the limit is :all, then all resources matching
|
|
68
|
+
# the given attributes will be returned.
|
|
69
|
+
#
|
|
67
70
|
# Resources can be found using any combination of attributes by passing them
|
|
68
71
|
# in as options to the +find+ method. This will used simple equality
|
|
69
72
|
# comparison to find the resource or resources.
|
|
@@ -80,41 +83,46 @@ class DB
|
|
|
80
83
|
# on the limit. The method will return the first resource or all
|
|
81
84
|
# resources, respectively, for which the block returns true.
|
|
82
85
|
#
|
|
83
|
-
# Options
|
|
84
|
-
#
|
|
85
|
-
#
|
|
86
|
-
#
|
|
87
|
-
#
|
|
88
|
-
#
|
|
89
|
-
#
|
|
90
|
-
#
|
|
91
|
-
#
|
|
86
|
+
# ==== Options
|
|
87
|
+
# :in_directory<String>::
|
|
88
|
+
# The directory to search.
|
|
89
|
+
# :recursive<Boolean>::
|
|
90
|
+
# Whether or not to recurse into subdirectories
|
|
91
|
+
# :sort_by<Symbol>::
|
|
92
|
+
# Sort results using the given attribute
|
|
93
|
+
# :reverse<Boolean>::
|
|
94
|
+
# Reverse the order of the search results
|
|
95
|
+
#
|
|
96
|
+
# ==== Examples
|
|
92
97
|
# # find the "index" resource in the "foo/bar" directory
|
|
93
98
|
# @pages.find( :filename => 'index', :in_directory => 'foo/bar' )
|
|
94
99
|
#
|
|
95
100
|
# # find all resources under the "foo/bar" directory recursively
|
|
96
|
-
# @pages.find( :
|
|
101
|
+
# @pages.find( :all, :in_directory => 'foo/bar', :recursive => true )
|
|
97
102
|
#
|
|
98
103
|
# # find the resource named "widgets" whose color is "blue"
|
|
99
104
|
# @pages.find( :name => 'widgets', :color => 'blue' )
|
|
100
105
|
#
|
|
101
106
|
# # find all resources created in the past week
|
|
102
|
-
# @pages.find( :
|
|
107
|
+
# @pages.find( :all ) do |resource|
|
|
103
108
|
# resource.created_at > Time.now - (7 * 24 * 3600)
|
|
104
109
|
# end
|
|
105
110
|
#
|
|
106
111
|
def find( *args, &block )
|
|
107
112
|
opts = Hash === args.last ? args.pop : {}
|
|
108
113
|
|
|
109
|
-
limit =
|
|
114
|
+
limit = args.shift
|
|
115
|
+
limit = opts.delete(:limit) if opts.has_key?(:limit)
|
|
110
116
|
sort_by = opts.delete(:sort_by)
|
|
111
117
|
reverse = opts.delete(:reverse)
|
|
112
118
|
|
|
113
119
|
# figure out which directories to search through and whether to recurse
|
|
114
120
|
# into directories or not
|
|
115
121
|
search = if (dir = opts.delete(:in_directory))
|
|
122
|
+
dir = dir.sub(%r/^\//, '')
|
|
116
123
|
strategy = if opts.delete(:recursive)
|
|
117
|
-
|
|
124
|
+
rgxp = dir.empty? ? '.*' : Regexp.escape(dir)
|
|
125
|
+
lambda { |key| key =~ %r/^#{rgxp}(\/.*)?$/ }
|
|
118
126
|
else
|
|
119
127
|
lambda { |key| key == dir }
|
|
120
128
|
end
|
|
@@ -168,10 +176,11 @@ class DB
|
|
|
168
176
|
# resource. A sibling is any resource that is in the same directory as the
|
|
169
177
|
# _page_.
|
|
170
178
|
#
|
|
171
|
-
# Options
|
|
172
|
-
#
|
|
173
|
-
#
|
|
174
|
-
#
|
|
179
|
+
# ==== Options
|
|
180
|
+
# :sorty_by<Symbol>::
|
|
181
|
+
# The attribute to sort by
|
|
182
|
+
# :reverse<Boolean>::
|
|
183
|
+
# Reverse the order of the results
|
|
175
184
|
#
|
|
176
185
|
def siblings( page, opts = {} )
|
|
177
186
|
ary = @db[page.dir].dup
|
|
@@ -191,10 +200,11 @@ class DB
|
|
|
191
200
|
# resource. A child is any resource that exists in a subdirectory of the
|
|
192
201
|
# page's directory.
|
|
193
202
|
#
|
|
194
|
-
# Options
|
|
195
|
-
#
|
|
196
|
-
#
|
|
197
|
-
#
|
|
203
|
+
# ==== Options
|
|
204
|
+
# :sorty_by<Symbol>::
|
|
205
|
+
# The attribute to sort by
|
|
206
|
+
# :reverse<Boolean>::
|
|
207
|
+
# Reverse the order of the results
|
|
198
208
|
#
|
|
199
209
|
def children( page, opts = {} )
|
|
200
210
|
rgxp = Regexp.new "\\A#{page.dir}/[^/]+"
|
data/lib/webby/resources/file.rb
CHANGED
data/lib/webby/resources/page.rb
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
# $Id: page.rb 198 2008-03-10 15:25:55Z tim_pease $
|
|
2
|
-
|
|
3
1
|
require Webby.libpath(*%w[webby resources resource])
|
|
4
2
|
|
|
5
3
|
module Webby::Resources
|
|
@@ -32,16 +30,13 @@ class Page < Resource
|
|
|
32
30
|
# call-seq:
|
|
33
31
|
# render => string
|
|
34
32
|
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
37
|
-
# use is defined in the page's meta-data as the 'filter' key.
|
|
38
|
-
#
|
|
39
|
-
# Note, this only renders this page. The returned string does not include
|
|
40
|
-
# any layout rendering.
|
|
33
|
+
# This method is being deprecated. Please use the +Renderer#render+ method
|
|
34
|
+
# instead.
|
|
41
35
|
#
|
|
42
36
|
def render( renderer = nil )
|
|
37
|
+
Webby.deprecated "render", "it is being replaced by the Renderer#render() method"
|
|
43
38
|
renderer ||= ::Webby::Renderer.new(self)
|
|
44
|
-
renderer.
|
|
39
|
+
renderer._render_page
|
|
45
40
|
end
|
|
46
41
|
|
|
47
42
|
# call-seq
|