TwP-webby 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. data/History.txt +11 -0
  2. data/Manifest.txt +45 -2
  3. data/Rakefile +1 -2
  4. data/examples/webby/content/css/site.css +1 -1
  5. data/examples/webby/content/learn/index.txt +1 -1
  6. data/examples/webby/content/release-notes/index.txt +21 -0
  7. data/examples/webby/content/release-notes/rel-0-9-0/index.txt +1 -0
  8. data/examples/webby/content/release-notes/rel-0-9-1/index.txt +93 -0
  9. data/examples/webby/content/tips_and_tricks/index.txt +14 -13
  10. data/examples/webby/content/tutorial/index.txt +13 -9
  11. data/examples/webby/content/user-manual/index.txt +8 -8
  12. data/examples/webby/layouts/default.txt +1 -1
  13. data/lib/webby/apps/main.rb +25 -13
  14. data/lib/webby/auto_builder.rb +2 -0
  15. data/lib/webby/builder.rb +2 -5
  16. data/lib/webby/filters.rb +5 -13
  17. data/lib/webby/renderer.rb +7 -5
  18. data/lib/webby/resources/db.rb +4 -4
  19. data/lib/webby/resources/layout.rb +14 -23
  20. data/lib/webby/resources/meta_file.rb +208 -0
  21. data/lib/webby/resources/page.rb +21 -58
  22. data/lib/webby/resources/partial.rb +10 -4
  23. data/lib/webby/resources/resource.rb +68 -27
  24. data/lib/webby/resources/static.rb +6 -22
  25. data/lib/webby/resources.rb +54 -14
  26. data/lib/webby/stelan/paginator.rb +17 -2
  27. data/lib/webby.rb +2 -1
  28. data/spec/data/Sitefile +9 -0
  29. data/spec/data/content/_partial.txt +10 -0
  30. data/spec/data/content/css/coderay.css +111 -0
  31. data/spec/data/content/css/site.css +67 -0
  32. data/spec/data/content/css/tumblog.css +308 -0
  33. data/spec/data/content/images/tumblog/permalink.gif +0 -0
  34. data/spec/data/content/images/tumblog/rss.gif +0 -0
  35. data/spec/data/content/index.txt +19 -0
  36. data/spec/data/content/photos.txt +21 -0
  37. data/spec/data/content/tumblog/200806/the-noble-chicken/index.txt +12 -0
  38. data/spec/data/content/tumblog/200807/historical-perspectives-on-the-classic-chicken-joke/index.txt +12 -0
  39. data/spec/data/content/tumblog/200807/mad-city-chickens/index.txt +10 -0
  40. data/spec/data/content/tumblog/200807/the-wisdom-of-the-dutch/index.txt +11 -0
  41. data/spec/data/content/tumblog/200807/up-a-tree/index.txt +13 -0
  42. data/spec/data/content/tumblog/index.txt +37 -0
  43. data/spec/data/content/tumblog/rss.txt +37 -0
  44. data/spec/data/hooligans/bad_meta_data_1.txt +34 -0
  45. data/spec/data/hooligans/bad_meta_data_2.txt +34 -0
  46. data/spec/data/layouts/default.txt +58 -0
  47. data/spec/data/layouts/tumblog/default.txt +44 -0
  48. data/spec/data/layouts/tumblog/post.txt +15 -0
  49. data/spec/data/lib/breadcrumbs.rb +28 -0
  50. data/spec/data/lib/tumblog_helper.rb +32 -0
  51. data/spec/data/tasks/tumblog.rake +30 -0
  52. data/spec/data/templates/_partial.erb +10 -0
  53. data/spec/data/templates/atom_feed.erb +40 -0
  54. data/spec/data/templates/page.erb +18 -0
  55. data/spec/data/templates/presentation.erb +40 -0
  56. data/spec/data/templates/tumblog/conversation.erb +12 -0
  57. data/spec/data/templates/tumblog/link.erb +10 -0
  58. data/spec/data/templates/tumblog/photo.erb +13 -0
  59. data/spec/data/templates/tumblog/post.erb +12 -0
  60. data/spec/data/templates/tumblog/quote.erb +11 -0
  61. data/spec/spec_helper.rb +37 -0
  62. data/spec/webby/apps/generator_spec.rb +4 -0
  63. data/spec/webby/apps/main_spec.rb +16 -3
  64. data/spec/webby/filters/textile_spec.rb +20 -0
  65. data/spec/webby/renderer_spec.rb +139 -0
  66. data/spec/webby/resources/db_spec.rb +250 -0
  67. data/spec/webby/resources/layout_spec.rb +83 -0
  68. data/spec/webby/resources/meta_file_spec.rb +157 -0
  69. data/spec/webby/resources/page_spec.rb +111 -0
  70. data/spec/webby/resources/partial_spec.rb +58 -0
  71. data/spec/webby/resources/resource_spec.rb +214 -0
  72. data/spec/webby/resources/static_spec.rb +49 -0
  73. data/spec/webby/resources_spec.rb +55 -3
  74. data/tasks/rubyforge.rake +1 -1
  75. metadata +64 -6
  76. data/lib/webby/resources/file.rb +0 -221
  77. data/spec/webby/resources/file_spec.rb +0 -104
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: TwP-webby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Pease
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-08-25 00:00:00 -07:00
12
+ date: 2008-09-10 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -46,7 +46,7 @@ dependencies:
46
46
  requirements:
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 0.9.1
49
+ version: 0.9.2
50
50
  version:
