webby 0.7.4 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/History.txt +19 -0
  2. data/Manifest.txt +19 -6
  3. data/README.txt +21 -5
  4. data/Rakefile +2 -3
  5. data/data/Rakefile +1 -1
  6. data/data/lib/breadcrumbs.rb +28 -0
  7. data/data/tasks/create.rake +0 -1
  8. data/data/tasks/deploy.rake +0 -1
  9. data/data/tasks/growl.rake +0 -1
  10. data/data/tasks/heel.rake +2 -3
  11. data/data/tasks/setup.rb +0 -1
  12. data/data/templates/_partial.erb +10 -0
  13. data/data/templates/atom_feed.erb +34 -0
  14. data/examples/webby/content/manual/index.txt +11 -13
  15. data/examples/webby/content/tutorial/index.txt +1 -1
  16. data/examples/webby/tasks/heel.rake +2 -2
  17. data/examples/webby/tasks/setup.rb +6 -1
  18. data/lib/webby.rb +50 -23
  19. data/lib/webby/auto_builder.rb +4 -2
  20. data/lib/webby/builder.rb +6 -5
  21. data/lib/webby/filters.rb +6 -7
  22. data/lib/webby/filters/outline.rb +4 -2
  23. data/lib/webby/filters/tidy.rb +4 -2
  24. data/lib/webby/helpers.rb +32 -0
  25. data/lib/webby/helpers/coderay_helper.rb +78 -0
  26. data/lib/webby/helpers/graphviz_helper.rb +158 -0
  27. data/lib/webby/helpers/tag_helper.rb +9 -4
  28. data/lib/webby/helpers/tex_img_helper.rb +181 -0
  29. data/lib/webby/helpers/url_helper.rb +12 -11
  30. data/lib/webby/renderer.rb +97 -18
  31. data/lib/webby/resources.rb +82 -0
  32. data/lib/webby/{pages_db.rb → resources/db.rb} +63 -33
  33. data/lib/webby/{file.rb → resources/file.rb} +27 -24
  34. data/lib/webby/resources/layout.rb +65 -0
  35. data/lib/webby/resources/page.rb +109 -0
  36. data/lib/webby/resources/partial.rb +81 -0
  37. data/lib/webby/resources/resource.rb +145 -0
  38. data/lib/webby/resources/static.rb +54 -0
  39. data/lib/webby/stelan/mktemp.rb +137 -0
  40. data/lib/webby/stelan/spawner.rb +5 -1
  41. data/lib/webby/utils.rb +3 -1
  42. data/lib/webby/webby_task.rb +43 -24
  43. data/spec/spec_helper.rb +12 -1
  44. data/spec/webby/{file_spec.rb → resources/file_spec.rb} +21 -22
  45. data/tasks/ann.rake +76 -0
  46. data/tasks/annotations.rake +6 -14
  47. data/tasks/bones.rake +40 -0
  48. data/tasks/doc.rake +1 -2
  49. data/tasks/gem.rake +29 -2
  50. data/tasks/manifest.rake +15 -21
  51. data/tasks/post_load.rake +22 -8
  52. data/tasks/setup.rb +53 -15
  53. data/tasks/spec.rake +13 -0
  54. metadata +22 -9
  55. data/lib/webby/filters/coderay.rb +0 -98
  56. data/lib/webby/filters/graphviz.rb +0 -189
  57. data/lib/webby/resource.rb +0 -293
@@ -1,15 +1,9 @@
1
- # $Id: webby_task.rb 106 2008-01-25 04:58:49Z tim_pease $
1
+ # $Id: webby_task.rb 173 2008-02-27 02:58:43Z tim_pease $
2
2
 
3
- begin
4
- require 'rake'
5
- require 'rake/tasklib'
6
- rescue LoadError
7
- require 'rubygems'
8
- raise unless gem 'rake'
9
- retry
10
- end
3
+ require 'rake'
4
+ require 'rake/tasklib'
11
5
 
12
- module Rake
6
+ module Rake # :nodoc:
13
7
 
14
8
  # The WebbyTask defines several rake tasks for working with Webby based
