webby 0.7.1 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. data/History.txt +15 -0
  2. data/Manifest.txt +21 -15
  3. data/Rakefile +4 -2
  4. data/data/content/css/blueprint/compressed/print.css +76 -0
  5. data/data/content/css/blueprint/compressed/screen.css +696 -0
  6. data/data/content/css/blueprint/lib/forms.css +45 -0
  7. data/data/content/css/blueprint/lib/grid.css +95 -51
  8. data/data/content/css/blueprint/lib/grid.png +0 -0
  9. data/data/content/css/blueprint/lib/ie.css +30 -0
  10. data/data/content/css/blueprint/lib/reset.css +11 -12
  11. data/data/content/css/blueprint/lib/typography.css +69 -114
  12. data/data/content/css/blueprint/plugins/buttons/Readme +31 -0
  13. data/data/content/css/blueprint/{lib → plugins/buttons}/buttons.css +17 -32
  14. data/data/content/css/blueprint/{lib/img → plugins/buttons}/icons/cross.png +0 -0
  15. data/data/content/css/blueprint/{lib/img/icons/textfield_key.png → plugins/buttons/icons/key.png} +0 -0
  16. data/data/content/css/blueprint/{lib/img → plugins/buttons}/icons/tick.png +0 -0
  17. data/data/content/css/blueprint/plugins/css-classes/Readme +14 -0
  18. data/data/content/css/blueprint/plugins/css-classes/css-classes.css +24 -0
  19. data/data/content/css/blueprint/plugins/fancy-type/Readme +22 -0
  20. data/data/content/css/blueprint/plugins/fancy-type/fancy-type-compressed.css +5 -0
  21. data/data/content/css/blueprint/plugins/fancy-type/fancy-type.css +74 -0
  22. data/data/content/css/blueprint/print.css +35 -46
  23. data/data/content/css/blueprint/screen.css +10 -18
  24. data/data/content/css/site.css +8 -0
  25. data/data/content/index.txt +2 -2
  26. data/data/layouts/default.rhtml +4 -4
  27. data/data/templates/page.erb +3 -3
  28. data/examples/webby/content/css/blueprint/print.css +58 -61
  29. data/examples/webby/content/css/blueprint/screen.css +696 -30
  30. data/examples/webby/content/css/site.css +63 -45
  31. data/examples/webby/content/index.txt +2 -2
  32. data/examples/webby/content/manual.txt +366 -15
  33. data/examples/webby/content/script/jquery.corner.js +152 -0
  34. data/examples/webby/content/script/jquery.js +31 -0
  35. data/examples/webby/content/tips_and_tricks.txt +2 -2
  36. data/examples/webby/content/tutorial.txt +5 -5
  37. data/examples/webby/layouts/default.rhtml +19 -10
  38. data/examples/webby/templates/page.erb +5 -3
  39. data/lib/webby.rb +25 -3
  40. data/lib/webby/filters/basepath.rb +97 -0
  41. data/lib/webby/filters/coderay.rb +2 -2
  42. data/lib/webby/filters/graphviz.rb +10 -10
  43. data/lib/webby/filters/haml.rb +3 -7
  44. data/lib/webby/filters/outline.rb +194 -0
  45. data/lib/webby/helpers/tag_helper.rb +14 -13
  46. data/lib/webby/helpers/url_helper.rb +84 -13
  47. data/lib/webby/pages_db.rb +15 -8
  48. data/lib/webby/renderer.rb +2 -2
  49. data/lib/webby/resource.rb +6 -6
  50. data/lib/webby/utils.rb +17 -1
  51. data/lib/webby/webby_task.rb +20 -7
  52. data/tasks/annotations.rake +1 -1
  53. data/tasks/doc.rake +2 -2
  54. data/tasks/gem.rake +3 -3
  55. data/tasks/manifest.rake +5 -2
  56. data/tasks/post_load.rake +18 -0
  57. data/tasks/rubyforge.rake +1 -1
  58. data/tasks/setup.rb +56 -11
  59. data/tasks/spec.rake +4 -1
  60. data/tasks/svn.rake +44 -0
  61. data/tasks/website.rake +2 -2
  62. metadata +33 -18
  63. data/data/content/css/blueprint/lib/compressed.css +0 -137
  64. data/data/content/css/blueprint/lib/img/grid.png +0 -0
  65. data/examples/webby/content/css/blueprint/lib/buttons.css +0 -112
  66. data/examples/webby/content/css/blueprint/lib/compressed.css +0 -137
  67. data/examples/webby/content/css/blueprint/lib/grid.css +0 -149
  68. data/examples/webby/content/css/blueprint/lib/img/grid.png +0 -0
  69. data/examples/webby/content/css/blueprint/lib/img/icons/cross.png +0 -0
  70. data/examples/webby/content/css/blueprint/lib/img/icons/textfield_key.png +0 -0
  71. data/examples/webby/content/css/blueprint/lib/img/icons/tick.png +0 -0
  72. data/examples/webby/content/css/blueprint/lib/reset.css +0 -40
  73. data/examples/webby/content/css/blueprint/lib/typography.css +0 -161
