tagz 0.0.4 → 1.0.0
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.
- data/README +240 -0
- data/README.tmpl +240 -0
- data/install.rb +4 -0
- data/lib/tagz.rb +146 -351
- data/test/tagz.rb +226 -191
- metadata +3 -106
- data/lib/tagz/rails.rb +0 -198
- data/rails/README +0 -182
- data/rails/Rakefile +0 -10
- data/rails/app/controllers/application.rb +0 -7
- data/rails/app/controllers/tagz_controller.rb +0 -51
- data/rails/app/helpers/application_helper.rb +0 -3
- data/rails/app/helpers/tagz_helper.rb +0 -2
- data/rails/app/views/layouts/layout.rb +0 -16
- data/rails/app/views/tagz/b.rb +0 -19
- data/rails/app/views/tagz/c.rb +0 -9
- data/rails/app/views/tagz/d.rhtml +0 -17
- data/rails/app/views/tagz/e.rb +0 -3
- data/rails/config/boot.rb +0 -45
- data/rails/config/database.yml +0 -36
- data/rails/config/environment.rb +0 -65
- data/rails/config/environments/development.rb +0 -21
- data/rails/config/environments/production.rb +0 -18
- data/rails/config/environments/test.rb +0 -19
- data/rails/config/lighttpd.conf +0 -54
- data/rails/config/routes.rb +0 -23
- data/rails/doc/README_FOR_APP +0 -2
- data/rails/log/development.log +0 -6713
- data/rails/log/fastcgi.crash.log +0 -103
- data/rails/log/lighttpd.access.log +0 -171
- data/rails/log/lighttpd.error.log +0 -116
- data/rails/log/production.log +0 -0
- data/rails/log/server.log +0 -0
- data/rails/log/test.log +0 -0
- data/rails/public/404.html +0 -30
- data/rails/public/500.html +0 -30
- data/rails/public/dispatch.cgi +0 -10
- data/rails/public/dispatch.fcgi +0 -24
- data/rails/public/dispatch.rb +0 -10
- data/rails/public/favicon.ico +0 -0
- data/rails/public/images/rails.png +0 -0
- data/rails/public/index.html +0 -277
- data/rails/public/javascripts/application.js +0 -2
- data/rails/public/javascripts/controls.js +0 -833
- data/rails/public/javascripts/dragdrop.js +0 -942
- data/rails/public/javascripts/effects.js +0 -1088
- data/rails/public/javascripts/prototype.js +0 -2515
- data/rails/public/robots.txt +0 -1
- data/rails/script/about +0 -3
- data/rails/script/breakpointer +0 -3
- data/rails/script/console +0 -3
- data/rails/script/destroy +0 -3
- data/rails/script/generate +0 -3
- data/rails/script/performance/benchmarker +0 -3
- data/rails/script/performance/profiler +0 -3
- data/rails/script/plugin +0 -3
- data/rails/script/process/inspector +0 -3
- data/rails/script/process/reaper +0 -3
- data/rails/script/process/spawner +0 -3
- data/rails/script/runner +0 -3
- data/rails/script/server +0 -4
- data/rails/test/functional/tagz_controller_test.rb +0 -18
- data/rails/test/test_helper.rb +0 -28
- data/rails/tmp/cache/index.html-gzip-1958902-7552-1181801882 +0 -0
- data/rails/tmp/cache/javascripts/effects.js-gzip-1958907-38200-1181801882 +0 -0
- data/rails/tmp/cache/javascripts/prototype.js-gzip-1958906-71260-1181801882 +0 -0
- data/rails/tmp/sessions/ruby_sess.365e696810aa7418 +0 -0
- data/rails/tmp/sessions/ruby_sess.3ab0cb2f589d3855 +0 -0
- data/rails/tmp/sessions/ruby_sess.c812e68d96a6e99f +0 -0
- data/rails/tmp/sessions/ruby_sess.e0a954440a7e27d7 +0 -0
data/install.rb
CHANGED
@@ -36,7 +36,11 @@ def install_rb(srcdir=nil, destdir=nil, mode=nil, bin=nil)
|
|
36
36
|
next unless FileTest.file?(f)
|
37
37
|
next if (f = f[srcdir.length+1..-1]) == nil
|
38
38
|
next if (/CVS$/ =~ File.dirname(f))
|
39
|
+
next if (/\.svn/ =~ File.dirname(f))
|
39
40
|
next if f =~ %r/\.lnk/
|
41
|
+
next if f =~ %r/\.svn/
|
42
|
+
next if f =~ %r/\.swp/
|
43
|
+
next if f =~ %r/\.svn/
|
40
44
|
path.push f
|
41
45
|
dir |= [File.dirname(f)]
|
42
46
|
end
|
data/lib/tagz.rb
CHANGED
@@ -1,406 +1,201 @@
|
|
1
|
-
|
2
|
-
Tagz::VERSION = '0.0.4' unless defined? Tagz::VERSION
|
3
|
-
def self.version() VERSION end
|
1
|
+
unless defined? Tagz
|
4
2
|
|
5
|
-
|
6
|
-
class StillOpen < StandardError; end
|
3
|
+
require 'cgi'
|
7
4
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
5
|
+
module Tagz
|
6
|
+
unless defined?(Tagz::VERSION)
|
7
|
+
Tagz::VERSION = [
|
8
|
+
Tagz::VERSION_MAJOR = 1,
|
9
|
+
Tagz::VERSION_MINOR = 0,
|
10
|
+
Tagz::VERSION_TEENY = 0
|
11
|
+
].join('.')
|
12
|
+
def Tagz.version() Tagz::VERSION end
|
14
13
|
end
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
@non_container_tag_list
|
21
|
-
else
|
22
|
-
if defined?(@non_container_tag_list) and @non_container_tag_list
|
23
|
-
@non_container_tag_list
|
24
|
-
else
|
25
|
-
non_container_tag_list default_non_container_tag_list
|
26
|
-
@non_container_tag_list
|
27
|
-
end
|
15
|
+
class Fragment < ::String
|
16
|
+
def << other
|
17
|
+
super other.to_s
|
18
|
+
self
|
28
19
|
end
|
29
|
-
end
|
30
20
|
|
31
|
-
|
32
|
-
|
33
|
-
@non_container_tags
|
34
|
-
else
|
35
|
-
non_container_tag_list
|
36
|
-
@non_container_tags
|
21
|
+
def + other
|
22
|
+
self.dup << other
|
37
23
|
end
|
38
24
|
end
|
39
25
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
26
|
+
class Element < ::String
|
27
|
+
def Element.attributes options
|
28
|
+
unless options.empty?
|
29
|
+
' ' <<
|
30
|
+
options.map do |key, value|
|
31
|
+
key = CGI.escapeHTML key.to_s
|
32
|
+
value = CGI.escapeHTML value.to_s
|
33
|
+
if value =~ %r/"/
|
34
|
+
raise ArgumentError, value if value =~ %r/'/
|
35
|
+
value = "'#{ value }'"
|
36
|
+
else
|
37
|
+
raise ArgumentError, value if value =~ %r/"/
|
38
|
+
value = "\"#{ value }\""
|
39
|
+
end
|
40
|
+
[key, value].join('=')
|
41
|
+
end.join(' ')
|
42
|
+
else
|
43
|
+
''
|
44
|
+
end
|
45
|
+
end
|
48
46
|
|
49
|
-
|
50
|
-
attr_accessor 'tag'
|
51
|
-
attr_accessor 'open'
|
52
|
-
attr_accessor 'added'
|
53
|
-
attr_accessor 'created_at'
|
54
|
-
alias_method 'open?', 'open'
|
47
|
+
attr 'name'
|
55
48
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
str.tag = tag.to_s
|
60
|
-
str.stack << tag.to_s
|
61
|
-
str.open = true
|
62
|
-
str.added = { str.object_id => true }
|
63
|
-
options.each{|k,v| str.send "#{ k }=", v}
|
64
|
-
str.created_at = caller
|
65
|
-
str
|
66
|
-
end
|
49
|
+
def initialize name, *argv, &block
|
50
|
+
options = {}
|
51
|
+
content = []
|
67
52
|
|
68
|
-
|
69
|
-
|
70
|
-
|
53
|
+
argv.each do |arg|
|
54
|
+
case arg
|
55
|
+
when Hash
|
56
|
+
options.update arg
|
57
|
+
else
|
58
|
+
content.push arg
|
59
|
+
end
|
60
|
+
end
|
71
61
|
|
72
|
-
|
73
|
-
|
74
|
-
stack.push fragment.tag
|
75
|
-
end
|
76
|
-
end
|
62
|
+
content.push block.call if block
|
63
|
+
content.compact!
|
77
64
|
|
78
|
-
|
79
|
-
stack.pop
|
80
|
-
end
|
65
|
+
@name = name.to_s
|
81
66
|
|
82
|
-
|
83
|
-
|
67
|
+
if content.empty?
|
68
|
+
replace "<#{ @name }#{ Element.attributes options }>"
|
69
|
+
else
|
70
|
+
replace "<#{ @name }#{ Element.attributes options }>#{ content.join }</#{ name }>"
|
71
|
+
end
|
72
|
+
end
|
84
73
|
end
|
85
74
|
|
86
|
-
def
|
87
|
-
|
75
|
+
def Tagz.export *methods
|
76
|
+
methods.flatten.compact.uniq.each do |m|
|
77
|
+
module_function m
|
78
|
+
end
|
88
79
|
end
|
89
80
|
|
90
|
-
def
|
91
|
-
|
92
|
-
oid = fragment.object_id
|
93
|
-
self << fragment unless added[oid]
|
81
|
+
def Tagz.<< other
|
82
|
+
Tagz.tagz << other
|
94
83
|
self
|
95
|
-
ensure
|
96
|
-
added[oid] = true
|
97
84
|
end
|
98
|
-
end
|
99
85
|
|
100
|
-
|
101
|
-
module Abilities
|
102
86
|
private
|
103
|
-
def tagz *argv, &block
|
104
|
-
stack = __tag_stack__
|
105
|
-
top = stack.last
|
106
|
-
size = stack.size
|
107
87
|
|
108
|
-
|
109
|
-
|
110
|
-
if
|
111
|
-
|
112
|
-
|
113
|
-
string = argv.join
|
114
|
-
top.add string
|
115
|
-
string
|
88
|
+
def tagz &block
|
89
|
+
if block
|
90
|
+
if not defined?(@tagz) or @tagz.nil?
|
91
|
+
@tagz = Fragment.new
|
92
|
+
top = true
|
116
93
|
end
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
until stack.last.object_id == tid
|
126
|
-
pop = stack.pop
|
127
|
-
last = stack.last
|
128
|
-
last.add pop
|
94
|
+
begin
|
95
|
+
size = @tagz.size
|
96
|
+
value = instance_eval(&block)
|
97
|
+
@tagz << value unless(Fragment === value or @tagz.size > size)
|
98
|
+
@tagz
|
99
|
+
ensure
|
100
|
+
@tagz = nil if top
|
129
101
|
end
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
content_was_added = top.size > 0
|
134
|
-
top.add string unless content_was_added
|
135
|
-
|
136
|
-
top
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
def method_missing m, *a, &b
|
141
|
-
case m.to_s
|
142
|
-
when %r/^(.*[^_])_(!)?$/o
|
143
|
-
m, bang = $1, $2
|
144
|
-
unless bang
|
145
|
-
__tag_start__ m, *a, &b
|
146
|
-
else
|
147
|
-
__tag_start__(m, *a){}
|
148
|
-
end
|
149
|
-
when %r/^_([^_].*)$/o
|
150
|
-
m = $1
|
151
|
-
__tag_stop__ m, *a, &b
|
152
|
-
else
|
153
|
-
super
|
102
|
+
else
|
103
|
+
@tagz ||= Fragment.new
|
154
104
|
end
|
155
105
|
end
|
156
106
|
|
157
|
-
def
|
158
|
-
|
159
|
-
|
107
|
+
def tagz__ name, *argv, &block
|
108
|
+
options = {}
|
109
|
+
content = []
|
160
110
|
|
161
|
-
|
162
|
-
|
163
|
-
( 42 - 10 ).chr <<
|
164
|
-
case attrs
|
111
|
+
argv.each do |arg|
|
112
|
+
case arg
|
165
113
|
when Hash
|
166
|
-
|
114
|
+
options.update arg
|
167
115
|
else
|
168
|
-
|
116
|
+
content.push arg
|
169
117
|
end
|
170
|
-
end
|
171
|
-
|
172
|
-
def __tag_start__ *argv, &block
|
173
|
-
tag = argv.shift
|
174
|
-
|
175
|
-
case argv.size
|
176
|
-
when 0 # no attrs, no content
|
177
|
-
attrs = {}
|
178
|
-
content = nil
|
179
|
-
when 1 # string content
|
180
|
-
case argv.first
|
181
|
-
when Hash
|
182
|
-
attrs = argv.shift
|
183
|
-
content = nil
|
184
|
-
else
|
185
|
-
if block
|
186
|
-
attrs = argv.shift
|
187
|
-
content = nil
|
188
|
-
else
|
189
|
-
content = argv.shift
|
190
|
-
attrs = {}
|
191
|
-
end
|
192
|
-
end
|
193
|
-
when 2 # string attrs, string content OR string content, hash attrs
|
194
|
-
case argv.last
|
195
|
-
when Hash
|
196
|
-
attrs = argv.last
|
197
|
-
content = argv.first.to_s
|
198
|
-
else
|
199
|
-
attrs = argv.first
|
200
|
-
content = argv.last.to_s
|
201
|
-
end
|
202
|
-
else # string attrs, string content(s) OR string content(s), hash attrs
|
203
|
-
case argv.last
|
204
|
-
when Hash
|
205
|
-
attrs = argv.last
|
206
|
-
content = argv[0..-2].join
|
207
|
-
else
|
208
|
-
attrs = argv.first
|
209
|
-
content = argv[1..-1].join
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
if content and block
|
214
|
-
b = block and block = lambda{ "#{ content }#{ b.call }" }
|
215
118
|
end
|
216
119
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
120
|
+
unless options.empty?
|
121
|
+
attributes = ' ' <<
|
122
|
+
options.map do |key, value|
|
123
|
+
key = CGI.escapeHTML key.to_s
|
124
|
+
value = CGI.escapeHTML value.to_s
|
125
|
+
if value =~ %r/"/
|
126
|
+
raise ArgumentError, value if value =~ %r/'/
|
127
|
+
value = "'#{ value }'"
|
128
|
+
else
|
129
|
+
raise ArgumentError, value if value =~ %r/"/
|
130
|
+
value = "\"#{ value }\""
|
131
|
+
end
|
132
|
+
[key, value].join('=')
|
133
|
+
end.join(' ')
|
227
134
|
else
|
228
|
-
|
229
|
-
|
230
|
-
stack << start
|
231
|
-
size = start.size
|
232
|
-
pos = ( (size - 2) .. (size - 1) )
|
233
|
-
top = stack.last
|
234
|
-
tid = top.object_id
|
235
|
-
ssize = stack.size
|
236
|
-
|
237
|
-
|
238
|
-
content = block.call top
|
239
|
-
content_was_added = size < start.size
|
240
|
-
|
135
|
+
attributes = ''
|
136
|
+
end
|
241
137
|
|
242
|
-
|
243
|
-
if stack.size > ssize
|
244
|
-
i = ssize
|
245
|
-
while((opentag = stack[i]))
|
246
|
-
top.add opentag
|
247
|
-
i += 1
|
248
|
-
end
|
249
|
-
stack.pop until stack.size == ssize
|
250
|
-
end
|
138
|
+
tagz << "<#{ name }#{ attributes }>"
|
251
139
|
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
140
|
+
if content.empty?
|
141
|
+
if block
|
142
|
+
size = tagz.size
|
143
|
+
value = block.call(tagz)
|
144
|
+
unless value
|
145
|
+
tagz[-1] = "/>"
|
146
|
+
else
|
147
|
+
tagz << value.to_s unless(Fragment === value or tagz.size > size)
|
148
|
+
tagz << "</#{ name }>"
|
261
149
|
end
|
262
150
|
end
|
263
|
-
=end
|
264
|
-
|
265
|
-
if content or Tagz.container?(tag)
|
266
|
-
top[pos] = ' >'
|
267
|
-
top.add content unless content_was_added
|
268
|
-
stop = Fragment( "</#{ tag }>", tag, :open => false )
|
269
|
-
top.add stop
|
270
|
-
top.open = false
|
271
|
-
else
|
272
|
-
top[pos] = '/>'
|
273
|
-
top.open = false
|
274
|
-
end
|
275
|
-
|
276
|
-
content = stack.pop
|
277
|
-
|
278
|
-
top = stack.last
|
279
|
-
if top and top.open?
|
280
|
-
top.add content
|
281
|
-
end
|
282
|
-
|
283
|
-
content
|
284
|
-
end
|
285
|
-
end
|
286
|
-
|
287
|
-
def __tag_stop__ tag
|
288
|
-
stack = __tag_stack__
|
289
|
-
top = stack.last
|
290
|
-
stop = Fragment( "</#{ tag }>", tag, :open => false )
|
291
|
-
if top
|
292
|
-
if stop.closes?(top)
|
293
|
-
top.add stop
|
294
|
-
top.open = false
|
295
|
-
content = stack.pop
|
296
|
-
top = stack.last
|
297
|
-
top.add content if top and top.open?
|
298
|
-
content
|
299
|
-
else
|
300
|
-
raise NotOpen, tag.to_s
|
301
|
-
end
|
302
151
|
else
|
303
|
-
|
152
|
+
content.each{|c| tagz << c.to_s unless Fragment === c}
|
153
|
+
if block
|
154
|
+
size = tagz.size
|
155
|
+
value = block.call(tagz)
|
156
|
+
tagz << value.to_s unless(Fragment === value or tagz.size > size)
|
157
|
+
end
|
158
|
+
tagz << "</#{ name }>"
|
304
159
|
end
|
305
|
-
end
|
306
|
-
|
307
|
-
def Fragment(*a, &b) Fragment.new(*a, &b) end
|
308
|
-
|
309
|
-
def element tag, *a, &b
|
310
|
-
__tag_stack__ << (top=Fragment())
|
311
|
-
__tag_start__ tag, *a, &b
|
312
|
-
__tag_stack__.pop
|
313
|
-
end
|
314
|
-
alias_method "e", "element"
|
315
|
-
|
316
|
-
def element_ tag, *a, &b
|
317
|
-
__tag_stack__ << (top=Fragment())
|
318
|
-
__tag_start__ tag, *a, &b
|
319
|
-
__tag_stack__.pop
|
320
|
-
end
|
321
|
-
alias_method "e_", "element_"
|
322
160
|
|
323
|
-
|
324
|
-
__tag_stack__ << (top=Fragment())
|
325
|
-
__tag_stop__ tag, *a, &b
|
326
|
-
__tag_stack__.pop
|
161
|
+
tagz
|
327
162
|
end
|
328
|
-
alias_method "_e", "_element"
|
329
163
|
|
330
|
-
def
|
331
|
-
|
332
|
-
__tag_stack__ << (top=Fragment())
|
333
|
-
__tag_start__ tag, *a, &b
|
334
|
-
__tag_stack__.pop
|
164
|
+
def __tagz tag, *a, &b
|
165
|
+
tagz << "</#{ tag }>"
|
335
166
|
end
|
336
|
-
alias_method "e!", "element!"
|
337
167
|
|
338
|
-
def
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
def tag *a, &b
|
359
|
-
tagz{ __tag_start__ self, *a, &b }
|
360
|
-
end
|
361
|
-
def tag_ *a, &b
|
362
|
-
tagz{ __tag_start__ self, *a, &b }
|
363
|
-
end
|
364
|
-
def _tag *a, &b
|
365
|
-
tagz{ __tag_start__ self, *a, &b }
|
366
|
-
end
|
367
|
-
def tag! *a
|
368
|
-
tagz{ __tag_start__(self, *a){} }
|
168
|
+
def method_missing m, *a, &b
|
169
|
+
return super unless @tagz
|
170
|
+
case m.to_s
|
171
|
+
when %r/^(.*[^_])_(!)?$/o
|
172
|
+
m, bang = $1, $2
|
173
|
+
unless bang
|
174
|
+
tagz__(m, *a, &b)
|
175
|
+
else
|
176
|
+
tagz__(m, *a){}
|
177
|
+
end
|
178
|
+
when %r/^_([^_].*)$/o
|
179
|
+
m = $1
|
180
|
+
__tagz(m, *a, &b)
|
181
|
+
when 'e'
|
182
|
+
Element.new(*a, &b)
|
183
|
+
when '__'
|
184
|
+
tagz << "\n"
|
185
|
+
else
|
186
|
+
super
|
187
|
+
end
|
369
188
|
end
|
370
|
-
end
|
371
189
|
|
372
|
-
|
373
|
-
include Tagz
|
374
|
-
def tag *a, &b
|
375
|
-
tagz{ __tag_start__ self, *a, &b }
|
376
|
-
end
|
377
|
-
def tag_ *a, &b
|
378
|
-
tagz{ __tag_start__ self, *a, &b }
|
379
|
-
end
|
380
|
-
def _tag *a, &b
|
381
|
-
tagz{ __tag_start__ self, *a, &b }
|
382
|
-
end
|
383
|
-
def tag! *a
|
384
|
-
tagz{ __tag_start__(self, *a){} }
|
385
|
-
end
|
190
|
+
export %w( tagz tagz__ __tagz method_missing )
|
386
191
|
end
|
387
|
-
end
|
388
192
|
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
if block
|
393
|
-
if const === self
|
394
|
-
this = self
|
395
|
-
else
|
396
|
-
this = eval('self', block).dup
|
397
|
-
this.send :extend, Tagz
|
398
|
-
end
|
399
|
-
this.send :tagz, &block
|
193
|
+
def Tagz *argv, &block
|
194
|
+
if argv.empty? and block.nil?
|
195
|
+
::Tagz
|
400
196
|
else
|
401
|
-
|
197
|
+
Tagz.tagz(*argv, &block)
|
402
198
|
end
|
403
199
|
end
|
404
|
-
end
|
405
200
|
|
406
|
-
|
201
|
+
end
|