15
9
  # websites:
@@ -80,6 +74,8 @@ class WebbyTask < TaskLib
80
74
  end
81
75
  end
82
76
 
77
+ # TODO: modify creation task to handle folders of pages/partials
78
+
83
79
  # Scans the templates directory for any files, and creats a corresponding
84
80
  # task for creating a new page based on that template.
85
81
  #
@@ -87,25 +83,48 @@ class WebbyTask < TaskLib
87
83
  FileList["#{::Webby.site.template_dir}/*"].each do |template|
88
84
  name = template.pathmap '%n'
89
85
 
90
- desc "create a new #{name}"
91
- task name do |t|
92
- raise "Usage: rake #{t.name} path" unless ARGV.length == 2
86
+ # if the file is a partial template
87
+ if name =~ %r/^_(.*)/
88
+ name = $1
89
+ desc "create a new #{name}"
90
+ task name do |t|
91
+ raise "Usage: rake #{t.name} path" unless ARGV.length == 2
93
92
 
94
- page = t.application.top_level_tasks.pop
95
- name = ::Webby::File.basename(page)
96
- ext = ::Webby::File.extname(page)
97
- dir = ::Webby::File.dirname(page)
93
+ page = t.application.top_level_tasks.pop
94
+ name = '_' + ::Webby::Resources::File.basename(page)
95
+ ext = ::Webby::Resources::File.extname(page)
96
+ dir = ::File.dirname(page)
97
+ dir = '' if dir == '.'
98
98
 
99
- if ::Webby.site.create_mode == 'directory'
100
- page = ::File.join(::Webby.site.content_dir, name, 'index')
99
+ page = ::File.join(::Webby.site.content_dir, dir, name)
101
100
  page << '.' << (ext.empty? ? 'txt' : ext)
102
- else
103
- page = ::File.join(::Webby.site.content_dir, page)
104
- page << '.txt' if ext.empty?
101
+
102
+ ::Webby::Builder.create page, :from => template
105
103
  end
106
104
 
107
- ::Webby::Builder.create page, :from => template
108
- end # task
105
+ # otherwise it's a normal file
106
+ else
107
+ desc "create a new #{name}"
108
+ task name do |t|
109
+ raise "Usage: rake #{t.name} path" unless ARGV.length == 2
110
+
111
+ page = t.application.top_level_tasks.pop
112
+ name = ::Webby::Resources::File.basename(page)
113
+ ext = ::Webby::Resources::File.extname(page)
114
+ dir = ::File.dirname(page)
115
+ dir = '' if dir == '.'
116
+
117
+ if ::Webby.site.create_mode == 'directory'
118
+ page = ::File.join(::Webby.site.content_dir, dir, name, 'index')
119
+ page << '.' << (ext.empty? ? 'txt' : ext)
120
+ else
121
+ page = ::File.join(::Webby.site.content_dir, page)
122
+ page << '.txt' if ext.empty?
123
+ end
124
+
125
+ ::Webby::Builder.create page, :from => template
126
+ end # task
127
+ end
109
128
  end # each
110
129
  end
111
130
 
data/spec/spec_helper.rb CHANGED
@@ -1,6 +1,17 @@
1
- # $Id: spec_helper.rb 83 2007-12-30 02:22:02Z tim_pease $
1
+ # $Id: spec_helper.rb 155 2008-02-17 00:48:30Z tim_pease $
2
+
3
+ # Equivalent to a header guard in C/C++
4
+ # Used to prevent the spec helper from being loaded more than once
5
+ unless defined? WEBBY_SPEC_HELPER
6
+ WEBBY_SPEC_HELPER = true
7
+
8
+ require 'rubygems'
9
+ require 'fileutils'
2
10
 
3
11
  require File.expand_path(
4
12
  File.join(File.dirname(__FILE__), '..', 'lib', 'webby'))
5
13
 
14
+
15
+ end # unless defined?
16
+
6
17
  # EOF
@@ -1,11 +1,11 @@
1
- # $Id: file_spec.rb 46 2007-11-27 03:31:29Z tim_pease $
1
+ # $Id: file_spec.rb 167 2008-02-24 00:59:54Z tim_pease $
2
2
 