@@ -1,4 +1,4 @@
1
- # $Id: coderay.rb 68 2007-12-09 07:45:37Z tim_pease $
1
+ # $Id: coderay.rb 113 2008-01-26 23:09:13Z tim_pease $
2
2
 
3
3
  require 'enumerator'
4
4
  require 'hpricot'
@@ -25,7 +25,7 @@ module Filters
25
25
  # The supported CodeRay options are the following:
26
26
  #
27
27
  # lang : the language to highlight (ruby, c, html, ...)
28
- # line_numbers : include line nubers in 'table', 'inline',
28
+ # line_numbers : include line numbers in 'table', 'inline',
29
29
  # or 'list'
30
30
  # line_number_start : where to start with line number counting
31
31
  # bold_every : make every n-th number appear bold
@@ -1,4 +1,4 @@
1
- # $Id: graphviz.rb 71 2007-12-13 05:45:53Z tim_pease $
1
+ # $Id: graphviz.rb 113 2008-01-26 23:09:13Z tim_pease $
2
2
 
3
3
  require 'hpricot'
4
4
  require 'fileutils'
@@ -25,9 +25,9 @@ module Filters
25
25
  # }
26
26
  # </graphviz>
27
27
  #
28
- # If the DOT script contains *URL* or *href* cursorments on any of the nodes
28
+ # If the DOT script contains *URL* or *href* attributes on any of the nodes
29
29
  # or edges, then an image map will be generated and the image will be
30
- # "clikcable" in the webpage. If *URL* or *href* cursorments do not appear in
30
+ # "clikcable" in the webpage. If *URL* or *href* attributes do not appear in
31
31
  # the DOT script, then a regular image will be inserted into the webpage.
32
32
  #
33
33
  # The image is inserted into the page using an HTML <img /> tag. A
@@ -108,8 +108,8 @@ class Graphviz
108
108
 
109
109
  # generate the image filename based on the path, graph name, and type
110
110
  # of image to generate
111
- image_fn = path.nil? ? name.dup : File.join(path, name)
112
- image_fn = File.join('', image_fn) << '.' << type
111
+ image_fn = path.nil? ? name.dup : ::File.join(path, name)
112
+ image_fn = ::File.join('', image_fn) << '.' << type
113
113
 
114
114
  # create the HTML img tag
115
115
  out = "<img src=\"#{image_fn}\""
@@ -119,7 +119,7 @@ class Graphviz
119
119
  out << " %s=\"%s\"" % [attr, gviz[attr]]
120
120
  end
121
121
 
122
- out << " usemap=\"#{name}\"" if usemap
122
+ out << " usemap=\"\##{name}\"" if usemap
123
123
  out << " />\n"
124
124
 
125
125
  # generate the image map if needed
@@ -135,8 +135,8 @@ class Graphviz
135
135
  # generate the image using graphviz -- but first ensure that the
136
136
  # path exists
137
137
  out_dir = ::Webby.site.output_dir
138
- out_file = File.join(out_dir, image_fn)
139
- FileUtils.mkpath(File.join(out_dir, path)) unless path.nil?
138
+ out_file = ::File.join(out_dir, image_fn)
139
+ FileUtils.mkpath(::File.join(out_dir, path)) unless path.nil?
140
140
  cmd = "#{cmd} -T#{type} -o #{out_file} 2> #{@err.path}"
