webby 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ == 0.5.0 / 2007-11-26
2
+
3
+ * Launching heel now works on Windows boxen
4
+ * Now using "logging" gem to output build status
5
+ * Updated find routine for the pages DB
6
+ * First whack at pagination support
7
+
1
8
  == 0.4.0 / 2007-09-18
2
9
 
3
10
  * Updated the Blueprint CSS stylesheets to version 0.5
data/Manifest.txt CHANGED
@@ -23,6 +23,7 @@ data/content/index.txt
23
23
  data/layouts/default.rhtml
24
24
  data/tasks/create.rake
25
25
  data/tasks/deploy.rake
26
+ data/tasks/growl.rake
26
27
  data/tasks/heel.rake
27
28
  data/tasks/setup.rb
28
29
  data/templates/page.erb
@@ -35,6 +36,8 @@ lib/webby/main.rb
35
36
  lib/webby/pages_db.rb
36
37
  lib/webby/renderer.rb
37
38
  lib/webby/resource.rb
39
+ lib/webby/stelan/paginator.rb
40
+ lib/webby/stelan/spawner.rb
38
41
  lib/webby/utils.rb
39
42
  lib/webby/webby_task.rb
40
43
  spec/spec.opts
@@ -59,15 +62,18 @@ website/content/css/blueprint/lib/reset.css
59
62
  website/content/css/blueprint/lib/typography.css
60
63
  website/content/css/blueprint/print.css
61
64
  website/content/css/blueprint/screen.css
65
+ website/content/css/coderay.css
62
66
  website/content/css/site.css
63
67
  website/content/download.txt
64
68
  website/content/index.txt
65
69
  website/content/manual.txt
70
+ website/content/robots.txt
66
71
  website/content/tips_and_tricks.txt
67
72
  website/content/tutorial.txt
68
73
  website/layouts/default.rhtml
69
74
  website/tasks/create.rake
70
75
  website/tasks/deploy.rake
76
+ website/tasks/growl.rake
71
77
  website/tasks/heel.rake
72
78
  website/tasks/setup.rb
73
79
  website/templates/page.erb
data/README.txt CHANGED
@@ -8,7 +8,7 @@ Webby
8
8
 
9
9
  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.
10
10
 
11
- Webby works by combining the contents of a *page* with a *layout* to produce HTML. The layout contains everthing 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.
11
+ 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.
12
12
 
13
13
  Install Webby and try it out!
14
14
 
@@ -23,7 +23,7 @@ Install Webby and try it out!
23
23
 
24
24
  But Wait! There's More!
25
25
 
26
- Webby has a great _autobuild_ feature that continously 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.
26
+ 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.
27
27
 
28
28
  $ rake autobuild
29
29
  heel --root output --daemonize
@@ -46,11 +46,11 @@ Webby is not limited to producing HTML. By no means! Do you ever get tired of re
46
46
 
47
47
  $ cd my_site
48
48
 
49
- $ rake create:page new_page.rhtml
50
- creating content/new_page.rhtml
49
+ $ rake create:page new_page.txt
50
+ creating content/new_page.txt
51
51
 
52
- $ rake create:page another/new_page.rhtml
53
- creating content/another/new_page.rhtml
52
+ $ rake create:page another/new_page.txt
53
+ creating content/another/new_page.txt
54
54
 
55
55
  $ rake autobuild
56
56
  heel --root output --daemonize
@@ -62,11 +62,12 @@ Webby is not limited to producing HTML. By no means! Do you ever get tired of re
62
62
 
63
63
  == REQUIREMENTS:
64
64
 
65
- * rake
66
- * rspec
67
65
  * directory_watcher
68
- * hpricot
69
66
  * heel
67
+ * hpricot
68
+ * logging
69
+ * rake
70
+ * rspec
70
71
 
71
72
  == LICENSE:
72
73
 
