webby 0.7.3 → 0.7.4

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,13 @@
1
+ == 0.7.4 / 2008-02-15
2
+
3
+ * 3 minor enhancements
4
+ - Added "limit" and "sort_by" options to the pages find method
5
+ - Removed dependency on RedCloth for outline generation
6
+ - Added some more options for outline generation, numbering, and
7
+ table of contents generation
8
+ * 1 bug fix
9
+ - Fixed incompatibility with the new logging library
10
+
1
11
  == 0.7.3 / 2008-02-05
2
12
 
3
13
  * 2 bug fixes
data/Manifest.txt CHANGED
@@ -43,12 +43,12 @@ examples/webby/content/css/coderay.css
43
43
  examples/webby/content/css/site.css
44
44
  examples/webby/content/download.txt
45
45
  examples/webby/content/index.txt
46
- examples/webby/content/manual.txt
46
+ examples/webby/content/manual/index.txt
47
47
  examples/webby/content/robots.txt
48
48
  examples/webby/content/script/jquery.corner.js
49
49
  examples/webby/content/script/jquery.js
50
- examples/webby/content/tips_and_tricks.txt
51
- examples/webby/content/tutorial.txt
50
+ examples/webby/content/tips_and_tricks/index.txt
51
+ examples/webby/content/tutorial/index.txt
52
52
  examples/webby/layouts/default.rhtml
53
53
  examples/webby/tasks/create.rake
54
54
  examples/webby/tasks/deploy.rake
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- # $Id: Rakefile 130 2008-02-04 22:28:22Z tim_pease $
1
+ # $Id: Rakefile 148 2008-02-15 05:26:56Z tim_pease $
2
2
 
3
3
  load 'tasks/setup.rb'
4
4
 
@@ -32,9 +32,8 @@ PROJ.spec_opts << '--color'
32
32
  depend_on 'directory_watcher'
33
33
  depend_on 'heel'
34
34
  depend_on 'hpricot'
35
- depend_on 'logging', '0.6.1'
35
+ depend_on 'logging', '0.7.0'
36
36
  depend_on 'rake'
37
37
  depend_on 'rspec'
38
- depend_on 'RedCloth'
39
38
 
40
39
  # EOF
@@ -2,7 +2,7 @@
2
2
 
3
3
  desc 'send log events to Growl (Mac OS X only)'
4
4
  task :growl do