141
141
 
142
142
  IO.popen(cmd, 'w') {|io| io.write text}
@@ -169,8 +169,8 @@ class Graphviz
169
169
  # and log an error message and raise an exception.
170
170
  #
171
171
  def error_check
172
- if File.size(@err.path) != 0
173
- msg = "\n" << File.read(@err.path).strip
172
+ if ::File.size(@err.path) != 0
173
+ msg = "\n" << ::File.read(@err.path).strip
174
174
  raise Error, msg
175
175
  end
176
176
  end
@@ -1,16 +1,12 @@
1
- # $Id: haml.rb 68 2007-12-09 07:45:37Z tim_pease $
1
+ # $Id: haml.rb 112 2008-01-26 05:31:48Z tim_pease $
2
2
 
3
3
  try_require 'haml'
4
4
 
5
5
  # Render text via the Haml library
6
6
  Webby::Filters.register :haml do |input, cursor|
7
7
  opts = cursor.page.haml_options || {}
8
- opts[:locals] ||= {}
9
- opts[:locals].merge!(
10
- :page => cursor.renderer.page,
11
- :pages => cursor.renderer.pages
12
- )
13
- Haml::Engine.new(input, opts).to_html
8
+ b = cursor.renderer.get_binding
9
+ Haml::Engine.new(input, opts).to_html(b)
14
10
  end
15
11
 
16
12
  # EOF