3
- require 'spec/spec_helper.rb'
4
- require 'fileutils'
3
+ require ::File.join(::File.dirname(__FILE__), %w[.. .. spec_helper])
5
4
 
6
- describe Webby::File do
5
+ # ---------------------------------------------------------------------------
6
+ describe Webby::Resources::File do
7
7
 
8
- FN = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'lorem_ipsum.txt'))
8
+ FN = ::File.expand_path(::File.join(::File.dirname(__FILE__), '..', '..', 'lorem_ipsum.txt'))
9
9
  FN_YAML = FN.gsub %r/\.txt\z/, '_yaml.txt'
10
10
  LINES = [
11
11
  "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla orci\n",
@@ -21,22 +21,22 @@ describe Webby::File do
21
21
  ]
22
22
 
23
23
  before do
24
- File.open(FN,'w') {|fd| fd.write LINES}
25
- File.open(FN_YAML,'w') do |fd|
24
+ ::File.open(FN,'w') {|fd| fd.write LINES}
25
+ ::File.open(FN_YAML,'w') do |fd|
26
26
  fd.write "--- \n- one\n- two\n- three\n--- \n"
27
27
  fd.write LINES
28
28
  end
29
29
  end
30
30
 
31
31
  after do
32
- File.delete FN if File.exists?(FN)
33
- File.delete FN_YAML if File.exists?(FN_YAML)
32
+ ::FileUtils.rm_f(FN)
33
+ ::FileUtils.rm_f(FN_YAML)
34
34
  end
35
35
 
36
36
  it 'should return nil for meta-data on regular files' do
37
37
  begin
38
- fd = Webby::File.new FN, 'r'
39
- fd.meta_data.should == nil
38
+ fd = Webby::Resources::File.new FN, 'r'
39
+ fd.meta_data.should be_nil
40
40
 
41
41
  fd.readlines.should == LINES
42
42
  ensure
@@ -45,16 +45,16 @@ describe Webby::File do
45
45
  end
46
46
 
47
47
  it 'should add meta-data to the top of a file' do
48
- Webby::File.open(FN,'a+') do |fd|
49
- fd.meta_data.should == nil
48
+ Webby::Resources::File.open(FN,'a+') do |fd|
49
+ fd.meta_data.should be_nil
50
50
  fd.meta_data = %w(one two three)
51
51
  end
52
52
 
53
- Webby::File.open(FN,'r') do |fd|
53
+ Webby::Resources::File.open(FN,'r') do |fd|
54
54
  fd.meta_data.should == %w(one two three)
55
55
  end
56
56
 
57
- File.open(FN_YAML, 'r') do |fd|
57
+ ::File.open(FN_YAML, 'r') do |fd|
58
58
  ary = LINES.dup