data/Rakefile CHANGED
@@ -18,6 +18,7 @@ PROJ.rdoc_remote_dir = 'rdoc'
18
18
  PROJ.version = Webby::VERSION
19
19
 
20
20
  PROJ.exclude << '^(\.\/|\/)?website/output'
21
+ PROJ.exclude << '^(\.\/|\/)?doc'
21
22
  PROJ.rdoc_exclude << '^(\.\/|\/)?data'
22
23
  PROJ.rdoc_exclude << '^(\.\/|\/)?website'
23
24
 
@@ -26,6 +27,7 @@ PROJ.spec_opts << '--color'
26
27
  depend_on 'directory_watcher', '1.0.0'
27
28
  depend_on 'heel'
28
29
  depend_on 'hpricot'
30
+ depend_on 'logging', '0.5.1'
29
31
  depend_on 'rspec'
30
32
 
31
33
  # EOF
data/bin/webby CHANGED
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  begin
4
+ require 'rubygems'
4
5
  require 'webby'
5
6
  rescue LoadError
6
7
  path = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
@@ -0,0 +1,59 @@
1
+ ---
2
+ extension: css
3
+ filter: erb
4
+ layout: nil # no layout
5
+
6
+ color:
7
+ border: "#ddd"
8
+ header: "#111"
9
+ link: "#125AA7"
10
+ link-hover: "#000"
11
+ blockquote: "#666"
12
+ box-bg: "#eee"
13
+ highlight: "#B2CCFF"
14
+ quiet: "#666"
15
+ alt: "#666"
16
+ ---
17
+
18
+ body {
19
+ font-family: Verdana, "Bitstream Vera Sans", sans-serif;
20
+ }
21
+
22
+ /* Headings
23
+ * --------------------------------------------------------------------- */
24
+ h1,h2,h3,h4,h5,h6 { color: <%= @page.color['header'] %>; }
25
+
26
+ /* Text Elements
27
+ * --------------------------------------------------------------------- */
28
+ a { color: <%= @page.color['link'] %>; }
29
+ a:hover { color: <%= @page.color['link-hover'] %>; }
30
+ blockquote { color: <%= @page.color['blockquote'] %>; }
31
+
32
+ pre {
33
+ background: <%= @page.color['box-bg'] %>;
34
+ border: 1px solid <%= @page.color['border'] %>;
35
+ }
36
+
37
+ hr {
38
+ background: <%= @page.color['highlight'] %>;
39
+ color: <%= @page.color['highlight'] %>;
40
+ }
41
+
42
+ /* Tables
43
+ * --------------------------------------------------------------------- */
44
+ table {
45
+ border-top: 1px solid <%= @page.color['border'] %>;
46
+ border-left: 1px solid <%= @page.color['border'] %>;
47
+ }
48
+ th,td {
49
+ border-bottom: 1px solid <%= @page.color['border'] %>;
50
+ border-right: 1px solid <%= @page.color['border'] %>;
51
+ }
52
+
53
+ /* Default Classes
54
+ * --------------------------------------------------------------------- */
55
+ p.quiet { color: <%= @page.color['quiet'] %>; }
56
+ .alt { color: <%= @page.color['alt'] %>; }
57
+
58
+
59
+ /* EOF */
@@ -7,34 +7,34 @@ filter: erb
7
7
 
8
8
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en-us">
9
9
  <head>
10
- <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
11
11
  <title><%= @page.title %></title>
12
12
  <meta name="author" content="<%= @page.author %>" />
13
13
 
14
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" />
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
17
 
18
18
  <!-- CodeRay syntax highlighting CSS -->
19
- <link rel="stylesheet" href="css/coderay.css" type="text/css" />
19
+ <link rel="stylesheet" href="/css/coderay.css" type="text/css" />
20
20
 
21
21
  <!-- Homepage CSS -->