@@ -0,0 +1,194 @@
1
+ # $Id: outline.rb 124 2008-02-03 00:24:10Z tim_pease $
2
+
3
+ require 'hpricot'
4
+
5
+ module Webby
6
+ module Filters
7
+
8
+ # The Outline filter is used to insert outline numbering into HTML heading
9
+ # tags (h1, h2, h3, etc.) and to generate a table of contents based on the
10
+ # heading tags. The table of contents is inserted into the page at the
11
+ # location of the <toc /> tag. If there is no <toc /> tag, then a table of
12
+ # contents will not be created but outline numbering will still take place.
13
+ #
14
+ # If a table of contents is desired without outline number being inserted
15
+ # into the heading tags, this can be specified in the attibutes of the
16
+ # <toc /> tag itself.
17
+ #
18
+ # <toc outline_numbering="off" />
19
+ #
20
+ # This will generate a table of contents, but not insert outline numbering
21
+ # into the heading tags.
22
+ #
23
+ # The Outline filter will only work on valid HTML or XHTML pages. Therefore
24
+ # it should be used after any markup langauge filters (textile, markdown,
25
+ # etc.).
26
+ #
27
+ class Outline
28
+
29
+ class Error < StandardError; end # :nodoc:
30
+
31
+ # call-seq:
32
+ # Outline.new( html )
33
+ #
34
+ # Creates a new outline filter that will operate on the given
35
+ # _html_ string.
36
+ #
37
+ def initialize( str )
38
+ @str = str
39
+
40
+ @cur_level, @base_level, @cur_depth = nil
41
+ @level = [0] * 6
42
+ @h_rgxp = %r/^h(\d)$/o
43
+ @toc = []
44
+ @outline_numbering = true
45
+ end
46
+
47
+ # call-seq:
48
+ # filter => html
49
+ #
50
+ # Process the original html document passed to the filter when it was
51
+ # created. The document will be scanned for heading tags (h1, h2, etc.)
52
+ # and outline numbering and id attributes will be inserted. A table of
53
+ # contents will also be created and inserted into the page if a <toc />
54
+ # tag is found.
55
+ #
56
+ # For example, if there is a heading tag
57
+ #
58
+ # <h3>Get Fuzzy</h3>
59
+ #
60
+ # somewhere in a page about comic strips, the tag might be altered as such
61
+ #
62
+ # <h3 id="h2_2_1"><span class="heading-num>2.2.1</span>Get Fuzzy</h3>
63
+ #
64
+ # The id attribute is used to generate a linke from the table of contents
65
+ # to this particular heading tag. The original text of the tag is used in
66
+ # the table of contents -- "Get Fuzzy" in this example.
67
+ #
68
+ def filter
69
+ doc = Hpricot(@str)
70
+
71
+ # extract directives from the "toc" tag
72
+ toc_elem = doc.search('toc').first
73
+
74
+ unless toc_elem.nil?
75
+ @outline_numbering = toc_elem['outline_numbering'] !~ %r/off/i
76
+ end
77
+
78
+ doc.traverse_element(*%w[h1 h2 h3 h4 h5 h6]) do |elem|
79
+ text, id = heading_info(elem)
80
+ add_to_toc(text, id)
81
+ end
82
+
83
+ # create the TOC ordered list
84
+
85
+ toc_elem.swap(toc) unless toc_elem.nil?
86
+
87
+ # replace the "toc" tag with the ordered list
88
+
89
+ doc.to_html
90
+ end
91
+
92
+
93
+ private
94
+
95
+ # Returns information for the given heading element. The information is
96
+ # returned as a two element array: [text, id].
97
+ #
98
+ # This method will also insert outline numbering and an id attribute. The
99
+ # outline numbering can be disabled, but the id attribute must be present
100
+ # for TOC generation.
101
+ #
102
+ def heading_info( elem )
103
+ m = @h_rgxp.match(elem.name)
104
+ level = Integer(m[1])
105
+
106
+ self.current_level = level
107
+ text = elem.inner_text
108
+
109
+ lbl = label
110
+ if outline_numbering?
111
+ elem.children.first.before {tag!(:span, lbl, :class => 'heading-num')}
112
+ end
113
+ elem['id'] = "h#{lbl.tr('.','_')}" if elem['id'].nil?
114
+
115
+ return [text, elem['id']]
116
+ end
117
+
118
+ # Set the current heading level. This will set the label and depth as
119
+ # well. An error will be raised if the _level_ is less than the base
120
+ # heading level.
121
+ #
122
+ # The base heading level will be set to the _level_ if it has not already
123
+ # been set. Therefore, the first heading tag encountered defines the base
124
+ # heading level.
125
+ #
126
+ def current_level=( level )
127
+ @base_level ||= level
128
+ @cur_level ||= level
129
+
130
+ if level < @base_level
131
+ raise Error, "heading tags are not in order, cannot outline"
132
+ end
133
+
134
+ if level == @cur_level
135
+ @level[level-1] += 1
136
+ elsif level > @cur_level
137
+ @cur_level.upto(level-1) {|ii| @level[ii] += 1}
138
+ else
139
+ @cur_level.downto(level+1) {|ii| @level[ii-1] = 0}
140
+ @level[level-1] += 1
141
+ end
142
+
143
+ @cur_level = level
144
+ end
145
+
146
+ # Return the label string for the current heading level.
147
+ #
148
+ def label
149
+ rv = @level.dup
150
+ rv.delete(0)
151
+ rv.join('.')
152
+ end
153
+
154
+ # Return the nesting depth of the current heading level with respect to the
155
+ # base heading level. This is a one-based number.
156
+ #
157
+ def depth
158
+ @cur_level - @base_level + 1
159
+ end
160
+
161
+ # Add the given text and id reference to the table of contents.
162
+ #
163
+ def add_to_toc( text, id )
164
+ str = '#' * depth
165
+ str << ' ' << "\"#{text}\":##{id}"
166
+ @toc << str
167
+ end
168
+
169
+ # Returns the table of contents as a collection of nested ordered lists.
170
+ # This is fully formatted HTML.
171
+ #
172
+ def toc
173
+ RedCloth.new(@toc.join("\n"), %w(no_span_caps)).to_html
174
+ end
175
+
176
+ # Returns +true+ if outline numbering should be inserted into the heading
177
+ # tags. Returns +false+ otherwise.
178
+ #
179
+ def outline_numbering?
180
+ @outline_numbering
181
+ end
182
+ end # class Outline
183
+
184
+ # Generate a outline numbering and/or a table of contents in the input HTML
185
+ # text.
186
+ #
187
+ register :outline do |input|
188
+ Outline.new(input).filter
189
+ end
190
+
191
+ end # module Filters
192
+ end # module Webby
193
+
194
+ # EOF
@@ -37,22 +37,23 @@ module TagHelper
37
37
  end