51
51
  - !ruby/object:Gem::Dependency
52
52
  name: rake
@@ -55,7 +55,7 @@ dependencies:
55
55
  requirements:
56
56
  - - ">="
57
57
  - !ruby/object:Gem::Version
58
- version: 0.8.1
58
+ version: 0.8.2
59
59
  version:
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: rspec
@@ -84,6 +84,21 @@ extra_rdoc_files:
84
84
  - lib/webby/tasks/growl.rake
85
85
  - lib/webby/tasks/heel.rake
86
86
  - lib/webby/tasks/validate.rake
87
+ - spec/data/content/_partial.txt
88
+ - spec/data/content/index.txt
89
+ - spec/data/content/photos.txt
90
+ - spec/data/content/tumblog/200806/the-noble-chicken/index.txt
91
+ - spec/data/content/tumblog/200807/historical-perspectives-on-the-classic-chicken-joke/index.txt
92
+ - spec/data/content/tumblog/200807/mad-city-chickens/index.txt
93
+ - spec/data/content/tumblog/200807/the-wisdom-of-the-dutch/index.txt
94
+ - spec/data/content/tumblog/200807/up-a-tree/index.txt
95
+ - spec/data/content/tumblog/index.txt
96
+ - spec/data/content/tumblog/rss.txt
97
+ - spec/data/hooligans/bad_meta_data_1.txt
98
+ - spec/data/hooligans/bad_meta_data_2.txt
99
+ - spec/data/layouts/default.txt
100
+ - spec/data/layouts/tumblog/default.txt
101
+ - spec/data/layouts/tumblog/post.txt
87
102
  files:
88
103
  - History.txt
89
104
  - Manifest.txt
@@ -147,7 +162,9 @@ files:
147
162
  - examples/webby/content/index.txt
148
163
  - examples/webby/content/learn/index.txt
149
164
  - examples/webby/content/reference/index.txt
165
+ - examples/webby/content/release-notes/index.txt
150
166
  - examples/webby/content/release-notes/rel-0-9-0/index.txt
167
+ - examples/webby/content/release-notes/rel-0-9-1/index.txt
151
168
  - examples/webby/content/robots.txt
152
169
  - examples/webby/content/script/jquery.corner.js
153
170
  - examples/webby/content/script/jquery.js
@@ -221,8 +238,8 @@ files:
221
238
  - lib/webby/renderer.rb
222
239
  - lib/webby/resources.rb
223
240
  - lib/webby/resources/db.rb
224
- - lib/webby/resources/file.rb
225
241
  - lib/webby/resources/layout.rb
242
+ - lib/webby/resources/meta_file.rb
226
243
  - lib/webby/resources/page.rb
227
244
  - lib/webby/resources/partial.rb
228
245
  - lib/webby/resources/resource.rb
@@ -239,12 +256,53 @@ files:
239
256
  - spec/core_ext/hash_spec.rb
240
257
  - spec/core_ext/string_spec.rb
241
258
  - spec/core_ext/time_spec.rb
