public
Description: A lightweight and flexible website management system.
Homepage: http://webby.rubyforge.org/
Clone URL: git://github.com/TwP/webby.git
Search Repo:
added method to find the parent of any page
TwP (author)
Sat Feb 23 19:59:37 -0800 2008
commit  174cd07f04cfaf85359e9235c50f314d115c39a3
tree    3c0c0f6bb34d7716f1f53db6dae255639369c873
parent  4fd059bcad22599353db5f768cb2f42ecb8cc67a
...
30
31
32
 
33
34
35
...
30
31
32
33
34
35
36
0
@@ -30,6 +30,7 @@
0
 data/content/css/site.css
0
 data/content/index.txt
0
 data/layouts/default.rhtml
0
+data/lib/breadcrumbs.rb
0
 data/tasks/create.rake
0
 data/tasks/deploy.rake
0
 data/tasks/growl.rake
...
6
7
8
9
 
 
 
 
 
10
11
 
 
 
 
 
12
13
14
...
23
24
25
26
 
 
 
 
 
27
28
29
...
33
34
35
36
 
 
 
 
 
37
38
39
...
6
7
8
 
9
10
11
12
13
14
 
15
16
17
18
19
20
21
22
...
31
32
33
 
34
35
36
37
38
39
40
41
...
45
46
47
 
48
49
50
51
52
53
54
55
0
@@ -6,9 +6,17 @@
0
 
0
 == DESCRIPTION:
0
 
0
-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.
0
+Webby is a super fantastic little website management system. It would be
0
+called a _content management system_ if it were a bigger kid. But, it's
0
+just a runt with a special knack for transforming text. And that's really
0
+all it does - manages the legwork of turning text into something else, an
0
+*ASCII Alchemist* if you will.
0
 
0
-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.
0
+Webby works by combining the contents of a *page* with a *layout* to
0
+produce HTML. The layout contains everything common to all the pages -
0
+HTML headers, navigation menu, footer, etc. - and the page contains just
0
+the information for that page. You can use your favorite markup language
0
+to write your pages; Webby supports quite a few.
0
 
0
 Install Webby and try it out!
0
 
0
@@ -23,7 +31,11 @@
0
 
0
 But Wait! There's More!
0
 
0
-Webby has a great _autobuild_ feature that continuously generates HTML whenever the *pages* or *layouts* change. The HTML is served up via {heel}[http://copiousfreetime.rubyforge.org/heel/], a static file webserver based on mongrel. Whenever you change a page, you can immediately see those changes without having to run any commands.
0
+Webby has a great _autobuild_ feature that continuously generates HTML whenever
0
+the *pages* or *layouts* change. The HTML is served up via
0
+{heel}[http://copiousfreetime.rubyforge.org/heel/], a static file webserver
0
+based on mongrel. Whenever you change a page, you can immediately see those
0
+changes without having to run any commands.
0
 
0
    $ rake autobuild
0
    heel --root output --daemonize
0
@@ -33,7 +45,11 @@
0
    - started at 10:22:57
0
    creating output/index.html
0
 
0
-Webby is not limited to producing HTML. By no means! Do you ever get tired of repeating the same color code <b>#D3C4A2</b> in your CSS files? Webby can help. Need some customized JavaScript for your website. Webby can help. Anytime you find yourself repeating the same bit of text over and over, then you should be using Webby.
0
+Webby is not limited to producing HTML. By no means! Do you ever get tired of
0
+repeating the same color code <b>#D3C4A2</b> in your CSS files? Webby can help.
0
+Need some customized JavaScript for your website. Webby can help. Anytime you
0
+find yourself repeating the same bit of text over and over, then you should be
0
+using Webby.
0
 
0
 == INSTALL:
0
 
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
0
@@ -1 +1,29 @@
0
+# breadcrumbs.rb
0
+
0
+module BreadcrumbsHelper
0
+ # call-seq:
0
+ # breadcrumbs( page ) => html
0
+ #
0
+ # Create breadcrumb links for the current page. This will return an HTML
0
+ # <ul></ul> object.
0
+ #
0
+ def breadcrumbs( page )
0
+ list = ["<li>#{h(page.title)}</li>"]
0
+ loop do
0
+ page = @pages.parent_of(page)
0
+ break if page.nil?
0
+ list << "<li>#{link_to_page(page)}</li>"
0
+ end
0
+ list.reverse!
0
+
0
+ html = "<ul class=\"breadcrumbs\">\n"
0
+ html << list.join("\n")
0
+ html << "\n</ul>\n"
0
+ html
0
+ end
0
+end # module Breadcrumbs
0
+
0
+Webby::Helpers.register(BreadcrumbsHelper)
0
+
0
+# EOF
...
114
115
116
117
 
118
119
120
...
209
210
211
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
212
213
214
...
114
115
116
 
117
118
119
120
...
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
0
@@ -114,7 +114,7 @@
0
     # into directories or not
0
     search = if (dir = opts.delete(:in_directory))
0
       strategy = if opts.delete(:recursive)
0
- lambda { |key| key =~ /^#{Regexp.escape(dir)}(?:\/|$)/ }
0
+ lambda { |key| key =~ %r/^#{Regexp.escape(dir)}(?:\/|$)/ }
0
       else
0
         lambda { |key| key == dir }
0
       end
0
@@ -209,6 +209,30 @@
0
     ary.sort! {|a,b| a.__send__(m) <=> b.__send__(m)}
0
     ary.reverse! if opts[:reverse]
0
     ary
0
+ end
0
+
0
+ # call-seq:
0
+ # parent_of( resource ) => resource or nil
0
+ #
0
+ # Returns the parent page of the given resource or nil if the resource is
0
+ # at the root of the directory structure. The parent is the "index" page
0
+ # of the current directory or the next directory up the chain.
0
+ #
0
+ def parent_of( page )
0
+ dir = page.dir
0
+
0
+ loop do
0
+ if @db.has_key? dir
0
+ parent = @db[dir].find {|p| p.filename == 'index'}
0
+ return parent unless parent.nil? or parent == page
0
+ end
0
+
0
+ break if dir.empty?
0
+ dir = ::File.dirname(dir)
0
+ dir = '' if dir == '.'
0
+ end
0
+
0
+ return
0
   end
0
 
0
 end # class DB

Comments

    No one has commented yet.