38
38
 
39
39
  private
40
- def tag_options( options, escape = true )
41
- unless options.empty?
42
- attrs = []
43
- if escape
44
- options.each do |key, value|
45
- next if value.nil?
46
- key = key.to_s
47
- value = BOOLEAN_ATTRIBUTES.include?(key) ? key : escape_once(value)
48
- attrs << %Q(#{key}="#{value}")
49
- end
50
- else
51
- attrs = options.map {|key, value| %Q(#{key}="#{value}")}
40
+
41
+ def tag_options( options, escape = true )
42
+ unless options.empty?
43
+ attrs = []
44
+ if escape
45
+ options.each do |key, value|
46
+ next if value.nil?
47
+ key = key.to_s
48
+ value = BOOLEAN_ATTRIBUTES.include?(key) ? key : escape_once(value)
49
+ attrs << %Q(#{key}="#{value}")
52
50
  end
53
- %Q( #{attrs.sort * ' '}) unless attrs.empty?
51
+ else
52
+ attrs = options.map {|key, value| %Q(#{key}="#{value}")}
54
53
  end
54
+ %Q( #{attrs.sort * ' '}) unless attrs.empty?
55
55
  end
56
+ end
56
57
 
57
58
  end # module TagHelper
58
59
  end # module Helpers
@@ -1,4 +1,4 @@
1
- # $Id: url_helper.rb 75 2007-12-20 23:10:19Z tim_pease $
1
+ # $Id: url_helper.rb 103 2008-01-20 23:58:14Z tim_pease $
2
2
 
3
3
  module Webby
4
4
  module Helpers #:nodoc:
@@ -8,14 +8,30 @@ module Helpers #:nodoc:
8
8
  module UrlHelper
9
9
 
10
10
  # call-seq:
11
- # url_for( string, opts = {} )
12
- # url_for( page, opts ={} )
11
+ # url_for( name, opts = {} )
13
12
  #
14
- # Options
13
+ # Creates a URL for the given _name_ and _opts_. If _name_ is a string
14
+ # then it is used as the URL base. If _name_ is a Resource then it is
15
+ # converted to a URL by calling its +url+ method.
16
+ #
17
+ # ==== Options
15
18
  #
16
- # :escape => determins whether the returned URL will be HTML escaped
17
- # or not (+true+ by default)
18
- # :anchor => specifies the anchor name to be appended to the path
19
+ # * <tt>:escape</tt> -- determines whether the returned URL will be HTML escaped or not (+true+ by default)
20
+ # * <tt>:anchor</tt> -- specifies the anchor name to be appended to the path
21
+ #
22
+ # ==== Examples
23
+ #
24
+ # <%= url_for('/some/page.html') %>
25
+ # # => /some/page
26
+ #
27
+ # <%= url_for('/some/page.html', :anchor => 'tidbit') %>
28
+ # # => /some/page#tidbit
29
+ #
30
+ # <%= url_for(@page) %>
31
+ # # => /current/page.html
32
+ #
33
+ # <%= url_for(@page, :anchor => 'this&that') %>
34
+ # # => /current/page.html#this&amp;that
19
35
  #
20
36
  def url_for( *args )
21
37
  opts = Hash === args.last ? args.pop : {}
@@ -31,6 +47,22 @@ module UrlHelper
31
47
  return url
32
48
  end
33
49
 
50
+ # call-seq:
51
+ # url_for_page( :key => value, :url => {} )
52
+ #
53
+ # Creates a URL for the page identified by the set of <em>:key /
54
+ # value</em> pairs. The <em>:url</em> options are passed to the url_for
55
+ # method for final URL creation; see the url_for method for
56
+ # documentation on those options.
57
+ #
58
+ # The PagesDB#find method is used to locate the page; see the find method
59
+ # for the available options.
60
+ #
61
+ # ==== Examples
62
+ #
63
+ # <%= url_for_page(:title => 'Funny Story', :anchor => 'punchline') %>
64
+ # # => /humor/funny_story.html#punchline
65
+ #
34
66
  def url_for_page( opts = {} )
35
67
  opts = opts.symbolize_keys
36
68
  url_opts = opts.delete(:url)
@@ -42,7 +74,22 @@ module UrlHelper
42
74
  self.url_for(p, url_opts)
43
75
  end
44
76
 
77
+ # call-seq:
78
+ # link_to( name, url, :attrs => {} )
45
79
  #
80
+ # Create an HTTP anchor tag with
81
+ #
82
+ # url can be a url string, a page, :back, or nothing
83
+ #
84
+ # :attrs are used to generate HTML anchor tag attributes
85
+ #
86
+ # ==== Examples
87
+ #
88
+ # <%= link_to('Google', 'http://www.google.com/', :attrs => {:name => 'google'}) %>
89
+ # # => <a href="http://www.google.com/" name="google">Google</a>
90
+ #
91
+ # <%= link_to('A Page', @page, :anchor => 'blah') %>
92
+ # # => <a href="/a/page.html#blah">A Page</a>
46
93
  #
47
94
  def link_to( name, *args )
48
95
  opts = Hash === args.last ? args.pop : {}
@@ -50,9 +97,7 @@ module UrlHelper
50
97
  attrs = opts.delete(:attrs)
51
98
 
52
99
  url = case url
53
- when String
54
- url
55
- when Webby::Resource
100
+ when String, Webby::Resource
56
101
  self.url_for(url, opts)
57
102
  when :back
58
103
  'javascript:history.back()'
@@ -82,9 +127,8 @@ module UrlHelper
82
127
  # Creates a link tag of the given _name_ using a URL created by finding
83
128
  # the associated page from the key/value pairs. If the key/value pairs are
84
129
  # omitted, the _name_ is used in conjunction with the default site +find_by+
85
- # attribute. If the _name_ is omitted, then either the page +title+
86
- # attribute or the page +filename+ attribute is used as the name (in that
87
- # order of preference).
130
+ # attribute. Unless changed by the user, the default +find_by+ attribute
131
+ # is the page title.
88
132
  #
89
133
  # Pages are found using key/value pairs. The key is any of the page
90
134
  # attributes, and the value is what that attribute should be. Any number
@@ -108,11 +152,33 @@ module UrlHelper
108
152
  #
109
153
  # ==== Examples
110
154
  #
155
+ # <%= link_to_page('Funny Story', :url => {:anchor => 'punchline'}) %>
156
+ # # => <a href="/humor/funny_story.html#punchline">Funny Story</a>
157
+ #
158
+ # <%= link_to_page('Hilarious', :title => 'Funny Story') %>
159
+ # # => <a href="/humor/funn_story.html">Hilarious</a>
160
+ #
111
161
  def link_to_page( *args )
112
162
  self.link_to(*_find_page(args))
113
163
  end
114
164
 
165
+ # call-seq:
166
+ # link_to_page_unless_current( name )
167
+ # link_to_page_unless_current( :key => value )
168
+ # link_to_page_unless_current( name, :key => value )
169
+ # link_to_page_unless_current( page )
170
+ #
171
+ # This function operates in the same fashion as the +link_to_page+ fuction
172
+ # with the exception that if the page to be linked to is the current page,
173
+ # then only the _name_ is rendered without an HTML anchor tag.
174
+ #
175
+ # ==== Examples
115
176
  #
177
+ # <%= link_to_page_unless_current('Funny Story') %>
178
+ # # => <a href="/humor/funny_story.html">Funny Story</a>
179
+ #
180
+ # <%= link_to_page_unless_current(@page) %>
181
+ # # => This Page
116
182
  #
117
183
  def link_to_page_unless_current( *args )
118
184
  name, page, link_opts = _find_page(args)
@@ -132,6 +198,11 @@ module UrlHelper
132
198
  #
133
199
  # Returns an array of the [name, page, options].
134
200
  #
201
+ # ==== Options
202
+ #
203
+ # * <tt>:url</tt> -- hash of options for the +url_for+ method
204
+ # * <tt>:attrs</tt> -- hash of options for the +link_to+ method
205
+ #
135
206
  def _find_page( args )
136
207
  raise ArgumentError, 'wrong number of arguments (0 for 1)' if args.empty?
137
208