259
+ - spec/data/Sitefile
260
+ - spec/data/content/_partial.txt
261
+ - spec/data/content/css/coderay.css
262
+ - spec/data/content/css/site.css
263
+ - spec/data/content/css/tumblog.css
264
+ - spec/data/content/images/tumblog/permalink.gif
265
+ - spec/data/content/images/tumblog/rss.gif
266
+ - spec/data/content/index.txt
267
+ - spec/data/content/photos.txt
268
+ - spec/data/content/tumblog/200806/the-noble-chicken/index.txt
269
+ - spec/data/content/tumblog/200807/historical-perspectives-on-the-classic-chicken-joke/index.txt
270
+ - spec/data/content/tumblog/200807/mad-city-chickens/index.txt
271
+ - spec/data/content/tumblog/200807/the-wisdom-of-the-dutch/index.txt
272
+ - spec/data/content/tumblog/200807/up-a-tree/index.txt
273
+ - spec/data/content/tumblog/index.txt
274
+ - spec/data/content/tumblog/rss.txt
275
+ - spec/data/hooligans/bad_meta_data_1.txt
276
+ - spec/data/hooligans/bad_meta_data_2.txt
277
+ - spec/data/layouts/default.txt
278
+ - spec/data/layouts/tumblog/default.txt
279
+ - spec/data/layouts/tumblog/post.txt
280
+ - spec/data/lib/breadcrumbs.rb
281
+ - spec/data/lib/tumblog_helper.rb
282
+ - spec/data/tasks/tumblog.rake
283
+ - spec/data/templates/_partial.erb
284
+ - spec/data/templates/atom_feed.erb
285
+ - spec/data/templates/page.erb
286
+ - spec/data/templates/presentation.erb
287
+ - spec/data/templates/tumblog/conversation.erb
288
+ - spec/data/templates/tumblog/link.erb
289
+ - spec/data/templates/tumblog/photo.erb
290
+ - spec/data/templates/tumblog/post.erb
291
+ - spec/data/templates/tumblog/quote.erb
242
292
  - spec/spec.opts
243
293
  - spec/spec_helper.rb
244
294
  - spec/webby/apps/generator_spec.rb
245
295
  - spec/webby/apps/main_spec.rb
296
+ - spec/webby/filters/textile_spec.rb
246
297
  - spec/webby/helpers/capture_helper_spec.rb
247
- - spec/webby/resources/file_spec.rb
298
+ - spec/webby/renderer_spec.rb
299
+ - spec/webby/resources/db_spec.rb
300
+ - spec/webby/resources/layout_spec.rb
301
+ - spec/webby/resources/meta_file_spec.rb
302
+ - spec/webby/resources/page_spec.rb
303
+ - spec/webby/resources/partial_spec.rb
304
+ - spec/webby/resources/resource_spec.rb
305
+ - spec/webby/resources/static_spec.rb
248
306
  - spec/webby/resources_spec.rb
249
307
  - tasks/ann.rake
250
308
  - tasks/bones.rake