59
59
  ary.insert 0, [
60
60
  "--- \n",
@@ -68,23 +68,23 @@ describe Webby::File do
68
68
  end
69
69
 
70
70
  it 'should remove the meta-data when set to nil' do
71
- Webby::File.open(FN_YAML,'a+') do |fd|
71
+ Webby::Resources::File.open(FN_YAML,'a+') do |fd|
72
72
  fd.meta_data.should == %w(one two three)
73
73
  fd.meta_data = nil
74
74
  end
75
75
 
76
- Webby::File.open(FN_YAML,'r') do |fd|
77
- fd.meta_data.should == nil
76
+ Webby::Resources::File.open(FN_YAML,'r') do |fd|
77
+ fd.meta_data.should be_nil
78
78
  end
79
79
 
80
- File.open(FN_YAML, 'r') do |fd|
80
+ ::File.open(FN_YAML, 'r') do |fd|
81
81
  fd.readlines.should == LINES
82
82
  end
83
83
  end
84
84
 
85
85
  it 'should skip the meta-data when reading from the file' do
86
86
  begin
87
- fd = Webby::File.new FN_YAML, 'r'
87
+ fd = Webby::Resources::File.new FN_YAML, 'r'
88
88
  fd.meta_data.should == %w(one two three)
89
89
 
90
90
  fd.getc.should == ?L; fd.seek 0
@@ -100,7 +100,6 @@ describe Webby::File do
100
100
  fd.close
101
101
  end
102
102
  end
103
-
104
- end # describe Webby::File
103
+ end # describe Webby::Resources::File
105
104
 
106
105
  # EOF
data/tasks/ann.rake ADDED
@@ -0,0 +1,76 @@
1
+ # $Id$
2
+
3
+ begin
4
+ require 'bones/smtp_tls'
5
+ rescue LoadError
6
+ require 'net/smtp'
7
+ end
8
+ require 'time'
9
+
10
+ namespace :ann do
11
+
12
+ file PROJ.ann_file do
13
+ puts "Generating #{PROJ.ann_file}"
14
+ File.open(PROJ.ann_file,'w') do |fd|
15
+ fd.puts("#{PROJ.name} version #{PROJ.version}")
16
+ fd.puts(" by #{Array(PROJ.authors).first}") if PROJ.authors
17
+ fd.puts(" #{PROJ.url}") if PROJ.url
18
+ fd.puts(" (the \"#{PROJ.release_name}\" release)") if PROJ.release_name
19
+ fd.puts
20
+ fd.puts("== DESCRIPTION")
21
+ fd.puts
22
+ fd.puts(PROJ.description)
23
+ fd.puts
24
+ fd.puts(PROJ.changes.sub(%r/^.*$/, '== CHANGES'))
25
+ fd.puts
26
+ PROJ.ann_paragraphs.each do |p|
27
+ fd.puts "== #{p.upcase}"
28
+ fd.puts
29
+ fd.puts paragraphs_of(PROJ.readme_file, p).join("\n\n")
30
+ fd.puts
31
+ end
32
+ fd.puts PROJ.ann_text if PROJ.ann_text
33
+ end
34
+ end
35
+
36
+ desc "Create an announcement file"
37
+ task :announcement => PROJ.ann_file
38
+
39
+ desc "Send an email announcement"
40
+ task :email => PROJ.ann_file do
41
+ from = PROJ.ann_email[:from] || PROJ.email
42
+ to = Array(PROJ.ann_email[:to])
43
+
44
+ ### build a mail header for RFC 822
45
+ rfc822msg = "From: #{from}\n"
46
+ rfc822msg << "To: #{to.join(',')}\n"
47
+ rfc822msg << "Subject: [ANN] #{PROJ.name} #{PROJ.version}"
48
+ rfc822msg << " (#{PROJ.release_name})" if PROJ.release_name
49
+ rfc822msg << "\n"
50
+ rfc822msg << "Date: #{Time.new.rfc822}\n"
51
+ rfc822msg << "Message-Id: "
52
+ rfc822msg << "<#{"%.8f" % Time.now.to_f}@#{PROJ.ann_email[:domain]}>\n\n"
53
+ rfc822msg << File.read(PROJ.ann_file)
54
+
55
+ params = [:server, :port, :domain, :acct, :passwd, :authtype].map do |key|
56
+ PROJ.ann_email[key]
57
+ end
58
+
59
+ params[3] = PROJ.email if params[3].nil?
60
+
61
+ if params[4].nil?
62
+ STDOUT.write "Please enter your e-mail password (#{params[3]}): "
63
+ params[4] = STDIN.gets.chomp
64
+ end
65
+
66
+ ### send email
67
+ Net::SMTP.start(*params) {|smtp| smtp.sendmail(rfc822msg, from, to)}
68
+ end
69
+ end # namespace :ann
70
+
71
+ desc 'Alias to ann:announcement'
72
+ task :ann => 'ann:announcement'
73
+
74
+ CLOBBER << PROJ.ann_file
75
+
76
+ # EOF
@@ -5,23 +5,15 @@ if HAVE_BONES
5
5
  desc "Enumerate all annotations"
6
6
  task :notes do
7
7
  Bones::AnnotationExtractor.enumerate(
8
- PROJ, "OPTIMIZE|FIXME|TODO", :tag => true)
8
+ PROJ, PROJ.annotation_tags.join('|'), :tag => true)
9
9
  end
