webby 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. data/History.txt +11 -0
  2. data/Manifest.txt +45 -2
  3. data/Rakefile +1 -2
  4. data/examples/webby/content/css/site.css +1 -1
  5. data/examples/webby/content/learn/index.txt +1 -1
  6. data/examples/webby/content/release-notes/index.txt +21 -0
  7. data/examples/webby/content/release-notes/rel-0-9-0/index.txt +1 -0
  8. data/examples/webby/content/release-notes/rel-0-9-1/index.txt +93 -0
  9. data/examples/webby/content/tips_and_tricks/index.txt +14 -13
  10. data/examples/webby/content/tutorial/index.txt +13 -9
  11. data/examples/webby/content/user-manual/index.txt +8 -8
  12. data/examples/webby/layouts/default.txt +1 -1
  13. data/lib/webby.rb +2 -1
  14. data/lib/webby/apps/main.rb +25 -13
  15. data/lib/webby/auto_builder.rb +2 -0
  16. data/lib/webby/builder.rb +2 -5
  17. data/lib/webby/filters.rb +5 -13
  18. data/lib/webby/renderer.rb +7 -5
  19. data/lib/webby/resources.rb +54 -14
  20. data/lib/webby/resources/db.rb +4 -4
  21. data/lib/webby/resources/layout.rb +14 -23
  22. data/lib/webby/resources/meta_file.rb +208 -0
  23. data/lib/webby/resources/page.rb +21 -58
  24. data/lib/webby/resources/partial.rb +10 -4
  25. data/lib/webby/resources/resource.rb +68 -27
  26. data/lib/webby/resources/static.rb +6 -22
  27. data/lib/webby/stelan/paginator.rb +17 -2
  28. data/spec/data/Sitefile +9 -0
  29. data/spec/data/content/_partial.txt +10 -0
  30. data/spec/data/content/css/coderay.css +111 -0
  31. data/spec/data/content/css/site.css +67 -0
  32. data/spec/data/content/css/tumblog.css +308 -0
  33. data/spec/data/content/images/tumblog/permalink.gif +0 -0
  34. data/spec/data/content/images/tumblog/rss.gif +0 -0
  35. data/spec/data/content/index.txt +19 -0
  36. data/spec/data/content/photos.txt +21 -0
  37. data/spec/data/content/tumblog/200806/the-noble-chicken/index.txt +12 -0
  38. data/spec/data/content/tumblog/200807/historical-perspectives-on-the-classic-chicken-joke/index.txt +12 -0
  39. data/spec/data/content/tumblog/200807/mad-city-chickens/index.txt +10 -0
  40. data/spec/data/content/tumblog/200807/the-wisdom-of-the-dutch/index.txt +11 -0
  41. data/spec/data/content/tumblog/200807/up-a-tree/index.txt +13 -0
  42. data/spec/data/content/tumblog/index.txt +37 -0
  43. data/spec/data/content/tumblog/rss.txt +37 -0
  44. data/spec/data/hooligans/bad_meta_data_1.txt +34 -0
  45. data/spec/data/hooligans/bad_meta_data_2.txt +34 -0
  46. data/spec/data/layouts/default.txt +58 -0
  47. data/spec/data/layouts/tumblog/default.txt +44 -0
  48. data/spec/data/layouts/tumblog/post.txt +15 -0
  49. data/spec/data/lib/breadcrumbs.rb +28 -0
  50. data/spec/data/lib/tumblog_helper.rb +32 -0
  51. data/spec/data/tasks/tumblog.rake +30 -0
  52. data/spec/data/templates/_partial.erb +10 -0
  53. data/spec/data/templates/atom_feed.erb +40 -0
  54. data/spec/data/templates/page.erb +18 -0
  55. data/spec/data/templates/presentation.erb +40 -0
  56. data/spec/data/templates/tumblog/conversation.erb +12 -0
  57. data/spec/data/templates/tumblog/link.erb +10 -0
  58. data/spec/data/templates/tumblog/photo.erb +13 -0
  59. data/spec/data/templates/tumblog/post.erb +12 -0
  60. data/spec/data/templates/tumblog/quote.erb +11 -0
  61. data/spec/spec_helper.rb +37 -0
  62. data/spec/webby/apps/generator_spec.rb +4 -0
  63. data/spec/webby/apps/main_spec.rb +16 -3
  64. data/spec/webby/filters/textile_spec.rb +20 -0
  65. data/spec/webby/renderer_spec.rb +139 -0
  66. data/spec/webby/resources/db_spec.rb +250 -0
  67. data/spec/webby/resources/layout_spec.rb +83 -0
  68. data/spec/webby/resources/meta_file_spec.rb +157 -0
  69. data/spec/webby/resources/page_spec.rb +111 -0
  70. data/spec/webby/resources/partial_spec.rb +58 -0
  71. data/spec/webby/resources/resource_spec.rb +214 -0
  72. data/spec/webby/resources/static_spec.rb +49 -0
  73. data/spec/webby/resources_spec.rb +55 -3
  74. metadata +64 -6
  75. data/lib/webby/resources/file.rb +0 -221
  76. data/spec/webby/resources/file_spec.rb +0 -104