@@ -1,221 +0,0 @@
1
- require 'yaml'
2
-
3
- module Webby::Resources
4
-
5
- # The Webby::Resources::File class is identical to the core Ruby file class
6
- # except for YAML meta-data stored at the top of the file. This meta-data
7
- # is made available through the <code>meta_data</code> and
8
- # <code>meta_data=</code> functions.
9
- #
10
- # The meta-data data must be found between two YAML block separators "---",
11
- # each on their own line.
12
- #
13
- # Example:
14
- #
15
- # ---
16
- # layout: blog
17
- # filter: markdown
18
- # tags:
19
- # - ruby
20
- # - web development
21
- # ---
22
- # This is a blog entry formatted using MarkDown and tagged as "ruby" and
23
- # "web development". The layout being used is the "blog" format.
24
- #
25
- class File < ::File
26
-
27
- META_SEP = %r/\A---\s*\r?\n\z/o # :nodoc:
28
-
29
- class << self
30
- # call-seq:
31
- # File.read( name [, length [, offset]]) => string
32
- #
33
- # Opens the file, optionally seeks to the given _offset_, then returns
34
- # _length_ bytes (defaulting to the rest of the file). +read+ ensures
35
- # the file is closed before returning.
36
- #
37
- def read( name, *args )
38
- fd = new name, 'r'
39
- fd.read(*args)
40
- ensure
41
- fd.close unless fd.nil?
42
- end
43
-
44
- # call-seq:
45
- # File.readlines( name, sep_string = $/ ) => array
46
- #
47
- # Reads the entire file specified by _name_ as individual lines, and
48
- # returns those lines in an array. Lines are separated by _sep_string_.
49
- # +readlines+ ensures the file is closed before returning.
50
- #
51
- def readlines( name, sep = $/ )
52
- fd = new name, 'r'
53
- fd.readlines sep
54
- ensure
55
- fd.close unless fd.nil?
56
- end
57
-
58
- # call-seq:
59
- # File.meta_data( name ) => object or nil
60
- #
61
- # Reads the meta-data from the file specified by _name_. +meta_data+
62
- # ensures the files is closed before returning.
63
- #
64
- def meta_data( name )
65
- fd = new name, 'r'
66
- fd.meta_data
67
- ensure
68
- fd.close unless fd.nil?
69
- end
70
-
71
- # call-seq:
72
- # File.dirname( filename ) => dir_name
73
- #
74
- # Returns all components of the _filename_ except the last one. The
75
- # filename must be formed using forward slashes ("/") regardless of the
76
- # separator used on the local file system.
77
- #
78
- def dirname( fn )
79
- ::File.dirname(fn).sub(%r/\A[^\/]+\/?/o, '')
80
- end
81
-
82
- # call-seq:
83
- # File.basename( filename ) => base_name
84
- #
85
- # Returns the last component of the _filename_, which must be formed
86
- # using forward slashes ("/"regardless of the separator used on the
87
- # local file system. The suffix is removed from the filename.
88
- #
89
- def basename( fn )
90
- ::File.basename(fn, '.*')
91
- end
92
-
93
- # call-seq:
94
- # File.extname( filename ) => ext_name
95
- #
96
- # Returns the extension (the portion of file name in path after the
97
- # period). This method excludes the period from the extension name.
98
- #
99
- def extname( fn )
100
- ::File.extname(fn).tr('.', '')
101
- end
102
- end
103
-
104
- # call-seq:
105
- # File.new( filename, mode = "r" ) => file
106
- # File.new( filename [, mode [, perm]] ) => file
107
- #
108
- # Opens the file named by _filename_ according to _mode_ (default is 'r')
109
- # and returns a new +Webby::Resources::File+ object. See the description
110
- # of class +IO+ for a description of _mode_. The file _mode_ may
111
- # optionally be specified as a +Fixnum+ by or-ing together the flags
112
- # (+O_RDONLY+ etc, again described under +IO+). Optional permission bits
113
- # may be given in _perm_. These _mode_ and permission bits are platform
114
- # dependent; on Unix systems, see +open(2)+ for details.
115
- #
116
- # f = File.new("testfile", "r")
117
- # f = File.new("newfile", "w+")
118
- # f = File.new("newfile", File::CREAT|File::TRUNC|File::RDWR, 0644)
119
- #
120
- def initialize( *args )
121
- super
122
- @meta_end = end_of_meta_data
123
- end
124
-
125
- # call-seq:
126
- # meta_data
127
- #
128
- # Returns the meta-data defined at the top of the file. Returns +nil+ if
129
- # no meta-data is defined. The meta-data is returned as Ruby objects
130
- #
131
- # Meta-data is stored in YAML format between two YAML separators "---" on
132
- # their own lines.
133
- #
134
- def meta_data
135
- return if @meta_end.nil?
136
-
137
- cur, meta_end, @meta_end = tell, @meta_end, nil
138
- seek 0
139
- return YAML.load(self)
140
-
141
- ensure
142
- @meta_end = meta_end if defined? meta_end and meta_end
143
- seek cur if defined? cur and cur
144
- end
145
-
146
- # call-seq
147
- # meta_data = object
148
- #
149
- # Stores the given _object_ as meta-data in YAML format at the top of the
150
- # file. If the _objectc_ is +nil+, then the meta-data section will be
151
- # removed from the file.
152
- #
153
- # Meta-data is stored in YAML format between two YAML separators "---" on
154
- # their own lines.
155
- #
156
- def meta_data=( data )
157
- return if data.nil? and @meta_end.nil?
158
-
159
- seek 0
160
- lines = readlines
161
-
162
- truncate 0
163
- unless data.nil?
164
- write YAML.dump(data)
165
- write "--- #$/"
166
- end
167
- lines.each {|line| write line}
168
- ensure
169
- @meta_end = end_of_meta_data
170
- seek 0, IO::SEEK_END
171
- end
172
-
173
- alias :_gets :gets
174
- private :_gets
175
-
176
- %w(getc gets read read_nonblock readbytes readchar readline readlines readpartial scanf).each do |m|
177
- self.class_eval <<-CODE
178
- def #{m}(*a)
179
- skip_meta_data
180
- super
181
- end
182
- CODE
183
- end
184
-
185
-
186
- private
187
-
188
- # Moves the file pointer to the end of the meta-data section. Does nothing
189
- # if there is no meta-data section or if the file pointer is already past
190
- # the meta-data section.
191
- #
192
- def skip_meta_data
193
- return if @meta_end.nil?
194
- return if tell >= @meta_end
195
- seek @meta_end
196
- end
197
-
198
- # Returns the position in this file where the meta-data ends and the file
199
- # data begins. If there is no meta-data in the file, returns +nil+.
200
- #
201
- def end_of_meta_data
202
- cur = tell
203
-
204
- seek 0
205
- line = _gets
206
- return unless META_SEP =~ line
207
-
208
- while line = _gets
209
- break if META_SEP =~ line
210
- end
211
- return if line.nil?
212
- tell
213
-
214
- ensure
215
- seek cur
216
- end
217
-
218
- end # class File
219
- end # module Webby::Resources
220
-
221
- # EOF
@@ -1,104 +0,0 @@
1
-
2
- require ::File.join(::File.dirname(__FILE__), %w[.. .. spec_helper])
3
-
4
- # ---------------------------------------------------------------------------
5
- describe Webby::Resources::File do
6
-
7
- FN = ::File.expand_path(::File.join(::File.dirname(__FILE__), '..', '..', 'lorem_ipsum.txt'))
8
- FN_YAML = FN.gsub %r/\.txt\z/, '_yaml.txt'
9
- LINES = [
10
- "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nulla orci\n",
11
- "ante, aliquet ac, vulputate ut, suscipit et, sapien. Integer elementum\n",
12
- "nisi quis magna tincidunt mattis. Aliquam semper. Pellentesque pretium.\n",
13
- "Ut a ligula sit amet pede malesuada laoreet. Ut et purus. Morbi turpis\n",
14
- "justo, pharetra vitae, consequat a, sodales vitae, tortor. Donec non\n",
15
- "massa. Maecenas adipiscing venenatis nisi. Proin vulputate lorem posuere\n",
16
- "mi. Cras sagittis. Pellentesque tortor mauris, accumsan vitae, ultrices\n",
17
- "vel, tristique ultricies, eros. Donec fringilla hendrerit mauris. Nam in\n",
18
- "orci. Curabitur congue consectetuer leo. Donec ut pede. Proin et lorem.\n",
19
- "Aliquam eget lacus. In nibh.\n"
20
- ]
21
-
22
- before do
23
- ::File.open(FN,'w') {|fd| fd.write LINES}
24
- ::File.open(FN_YAML,'w') do |fd|
25
- fd.write "--- \n- one\n- two\n- three\n--- \n"
26
- fd.write LINES
27
- end
28
- end
29
-
30
- after do
31
- ::FileUtils.rm_f(FN)
32
- ::FileUtils.rm_f(FN_YAML)
33
- end
34
-
35
- it 'should return nil for meta-data on regular files' do
36
- begin
37
- fd = Webby::Resources::File.new FN, 'r'
38
- fd.meta_data.should be_nil
39
-
40
- fd.readlines.should == LINES
41
- ensure
42
- fd.close
43
- end
44
- end
45
-
46
- it 'should add meta-data to the top of a file' do
47
- Webby::Resources::File.open(FN,'a+') do |fd|
48
- fd.meta_data.should be_nil
49
- fd.meta_data = %w(one two three)
50
- end
51
-
52
- Webby::Resources::File.open(FN,'r') do |fd|
53
- fd.meta_data.should == %w(one two three)
54
- end
55
-
56
- ::File.open(FN_YAML, 'r') do |fd|
57
- ary = LINES.dup
58
- ary.insert 0, [
59
- "--- \n",
60
- "- one\n",
61
- "- two\n",
62
- "- three\n",
63
- "--- \n"
64
- ]
65
- fd.readlines.should == ary.flatten
66
- end
67
- end
68
-
69
- it 'should remove the meta-data when set to nil' do
70
- Webby::Resources::File.open(FN_YAML,'a+') do |fd|
71
- fd.meta_data.should == %w(one two three)
72
- fd.meta_data = nil
73
- end
74
-
75
- Webby::Resources::File.open(FN_YAML,'r') do |fd|
76
- fd.meta_data.should be_nil
77
- end
78
-
79
- ::File.open(FN_YAML, 'r') do |fd|
80
- fd.readlines.should == LINES
81
- end
82
- end
83
-
84
- it 'should skip the meta-data when reading from the file' do
85
- begin
86
- fd = Webby::Resources::File.new FN_YAML, 'r'
87
- fd.meta_data.should == %w(one two three)
88
-
89
- fd.getc.should == ?L; fd.seek 0
90
- fd.gets.should == LINES.first; fd.seek 0
91
- fd.read(5).should == 'Lorem'; fd.seek 0
92
- fd.read_nonblock(11) == 'Lorem ipsum'; fd.seek 0
93
- fd.readchar.should == ?L; fd.seek 0
94
- fd.readline.should == LINES.first; fd.seek 0
95
- fd.readlines.should == LINES; fd.seek 0
96
- fd.readpartial(11).should == 'Lorem ipsum'; fd.seek 0
97
-
98
- ensure
99
- fd.close
100
- end
101
- end
102
- end # describe Webby::Resources::File
103
-
104
- # EOF