10
10
 
11
11
  namespace :notes do
12
- desc "Enumerate all OPTIMIZE annotations"
13
- task :optimize do
14
- Bones::AnnotationExtractor.enumerate(PROJ, "OPTIMIZE")
15
- end
16
-
17
- desc "Enumerate all FIXME annotations"
18
- task :fixme do
19
- Bones::AnnotationExtractor.enumerate(PROJ, "FIXME")
20
- end
21
-
22
- desc "Enumerate all TODO annotations"
23
- task :todo do
24
- Bones::AnnotationExtractor.enumerate(PROJ, "TODO")
12
+ PROJ.annotation_tags.each do |tag|
13
+ desc "Enumerate all #{tag} annotations"
14
+ task tag.downcase.to_sym do
15
+ Bones::AnnotationExtractor.enumerate(PROJ, tag)
16
+ end
25
17
  end
26
18
  end
27
19
 
data/tasks/bones.rake ADDED
@@ -0,0 +1,40 @@
1
+ # $Id$
2
+
3
+ require 'pp'
4
+ require 'stringio'
5
+
6
+ namespace :bones do
7
+
8
+ desc 'Show the PROJ open struct'
9
+ task :debug do |t|
10
+ atr = if ARGV.length == 2
11
+ t.application.top_level_tasks.pop
12
+ end
13
+ sio = StringIO.new
14
+ sep = "\n" + ' '*27
15
+ fmt = "%23s => %s"
16
+
17
+ if atr
18
+ PP.pp(PROJ.send(atr.to_sym), sio, 49)
19
+ sio.seek 0
20
+ val = sio.read
21
+ val = val.split("\n").join(sep)
22
+
23
+ puts fmt % [atr, val]
24
+ else
25
+ h = PROJ.instance_variable_get(:@table)
26
+ h.keys.map {|k| k.to_s}.sort.each do |k|
27
+ sio.truncate 0
28
+ PP.pp(h[k.to_sym], sio, 49)
29
+ sio.seek 0
30
+ val = sio.read
31
+ val = val.split("\n").join(sep)
32
+
33
+ puts fmt % [k, val]
34
+ end
35
+ end
36
+ end
37
+
38
+ end # namespace :bones
39
+
40
+ # EOF
data/tasks/doc.rake CHANGED
@@ -31,7 +31,6 @@ namespace :doc do
31
31
  sh "#{RDOC} --ri -o ri ."
32
32
  end
33
33
 
34
- desc 'Remove ri products'
35
34
  task :clobber_ri do
36
35
  rm_r 'ri' rescue nil
37
36
  end
@@ -44,6 +43,6 @@ task :doc => 'doc:rdoc'
44
43
  desc 'Remove all build products'
45
44
  task :clobber => %w(doc:clobber_rdoc doc:clobber_ri)
46
45
 
47
- remove_desc_for_task %w(doc:clobber_rdoc doc:clobber_ri)
46
+ remove_desc_for_task %w(doc:clobber_rdoc)
48
47
 
49
48
  # EOF
data/tasks/gem.rake CHANGED
@@ -12,6 +12,7 @@ namespace :gem do
12
12
  s.email = PROJ.email
13
13
  s.homepage = Array(PROJ.url).first
14
14
  s.rubyforge_project = PROJ.rubyforge_name
15
+ s.post_install_message = PROJ.post_install_message
15
16
 
16
17
  s.description = PROJ.description
17
18
 
@@ -62,9 +63,29 @@ namespace :gem do
62
63
  puts PROJ.spec.to_ruby
63
64
  end
64
65
 
65
- Rake::GemPackageTask.new(PROJ.spec) do |pkg|
66
+ pkg = Rake::PackageTask.new(PROJ.name, PROJ.version) do |pkg|
66
67
  pkg.need_tar = PROJ.need_tar
67
68
  pkg.need_zip = PROJ.need_zip
