francois-webby 0.9.4.1
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +218 -0
- data/README.rdoc +92 -0
- data/Rakefile +62 -0
- data/bin/webby +41 -0
- data/bin/webby-gen +41 -0
- data/examples/blog/Sitefile +7 -0
- data/examples/blog/tasks/blog.rake +72 -0
- data/examples/blog/templates/atom_feed.erb +40 -0
- data/examples/blog/templates/blog/month.erb +22 -0
- data/examples/blog/templates/blog/post.erb +16 -0
- data/examples/blog/templates/blog/year.erb +22 -0
- data/examples/presentation/Sitefile +10 -0
- data/examples/presentation/content/css/uv/twilight.css +137 -0
- data/examples/presentation/content/presentation/_sample_code.txt +10 -0
- data/examples/presentation/content/presentation/index.txt +63 -0
- data/examples/presentation/content/presentation/s5/blank.gif +0 -0
- data/examples/presentation/content/presentation/s5/bodybg.gif +0 -0
- data/examples/presentation/content/presentation/s5/framing.css +23 -0
- data/examples/presentation/content/presentation/s5/iepngfix.htc +42 -0
- data/examples/presentation/content/presentation/s5/opera.css +7 -0
- data/examples/presentation/content/presentation/s5/outline.css +15 -0
- data/examples/presentation/content/presentation/s5/pretty.css +86 -0
- data/examples/presentation/content/presentation/s5/print.css +25 -0
- data/examples/presentation/content/presentation/s5/s5-core.css +9 -0
- data/examples/presentation/content/presentation/s5/slides.css +3 -0
- data/examples/presentation/content/presentation/s5/slides.js +553 -0
- data/examples/presentation/layouts/presentation.txt +43 -0
- data/examples/presentation/templates/_code_partial.erb +13 -0
- data/examples/presentation/templates/presentation.erb +40 -0
- data/examples/tumblog/Sitefile +9 -0
- data/examples/tumblog/content/css/tumblog.css +308 -0
- data/examples/tumblog/content/images/tumblog/permalink.gif +0 -0
- data/examples/tumblog/content/images/tumblog/rss.gif +0 -0
- data/examples/tumblog/content/tumblog/200806/the-noble-chicken/index.txt +12 -0
- data/examples/tumblog/content/tumblog/200807/historical-perspectives-on-the-classic-chicken-joke/index.txt +12 -0
- data/examples/tumblog/content/tumblog/200807/mad-city-chickens/index.txt +10 -0
- data/examples/tumblog/content/tumblog/200807/the-wisdom-of-the-dutch/index.txt +11 -0
- data/examples/tumblog/content/tumblog/200807/up-a-tree/index.txt +13 -0
- data/examples/tumblog/content/tumblog/index.txt +37 -0
- data/examples/tumblog/content/tumblog/rss.txt +37 -0
- data/examples/tumblog/layouts/tumblog/default.txt +44 -0
- data/examples/tumblog/layouts/tumblog/post.txt +15 -0
- data/examples/tumblog/lib/tumblog_helper.rb +32 -0
- data/examples/tumblog/tasks/tumblog.rake +30 -0
- data/examples/tumblog/templates/atom_feed.erb +40 -0
- data/examples/tumblog/templates/tumblog/conversation.erb +12 -0
- data/examples/tumblog/templates/tumblog/link.erb +10 -0
- data/examples/tumblog/templates/tumblog/photo.erb +13 -0
- data/examples/tumblog/templates/tumblog/post.erb +12 -0
- data/examples/tumblog/templates/tumblog/quote.erb +11 -0
- data/examples/webby/Sitefile +19 -0
- data/examples/webby/content/communicate/index.txt +28 -0
- data/examples/webby/content/css/background.gif +0 -0
- data/examples/webby/content/css/blueprint/print.css +76 -0
- data/examples/webby/content/css/blueprint/screen.css +696 -0
- data/examples/webby/content/css/coderay.css +96 -0
- data/examples/webby/content/css/site.css +196 -0
- data/examples/webby/content/css/uv/twilight.css +137 -0
- data/examples/webby/content/index.txt +37 -0
- data/examples/webby/content/learn/index.txt +28 -0
- data/examples/webby/content/reference/index.txt +204 -0
- data/examples/webby/content/release-notes/index.txt +21 -0
- data/examples/webby/content/release-notes/rel-0-9-0/index.txt +74 -0
- data/examples/webby/content/release-notes/rel-0-9-1/index.txt +93 -0
- data/examples/webby/content/release-notes/rel-0-9-2/index.txt +14 -0
- data/examples/webby/content/release-notes/rel-0-9-3/index.txt +47 -0
- data/examples/webby/content/robots.txt +6 -0
- data/examples/webby/content/script/jquery.corner.js +152 -0
- data/examples/webby/content/script/jquery.js +31 -0
- data/examples/webby/content/sitemap.txt +31 -0
- data/examples/webby/content/tips_and_tricks/index.txt +97 -0
- data/examples/webby/content/tutorial/index.txt +135 -0
- data/examples/webby/content/user-manual/index.txt +419 -0
- data/examples/webby/layouts/default.txt +49 -0
- data/examples/webby/templates/page.erb +10 -0
- data/examples/website/Sitefile +7 -0
- data/examples/website/content/css/blueprint/ie.css +26 -0
- data/examples/website/content/css/blueprint/plugins/buttons/icons/cross.png +0 -0
- data/examples/website/content/css/blueprint/plugins/buttons/icons/key.png +0 -0
- data/examples/website/content/css/blueprint/plugins/buttons/icons/tick.png +0 -0
- data/examples/website/content/css/blueprint/plugins/buttons/readme.txt +32 -0
- data/examples/website/content/css/blueprint/plugins/buttons/screen.css +97 -0
- data/examples/website/content/css/blueprint/plugins/fancy-type/readme.txt +14 -0
- data/examples/website/content/css/blueprint/plugins/fancy-type/screen.css +71 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/icons/doc.png +0 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/icons/email.png +0 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/icons/external.png +0 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/icons/feed.png +0 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/icons/im.png +0 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/icons/pdf.png +0 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/icons/visited.png +0 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/icons/xls.png +0 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/readme.txt +18 -0
- data/examples/website/content/css/blueprint/plugins/link-icons/screen.css +40 -0
- data/examples/website/content/css/blueprint/plugins/rtl/readme.txt +10 -0
- data/examples/website/content/css/blueprint/plugins/rtl/screen.css +109 -0
- data/examples/website/content/css/blueprint/print.css +30 -0
- data/examples/website/content/css/blueprint/screen.css +251 -0
- data/examples/website/content/css/blueprint/src/forms.css +49 -0
- data/examples/website/content/css/blueprint/src/grid.css +212 -0
- data/examples/website/content/css/blueprint/src/grid.png +0 -0
- data/examples/website/content/css/blueprint/src/ie.css +59 -0
- data/examples/website/content/css/blueprint/src/print.css +85 -0
- data/examples/website/content/css/blueprint/src/reset.css +38 -0
- data/examples/website/content/css/blueprint/src/typography.css +105 -0
- data/examples/website/content/css/coderay.css +111 -0
- data/examples/website/content/css/site.css +67 -0
- data/examples/website/content/index.txt +19 -0
- data/examples/website/layouts/default.txt +61 -0
- data/examples/website/lib/breadcrumbs.rb +28 -0
- data/examples/website/templates/_partial.erb +10 -0
- data/examples/website/templates/page.erb +18 -0
- data/lib/webby/apps/generator.rb +276 -0
- data/lib/webby/apps/main.rb +258 -0
- data/lib/webby/apps.rb +12 -0
- data/lib/webby/auto_builder.rb +157 -0
- data/lib/webby/builder.rb +172 -0
- data/lib/webby/core_ext/enumerable.rb +11 -0
- data/lib/webby/core_ext/hash.rb +28 -0
- data/lib/webby/core_ext/kernel.rb +26 -0
- data/lib/webby/core_ext/string.rb +163 -0
- data/lib/webby/core_ext/time.rb +9 -0
- data/lib/webby/filters/basepath.rb +97 -0
- data/lib/webby/filters/erb.rb +9 -0
- data/lib/webby/filters/haml.rb +18 -0
- data/lib/webby/filters/markdown.rb +16 -0
- data/lib/webby/filters/maruku.rb +16 -0
- data/lib/webby/filters/outline.rb +309 -0
- data/lib/webby/filters/sass.rb +17 -0
- data/lib/webby/filters/slides.rb +56 -0
- data/lib/webby/filters/textile.rb +16 -0
- data/lib/webby/filters/tidy.rb +76 -0
- data/lib/webby/filters/wiki_words.rb +14 -0
- data/lib/webby/filters.rb +85 -0
- data/lib/webby/helpers/capture_helper.rb +141 -0
- data/lib/webby/helpers/coderay_helper.rb +69 -0
- data/lib/webby/helpers/graphviz_helper.rb +136 -0
- data/lib/webby/helpers/tag_helper.rb +65 -0
- data/lib/webby/helpers/tex_img_helper.rb +133 -0
- data/lib/webby/helpers/ultraviolet_helper.rb +63 -0
- data/lib/webby/helpers/url_helper.rb +241 -0
- data/lib/webby/helpers.rb +30 -0
- data/lib/webby/journal.rb +126 -0
- data/lib/webby/link_validator.rb +160 -0
- data/lib/webby/renderer.rb +389 -0
- data/lib/webby/resources/db.rb +251 -0
- data/lib/webby/resources/layout.rb +54 -0
- data/lib/webby/resources/meta_file.rb +211 -0
- data/lib/webby/resources/page.rb +81 -0
- data/lib/webby/resources/partial.rb +85 -0
- data/lib/webby/resources/resource.rb +201 -0
- data/lib/webby/resources/static.rb +36 -0
- data/lib/webby/resources.rb +137 -0
- data/lib/webby/stelan/mktemp.rb +135 -0
- data/lib/webby/stelan/paginator.rb +165 -0
- data/lib/webby/tasks/build.rake +27 -0
- data/lib/webby/tasks/create.rake +25 -0
- data/lib/webby/tasks/deploy.rake +22 -0
- data/lib/webby/tasks/growl.rake +16 -0
- data/lib/webby/tasks/validate.rake +19 -0
- data/lib/webby.rb +232 -0
- data/spec/core_ext/hash_spec.rb +47 -0
- data/spec/core_ext/string_spec.rb +110 -0
- data/spec/core_ext/time_spec.rb +19 -0
- data/spec/data/hooligans/bad_meta_data_1.txt +34 -0
- data/spec/data/hooligans/bad_meta_data_2.txt +34 -0
- data/spec/data/html/anchor.html +11 -0
- data/spec/data/html/external.html +10 -0
- data/spec/data/html/invalid-relative.html +10 -0
- data/spec/data/html/relative-anchor.html +10 -0
- data/spec/data/html/relative-invalid-anchor.html +10 -0
- data/spec/data/html/relative.html +10 -0
- data/spec/data/outline/basic.out +81 -0
- data/spec/data/outline/basic.txt +25 -0
- data/spec/data/outline/no_clobber.out +86 -0
- data/spec/data/outline/numbering.out +81 -0
- data/spec/data/outline/numbering_only.out +21 -0
- data/spec/data/outline/toc_range_1.out +66 -0
- data/spec/data/outline/toc_range_2.out +55 -0
- data/spec/data/outline/toc_style.out +81 -0
- data/spec/data/site/Sitefile +9 -0
- data/spec/data/site/content/_partial.txt +10 -0
- data/spec/data/site/content/css/coderay.css +111 -0
- data/spec/data/site/content/css/site.css +67 -0
- data/spec/data/site/content/css/tumblog.css +308 -0
- data/spec/data/site/content/images/tumblog/permalink.gif +0 -0
- data/spec/data/site/content/images/tumblog/rss.gif +0 -0
- data/spec/data/site/content/index.txt +19 -0
- data/spec/data/site/content/photos.txt +21 -0
- data/spec/data/site/content/tumblog/200806/the-noble-chicken/index.txt +12 -0
- data/spec/data/site/content/tumblog/200807/historical-perspectives-on-the-classic-chicken-joke/index.txt +12 -0
- data/spec/data/site/content/tumblog/200807/mad-city-chickens/index.txt +10 -0
- data/spec/data/site/content/tumblog/200807/the-wisdom-of-the-dutch/index.txt +11 -0
- data/spec/data/site/content/tumblog/200807/up-a-tree/index.txt +13 -0
- data/spec/data/site/content/tumblog/index.txt +37 -0
- data/spec/data/site/content/tumblog/rss.txt +37 -0
- data/spec/data/site/layouts/default.txt +58 -0
- data/spec/data/site/layouts/tumblog/default.txt +44 -0
- data/spec/data/site/layouts/tumblog/post.txt +15 -0
- data/spec/data/site/lib/breadcrumbs.rb +28 -0
- data/spec/data/site/lib/tumblog_helper.rb +32 -0
- data/spec/data/site/tasks/tumblog.rake +30 -0
- data/spec/data/site/templates/_partial.erb +10 -0
- data/spec/data/site/templates/atom_feed.erb +40 -0
- data/spec/data/site/templates/page.erb +18 -0
- data/spec/data/site/templates/presentation.erb +40 -0
- data/spec/data/site/templates/tumblog/conversation.erb +12 -0
- data/spec/data/site/templates/tumblog/link.erb +10 -0
- data/spec/data/site/templates/tumblog/photo.erb +13 -0
- data/spec/data/site/templates/tumblog/post.erb +12 -0
- data/spec/data/site/templates/tumblog/quote.erb +11 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +58 -0
- data/spec/webby/apps/generator_spec.rb +117 -0
- data/spec/webby/apps/main_spec.rb +88 -0
- data/spec/webby/filters/basepath_spec.rb +167 -0
- data/spec/webby/filters/maruku_spec.rb +31 -0
- data/spec/webby/filters/outline_spec.rb +92 -0
- data/spec/webby/filters/textile_spec.rb +31 -0
- data/spec/webby/helpers/capture_helper_spec.rb +56 -0
- data/spec/webby/link_validator_spec.rb +154 -0
- data/spec/webby/renderer_spec.rb +139 -0
- data/spec/webby/resources/db_spec.rb +250 -0
- data/spec/webby/resources/layout_spec.rb +83 -0
- data/spec/webby/resources/meta_file_spec.rb +171 -0
- data/spec/webby/resources/page_spec.rb +111 -0
- data/spec/webby/resources/partial_spec.rb +58 -0
- data/spec/webby/resources/resource_spec.rb +219 -0
- data/spec/webby/resources/static_spec.rb +49 -0
- data/spec/webby/resources_spec.rb +69 -0
- data/tasks/mswin32.rake +38 -0
- data/tasks/website.rake +37 -0
- metadata +372 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
---
|
2
|
+
title: Home Page
|
3
|
+
created_at: 2008-08-02 14:06:40.000000 -06:00
|
4
|
+
filter:
|
5
|
+
- erb
|
6
|
+
- textile
|
7
|
+
---
|
8
|
+
p(title). <%= @page.title %>
|
9
|
+
|
10
|
+
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc congue ipsum vestibulum libero. Aenean vitae justo. Nam eget tellus. Etiam convallis, est eu lobortis mattis, lectus tellus tempus felis, a ultricies erat ipsum at metus.
|
11
|
+
|
12
|
+
h2. Litora Sociis
|
13
|
+
|
14
|
+
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi et risus. Aliquam nisl. Nulla facilisi. Cras accumsan vestibulum ante. Vestibulum sed tortor. Praesent tempus fringilla elit. Ut elit diam, sagittis in, nonummy in, gravida non, nunc. Ut orci. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Nam egestas, orci eu imperdiet malesuada, nisl purus fringilla odio, quis commodo est orci vitae justo. Aliquam placerat odio tincidunt nulla. Cras in libero. Aenean rutrum, magna non tristique posuere, erat odio eleifend nisl, non convallis est tortor blandit ligula. Nulla id augue.
|
15
|
+
|
16
|
+
bq. Nullam mattis, odio ut tempus facilisis, metus nisl facilisis metus, auctor consectetuer felis ligula nec mauris. Vestibulum odio erat, fermentum at, commodo vitae, ultrices et, urna. Mauris vulputate, mi pulvinar sagittis condimentum, sem nulla aliquam velit, sed imperdiet mi purus eu magna. Nulla varius metus ut eros. Aenean aliquet magna eget orci. Class aptent taciti sociosqu ad litora.
|
17
|
+
|
18
|
+
Vivamus euismod. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Suspendisse vel nibh ut turpis dictum sagittis. Aliquam vel velit a elit auctor sollicitudin. Nam vel dui vel neque lacinia pretium. Quisque nunc erat, venenatis id, volutpat ut, scelerisque sed, diam. Mauris ante. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec mattis. Morbi dignissim sollicitudin libero. Nulla lorem.
|
19
|
+
|
@@ -0,0 +1,61 @@
|
|
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
|
+
<!--[if IE]>
|
18
|
+
<link rel="stylesheet" href="/css/blueprint/ie.css" type="text/css" media="screen, projection">
|
19
|
+
<![endif]-->
|
20
|
+
|
21
|
+
<!-- CodeRay syntax highlighting CSS -->
|
22
|
+
<link rel="stylesheet" href="/css/coderay.css" type="text/css" />
|
23
|
+
|
24
|
+
<!-- Homepage CSS -->
|
25
|
+
<link rel="stylesheet" href="/css/site.css" type="text/css" media="screen, projection" />
|
26
|
+
</head>
|
27
|
+
<body>
|
28
|
+
|
29
|
+
<div class="container">
|
30
|
+
|
31
|
+
<div class="column span-20 prepend-2 append-2 first last" id="header">
|
32
|
+
<p class="title">A New Website</p>
|
33
|
+
<hr>
|
34
|
+
</div>
|
35
|
+
|
36
|
+
<div class="column span-15 prepend-2 first">
|
37
|
+
<%= @content %>
|
38
|
+
</div>
|
39
|
+
|
40
|
+
<div class="column span-5 append-2 last">
|
41
|
+
<h4>Sidebar</h4>
|
42
|
+
<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>
|
43
|
+
|
44
|
+
<div class="box">
|
45
|
+
<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>
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<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>
|
49
|
+
|
50
|
+
<h5>Incremental leading</h5>
|
51
|
+
<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>
|
52
|
+
</div>
|
53
|
+
|
54
|
+
<div class="column span-20 prepend-2 append-2 first last" id="footer">
|
55
|
+
<hr />
|
56
|
+
<p>This website was created with <a href="http://webby.rubyforge.org">Webby</a></p>
|
57
|
+
</div>
|
58
|
+
|
59
|
+
</div>
|
60
|
+
</body>
|
61
|
+
</html>
|
@@ -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,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,18 @@
|
|
1
|
+
---
|
2
|
+
title: <%= title %>
|
3
|
+
created_at: <%= Time.now.to_y %>
|
4
|
+
filter:
|
5
|
+
- erb
|
6
|
+
- textile
|
7
|
+
---
|
8
|
+
p(title). <%%= h(@page.title) %>
|
9
|
+
|
10
|
+
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc congue ipsum vestibulum libero. Aenean vitae justo. Nam eget tellus. Etiam convallis, est eu lobortis mattis, lectus tellus tempus felis, a ultricies erat ipsum at metus.
|
11
|
+
|
12
|
+
h2. Litora Sociis
|
13
|
+
|
14
|
+
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi et risus. Aliquam nisl. Nulla facilisi. Cras accumsan vestibulum ante. Vestibulum sed tortor. Praesent tempus fringilla elit. Ut elit diam, sagittis in, nonummy in, gravida non, nunc. Ut orci. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Nam egestas, orci eu imperdiet malesuada, nisl purus fringilla odio, quis commodo est orci vitae justo. Aliquam placerat odio tincidunt nulla. Cras in libero. Aenean rutrum, magna non tristique posuere, erat odio eleifend nisl, non convallis est tortor blandit ligula. Nulla id augue.
|
15
|
+
|
16
|
+
bq. Nullam mattis, odio ut tempus facilisis, metus nisl facilisis metus, auctor consectetuer felis ligula nec mauris. Vestibulum odio erat, fermentum at, commodo vitae, ultrices et, urna. Mauris vulputate, mi pulvinar sagittis condimentum, sem nulla aliquam velit, sed imperdiet mi purus eu magna. Nulla varius metus ut eros. Aenean aliquet magna eget orci. Class aptent taciti sociosqu ad litora.
|
17
|
+
|
18
|
+
Vivamus euismod. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Suspendisse vel nibh ut turpis dictum sagittis. Aliquam vel velit a elit auctor sollicitudin. Nam vel dui vel neque lacinia pretium. Quisque nunc erat, venenatis id, volutpat ut, scelerisque sed, diam. Mauris ante. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec mattis. Morbi dignissim sollicitudin libero. Nulla lorem.
|
@@ -0,0 +1,276 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'optparse'
|
3
|
+
require 'forwardable'
|
4
|
+
|
5
|
+
module Webby::Apps
|
6
|
+
|
7
|
+
# webby gen template site => creates the tmplate
|
8
|
+
# webby gen -h / --help
|
9
|
+
# webby gen => same as --help
|
10
|
+
#
|
11
|
+
|
12
|
+
class Generator
|
13
|
+
extend Forwardable
|
14
|
+
|
15
|
+
# Create a new Generator instance and run the +webby+ application given the
|
16
|
+
# command line _args_.
|
17
|
+
#
|
18
|
+
def self.run( args )
|
19
|
+
self.new.run args
|
20
|
+
end
|
21
|
+
|
22
|
+
attr_accessor :template, :site
|
23
|
+
attr_reader :options
|
24
|
+
|
25
|
+
# Initialize a new generator object.
|
26
|
+
#
|
27
|
+
def initialize( output = $stdout, input = $stdin )
|
28
|
+
@options = {}
|
29
|
+
@site = @template = nil
|
30
|
+
@output, @input = output, input
|
31
|
+
@journal = journal
|
32
|
+
end
|
33
|
+
|
34
|
+
def_delegators :@journal,
|
35
|
+
:exists, :create, :force, :skip, :identical
|
36
|
+
|
37
|
+
# Writes the given objects to the output destination. Each object is
|
38
|
+
# followed by a newline unless the object is a string with a newline
|
39
|
+
# already at the end.
|
40
|
+
#
|
41
|
+
def puts( *args )
|
42
|
+
@output.puts(*args)
|
43
|
+
end
|
44
|
+
|
45
|
+
# Writes the given objects to the output destination.
|
46
|
+
#
|
47
|
+
def print( *args )
|
48
|
+
@output.print(*args)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Reads a line text frim the input source.
|
52
|
+
#
|
53
|
+
def gets
|
54
|
+
@input.gets
|
55
|
+
end
|
56
|
+
|
57
|
+
# Run the generator executing the commands specified by the user on the
|
58
|
+
# command line.
|
59
|
+
#
|
60
|
+
def run( args )
|
61
|
+
parse args
|
62
|
+
create_site
|
63
|
+
end
|
64
|
+
|
65
|
+
# Parse out the command line options found in the args array.
|
66
|
+
#
|
67
|
+
def parse( args )
|
68
|
+
opts = OptionParser.new
|
69
|
+
opts.banner = 'Usage: webby-gen [options] template site'
|
70
|
+
|
71
|
+
opts.separator ''
|
72
|
+
opts.separator 'The webby-gen command is used to generate a site from a standard template.'
|
73
|
+
opts.separator 'A new site can be created, or an existing site can be added to or updated.'
|
74
|
+
|
75
|
+
opts.separator ''
|
76
|
+
opts.on('-f', '--force',
|
77
|
+
'overwrite files that already exist') {options[:collision] = :force}
|
78
|
+
opts.on('-s', '--skip',
|
79
|
+
'skip files that already exist') {options[:collision] = :skip}
|
80
|
+
opts.on('-u', '--update',
|
81
|
+
'update rake tasks for the site') {options[:update] = true}
|
82
|
+
opts.on('-p', '--pretend',
|
83
|
+
'run but do not make any changes') {options[:pretend] = true}
|
84
|
+
|
85
|
+
opts.separator ''
|
86
|
+
opts.on('-t', '--templates', 'list available templates') {
|
87
|
+
ary = templates.map {|t| ::File.basename(t)}
|
88
|
+
ary.delete 'webby'
|
89
|
+
puts "\nAvailable Templates"
|
90
|
+
puts " #{ary.join(', ')}"
|
91
|
+
puts
|
92
|
+
exit
|
93
|
+
}
|
94
|
+
|
95
|
+
opts.separator ''
|
96
|
+
opts.separator 'common options:'
|
97
|
+
|
98
|
+
opts.on( '-h', '--help', 'show this message' ) {puts opts; exit}
|
99
|
+
opts.on( '--version', 'show version' ) do
|
100
|
+
puts "Webby #{::Webby::VERSION}"
|
101
|
+
exit
|
102
|
+
end
|
103
|
+
|
104
|
+
# parse the command line arguments
|
105
|
+
opts.parse! args
|
106
|
+
tmpl, @site = args
|
107
|
+
|
108
|
+
# if no site was given, see if there is a Sitefile in the current
|
109
|
+
# directory
|
110
|
+
if site.nil?
|
111
|
+
self.site = '.' if test(?f, 'Sitefile')
|
112
|
+
end
|
113
|
+
|
114
|
+
# exit if comand line args are missing
|
115
|
+
if site.nil? or tmpl.nil?
|
116
|
+
puts opts
|
117
|
+
exit 1
|
118
|
+
end
|
119
|
+
|
120
|
+
templates.each {|t| self.template = t if t =~ %r/\/#{tmpl}$/}
|
121
|
+
if template.nil?
|
122
|
+
puts opts
|
123
|
+
abort "Could not find template '#{tmpl}'"
|
124
|
+
end
|
125
|
+
|
126
|
+
nil
|
127
|
+
end
|
128
|
+
|
129
|
+
# Returns +true+ if we are only going to pretend to do something. All the
|
130
|
+
# output messages will be written, but no changes will be made on the
|
131
|
+
# disc.
|
132
|
+
#
|
133
|
+
def pretend?
|
134
|
+
options[:pretend] == true
|
135
|
+
end
|
136
|
+
|
137
|
+
# Returns an array of available site templates.
|
138
|
+
#
|
139
|
+
def templates
|
140
|
+
Dir.glob(::Webby.path('examples') / '*').sort
|
141
|
+
end
|
142
|
+
|
143
|
+
# Create the site from the template specified by the user.
|
144
|
+
#
|
145
|
+
def create_site
|
146
|
+
files = site_files
|
147
|
+
|
148
|
+
# in update mode we only want to update the tasks directory
|
149
|
+
if options[:update]
|
150
|
+
FileUtils.mkdir_p site unless pretend?
|
151
|
+
mkdir 'tasks'
|
152
|
+
files['tasks'].sort.each {|file| cp file}
|
153
|
+
else
|
154
|
+
dirs = files.keys.concat %w[content layouts lib tasks templates]
|
155
|
+
dirs.sort!
|
156
|
+
dirs.uniq!
|
157
|
+
|
158
|
+
# create the directories first
|
159
|
+
dirs.each do |dir|
|
160
|
+
next if dir =~ %r/^output\/.*$/
|
161
|
+
mkdir dir
|
162
|
+
end
|
163
|
+
|
164
|
+
# and the create the files under each directory
|
165
|
+
dirs.each do |dir|
|
166
|
+
next if dir =~ %r/^output(\/.*)?$/
|
167
|
+
files[dir].sort.each {|file| cp file}
|
168
|
+
end
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
# Make a directory in the user specified site location. A message will be
|
173
|
+
# displayed to the screen indicating tha the directory is being created.
|
174
|
+
#
|
175
|
+
def mkdir( dir )
|
176
|
+
dir = dir.empty? ? site : site / dir
|
177
|
+
if test ?d, dir
|
178
|
+
exists dir
|
179
|
+
else
|
180
|
+
create dir
|
181
|
+
FileUtils.mkdir_p dir unless pretend?
|
182
|
+
end
|
183
|
+
end
|
184
|
+
|
185
|
+
# Copy a file from the template location to the user specified site
|
186
|
+
# location. A message will be displayed to the screen indicating tha the
|
187
|
+
# file is being created.
|
188
|
+
#
|
189
|
+
def cp( file )
|
190
|
+
src = template / file
|
191
|
+
dst = site / file
|
192
|
+
|
193
|
+
if test(?e, dst)
|
194
|
+
if identical?(src, dst)
|
195
|
+
identical(dst)
|
196
|
+
return
|
197
|
+
end
|
198
|
+
|
199
|
+
choice = case options[:collision]
|
200
|
+
when :force then :force
|
201
|
+
when :skip then :skip
|
202
|
+
else force_file_collision?( dst ) end
|
203
|
+
|
204
|
+
case choice
|
205
|
+
when :force then force(dst)
|
206
|
+
when :skip then skip(dst); return
|
207
|
+
else raise "Invalid collision choice: #{choice.inspect}" end
|
208
|
+
else
|
209
|
+
create(dst)
|
210
|
+
end
|
211
|
+
return if pretend?
|
212
|
+
|
213
|
+
FileUtils.cp(src, dst)
|
214
|
+
end
|
215
|
+
|
216
|
+
# Prints an abort message to the screen and then exits the Ruby
|
217
|
+
# interpreter. A non-zero return code is used to indicate an error.
|
218
|
+
#
|
219
|
+
def abort( msg )
|
220
|
+
puts "\nAborting!"
|
221
|
+
puts " #{msg}"
|
222
|
+
puts
|
223
|
+
exit 1
|
224
|
+
end
|
225
|
+
|
226
|
+
# Iterates over all the files in the template directory and stores them in
|
227
|
+
# a hash.
|
228
|
+
#
|
229
|
+
def site_files
|
230
|
+
exclude = %r/tmp$|bak$|~$|CVS|\.svn/o
|
231
|
+
|
232
|
+
rgxp = %r/\A#{template}\/?/o
|
233
|
+
paths = Hash.new {|h,k| h[k] = []}
|
234
|
+
|
235
|
+
Find.find(template) do |p|
|
236
|
+
next if exclude =~ p
|
237
|
+
|
238
|
+
if test(?d, p)
|
239
|
+
paths[p.sub(rgxp, '')]
|
240
|
+
next
|
241
|
+
end
|
242
|
+
dir = ::File.dirname(p).sub(rgxp, '')
|
243
|
+
paths[dir] << p.sub(rgxp, '')
|
244
|
+
end
|
245
|
+
|
246
|
+
paths
|
247
|
+
end
|
248
|
+
|
249
|
+
# Returns +true+ if the source file is identical to the destination file.
|
250
|
+
# Returns +false+ if this is not the case.
|
251
|
+
#
|
252
|
+
def identical?( src, dst )
|
253
|
+
source = IO.read(src)
|
254
|
+
destination = IO.read(dst)
|
255
|
+
source == destination
|
256
|
+
end
|
257
|
+
|
258
|
+
# Ask the user what to do about the file collision.
|
259
|
+
#
|
260
|
+
def force_file_collision?( dst )
|
261
|
+
dst = dst.sub(%r/#{site}\/?/, '')
|
262
|
+
print "overwrite #{dst}? [(Y)es (n)o (q)uit] "
|
263
|
+
case gets
|
264
|
+
when %r/q/i then abort 'user asked to quit'
|
265
|
+
when %r/n/i then :skip
|
266
|
+
when %r/y/i then :force
|
267
|
+
when %r/\s*/ then :force
|
268
|
+
else force_file_collision?(dst) end
|
269
|
+
rescue
|
270
|
+
retry
|
271
|
+
end
|
272
|
+
|
273
|
+
end # class Generator
|
274
|
+
end # module Webby::Apps
|
275
|
+
|
276
|
+
# EOF
|
@@ -0,0 +1,258 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
module Webby::Apps
|
5
|
+
|
6
|
+
class Main
|
7
|
+
|
8
|
+
# Create a new instance of Main, and run the +webby+ application given the
|
9
|
+
# command line _args_.
|
10
|
+
#
|
11
|
+
def self.run( args )
|
12
|
+
self.new.run args
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader :cmd_line_options
|
16
|
+
|
17
|
+
# Create a new Main webby object for building websites.
|
18
|
+
#
|
19
|
+
def initialize
|
20
|
+
@stdout = $stdout
|
21
|
+
@cmd_line_options = {}
|
22
|
+
end
|
23
|
+
|
24
|
+
# Runs the main webby application. The command line arguments are passed
|
25
|
+
# in to this method as an array of strings. The command line arguments are
|
26
|
+
# parsed to figure out which rake task to invoke.
|
27
|
+
#
|
28
|
+
def run( args )
|
29
|
+
args = args.dup
|
30
|
+
|
31
|
+
parse args
|
32
|
+
init args
|
33
|
+
rake
|
34
|
+
end
|
35
|
+
|
36
|
+
# Parse the command line _args_ for options and commands to invoke.
|
37
|
+
#
|
38
|
+
def parse( args )
|
39
|
+
opts = OptionParser.new
|
40
|
+
opts.banner = 'Usage: webby [options] target [target args]'
|
41
|
+
|
42
|
+
opts.separator ''
|
43
|
+
|
44
|
+
desired_opts = %[--describe --prereqs --tasks --trace]
|
45
|
+
app.standard_rake_options.each do |options|
|
46
|
+
next unless desired_opts.include?(options.first)
|
47
|
+
opts.on(*options)
|
48
|
+
end
|
49
|
+
|
50
|
+
opts.separator ''
|
51
|
+
opts.separator 'autobuild options:'
|
52
|
+
|
53
|
+
opts.on('--web-server', 'Start a local web server') {
|
54
|
+
cmd_line_options[:use_web_server] = true
|
55
|
+
}
|
56
|
+
opts.on('--no-web-server', 'Do not start a local web server') {
|
57
|
+
cmd_line_options[:use_web_server] = false
|
58
|
+
}
|
59
|
+
|
60
|
+
opts.separator ''
|
61
|
+
opts.separator 'common options:'
|
62
|
+
|
63
|
+
opts.on_tail( '-h', '--help', 'show this message' ) do
|
64
|
+
@stdout.puts opts
|
65
|
+
exit
|
66
|
+
end
|
67
|
+
opts.on_tail( '--version', 'show version' ) do
|
68
|
+
@stdout.puts "Webby #{::Webby::VERSION}"
|
69
|
+
exit
|
70
|
+
end
|
71
|
+
|
72
|
+
opts.parse! args
|
73
|
+
|
74
|
+
ARGV.replace Array(args.shift)
|
75
|
+
args.delete_if do |arg|
|
76
|
+
if %r/^[A-Z_]+=/ =~ arg
|
77
|
+
ARGV << arg
|
78
|
+
next true
|
79
|
+
end
|
80
|
+
false
|
81
|
+
end
|
82
|
+
|
83
|
+
args
|
84
|
+
end
|
85
|
+
|
86
|
+
# Initialize the Rake application object and load the core rake tasks, the
|
87
|
+
# site specific rake tasks, and the site specific ruby code. Any extra
|
88
|
+
# command line arguments are converted into a page name and directory that
|
89
|
+
# might get created (depending upon the task invoked).
|
90
|
+
#
|
91
|
+
def init( args )
|
92
|
+
# Make sure we're in a folder with a Sitefile
|
93
|
+
options = app.standard_rake_options
|
94
|
+
[['--rakefile', 'Sitefile'],
|
95
|
+
['--no-search', nil],
|
96
|
+
['--silent', nil]].each {|opt, value| options.assoc(opt).last.call(value)}
|
97
|
+
|
98
|
+
unless app.have_rakefile
|
99
|
+
raise RuntimeError, "Sitefile not found"
|
100
|
+
end
|
101
|
+
|
102
|
+
import_default_tasks
|
103
|
+
import_website_tasks
|
104
|
+
require_lib_files
|
105
|
+
capture_command_line_args(args)
|
106
|
+
args
|
107
|
+
end
|
108
|
+
|
109
|
+
# Execute the rake command.
|
110
|
+
#
|
111
|
+
def rake
|
112
|
+
app.init 'webby'
|
113
|
+
app.load_rakefile
|
114
|
+
load_command_line_options
|
115
|
+
app.top_level
|
116
|
+
end
|
117
|
+
|
118
|
+
# Return the Rake application object.
|
119
|
+
#
|
120
|
+
def app
|
121
|
+
Rake.application
|
122
|
+
end
|
123
|
+
|
124
|
+
# Returns the options hash from the Rake application object.
|
125
|
+
#
|
126
|
+
def options
|
127
|
+
app.options
|
128
|
+
end
|
129
|
+
|
130
|
+
# Search for the "Sitefile" starting in the current directory and working
|
131
|
+
# upwards through the filesystem until the root of the filesystem is
|
132
|
+
# reached. If a "Sitefile" is not found, a RuntimeError is raised.
|
133
|
+
#
|
134
|
+
def find_sitefile
|
135
|
+
here = Dir.pwd
|
136
|
+
while ! app.have_rakefile
|
137
|
+
Dir.chdir("..")
|
138
|
+
if Dir.pwd == here || options.nosearch
|
139
|
+
fail "No Sitefile found"
|
140
|
+
end
|
141
|
+
here = Dir.pwd
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def import_default_tasks
|
146
|
+
Dir.glob(::Webby.libpath(%w[webby tasks *.rake])).sort.each {|fn| import fn}
|
147
|
+
end
|
148
|
+
|
149
|
+
def import_website_tasks
|
150
|
+
Dir.glob(::File.join(%w[tasks *.rake])).sort.each {|fn| import fn}
|
151
|
+
end
|
152
|
+
|
153
|
+
def require_lib_files
|
154
|
+
Dir.glob(::File.join(%w[lib ** *.rb])).sort.each {|fn| require fn}
|
155
|
+
end
|
156
|
+
|
157
|
+
def capture_command_line_args(args)
|
158
|
+
args = OpenStruct.new(
|
159
|
+
:raw => args,
|
160
|
+
:rake => ARGV.dup
|
161
|
+
)
|
162
|
+
|
163
|
+
if args.raw.size > 1
|
164
|
+
::Webby.deprecated "multiple arguments used for page title",
|
165
|
+
"please quote the page title"
|
166
|
+
end
|
167
|
+
|
168
|
+
dashed = args.raw.join('-').downcase
|
169
|
+
spaced = args.raw.join(' ')
|
170
|
+
dir = ::File.dirname(dashed)
|
171
|
+
|
172
|
+
args.dir = ('.' == dir ? '' : dir)
|
173
|
+
args.slug = ::Webby::Resources.basename(dashed).to_url
|
174
|
+
args.title = ::Webby::Resources.basename(spaced).titlecase
|
175
|
+
|
176
|
+
# page should be dir/slug without leading /
|
177
|
+
args.page = ::File.join(args.dir, args.slug).gsub(/^\//, '')
|
178
|
+
|
179
|
+
ext = ::File.extname(dashed)
|
180
|
+
args.page << ext unless ext.empty?
|
181
|
+
|
182
|
+
::Webby.site.args = args
|
183
|
+
Object.const_set(:SITE, Webby.site)
|
184
|
+
args
|
185
|
+
end
|
186
|
+
|
187
|
+
# Load options from the command line into the ::Webby.site struct
|
188
|
+
#
|
189
|
+
def load_command_line_options
|
190
|
+
cmd_line_options.each do |key, value|
|
191
|
+
::Webby.site.__send__("#{key}=", value)
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
end # class Main
|
196
|
+
end # module Webby::Apps
|
197
|
+
|
198
|
+
# :stopdoc:
|
199
|
+
# Monkey patches so that rake displays the correct application name in the
|
200
|
+
# help messages.
|
201
|
+
#
|
202
|
+
class Rake::Application
|
203
|
+
def display_prerequisites
|
204
|
+
tasks.each do |t|
|
205
|
+
puts "#{name} #{t.name}"
|
206
|
+
t.prerequisites.each { |pre| puts " #{pre}" }
|
207
|
+
end
|
208
|
+
end
|
209
|
+
|
210
|
+
def display_tasks_and_comments
|
211
|
+
displayable_tasks = tasks.select { |t|
|
212
|
+
t.comment && t.name =~ options.show_task_pattern
|
213
|
+
}
|
214
|
+
if options.full_description
|
215
|
+
displayable_tasks.each do |t|
|
216
|
+
puts "#{name} #{t.name_with_args}"
|
217
|
+
t.full_comment.split("\n").each do |line|
|
218
|
+
puts " #{line}"
|
219
|
+
end
|
220
|
+
puts
|
221
|
+
end
|
222
|
+
else
|
223
|
+
width = displayable_tasks.collect { |t| t.name_with_args.length }.max || 10
|
224
|
+
max_column = truncate_output? ? terminal_width - name.size - width - 7 : nil
|
225
|
+
displayable_tasks.each do |t|
|
226
|
+
printf "#{name} %-#{width}s # %s\n",
|
227
|
+
t.name_with_args, max_column ? truncate(t.comment, max_column) : t.comment
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
# Provide standard execption handling for the given block.
|
233
|
+
def standard_exception_handling
|
234
|
+
begin
|
235
|
+
yield
|
236
|
+
rescue SystemExit => ex
|
237
|
+
# Exit silently with current status
|
238
|
+
exit(ex.status)
|
239
|
+
rescue SystemExit, OptionParser::InvalidOption => ex
|
240
|
+
# Exit silently
|
241
|
+
exit(1)
|
242
|
+
rescue Exception => ex
|
243
|
+
# Exit with error message
|
244
|
+
$stderr.puts "#{name} aborted!"
|
245
|
+
$stderr.puts ex.message
|
246
|
+
if options.trace
|
247
|
+
$stderr.puts ex.backtrace.join("\n")
|
248
|
+
else
|
249
|
+
$stderr.puts ex.backtrace.find {|str| str =~ /#{@rakefile}/ } || ""
|
250
|
+
$stderr.puts "(See full trace by running task with --trace)"
|
251
|
+
end
|
252
|
+
exit(1)
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end # class Rake::Application
|
256
|
+
# :startdoc:
|
257
|
+
|
258
|
+
# EOF
|