5
- Logging::Logger['Webby'].add(Logging::Appenders::Growl.new(
5
+ Logging::Logger['Webby'].add_appenders(Logging::Appenders::Growl.new(
6
6
  "Webby",
7
7
  :layout => Logging::Layouts::Pattern.new(:pattern => "%5l - Webby\000%m"),
8
8
  :coalesce => true,
@@ -8,6 +8,7 @@ task :deploy => [:build, 'deploy:rsync']
8
8
 
9
9
  SITE.host = 'tim_pease@rubyforge.org'
10
10
  SITE.remote_dir = '/var/www/gforge-projects/webby/'
11
+ SITE.create_mode = 'directory'
11
12
 
12
13
  task :autobuild => :growl
13
14
 
@@ -84,10 +84,15 @@ p.quiet
84
84
  :font-size 16px
85
85
  :list-style-type none
86
86
  li
87
+ :display block
88
+ :padding-right 5px
89
+ :background-color = !box_bg
87
90
  a
88
91
  :display block
89
92
  :text-decoration none
93
+ :margin-right -5px
90
94
  :padding-right 5px
95
+ :background-color white
91
96
  &:hover
92
97
  :background-color = !highlight
93
98
 
@@ -3,7 +3,7 @@ title: Home
3
3
  created_at: Tue Aug 21 11:25:06 -0600 2007
4
4
  filter: textile
5
5
  ---
6
- *Webby* is a super fantastic little website management system. It would be called a _content management system_ if it were a bigger kid. But, it's just a runt with a special knack for transforming text. And that's really all it does - manages the legwork of turning text into something else, an *ASCII Alchemist* if you will.
6
+ *Webby* is a fantastic little website management system. It would be called a _content management system_ if it were a bigger kid. But, it's just a runt with a special knack for transforming text. And that's really all it does - manages the legwork of turning text into something else, an *ASCII Alchemist* if you will.
7
7
 
8
8
  Webby works by combining the contents of a *page* with a *layout* to produce HTML. The layout contains everything common to all the pages - HTML headers, navigation menu, footer, etc. - and the page contains just the information for that page. You can use your favorite markup language to write your pages; Webby supports quite a few.
9
9
 
@@ -15,37 +15,95 @@ p(title). Table of Contents
15
15
  <toc />
16
16
  </div>
17
17
 
18
- h2{clear:none}. Getting Started
18
+ h2{clear:none}. Introduction
19
+
20
+ Webby was created out of the need for a simple way to build and manage small websites. The desire was for a system that could take files written in plain text, combine them with a layout file and produce web pages. In this system, a single page can be written quickly without the need for HTML markup; the look and feel of the entire site can be changed by modifying the site layout file.
21
+
22
+ <graphviz path="images" alt="Webby Overview">
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
+ </graphviz>
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.
19
45
 
20
46
  h3{clear:none}. Requirements
21
47
 
22
- Webby is an application written using the Ruby programming language. To install and run Webby you will need the following applications on your system:
48
+ Webby is written in the Ruby programming language. To install and run Webby you will need the following applications installed on your system:
23
49
 
24
50
  * "Ruby":http://ruby-lang.org
25
51
  * "RubyGems":http://rubygems.org/read/chapter/3
26
52
 
27
53
  h3{clear:none}. Installation
28
54
 
29
- Webby is an application written using the Ruby programming language. You will need to install a Ruby interpreter on your computer. Download and installation instructions can be found on the "Ruby":http://ruby-lang.org website. For the Windows platform, the one-click installer is recommended. Webby is not compatible with the Ruby 1.9.0 release; please use the Ruby 1.8.6 release.
30
-
31
- You will also need to install RubyGems. If you used the Windows one-click installer, RubyGems is already present on your system. For everyone else you can find installation instructions on the "RubyGems":http://rubygems.org/read/chapter/3 website.
32
-
33
- To install Webby and its dependent gems type the following command. Omit the @sudo@ portion for the Windows platform; you will need to specify the *mswin32* versions of the _mongrel_ and _hpricot_ dependent gems when prompted.
55
+ Webby is easily installed as a Ruby gem. From a command prompt, type in the following:
34
56
 
35
57
  <pre>
36
58
  sudo gem install -y webby
37
59
  </pre>
38
60
 
61
+ This will install Webby and all its required dependencies.
62
+
63
+ bq. For those users installing Webby on the Windows platform, please omit the @sudo@ portion of the above command. You will also need to specify the *mswin32* versions of the _mongrel_ and _hpricot_ gems when prompted.
64
+
39
65
  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.
40
66
 
41
67
  <pre>
42
- sudo gem install -y RedcCoth
43
68
  sudo gem install -y BlueCloth
44
69
  sudo gem install -y haml
45
70
  sudo gem install -y coderay
46
71
  </pre>
47
72
 
48
- h3. New Website
73
+ Webby can also use a few other programs to clean up generated HTML and to created pretty graphs. You can read more about these programs and how they are used in the Filters section of this manual -- specifically, the sections on the "Tidy":#tidy filter and the "Graphviz":#graphviz filter.
74
+
75
+ h3. Running Webby
76
+
77
+ When the Webby gem is installed it also installs a @webby@ executable program. This program is used to create a new website and to udpate the associated rake tasks when a new version of Webby is released. Typing in @webby --help@ will show you the options this program supports. After you create a webiste, though, the webby command will not be needed.
78
+
79
+ <pre>
80
+ $ webby --help
81
+
82
+ Usage: webby [options] site
83
+
84
+ -u, --update update the rake tasks for the site
85
+
86
+ common options:
87
+ -h, --help show this message
88
+ --version show version
89
+ </pre>
90
+
91
+ The tasks of building the webiste and deploying it to the destnation server are handled by "Rake":http://docs.rubyrake.org/, a Ruby version of the more famous *make* program. Several rake tasks are provided by default. You are free to create others to make developing and deploying your webiste easier. To see the current list of rake tasks type in @rake -T@.
92
+
93
+ <pre>
94
+ $ rake -T
95
+
96
+ rake autobuild # continuously build the website
97
+ rake build # build the website
98
+ rake clobber # delete the website
99
+ rake create:page # create a new page
100
+ rake deploy # depoloy the site to the webserver
101
+ rake deploy:rsync # deploy to the server using rsync
102
+ rake deploy:ssh # deploy to the server using ssh
103
+ rake heel:start # start the heel server to view website (not for Windows)
104
+ rake heel:stop # stop the heel server
105
+ rake rebuild # rebuild the website
106
+ </pre>
49
107
 
50
108
  h2. Working With Resources
51
109
 
@@ -300,7 +358,7 @@ p(column span-2). *Require*:
300
358
 
301
359
  p(column span-13). The @coderay@ gem must be installed on your system in order to use the coderay filter. Be sure to include the coderay stylesheet in your layout.
302
360
 
303
- h3. Graphviz
361
+ h3(#graphviz). Graphviz
304
362
 
305
363
  "Graphviz":http://www.graphviz.org/ is open source graph visualization software. Graph visualization is a way of representing structural information as diagrams of abstract graphs and networks. The Graphviz layout programs take descriptions of graphs in a simple text language, and make diagrams in several useful formats. The graphviz filter allows you to embed Graphviz scripts into a page and generate an image in the page.
306
364
 
@@ -363,7 +421,7 @@ p(column span-2). *Require*:
363
421
 
364
422
  p(column span-13). none
365
423
 
366
- h3. Tidy
424
+ h3(#tidy). Tidy
367
425
 
368
426
  "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:
369
427
 
@@ -37,11 +37,11 @@ filter:
37
37
 
38
38
  <div class="column span-4 prepend-1 first" id="navigation">
39
39
  <ul
40
- ><li><a href="/index.html">Home</a></li
41
- ><li><a href="/download.html">Download</a></li
42
- ><li><a href="/tutorial.html">Tutorial</a></li
43
- ><li><a href="/manual.html">Manual</a></li
44
- ><li><a href="/tips_and_tricks.html">Tips &amp; Tricks</a></li
40
+ ><li><%= link_to_page_unless_current 'Home' %></li
41
+ ><li><%= link_to_page_unless_current 'Download' %></li
42
+ ><li><%= link_to_page_unless_current 'Tutorial' %></li
43
+ ><li><%= link_to_page_unless_current 'Manual' %></li
44
+ ><li><%= link_to_page_unless_current 'Tips & Tricks' %></li
45
45
  ></ul>
46
46
  </div>
47
47
 
@@ -1,7 +1,7 @@
1
1
 
2
2
  desc 'send log events to Growl (Mac OS X only)'
3
3
  task :growl do
4
- Logging::Logger['Webby'].add(Logging::Appenders::Growl.new(
4
+ Logging::Logger['Webby'].add_appenders(Logging::Appenders::Growl.new(
5
5
  "Webby",
6
6
  :layout => Logging::Layouts::Pattern.new(:pattern => "%5l - Webby\000%m"),
7
7
  :coalesce => true,
data/lib/webby.rb CHANGED
@@ -1,11 +1,12 @@
1
- # $Id: webby.rb 130 2008-02-04 22:28:22Z tim_pease $
1
+ # $Id: webby.rb 145 2008-02-13 00:39:03Z tim_pease $
2
2
 
3
3
  require 'logging'
4
4
  require 'ostruct'
5
+ require 'date'
5
6
 
6
7
  # Configure Webby to log to STDOUT at the 'info' level
7
8
  Logging::Logger['Webby'].level = :info
8
- Logging::Logger['Webby'].add(Logging::Appender.stdout)
9
+ Logging::Logger['Webby'].add_appenders(Logging::Appender.stdout)
9
10
  Logging::Appender.stdout.layout = Logging::Layouts::Pattern.new(
10
11
  :pattern => "[%d] %5l: %m\n", # [date] LEVEL: message
11
12
  :date_pattern => "%H:%M:%S" # date == HH:MM:SS
@@ -14,7 +15,7 @@ Logging::Appender.stdout.layout = Logging::Layouts::Pattern.new(
14
15
 
15
16
  module Webby
16
17
 
17
- VERSION = '0.7.3' # :nodoc:
18
+ VERSION = '0.7.4' # :nodoc:
18
19
 
19
20
  # Path to the Webby package
20
21
  PATH = ::File.expand_path(::File.join(::File.dirname(__FILE__), '..'))
@@ -1,4 +1,4 @@
1
- # $Id: outline.rb 124 2008-02-03 00:24:10Z tim_pease $
1
+ # $Id: outline.rb 151 2008-02-15 21:09:47Z tim_pease $
2
2
 
3
3
  require 'hpricot'
4
4
 
@@ -15,7 +15,7 @@ module Filters
15
15
  # into the heading tags, this can be specified in the attibutes of the
16
16
  # <toc /> tag itself.
17
17
  #
18
- # <toc outline_numbering="off" />
18
+ # <toc numbering="off" />
19
19
  #
20
20
  # This will generate a table of contents, but not insert outline numbering
21
21
  # into the heading tags.
@@ -25,6 +25,7 @@ module Filters
25
25
  # etc.).
26
26
  #
27
27
  class Outline
28
+ include ERB::Util
28
29
 
29
30
  class Error < StandardError; end # :nodoc:
30
31
 
@@ -40,8 +41,14 @@ class Outline
40
41
  @cur_level, @base_level, @cur_depth = nil
41
42
  @level = [0] * 6
42
43
  @h_rgxp = %r/^h(\d)$/o
44
+
45
+ @numbering = true
46
+ @numbering_start = 1
47
+
43
48
  @toc = []
44
- @outline_numbering = true
49
+ @toc_style = 'ol'
50
+ @toc_range = 'h1-h6'
51
+ @list_opening = nil
45
52
  end
46
53
 
47
54
  # call-seq:
@@ -59,7 +66,7 @@ class Outline
59
66
  #
60
67
  # somewhere in a page about comic strips, the tag might be altered as such
61
68
  #
62
- # <h3 id="h2_2_1"><span class="heading-num>2.2.1</span>Get Fuzzy</h3>
69
+ # <h3 id="h2_2_1"><span class="heading-num">2.2.1</span>Get Fuzzy</h3>
63
70
  #
64
71
  # The id attribute is used to generate a linke from the table of contents
65
72
  # to this particular heading tag. The original text of the tag is used in
@@ -72,26 +79,46 @@ class Outline
72
79
  toc_elem = doc.search('toc').first
73
80
 
74
81
  unless toc_elem.nil?
75
- @outline_numbering = toc_elem['outline_numbering'] !~ %r/off/i
82
+ @numbering = toc_elem['numbering'] !~ %r/off/i
83
+ @numbering_start = Integer(toc_elem['numbering_start']) if toc_elem.has_attribute? 'numbering_start'
84
+ @toc_style = toc_elem['toc_style'] if toc_elem.has_attribute? 'toc_style'
85
+ @toc_range = toc_elem['toc_range'] if toc_elem.has_attribute? 'toc_range'
86
+ end
87
+
88
+ unless %w[ul ol].include? @toc_style
89
+ raise ArgumentError, "unknown ToC list type '#{@toc_style}'"
76
90
  end
77
91
 
92
+ m = %r/h(\d)\s*-\s*h(\d)/i.match @toc_range
93
+ @toc_range = Integer(m[1])..Integer(m[2])
94
+ @list_opening = build_list_opening(toc_elem)
95
+
78
96
  doc.traverse_element(*%w[h1 h2 h3 h4 h5 h6]) do |elem|
79
97
  text, id = heading_info(elem)
80
- add_to_toc(text, id)
98
+ add_to_toc(text, id) if @toc_range.include? current_level
81
99
  end
82
100
 
83
- # create the TOC ordered list
84
-
85
101
  toc_elem.swap(toc) unless toc_elem.nil?
86
-
87
- # replace the "toc" tag with the ordered list
88
-
89
102
  doc.to_html
90
103
  end
91
104
 
92
105
 
93
106
  private
94
107
 
108
+ def build_list_opening( elem )
109
+ lo = "<#{@toc_style}"
110
+ unless elem.nil?
111
+ %w[class style id].each do |atr|
112
+ next unless elem.has_attribute? atr
113
+ lo << " %s=\"%s\"" % [atr, elem[atr]]
114
+ end
115
+ end
116
+ if @toc_style == 'ol' and @numbering_start != 1
117
+ lo << " start=\"#{@numbering_start}\""
118
+ end
119
+ lo << ">"
120
+ end
121
+
95
122
  # Returns information for the given heading element. The information is
96
123
  # returned as a two element array: [text, id].
97
124
  #
@@ -107,7 +134,7 @@ class Outline
107
134
  text = elem.inner_text
108
135
 
109
136
  lbl = label
110
- if outline_numbering?
137
+ if numbering?
111
138
  elem.children.first.before {tag!(:span, lbl, :class => 'heading-num')}
112
139
  end
113
140
  elem['id'] = "h#{lbl.tr('.','_')}" if elem['id'].nil?
@@ -124,8 +151,10 @@ class Outline
124
151
  # heading level.
125
152
  #
126
153
  def current_level=( level )
127
- @base_level ||= level
128
- @cur_level ||= level
154
+ if @base_level.nil?
155
+ @base_level = @cur_level = level
156
+ @level[@base_level-1] = @numbering_start-1
157
+ end
129
158
 
130
159
  if level < @base_level
131
160
  raise Error, "heading tags are not in order, cannot outline"
@@ -143,6 +172,12 @@ class Outline
143
172
  @cur_level = level
144
173
  end
145
174
 
175
+ # Returns the current heading level number.
176
+ #
177
+ def current_level
178
+ @cur_level
179
+ end
180
+
146
181
  # Return the label string for the current heading level.
147
182
  #
148
183
  def label
@@ -161,23 +196,63 @@ class Outline
161
196
  # Add the given text and id reference to the table of contents.
162
197
  #
163
198
  def add_to_toc( text, id )
164
- str = '#' * depth
165
- str << ' ' << "\"#{text}\":##{id}"
166
- @toc << str
199
+ a = "<a href=\"##{id}\">#{h(text)}</a>"
200
+ @toc << [depth, a]
167
201
  end
168
202
 
169
203
  # Returns the table of contents as a collection of nested ordered lists.
170
204
  # This is fully formatted HTML.
171
205
  #
172
206
  def toc
173
- RedCloth.new(@toc.join("\n"), %w(no_span_caps)).to_html
207
+ ary = []
208
+
209
+ lopen = "<#@toc_style>"
210
+ lclose = "</#@toc_style>"
211
+ prev_depth = open = 0
212
+
213
+ @toc.each do |a|
214
+ cur = a.first
215
+
216
+ # close out the previous list item if we're at the same level
217
+ if cur == prev_depth
218
+ ary << "</li>"
219
+
220
+ # if we are increasing the level, then start a new list
221
+ elsif cur > prev_depth
222
+ ary << if ary.empty? then @list_opening else lopen end
223
+ open += 1
224
+
225
+ # we are decreasing the level; close out tags but ensure we don't
226
+ # close out all the tags (leave one open)
227
+ else
228
+ (prev_depth - cur).times {
229
+ ary << "</li>" << lclose
230
+ open -= 1
231
+ break if open <= 0
232
+ }
233
+ if open > 0
234
+ ary << "</li>"
235
+ else
236
+ ary << lopen
237
+ open += 1
238
+ end
239
+ end
240
+
241
+ # add the current element
242
+ ary << "<li>" << a.last
243
+ prev_depth = cur
244
+ end
245
+
246
+ # close out the remaingling tags
247
+ ary << "</li>" << lclose
248
+ ary.join("\n")
174
249
  end
175
250
 
176
251
  # Returns +true+ if outline numbering should be inserted into the heading
177
252
  # tags. Returns +false+ otherwise.
178
253
  #
179
- def outline_numbering?
180
- @outline_numbering
254
+ def numbering?
255
+ @numbering
181
256
  end
182
257
  end # class Outline
183
258
 
@@ -1,4 +1,4 @@
1
- # $Id: url_helper.rb 103 2008-01-20 23:58:14Z tim_pease $
1
+ # $Id: url_helper.rb 147 2008-02-14 20:14:04Z tim_pease $
2
2
 
3
3
  module Webby
4
4
  module Helpers #:nodoc:
@@ -115,7 +115,7 @@ module UrlHelper
115
115
  end
116
116
 
117
117
  href_attr = href ? nil : %Q(href="#{url}")
118
- "<a #{href_attr}#{attrs}>#{name || url}</a>"
118
+ "<a #{href_attr}#{attrs}>#{name || h(url)}</a>"
119
119
  end
120
120
 
121
121
  # call-seq:
@@ -222,8 +222,8 @@ module UrlHelper
222
222
  raise Webby::Renderer::Error,
223
223
  "could not find requested page: #{opts.inspect}" if p.nil?
224
224
 
225
- name = h(p.title || p.filename) if name.nil?
226
- return [name, p, link_opts]
225
+ name = p.title || p.filename if name.nil?
226
+ return [h(name), p, link_opts]
227
227
  end
228
228
 
229
229
  end # module UrlHelper
@@ -1,4 +1,4 @@
1
- # $Id: pages_db.rb 119 2008-01-29 04:26:27Z wbruce $
1
+ # $Id: pages_db.rb 137 2008-02-08 05:05:55Z tim_pease $
2
2
 
3
3
  module Webby
4
4
 
@@ -78,14 +78,20 @@ class PagesDB
78
78
  #
79
79
  # Options include:
80
80
  #
81
- # :all
82
81
  # :in_directory => 'directory'
82
+ # :recursive => true or false
83
+ #
84
+ # :limit => :all or integer
85
+ # :sorty_by => 'attribute'
83
86
  #
84
87
  # Examples:
85
88
  #
86
89
  # # find the "index" resource in the "foo/bar" directory
87
90
  # pages_db.find( :filename => 'index', :in_directory => 'foo/bar' )
88
91
  #
92
+ # # find any "index" resource under the "foo/bar" directory
93
+ # pages_db.find( :filename => 'index', :in_directory => 'foo/bar', :recursive => true )
94
+ #
89
95
  # # find all resources named "widgets" whose color is "blue"
90
96
  # pages_db.find( :all, :name => 'widgets', :color => 'blue' )
91
97
  #
@@ -96,8 +102,12 @@ class PagesDB
96
102
  #
97
103
  def find( *args, &block )
98
104
  opts = Hash === args.last ? args.pop : {}
99
- find_all = args.include? :all
100
105
 
106
+ limit = opts.delete(:limit)
107
+ sort_by = opts.delete(:sort_by)
108
+
109
+ # figure out which directories to search through and whether to recurse
110
+ # into directories or not
101
111
  search = if (dir = opts.delete(:in_directory))
102
112
  strategy = if opts.delete(:recursive)
103
113
  lambda { |key| key =~ /^#{Regexp.escape(dir)}(?:\/|$)/ }
@@ -111,6 +121,7 @@ class PagesDB
111
121
  self
112
122
  end
113
123
 
124
+ # construct a search block if one was not supplied by the user
114
125
  block ||= lambda do |page|
115
126
  found = true
116
127
  opts.each do |key, value|
@@ -120,16 +131,28 @@ class PagesDB
120
131
  found
121
132
  end
122
133
 
134
+ # search through the directories for the desired pages
123
135
  ary = []
124
136
  search.each do |page|
125
- if block.call(page)
126
- ary << page
127
- break unless find_all
128
- end
137
+ ary << page if block.call(page)
138
+ end
139
+
140
+ # sort the search results if the user gave an attribute to sort by
141
+ if sort_by
142
+ m = sort_by.to_sym
143
+ ary.delete_if {|p| p.__send__(m).nil?}
144
+ ary.sort! {|a,b| a.__send__(m) <=> b.__send__(m)}
145
+ end
146
+
147
+ # limit the search results
148
+ case limit
149
+ when :all, 'all'
150
+ ary
151
+ when Integer
152
+ ary.slice(0,limit)
153
+ else
154
+ ary.first
129
155
  end
130
-
131
- return ary if find_all
132
- return ary.first
133
156
  end
134
157
 
135
158
  # call-seq:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.3
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Pease
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-02-05 00:00:00 -07:00
12
+ date: 2008-02-15 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -46,7 +46,7 @@ dependencies:
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 0.6.1
49
+ version: 0.7.0
50
50
  version:
51
51
  - !ruby/object:Gem::Dependency
52
52
  name: rake
@@ -66,15 +66,6 @@ dependencies:
66
66
  - !ruby/object:Gem::Version
67
67
  version: 1.1.3
68
68
  version:
69
- - !ruby/object:Gem::Dependency
70
- name: RedCloth
71
- version_requirement:
72
- version_requirements: !ruby/object:Gem::Requirement
73
- requirements:
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- version: 3.0.4
77
- version:
78
69
  description: Webby is a super fantastic little website management system. It would be called a _content management system_ if it were a bigger kid. But, it's just a runt with a special knack for transforming text. And that's really all it does - manages the legwork of turning text into something else, an *ASCII Alchemist* if you will.
79
70
  email: tim.pease@gmail.com
80
71
  executables:
@@ -131,12 +122,12 @@ files:
131
122
  - examples/webby/content/css/site.css
132
123
  - examples/webby/content/download.txt
133
124
  - examples/webby/content/index.txt
134
- - examples/webby/content/manual.txt
125
+ - examples/webby/content/manual/index.txt
135
126
  - examples/webby/content/robots.txt
136
127
  - examples/webby/content/script/jquery.corner.js
137
128
  - examples/webby/content/script/jquery.js
138
- - examples/webby/content/tips_and_tricks.txt
139
- - examples/webby/content/tutorial.txt
129
+ - examples/webby/content/tips_and_tricks/index.txt
130
+ - examples/webby/content/tutorial/index.txt
140
131
  - examples/webby/layouts/default.rhtml
141
132
  - examples/webby/tasks/create.rake
142
133
  - examples/webby/tasks/deploy.rake