22
- <link rel="stylesheet" href="css/site.css" type="text/css" media="screen, projection" />
22
+ <link rel="stylesheet" href="/css/site.css" type="text/css" media="screen, projection" />
23
23
  </head>
24
24
  <body>
25
25
 
26
26
  <div class="container">
27
27
 
28
- <div class="column span-11 prepend-1 first last">
28
+ <div class="column span-18 prepend-2 append-4 first last" id="header">
29
29
  <h2>A New Website</h2>
30
30
  <hr>
31
31
  </div>
32
32
 
33
- <div class="column span-8 prepend-1 first">
33
+ <div class="column span-15 prepend-2 first">
34
34
  <%= @content %>
35
35
  </div>
36
36
 
37
- <div class="column span-3 last">
37
+ <div class="column span-3 append-4 last">
38
38
  <h4>Sidebar</h4>
39
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
40
 
@@ -48,7 +48,7 @@ filter: erb
48
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
49
  </div>
50
50
 
51
- <div class="column span-11 prepend-1 first last">
51
+ <div class="column span-18 prepend-2 append-4 first last" id="footer">
52
52
  <hr />
53
53
  <p>This website was created with <a href="http://webby.rubyforge.org">Webby</a></p>
54
54
  </div>
@@ -10,3 +10,4 @@ Rake::WebbyTask.new do |webby|
10
10
  webby.page_defaults = SITE.page_defaults
11
11
  end
12
12
 
13
+ # EOF
@@ -0,0 +1,12 @@
1
+
2
+ desc 'send log events to Growl (Mac OS X only)'
3
+ task :growl do
4
+ Logging::Logger['Webby'].add(Logging::Appenders::Growl.new(
5
+ "Webby",
6
+ :layout => Logging::Layouts::Pattern.new(:pattern => "%5l - Webby\000%m"),
7
+ :coalesce => true,
8
+ :separator => "\000"
9
+ ))
10
+ end
11
+
12
+ # EOF
data/data/tasks/heel.rake CHANGED
@@ -3,18 +3,24 @@ if HAVE_HEEL
3
3
 
4
4
  namespace :heel do
5
5
 
6
- desc 'start the heel server to view website'
7
- task :run do
6
+ desc 'start the heel server to view website (not for Windows)'
7
+ task :start do
8
8
  sh "heel --root #{SITE.output_dir} --daemonize"
9
9
  end
10
-
10
+
11
11
  desc 'stop the heel server'
12
- task :kill do
12
+ task :stop do
13
13
  sh "heel --kill"
14
14
  end
15
15
 
16
- task :autobuild => :run do
17
- at_exit {sh "heel --kill"}
16
+ task :autorun do
17
+ heel_exe = File.join(Gem.bindir, 'heel')
18
+ @heel_spawner = Spawner.new(Spawner.ruby, heel_exe, '--root', SITE.output_dir, :pause => 86_400)
19
+ @heel_spawner.start
20
+ end
21
+
22
+ task :autobuild => :autorun do
23
+ at_exit {@heel_spawner.stop if defined? @heel_spawner and not @heel_spawner.nil?}
18
24
  end
19
25
 
20
26
  end
data/lib/webby.rb CHANGED
@@ -1,8 +1,19 @@
1
- # $Id: webby.rb 29 2007-09-18 18:14:50Z tim_pease $
1
+ # $Id: webby.rb 41 2007-10-15 20:44:21Z tim_pease $
2
+
3
+ require 'logging'
4
+
5
+ # Configure Webby to log to STDOUT at the 'info' level
6
+ Logging::Appender.stdout.layout = Logging::Layouts::Pattern.new(
7
+ :pattern => "[%d] %5l: %m\n", # [date] LEVEL: message
8
+ :date_pattern => "%H:%M:%S" # date == HH:MM:SS
9
+ )
10
+ Logging::Logger['Webby'].add(Logging::Appender.stdout)
11
+ Logging::Logger['Webby'].level = :info
12
+
2
13
 