69
+ pkg.package_files += PROJ.spec.files
70
+ end
71
+ Rake::Task['gem:package'].instance_variable_set(:@full_comment, nil)
72
+
73
+ gem_file = if PROJ.spec.platform == Gem::Platform::RUBY
74
+ "#{pkg.package_name}.gem"
75
+ else
76
+ "#{pkg.package_name}-#{PROJ.spec.platform}.gem"
77
+ end
78
+
79
+ desc "Build the gem file #{gem_file}"
80
+ task :package => "#{pkg.package_dir}/#{gem_file}"
81
+
82
+ file "#{pkg.package_dir}/#{gem_file}" => [pkg.package_dir] + PROJ.spec.files do
83
+ when_writing("Creating GEM") {
84
+ Gem::Builder.new(PROJ.spec).build
85
+ verbose(true) {
86
+ mv gem_file, "#{pkg.package_dir}/#{gem_file}"
87
+ }
88
+ }
68
89
  end
69
90
 
70
91
  desc 'Install the gem'
@@ -74,9 +95,15 @@ namespace :gem do
74
95
 
75
96
  desc 'Uninstall the gem'
76
97
  task :uninstall do
77
- sh "#{SUDO} #{GEM} uninstall -v '#{PROJ.version}' -x #{PROJ.name}"
98
+ installed_list = Gem.source_index.find_name(PROJ.name)
99
+ if installed_list and installed_list.collect { |s| s.version.to_s}.include?(PROJ.version) then
100
+ sh "#{SUDO} #{GEM} uninstall -v '#{PROJ.version}' -i -x #{PROJ.name}"
101
+ end
78
102
  end
79
103
 
104
+ desc 'Reinstall the gem'
105
+ task :reinstall => [:uninstall, :install]
106
+
80
107
  end # namespace :gem
81
108
 
82
109
  desc 'Alias to gem:package'
data/tasks/manifest.rake CHANGED
@@ -6,18 +6,11 @@ namespace :manifest do
6
6
 
7
7
  desc 'Verify the manifest'
8
8
  task :check do
9
- fn = 'Manifest.tmp'
10
- files = []
11
- exclude = Regexp.new(PROJ.exclude.join('|'))
12
- Find.find '.' do |path|
13
- path.sub! %r/^(\.\/|\/)/o, ''
14
- next unless test ?f, path
15
- next if path =~ exclude
16
- files << path
17
- end
9
+ fn = PROJ.manifest_file + '.tmp'
10
+ files = manifest_files
18
11
 
19
- File.open(fn, 'w') {|fp| fp.puts files.sort}
20
- lines = %x(#{DIFF} -du Manifest.txt #{fn}).split("\n")
12
+ File.open(fn, 'w') {|fp| fp.puts files}
13
+ lines = %x(#{DIFF} -du #{PROJ.manifest_file} #{fn}).split("\n")
21
14
  if HAVE_FACETS_ANSICODE and ENV.has_key?('TERM')
22
15
  lines.map! do |line|
23
16
  case line
@@ -34,19 +27,20 @@ namespace :manifest do
34
27
 
35
28
  desc 'Create a new manifest'
36
29
  task :create do
37
- fn = 'Manifest.txt'
38
- files = []
39
- exclude = Regexp.new(PROJ.exclude.join('|'))
40
- Find.find '.' do |path|
41
- path.sub! %r/^(\.\/|\/)/o, ''
42
- next unless test ?f, path
43
- next if path =~ exclude
44
- files << path
30
+ files = manifest_files
31
+ unless test(?f, PROJ.manifest_file)
32
+ files << PROJ.manifest_file
33
+ files.sort!
45
34
  end
35
+ File.open(PROJ.manifest_file, 'w') {|fp| fp.puts files}
36
+ end
46
37
 
47
- files << fn unless test ?f, fn
48
- File.open(fn, 'w') {|fp| fp.puts files.sort}
38
+ task :assert do
39
+ files = manifest_files
40
+ manifest = File.read(PROJ.manifest_file).split($/)
41
+ raise "ERROR: #{PROJ.manifest_file} is out of date" unless files == manifest
49
42
  end
43
+
50
44
  end # namespace :manifest
51
45
 
52
46
  desc 'Alias to manifest:check'