@@ -0,0 +1,10 @@
1
+ ---
2
+ title: Mad City Chickens
3
+ created_at: 2008-07-26 16:11:09.306365 -06:00
4
+ author: Tim Pease
5
+ filter:
6
+ - textile
7
+ layout: tumblog/post
8
+ tumblog_type: link
9
+ ---
10
+ "(link)Raising chickens in Madison, WI":http://www.madcitychickens.com/
@@ -0,0 +1,11 @@
1
+ ---
2
+ title: The Wisdom of the Dutch
3
+ created_at: 2008-07-26 16:11:39.658919 -06:00
4
+ author: Not Tim Pease
5
+ filter:
6
+ - textile
7
+ layout: tumblog/post
8
+ tumblog_type: quote
9
+ ---
10
+ <big>&#147;</big> You can't hatch chickens from fried eggs.
11
+ %(source)Dutch Proverb%
@@ -0,0 +1,13 @@
1
+ ---
2
+ title: Up a Tree
3
+ created_at: 2008-07-06 16:09:49.530410 -06:00
4
+ author: Tim Pease
5
+ filter:
6
+ - erb
7
+ - textile
8
+ layout: tumblog/post
9
+ tumblog_type: photo
10
+ ---
11
+ !http://www.madcitychickens.com/images/bttrcups_tree.jpg(<%= h(@page.title) %>)!
12
+
13
+ p(caption). via "Mad City Chickens":http://www.madcitychickens.com/
@@ -0,0 +1,37 @@
1
+ ---
2
+ title: A Mother Clucker
3
+ author: Tim Pease
4
+ layout: tumblog/default
5
+ filter: erb
6
+ dirty: true
7
+ ---
8
+ <% prev = nil
9
+ posts = @pages.find(
10
+ :all,
11
+ :layout => 'tumblog/post',
12
+ :sort_by => :created_at,
13
+ :reverse => true
14
+ )
15
+ paginate(posts, 4) do |p| -%>
16
+ <div class="post">
17
+ <% if prev != p.created_at.strftime('%Y%m%d') -%>
18
+ <%= tumblog_date(p.created_at) %>
19
+ <% prev = p.created_at.strftime('%Y%m%d')
20
+ end -%>
21
+ <a href="<%= p.url %>">
22
+ <img src="/images/tumblog/permalink.gif" class="permalink" alt="permalink" />
23
+ </a>
24
+
25
+ <div class="<%= p.tumblog_type %>">
26
+ <% if p.title -%>
27
+ <h2><%= link_to_page(p) %></h2>
28
+ <% end -%>
29
+ <%= render(p) %>
30
+ </div>
31
+ </div>
32
+ <% end -%>
33
+
34
+ <% content_for :footer do -%>
35
+ <%= link_to("&#171; Prev", @pager.prev) if @pager.prev? %>
36
+ <%= link_to("Next &#187;", @pager.next) if @pager.next? %>
37
+ <% end -%>
@@ -0,0 +1,37 @@
1
+ ---
2
+ title: A Mother Clucker
3
+ subtitle: raising chickens in the city
4
+ site: example.com
5
+ author: Tim Pease
6
+ email: author@example.com
7
+ extension: xml
8
+ layout: nil
9
+ dirty: true
10
+ filter: erb
11
+ ---
12
+ <?xml version="1.0" encoding="utf-8"?>
13
+ <feed xmlns="http://www.w3.org/2005/Atom">
14
+
15
+ <title><%= h(@page.title) %></title>
16
+ <subtitle><%= h(@page.subtitle) %></subtitle>
17
+ <link href="http://<%= @page.site %>/tumblog/" rel="self" />
18
+ <link href="http://<%= @page.site %>/" />
19
+ <updated><%= Time.now.xmlschema %></updated>
20
+ <author>
21
+ <name><%= h(@page.author) %></name>
22
+ <email><%= h(@page.email) %></email>
23
+ </author>
24
+ <id>http://<%= @page.site %>/</id>
25
+ <% @pages.find(:limit => 10,
26
+ :layout => 'tumblog/post',
27
+ :sort_by => 'created_at',
28
+ :reverse => true).each do |article| %>
29
+ <entry>
30
+ <title><%= h(article.title) %></title>
31
+ <link href="<%= article.url %>" />
32
+ <id>tag:<%= @page.site %>,<%= article.created_at.strftime('%Y-%m-%d') %>:<%= article.created_at.to_i %></id>
33
+ <updated><%= article.created_at.xmlschema %></updated>
34
+ <content type="html"><%= h(render(article)) %></content>
35
+ </entry>
36
+ <% end %>
37
+ </feed>
@@ -0,0 +1,34 @@
1
+ ---
2
+ title: Bad Meta-Data 1
3
+ created_at: 2007-08-29 08:57:11.000000 -06:00
4
+ filter: textile
5
+ ---
6
+ h2. Pagination
7
+
8
+ Pagination is the process of organizing information onto a page such that a fixed number of items appear on each page. Webby provides some methods for paginating information.
9
+
10
+ Let's assume that your website has a collection of articles in a folder called "articles" in the content directory. The goal is to display these articles ten at a time in reverse chronological order.
11
+
12
+ <pre>
13
+ ---
14
+ title: Articles
15
+ filter:
16
+ - erb
17
+ - textile
18
+ ---
19
+ h2. <%= h(@page.title) %>
20
+
21
+ <%
22
+ articles = @pages.find(:all, :in_directory => "articles",
23
+ :sort_by => "mtime", :reverse => true)
24
+ paginate(articles, 10) do |page|
25
+ %>
26
+ <%= page.render %>
27
+ <hr />
28
+ <% end %>
29
+
30
+ <%= link_to("Prev", @pager.prev) if @pager.prev? %>
31
+ <%= link_to("Next", @pager.next) if @pager.next? %>
32
+ </pre>
33
+
34
+ In the example page above, the first step is get the collection of articles we are interested in the paginating. This is done using the <code>@pages.find</code> method to retrieve all the pages from the articles folder sorted in reverse order by modification time. When we have the collection of articles, we pass them to the @paginate@ method along with the desired number of articles per page. The @paginate@ method will pass each page in the @articles@ collection to the supplied block of code, but for each ten pages passed to the block, a new webpage will be created.
@@ -0,0 +1,34 @@
1
+ ---
2
+ title: Bad Meta-Data 2
3
+ created_at: 2007-08-29 08:57:11.000000 -06:00
4
+ filter:
5
+ - erb
6
+ - textile
7
+ ---
8
+ h3. Requirements
9
+
10
+ Webby is written in the Ruby programming language. To install and run Webby you will need the following applications installed on your system:
11
+
12
+ * "Ruby":http://ruby-lang.org
13
+ * "RubyGems":http://rubygems.org/read/chapter/3
14
+
15
+ h3(#pages). Pages
16
+
17
+ Pages are found in the _content_ folder along with regular files. Pages contain *meta-data* at the top of the file; this is what differentiates a page from a regular file. The meta-data is a section of "YAML":http://www.yaml.org/spec/1.1/ formatted text that describes various properties and attributes of the page. These attributes are used by Webby to determine how the page will be processed by the filter engine.
18
+
19
+ Let's look at an example page.
20
+
21
+ <pre>
22
+ ---
23
+ title: Lorem Ipsum
24
+ created_at: Wed Aug 29 08:57:00 -0600 2007
25
+ filter:
26
+ - erb
27
+ - textile
28
+ ---
29
+ h2. <%%= @page.title %>
30
+
31
+ Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc congue ipsum
32
+ vestibulum libero. Aenean vitae justo. Nam eget tellus. Etiam convallis, est eu
33
+ lobortis mattis, lectus tellus tempus felis, a ultricies erat ipsum at metus.
34
+ </pre>
@@ -0,0 +1,58 @@
1
+ ---
2
+ extension: html
3
+ filter: erb
4
+ ---
5
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
6
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
7
+
8
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-us">
9
+ <head>
10
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
11
+ <title><%= @page.title %></title>
12
+ <meta name="author" content="<%= @page.author %>" />
13
+
14
+ <!--- Blueprint CSS Framework -->
15
+ <link rel="stylesheet" href="/css/blueprint/screen.css" type="text/css" media="screen, projection" />
16
+ <link rel="stylesheet" href="/css/blueprint/print.css" type="text/css" media="print" />
17
+
18
+ <!-- CodeRay syntax highlighting CSS -->
19
+ <link rel="stylesheet" href="/css/coderay.css" type="text/css" />
20
+
21
+ <!-- Homepage CSS -->
22
+ <link rel="stylesheet" href="/css/site.css" type="text/css" media="screen, projection" />
23
+ </head>
24
+ <body>
25
+
26
+ <div class="container">
27
+
28
+ <div class="column span-20 prepend-2 append-2 first last" id="header">
29
+ <p class="title">A New Website</p>
30
+ <hr>
31
+ </div>
32
+
33
+ <div class="column span-15 prepend-2 first">
34
+ <%= @content %>
35
+ </div>
36
+
37
+ <div class="column span-5 append-2 last">
38
+ <h4>Sidebar</h4>
39
+ <p>Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras ornare mattis nunc. Mauris venenatis, pede sed aliquet vehicula, lectus tellus pulvinar neque, non cursus sem nisi vel augue. </p>
40
+
41
+ <div class="box">
42
+ <p class="last">Mauris a lectus. Aliquam erat volutpat. Phasellus ultrices mi a sapien. Nunc rutrum egestas lorem. Duis ac sem sagittis elit tincidunt gravida.</p>
43
+ </div>
44
+
45
+ <p class="quiet">Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras ornare mattis nunc. Mauris venenatis, pede sed aliquet vehicula, lectus tellus pulvinar neque, non cursus sem nisi vel augue.</p>
46
+
47
+ <h5>Incremental leading</h5>
48
+ <p class="incr">Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras ornare mattis nunc. Mauris venenatis, pede sed aliquet vehicula, lectus tellus pulvinar neque, non cursus sem nisi vel augue. sed aliquet vehicula, lectus tellus.</p>
49
+ </div>
50
+
51
+ <div class="column span-20 prepend-2 append-2 first last" id="footer">
52
+ <hr />
53
+ <p>This website was created with <a href="http://webby.rubyforge.org">Webby</a></p>
54
+ </div>
55
+
56
+ </div>
57
+ </body>
58
+ </html>
@@ -0,0 +1,44 @@
1
+ ---
2
+ extension: html
3
+ filter: erb
4
+ ---
5
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
6
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
7
+
8
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-us">
9
+ <head>
10
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
11
+ <title><%= h(@page.title) %></title>
12
+ <meta name="author" content="<%= h(@page.author) %>" />
13
+ <link rel="alternate" type="application/atom+xml" title="RSS" href="/tumblog/rss.xml"/>
14
+
15
+
16
+ <link rel="stylesheet" href="/css/tumblog.css" type="text/css" media="screen, projection" />
17
+ </head>
18
+ <body>
19
+
20
+ <h1>
21
+ <a href="/">Fowl Friends</a>
22
+ <a href="/tumblog/rss.xml"><img src="/images/tumblog/rss.gif" id="rss" alt="RSS" /></a>
23
+ </h1>
24
+
25
+ <div id="content">
26
+ <div id="description">
27
+ <div>
28
+ <p><a href="/tumblog/archive">Archive</a></p>
29
+ </div>
30
+ </div>
31
+
32
+ <%= @content %>
33
+
34
+ <div id="footer">
35
+ <%= content_for :footer %>
36
+
37
+ <div id="credit">
38
+ Powered by <a href="http://webby.rubyforge.org/">Webby</a>
39
+ </div>
40
+ </div>
41
+
42
+ </div>
43
+ </body>
44
+ </html>
@@ -0,0 +1,15 @@
1
+ ---
2
+ filter: erb
3
+ layout: tumblog/default
4
+ ---
5
+ <div class="post">
6
+ <%= tumblog_date(@page.created_at) %>
7
+ <a href="<%= @page.url %>">
8
+ <img src="/images/tumblog/permalink.gif" class="permalink" alt="permalink" />
9
+ </a>
10
+
11
+ <div class="<%= @page.tumblog_type %>">
12
+ <h2><%= link_to_page(@page) %></h2>
13
+ <%= @content %>
14
+ </div>
15
+ </div>
@@ -0,0 +1,28 @@
1
+ # breadcrumbs.rb
2
+
3
+ module BreadcrumbsHelper
4
+ # call-seq:
5
+ # breadcrumbs( page ) => html
6
+ #
7
+ # Create breadcrumb links for the current page. This will return an HTML
8
+ # <ul></ul> object.
9
+ #
10
+ def breadcrumbs( page )
11
+ list = ["<li>#{h(page.title)}</li>"]
12
+ loop do
13
+ page = @pages.parent_of(page)
14
+ break if page.nil?
15
+ list << "<li>#{link_to_page(page)}</li>"
16
+ end
17
+ list.reverse!
18
+
19
+ html = "<ul class=\"breadcrumbs\">\n"
20
+ html << list.join("\n")
21
+ html << "\n</ul>\n"
22
+ html
23
+ end
24
+ end # module Breadcrumbs
25
+
26
+ Webby::Helpers.register(BreadcrumbsHelper)
27
+
28
+ # EOF
@@ -0,0 +1,32 @@
1
+
2
+ require 'time'
3
+
4
+ module TumblogHelper
5
+
6
+ DAYS = {}
7
+ (1..31).each {|day| DAYS[day] = "%dth" % day}
8
+ DAYS[1] = "1st"
9
+ DAYS[2] = "2nd"
10
+ DAYS[3] = "3rd"
11
+ DAYS[21] = "21st"
12
+ DAYS[22] = "22nd"
13
+ DAYS[23] = "23rd"
14
+ DAYS[31] = "31st"
15
+
16
+ def tumblog_date( time )
17
+ <<-HTML
18
+ <div class="date">
19
+ <div class="date_brick">
20
+ #{Time::RFC2822_MONTH_NAME.at(time.month-1)}<br />
21
+ #{TumblogHelper::DAYS[time.day]}
22
+ </div>
23
+ #{Time::RFC2822_DAY_NAME.at(time.wday)}
24
+ </div>
25
+ HTML
26
+ end
27
+
28
+ end # module TumblogHelper
29
+
30
+ Webby::Helpers.register(TumblogHelper)
31
+
32
+ # EOF
@@ -0,0 +1,30 @@
1
+
2
+ namespace :tumblog do
3
+
4
+ # iterate over all the files in the "templates/tumblog" folder and create a
5
+ # rake task corresponding to each file found
6
+ FileList["#{Webby.site.template_dir}/tumblog/*"].each do |template|
7
+ next unless test(?f, template)
8
+ name = template.pathmap('%n')
9
+
10
+ desc "Create a new tumblog #{name}"
11
+ task name do |t|
12
+ page = Webby.site.args.page
13
+ title = Webby.site.args.title
14
+ dir = Webby.site.args.dir
15
+
16
+ # if no directory was given use the default tumblog directory (underneath
17
+ # the content directory)
18
+ dir = Webby.site.tumblog_dir if dir.empty?
19
+ dir = File.join(dir, Time.now.strftime('%Y%m'))
20
+
21
+ page = File.join(dir, File.basename(page))
22
+ page = Webby::Builder.create(page, :from => template,
23
+ :locals => {:title => title, :directory => dir})
24
+ exec(::Webby.editor, page) unless ::Webby.editor.nil?
25
+ end
26
+ end # each
27
+
28
+ end # namespace :tumblog
29
+
30
+ # EOF
@@ -0,0 +1,10 @@
1
+ ---
2
+ filter: erb
3
+ ---
4
+ A partial has access to the page from which it was called. The title below will be the title of the page in which this partial is rendered.
5
+
6
+ <%%= h(@page.title) %>
7
+
8
+ A partial does not have access to it's own meta-data. The partial meta-data is used primarily for finding partials or for use in other pages. The filter(s) specified in the meta-data will be applied to the partial text when it is rendered.
9
+
10
+ A partial does not require meta-data at all. They can contain just text.
@@ -0,0 +1,40 @@
1
+ ---
2
+ title: A New Atom Feed
3
+ subtitle: A really swell blog built with Webby
4
+ site: fake-n-site.org
5
+ author: Author's Name
6
+ email: author@fake-n-site.org
7
+ extension: xml
8
+ layout: nil
9
+ dirty: true
10
+ filter: erb
11
+ ---
12
+ <?xml version="1.0" encoding="utf-8"?>
13
+ <feed xmlns="http://www.w3.org/2005/Atom">
14
+
15
+ <title><%%= h(@page.title) %></title>
16
+ <subtitle><%%= h(@page.subtitle) %></subtitle>
17
+ <link href="http://<%%= @page.site %>/<%= directory %>/" rel="self" />
18
+ <link href="http://<%%= @page.site %>/" />
19
+ <updated><%%= Time.now.xmlschema %></updated>
20
+ <author>
21
+ <name><%%= h(@page.author) %></name>
22
+ <email><%%= h(@page.email) %></email>
23
+ </author>
24
+ <id>http://<%%= @page.site %>/</id>
25
+ <%% @pages.find(:limit => 10,
26
+ :in_directory => '<%= directory %>',
27
+ :recursive => true,
28
+ :sort_by => 'mtime',
29
+ :reverse => true).each do |article|
30
+ next if article == @page
31
+ %>
32
+ <entry>
33
+ <title><%%= h(article.title) %></title>
34
+ <link href="<%%= article.url %>" />
35
+ <id>tag:<%%= @page.site %>,<%%= article.created_at.strftime('%Y-%m-%d') %>:<%%= article.created_at.to_i %></id>
36
+ <updated><%%= article.created_at.xmlschema %></updated>
37
+ <content type="html"><%%= h(render(article)) %></content>
38
+ </entry>
39
+ <%% end %>
40
+ </feed>