3
14
  module Webby
4
15
 
5
- VERSION = '0.4.0' # :nodoc:
16
+ VERSION = '0.5.0' # :nodoc:
6
17
 
7
18
  # Path to the Webby package
8
19
  PATH = ::File.expand_path(::File.join(::File.dirname(__FILE__), '..'))
@@ -52,6 +63,28 @@ module Webby
52
63
  }
53
64
  end
54
65
 
66
+ # call-seq
67
+ # Webby.exclude => regexp
68
+ #
69
+ # Returns a regular expression used to exclude resources from the content
70
+ # directory from being processed by Webby. This same regular expression is
71
+ # also used to exclude layouts.
72
+ #
73
+ def self.exclude
74
+ @exclude ||= Regexp.new(config['exclude'].join('|'))
75
+ end
76
+
77
+ # call-seq:
78
+ # cairn => filename
79
+ #
80
+ # The Webby _cairn_ file is used to mark the last time the content was
81
+ # built into the output directory. It is an empty file; only the
82
+ # modification time of the file is important.
83
+ #
84
+ def self.cairn
85
+ @cairn ||= File.join(config['output_dir'], '.cairn')
86
+ end
87
+
55
88
  end # module Webby
56
89
 
57
90
 
@@ -1,4 +1,4 @@
1
- # $Id: auto_builder.rb 5 2007-08-22 04:25:49Z tim_pease $
1
+ # $Id: auto_builder.rb 40 2007-10-14 03:54:36Z tim_pease $
2
2
 
3
3
  require 'directory_watcher'
4
4
 
@@ -27,6 +27,9 @@ class AutoBuilder
27
27
  # Create a new AutoBuilder class.
28
28
  #
29
29
  def initialize
30
+ @log = Logging::Logger[self]
31
+
32
+ @builder = Builder.new
30
33
  @watcher = DirectoryWatcher.new '.', :interval => 2
31
34
  @watcher.add_observer self
32
35
 
@@ -47,11 +50,16 @@ class AutoBuilder
47
50
  ary = events.find_all {|evt| evt.type != :removed}
48
51
  return if ary.empty?
49
52
 
50
- print '- started at '
51
- puts Time.now.strftime('%H:%M:%S')
52
- Builder.run
53
+ ary.each do |evt|
54
+ @log.debug "changed #{evt.path}"
55
+ next unless test ?f, evt.path
56
+ next if evt.path =~ ::Webby.exclude
57
+ Resource.new evt.path
58
+ end
59
+
60
+ @builder.run :load_files => false
53
61
  rescue => err
54
- puts err.message
62
+ @log.error err
55
63
  end
56
64
 
57
65
  # call-seq:
@@ -61,7 +69,7 @@ class AutoBuilder
61
69
  # Ctrl-C to stop the watcher thread.
62
70
  #
63
71
  def run
64
- puts '-- starting autobuild (Ctrl-C to stop)'
72
+ @log.info 'starting autobuild (Ctrl-C to stop)'
65
73
 
66
74
  Signal.trap('INT') {@watcher.stop}
67
75
 
data/lib/webby/builder.rb CHANGED
@@ -1,4 +1,4 @@
1
- # $Id: builder.rb 16 2007-08-25 19:55:00Z tim_pease $
1
+ # $Id: builder.rb 46 2007-11-27 03:31:29Z tim_pease $
2
2
 
3
3
  require 'find'
4
4
  require 'fileutils'
@@ -38,7 +38,7 @@ class Builder
38
38
  raise Error, "template not given" unless tmpl
39
39
  raise Error, "#{page} already exists" if test ?e, page
40
40
 
41
- puts "creating #{page}"
41
+ Logging::Logger[self].info "creating #{page}"
42
42
  FileUtils.mkdir_p File.dirname(page)
43
43
  str = ERB.new(::File.read(tmpl), nil, '-').result
44
44
  ::File.open(page, 'w') {|fd| fd.write str}
@@ -48,7 +48,17 @@ class Builder
48
48
  end # class << self
49
49
 
50
50
  # call-seq:
51
- # run( :rebuild => false )
51
+ # Builder.new
52
+ #
53
+ # Creates a new Builder object for creating pages from the content and
54
+ # layout directories.
55
+ #
56
+ def initialize
57
+ @log = Logging::Logger[self]
58
+ end
59
+
60
+ # call-seq:
61
+ # run( :rebuild => false, :load_files => true )
52
62
  #
53
63
  # Runs the Webby builder by loading in the layout files from the
54
64
  # <code>layouts/</code> folder and the content from the
@@ -70,19 +80,20 @@ class Builder
70
80
  # more recently than the output file.
71
81
  #
72
82
  def run( opts = {} )
73
- Resource.clear
83
+ opts[:load_files] = true unless opts.has_key?(:load_files)
74
84
 
75
85
  unless test(?d, output_dir)
76
- puts "creating #{output_dir}"
86
+ @log.info "creating #{output_dir}"
77
87
  FileUtils.mkdir output_dir
78
88
  end
79
89
 
80
- load_files
90
+ load_files if opts[:load_files]
91
+ loop_check
81
92
 
82
93
  Resource.pages.each do |page|
83
94
  next unless page.dirty? or opts[:rebuild]
84
95
 
85
- puts "creating #{page.destination}"
96
+ @log.info "creating #{page.destination}"
86
97
 
87
98
  # make sure the directory exists
88
99
  FileUtils.mkdir_p ::File.dirname(page.destination)
@@ -93,18 +104,13 @@ class Builder
93
104
 
94
105
  # otherwise, layout the resource and write the results to
95
106
  # the output directory
96
- else
97
- ::File.open(page.destination, 'w') do |fd|
98
- fd.write Renderer.new(page).layout_page
99
- end
100
- end
107
+ else Renderer.write(page) end
101
108
  end
102
109
 
103
- # touch the output directory so we know when the
104
- # website was last generated
105
- FileUtils.touch output_dir
110
+ # touch the cairn so we know when the website was last generated
111
+ FileUtils.touch ::Webby.cairn
106
112
 
107
- return nil
113
+ nil
108
114
  end
109
115
 
110
116
 
@@ -114,18 +120,20 @@ class Builder
114
120
  # folder and create a new Resource object for each file found there.
115
121
  #
116
122
  def load_files
117
- excl = Regexp.new exclude.join('|')
118
-
119
123
  ::Find.find(layout_dir, content_dir) do |path|
120
124
  next unless test ?f, path
121
- next if path =~ excl
125
+ next if path =~ ::Webby.exclude
122
126
  Resource.new path
123
127
  end
128
+ end
124
129
 
130
+ # Loop over all the layout resources looking for circular reference -- a
131
+ # layout that eventually refers back to itself. These are bad. Raise an
132
+ # error if one is detected.
133
+ #
134
+ def loop_check
125
135
  layouts = Resource.layouts
126
136
 
127
- # look for loops in the layout references -- i.e. a layout
128
- # eventually refers back to itself
129
137
  layouts.each do |lyt|
130
138
  stack = []
131
139
  while lyt
@@ -135,12 +143,12 @@ class Builder
135
143
  "loop detected in layout references: #{stack.join(' > ')}"
136
144
  end
137
145
  stack << lyt.filename
138
- lyt = layouts.find_by_name lyt.layout
146
+ lyt = layouts.find :filename => lyt.layout
139
147
  end # while
140
148
  end # each
141
149
  end
142
150
 
143
- %w(output_dir layout_dir content_dir exclude).each do |key|
151
+ %w(output_dir layout_dir content_dir).each do |key|
144
152
  self.class_eval <<-CODE
145
153
  def #{key}( ) ::Webby.config['#{key}'] end
146
154
  CODE