reparcs 0.1.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/CHANGES +10 -0
- data/LICENSE +21 -0
- data/README +22 -0
- data/Rakefile +200 -0
- data/lib/reparcs/base.rb +159 -0
- data/lib/reparcs/elements/base_elements.rb +17 -0
- data/lib/reparcs/elements/edit_elements.rb +57 -0
- data/lib/reparcs/elements/form_elements.rb +225 -0
- data/lib/reparcs/elements/hypertext_elements.rb +33 -0
- data/lib/reparcs/elements/image_elements.rb +64 -0
- data/lib/reparcs/elements/link_elements.rb +24 -0
- data/lib/reparcs/elements/list_elements.rb +151 -0
- data/lib/reparcs/elements/meta_elements.rb +21 -0
- data/lib/reparcs/elements/object_elements.rb +47 -0
- data/lib/reparcs/elements/presentation_elements.rb +175 -0
- data/lib/reparcs/elements/scripting_elements.rb +41 -0
- data/lib/reparcs/elements/structure_elements.rb +62 -0
- data/lib/reparcs/elements/stylesheet_elements.rb +18 -0
- data/lib/reparcs/elements/table_elements.rb +217 -0
- data/lib/reparcs/elements/text_elements.rb +438 -0
- data/lib/reparcs/projects.rb +54 -0
- data/lib/reparcs/shortcuts.rb +106 -0
- data/lib/reparcs/utilities.rb +4 -0
- data/lib/reparcs/xml_entities.rb +9 -0
- data/lib/reparcs.rb +46 -0
- data/test/http_helpers.rb +76 -0
- data/test/test_shortcuts.rb +49 -0
- data/test/test_validmarkup.rb +23 -0
- data/www/create_www.rb +85 -0
- metadata +87 -0
@@ -0,0 +1,438 @@
|
|
1
|
+
include Base
|
2
|
+
|
3
|
+
#XHTML Text elements
|
4
|
+
module TextElements
|
5
|
+
|
6
|
+
#An Abbreviation '<abbr></abbr>'
|
7
|
+
#Use: Define an abbreviation.
|
8
|
+
class Abbreviation < ContainerElement
|
9
|
+
#Create a new Abbreviation element, takes a optional hash of attributes as parameter.
|
10
|
+
def initialize(attrs={})
|
11
|
+
aattrs = [
|
12
|
+
"class", "id", "title", "dir", "xml:lang",
|
13
|
+
"onclick", "ondblclick", "onkeydown", "onkeypress",
|
14
|
+
"onkeyup", "onmousedown", "onmousemove", "onmouseout",
|
15
|
+
"onmouseover", "onmouseup"
|
16
|
+
]
|
17
|
+
childs = [
|
18
|
+
"a", "abbr", "acronym", "b", "bdo", "big",
|
19
|
+
"br", "button", "cite", "code", "del", "dfn",
|
20
|
+
"em", "i", "img", "input", "ins", "kbd", "label",
|
21
|
+
"map", "object", "q", "samp", "script", "select",
|
22
|
+
"small", "span", "strong", "sub", "sup", "textarea",
|
23
|
+
"tt", "var"
|
24
|
+
]
|
25
|
+
super("abbr", aattrs, childs, attrs)
|
26
|
+
@start_element = "<abbr"
|
27
|
+
@end_element = "</abbr>"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
#An acronym element '<acronym></acronym>'
|
32
|
+
#Use: Define an acronym.
|
33
|
+
class Acronym < ContainerElement
|
34
|
+
#Create a new Acronym element, takes a optional hash of attributes as parameter.
|
35
|
+
def initialize(attrs={})
|
36
|
+
aattrs = [
|
37
|
+
"class", "id", "title", "dir", "xml:lang",
|
38
|
+
"onclick", "ondblclick", "onkeydown", "onkeypress",
|
39
|
+
"onkeyup", "onmousedown", "onmousemove", "onmouseout",
|
40
|
+
"onmouseover", "onmouseup"
|
41
|
+
]
|
42
|
+
childs = [
|
43
|
+
"a", "abbr", "acronym", "b", "bdo", "big",
|
44
|
+
"br", "button", "cite", "code", "del", "dfn",
|
45
|
+
"em", "i", "img", "input", "ins", "kbd", "label",
|
46
|
+
"map", "object", "q", "samp", "script", "select",
|
47
|
+
"small", "span", "strong", "sub", "sup", "textarea",
|
48
|
+
"tt", "var"
|
49
|
+
]
|
50
|
+
super("acronym", aattrs, childs, attrs)
|
51
|
+
@start_element = "<acronym"
|
52
|
+
@end_element = "</acronym>"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
#An address element '<address></address>'
|
57
|
+
#Use: Define contact information for a document.
|
58
|
+
class Address < ContainerElement
|
59
|
+
#Create a new Address element, takes a optional hash of attributes as parameter.
|
60
|
+
def initialize(attrs={})
|
61
|
+
aattrs = [
|
62
|
+
"class", "id", "dir", "xml:lang",
|
63
|
+
"onclick", "ondblclick", "onkeydown",
|
64
|
+
"onkeypress", "onkeyup", "onmousedown",
|
65
|
+
"onmousemove", "onmouseout", "onmouseover",
|
66
|
+
"onmouseup"
|
67
|
+
]
|
68
|
+
childs = [
|
69
|
+
"a", "abbr", "acronym", "b", "bdo", "big", "br",
|
70
|
+
"button", "cite", "code", "del", "dfn", "em",
|
71
|
+
"i", "img", "input", "ins", "kbd", "label",
|
72
|
+
"map", "object", "q", "samp", "script", "select",
|
73
|
+
"small", "span", "strong", "sub", "sup",
|
74
|
+
"textarea", "tt", "var"
|
75
|
+
]
|
76
|
+
super("address", aattrs, childs, attrs)
|
77
|
+
@start_element = "<address"
|
78
|
+
@end_element = "</address>"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
#A block quote element '<blockquote></blockquote>'
|
83
|
+
#Use: Define a long quotation.
|
84
|
+
class BlockQuote < ContainerElement
|
85
|
+
#Create a new BlockQuote element, takes a optional hash of attributes as parameter.
|
86
|
+
def initialize(attrs={})
|
87
|
+
aattrs = [
|
88
|
+
"class", "id", "title", "dir", "xml:lang",
|
89
|
+
"onclick", "ondblclick", "onkeydown", "onkeypress",
|
90
|
+
"onkeyup", "onmousedown", "onmousemove", "onmouseout",
|
91
|
+
"onmouseover", "onmouseup", "cite"
|
92
|
+
]
|
93
|
+
childs = [
|
94
|
+
"address", "blockquote", "del", "div", "fieldset", "form",
|
95
|
+
"h1", "h2", "h3", "h4", "h5", "h6", "hr", "ins", "noscript",
|
96
|
+
"ol", "p", "pre", "script", "table", "ul"
|
97
|
+
]
|
98
|
+
super("blockquote", aattrs, childs, attrs)
|
99
|
+
@start_element = "<blockquote"
|
100
|
+
@end_element = "</blockquote>"
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
#A Line break '<br />'
|
105
|
+
#Use: Insert a blank line.
|
106
|
+
class LineBreak < Element
|
107
|
+
#Create a new LineBreak element, takes a optional hash of attributes as parameter.
|
108
|
+
def initialize(attrs={})
|
109
|
+
aattrs = ["class", "id", "title"]
|
110
|
+
super("br", aattrs, attrs)
|
111
|
+
@start_element = "<br"
|
112
|
+
@end_element = " />"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
#A citation '<cite></cite>'
|
117
|
+
#Use: Define a citation.
|
118
|
+
class Citation < ContainerElement
|
119
|
+
#Create a new Citation element, takes a optional hash of attributes as parameter.
|
120
|
+
def initialize(attrs={})
|
121
|
+
aattrs = [
|
122
|
+
"class", "id", "title", "dir", "xml:lang",
|
123
|
+
"onclick", "ondblclick", "onkeydown", "onkeypress",
|
124
|
+
"onkeyup", "onmousedown", "onmousemove", "onmouseout",
|
125
|
+
"onmouseover", "onmouseup"
|
126
|
+
]
|
127
|
+
childs = [
|
128
|
+
"a", "abbr", "acronym", "b", "bdo", "big", "br", "button",
|
129
|
+
"cite", "code", "del", "dfn", "em", "i", "img", "input", "ins",
|
130
|
+
"kbd", "label", "map", "object", "q", "samp", "script", "select",
|
131
|
+
"small", "span", "strong", "sub", "sup", "textarea", "tt", "var"
|
132
|
+
]
|
133
|
+
super("cite", aattrs, childs, attrs)
|
134
|
+
@start_element = "<cite"
|
135
|
+
@end_element = "</cite>"
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
#A code element '<code></code>'
|
140
|
+
#Use: Define computer code text
|
141
|
+
class Code < ContainerElement
|
142
|
+
#Create a new Code element, takes a optional hash of attributes as parameter.
|
143
|
+
def initialize(attrs={})
|
144
|
+
aattrs = [
|
145
|
+
"class", "id", "title", "dir", "xml:lang",
|
146
|
+
"onclick", "ondblclick", "onkeydown", "onkeypress",
|
147
|
+
"onkeyup", "onmousedown", "onmousemove", "onmouseout",
|
148
|
+
"onmouseover", "onmouseup"
|
149
|
+
]
|
150
|
+
childs = [
|
151
|
+
"a", "abbr", "acronym", "b", "bdo", "big", "br", "button",
|
152
|
+
"cite", "code", "del", "dfn", "em", "i", "img", "input",
|
153
|
+
"ins", "kbd", "label", "map", "object", "q", "samp", "script",
|
154
|
+
"select", "small", "span", "strong", "sub", "sup", "textarea",
|
155
|
+
"tt", "var"
|
156
|
+
]
|
157
|
+
super("code", aattrs, childs, attrs)
|
158
|
+
@start_element = "<code"
|
159
|
+
@end_element = "</code>"
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
#A Division element '<div></div>'
|
164
|
+
#Use: Define a divison(usually refered to as a layer or div).
|
165
|
+
class Division < ContainerElement
|
166
|
+
#Create a new Division element, takes a optional hash of attributes as parameter.
|
167
|
+
def initialize(attrs={})
|
168
|
+
aattrs = [
|
169
|
+
"class", "id", "title", "dir", "xml:lang",
|
170
|
+
"onclick", "ondblclick", "onkeydown", "onkeypress",
|
171
|
+
"onkeyup", "onmousedown", "onmousemove", "onmouseout",
|
172
|
+
"onmouseover", "onmouseup"
|
173
|
+
]
|
174
|
+
childs = [
|
175
|
+
"a", "abbr", "acronym", "address", "b", "bdo", "big", "blockquote",
|
176
|
+
"br", "button", "cite", "code", "del" ,"dfn", "div", "dl", "em",
|
177
|
+
"fieldset", "form", "h1", "h2", "h3", "h4", "h5", "h6", "hr", "i",
|
178
|
+
"img", "input", "ins", "kbd", "label", "map", "noscript", "object",
|
179
|
+
"ol", "p", "pre", "q", "samp", "script", "select", "small", "span",
|
180
|
+
"strong", "sub", "sup", "textarea", "tt", "ul", "var"
|
181
|
+
]
|
182
|
+
super("div", aattrs, childs, attrs)
|
183
|
+
@start_element = "<div"
|
184
|
+
@end_element = "</div>"
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
#A emphasized element '<em></em>'
|
189
|
+
#Use: Emphasizes text.
|
190
|
+
class Emphasized < ContainerElement
|
191
|
+
#Create a new Emphasized element, takes a optional hash of attributes as parameter.
|
192
|
+
def initialize(attrs={})
|
193
|
+
aattrs = [
|
194
|
+
"class", "id", "title", "dir", "xml:lang",
|
195
|
+
"onclick", "ondblclick", "onkeydown", "onkeypress",
|
196
|
+
"onkeyup", "onmousedown", "onmousemove", "onmouseout",
|
197
|
+
"onmouseover", "onmouseup"
|
198
|
+
]
|
199
|
+
childs = [
|
200
|
+
"a", "abbr", "acronym", "b", "bdo", "big", "br", "button",
|
201
|
+
"cite", "code", "del", "dfn", "em", "i", "img", "input",
|
202
|
+
"ins", "kbd", "label", "map", "object", "q", "samp", "script",
|
203
|
+
"select", "small", "span", "strong", "sub", "sup", "textarea",
|
204
|
+
"tt", "var"
|
205
|
+
]
|
206
|
+
super("em", aattrs, childs, attrs)
|
207
|
+
@start_element = "<em"
|
208
|
+
@end_element = "</em>"
|
209
|
+
end
|
210
|
+
end
|
211
|
+
|
212
|
+
#A header element '<h1-6></h1-6>'
|
213
|
+
#Use: Defines a header
|
214
|
+
class Header < ContainerElement
|
215
|
+
#Create a new heade element, takes the size(1-6) and a optional hash of attributes as parameter.
|
216
|
+
def initialize(size, attrs={})
|
217
|
+
allowed = false
|
218
|
+
[1, 2, 3, 4, 5, 6].each do |s|
|
219
|
+
if s == size
|
220
|
+
allowed = true
|
221
|
+
break
|
222
|
+
end
|
223
|
+
end
|
224
|
+
unless allowed
|
225
|
+
raise "Headers come in six sizes 1-6, #{size.to_s} is not one of them."
|
226
|
+
end
|
227
|
+
aattrs = [
|
228
|
+
"class", "id", "title", "dir", "xml:lang",
|
229
|
+
"onclick", "ondblclick", "onkeydown", "onkeypress",
|
230
|
+
"onkeyup", "onmousedown", "onmousemove", "onmouseout",
|
231
|
+
"onmouseover", "onmouseup"
|
232
|
+
]
|
233
|
+
childs = [
|
234
|
+
"a", "abbr", "acronym", "b", "bdo", "big", "br", "button",
|
235
|
+
"cite", "code", "del", "dfn", "em", "i", "img", "input",
|
236
|
+
"ins", "kbd", "label", "map", "object", "q", "samp", "script",
|
237
|
+
"select", "small", "span", "strong", "sub", "sup", "textarea",
|
238
|
+
"tt", "var"
|
239
|
+
]
|
240
|
+
super("h#{size.to_s}", aattrs, childs, attrs)
|
241
|
+
@start_element = "<h#{size.to_s}"
|
242
|
+
@end_element = "</h#{size.to_s}>"
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
#A keyboard element '<kbd></kbd>'
|
247
|
+
#Use: Defines keyboard text
|
248
|
+
class Keyboard < ContainerElement
|
249
|
+
#Create a new Keyboard element,
|
250
|
+
#takes a optional hash of attributes as parameter.
|
251
|
+
def initialize(attrs={})
|
252
|
+
aattrs = [
|
253
|
+
"class", "id", "title", "dir", "xml:lang",
|
254
|
+
"onclick", "ondblclick", "onkeydown", "onkeypress",
|
255
|
+
"onkeyup", "onmousedown", "onmousemove", "onmouseout",
|
256
|
+
"onmouseover", "onmouseup"
|
257
|
+
]
|
258
|
+
childs = [
|
259
|
+
"a", "abbr", "acronym", "b", "bdo", "big", "br", "button",
|
260
|
+
"cite", "code", "del" ,"dfn", "em", "i", "img", "input",
|
261
|
+
"ins", "kbd", "label", "map", "object", "q", "samp", "script",
|
262
|
+
"select", "small", "span", "strong", "sub", "sup", "textarea",
|
263
|
+
"tt", "var"
|
264
|
+
]
|
265
|
+
super("kbd", aattrs, childs, attrs)
|
266
|
+
@start_element = "<kbd"
|
267
|
+
@end_element = "</kbd>"
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
271
|
+
#A paragraph element '<p></p>'
|
272
|
+
#Use: Define a new paragraph.
|
273
|
+
class Paragraph < ContainerElement
|
274
|
+
#Create a new Paragraph element, takes a optional hash of attributes as parameter.
|
275
|
+
def initialize(attrs={})
|
276
|
+
aattrs = [
|
277
|
+
"class", "id", "title", "dir", "xml:lang",
|
278
|
+
"onclick", "ondblclick", "onkeydown", "onkeypress",
|
279
|
+
"onkeyup", "onmousedown", "onmousemove", "onmouseout",
|
280
|
+
"onmouseover", "onmouseup"
|
281
|
+
]
|
282
|
+
childs = [
|
283
|
+
"a", "abbr", "acronym", "b", "bdo", "big", "br", "button",
|
284
|
+
"cite", "code", "del", "dfn", "em", "i", "img", "input",
|
285
|
+
"ins", "kbd", "label", "map", "object", "q", "samp", "script",
|
286
|
+
"select", "small", "span", "strong", "sub", "sup", "textarea",
|
287
|
+
"tt", "var"
|
288
|
+
]
|
289
|
+
super("p", aattrs, childs, attrs)
|
290
|
+
@start_element = "<p"
|
291
|
+
@end_element = "</p>"
|
292
|
+
end
|
293
|
+
end
|
294
|
+
|
295
|
+
#A Preformat element
|
296
|
+
#Use: define preformatted text
|
297
|
+
class Preformat < ContainerElement
|
298
|
+
#Create a new Preformat element, takes a optional hash of attributes as parameter.
|
299
|
+
def initialize(attrs={})
|
300
|
+
aattrs = [
|
301
|
+
"class", "id", "title", "dir", "xml:lang",
|
302
|
+
"onclick", "ondblclick", "onkeydown", "onkeypress",
|
303
|
+
"onkeyup", "onmousedown", "onmousemove", "onmouseout",
|
304
|
+
"onmouseover", "onmouseup"
|
305
|
+
]
|
306
|
+
childs = [
|
307
|
+
"a", "abbr", "acronym", "b", "bdo", "big", "br", "button",
|
308
|
+
"cite", "code", "del", "dfn", "em", "i", "input", "ins",
|
309
|
+
"kbd", "label", "map", "q", "samp" ,"script", "select",
|
310
|
+
"small", "span", "strong", "sub", "sup", "textarea", "tt", "var"
|
311
|
+
]
|
312
|
+
super("pre", aattrs, childs, attrs)
|
313
|
+
@start_element = "<pre"
|
314
|
+
@end_element = "</pre>"
|
315
|
+
end
|
316
|
+
end
|
317
|
+
|
318
|
+
#A quotaton element
|
319
|
+
#Use: Define a quotation.
|
320
|
+
class Quotation < ContainerElement
|
321
|
+
#Create a new Quotation element, takes a optional hash of attributes as parameter.
|
322
|
+
def initialize(attrs={})
|
323
|
+
aattrs = [
|
324
|
+
"class", "id", "title", "dir", "xml:lang",
|
325
|
+
"onclick", "ondblclick", "onkeydown", "onkeypress",
|
326
|
+
"onkeyup", "onmousedown", "onmousemove", "onmouseout",
|
327
|
+
"onmouseover", "onmouseup"
|
328
|
+
]
|
329
|
+
childs = [
|
330
|
+
"a", "abbr", "acronym", "b", "bdo", "big", "br", "button",
|
331
|
+
"cite", "code", "del", "dfn", "em" ,"i", "img", "input",
|
332
|
+
"ins", "kbd", "label", "map" ,"object", "q", "samp", "script",
|
333
|
+
"select", "small" ,"span" ,"strong" ,"sub", "sup", "textarea",
|
334
|
+
"tt", "var"
|
335
|
+
]
|
336
|
+
super("q", aattrs, childs, attrs)
|
337
|
+
@start_element = "<q"
|
338
|
+
@end_element = "</q>"
|
339
|
+
end
|
340
|
+
end
|
341
|
+
|
342
|
+
#A sample element
|
343
|
+
#Use: Define a sample code text.
|
344
|
+
class Sample < ContainerElement
|
345
|
+
#Create a new Sample element, takes a optional hash of attributes as parameter.
|
346
|
+
def initialize(attrs={})
|
347
|
+
aattrs = [
|
348
|
+
"class" ,"id" ,"title", "dir", "xml:lang",
|
349
|
+
"onclick", "ondblclick", "onkeydown", "onkeypress",
|
350
|
+
"onkeyup", "onmousedown", "onmousemove", "onmouseout",
|
351
|
+
"onmouseover", "onmouseup"
|
352
|
+
]
|
353
|
+
childs = [
|
354
|
+
"a", "abbr", "acronym", "b", "bdo", "big", "br", "button",
|
355
|
+
"cite", "code", "del", "dfn", "em", "i", "img" , "input",
|
356
|
+
"ins", "kbd", "label", "map", "object", "q", "samp", "script",
|
357
|
+
"select", "small", "span", "strong", "sub", "sup",
|
358
|
+
"textarea", "tt", "var"
|
359
|
+
]
|
360
|
+
super("samp", aattrs, childs, attrs)
|
361
|
+
@start_element = "<samp"
|
362
|
+
@end_element = "</samp>"
|
363
|
+
end
|
364
|
+
end
|
365
|
+
|
366
|
+
#A span element
|
367
|
+
#Use: define a inline grouping of elements.
|
368
|
+
class Span < ContainerElement
|
369
|
+
#Create a new Span element, takes a optional hash of attributes as parameter.
|
370
|
+
def initialize(attrs={})
|
371
|
+
aattrs = [
|
372
|
+
"class", "id" ,"title", "dir", "xml:lang",
|
373
|
+
"onclick", "ondblclick", "onkeydown", "onkeypress",
|
374
|
+
"onkeyup", "onmousedown", "onmousemove", "onmouseout",
|
375
|
+
"onmouseover", "onmouseup"
|
376
|
+
]
|
377
|
+
childs = [
|
378
|
+
"a", "abbr", "acronym", "b", "bdo", "big", "br", "button",
|
379
|
+
"cite", "code", "del", "dfn", "em" ,"i", "img", "input",
|
380
|
+
"ins", "kbd", "label", "map", "object", "q", "samp", "script",
|
381
|
+
"select", "small", "span", "strong", "sub", "sup", "textarea",
|
382
|
+
"tt", "var"
|
383
|
+
]
|
384
|
+
super("span", aattrs, childs, attrs)
|
385
|
+
@start_element = "<span"
|
386
|
+
@end_element = "</span>"
|
387
|
+
end
|
388
|
+
end
|
389
|
+
|
390
|
+
#A strong element
|
391
|
+
#Use: Defines a strong emphasized.
|
392
|
+
class Strong < ContainerElement
|
393
|
+
#Create a new Strong element, takes a optional hash of attributes as parameter.
|
394
|
+
def initialize(attrs={})
|
395
|
+
aattrs = [
|
396
|
+
"class", "id", "title", "dir", "xml:lang",
|
397
|
+
"onclick", "ondblclick", "onkeydown", "onkeypress",
|
398
|
+
"onkeyup", "onmousedown", "onmousemove", "onmouseout",
|
399
|
+
"onmouseover", "onmouseup"
|
400
|
+
]
|
401
|
+
childs = [
|
402
|
+
"a", "abbr", "acronym", "b" ,"bdo" ,"big", "br" ,"button",
|
403
|
+
"cite", "code", "del", "dfn", "em", "i", "img", "input",
|
404
|
+
"ins", "kbd", "label", "map", "object", "q", "samp", "script",
|
405
|
+
"select", "small", "span", "strong", "sub", "sup", "textarea",
|
406
|
+
"tt", "var"
|
407
|
+
]
|
408
|
+
super("strong", aattrs, childs, attrs)
|
409
|
+
@start_element = "<strong"
|
410
|
+
@end_element = "</strong>"
|
411
|
+
end
|
412
|
+
end
|
413
|
+
|
414
|
+
#A variable element
|
415
|
+
#Use: Defines a variable.
|
416
|
+
class Variable < ContainerElement
|
417
|
+
#Create a new Variable element, takes a optional hash of attributes as parameter.
|
418
|
+
def initialize(attrs={})
|
419
|
+
aattrs = [
|
420
|
+
"class", "id", "title", "dir", "xml:lang",
|
421
|
+
"onclick", "ondblclick", "onkeydown", "onkeypress",
|
422
|
+
"onkeyup", "onmousedown", "onmousemove", "onmouseout",
|
423
|
+
"onmouseover", "onmouseup"
|
424
|
+
]
|
425
|
+
childs = [
|
426
|
+
"a", "abbr", "acronym", "b", "bdo" ,"big", "br" ,"button",
|
427
|
+
"cite", "code", "del", "dfn", "em", "i", "img", "input",
|
428
|
+
"ins", "kbd", "label", "map", "object", "q", "samp", "script",
|
429
|
+
"select", "small", "span", "strong", "sub", "sup", "textarea",
|
430
|
+
"tt", "var"
|
431
|
+
]
|
432
|
+
super("var", aattrs, childs, attrs)
|
433
|
+
@start_element = "<var"
|
434
|
+
@end_element = "</var>"
|
435
|
+
end
|
436
|
+
end
|
437
|
+
|
438
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
include Base
|
2
|
+
|
3
|
+
#The Projects module contains the classes that act as good starting points for
|
4
|
+
#reparcs projects.
|
5
|
+
module Projects
|
6
|
+
|
7
|
+
#A Page(or document). If you project requires you to make
|
8
|
+
#a single html page, this is where you should start.
|
9
|
+
class Page < ContainerElement
|
10
|
+
#Create a new Page
|
11
|
+
def initialize
|
12
|
+
super("html")
|
13
|
+
@xml_lang = "en"
|
14
|
+
@lang = "en"
|
15
|
+
@xmlns = "http://www.w3.org/1999/xhtml"
|
16
|
+
@charset = "utf-8"
|
17
|
+
@start_element = %{<!DOCTYPE html PUBLIC
|
18
|
+
"-//W3C//DTD XHTML 1.0 Transitional//EN"
|
19
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
20
|
+
<html
|
21
|
+
xml:lang=\"#{@xml_lang}\"
|
22
|
+
lang=\"#{@lang}\"
|
23
|
+
xmlns=\"#{@xmlns}\"}.strip()
|
24
|
+
@end_element = "</html>"
|
25
|
+
["head", "body"].each do |c|
|
26
|
+
@allowed_child_elements << c
|
27
|
+
end
|
28
|
+
@head = Head.new
|
29
|
+
append(@head)
|
30
|
+
@body = Body.new
|
31
|
+
append(@body)
|
32
|
+
c_type = Meta.new
|
33
|
+
c_type.set_attribute("http-equiv", "Content-Type")
|
34
|
+
c_type.set_attribute("content", "text/html;charset=#{@charset}")
|
35
|
+
@head.append(c_type)
|
36
|
+
end
|
37
|
+
#'puts' the string representation(the entire xhtml tree)
|
38
|
+
def to_puts
|
39
|
+
puts to_s
|
40
|
+
end
|
41
|
+
#----->
|
42
|
+
attr_accessor :head, :body, :xml_lang, :lang, :xmlns, :charset
|
43
|
+
end
|
44
|
+
|
45
|
+
#A Project, a good starting point for larger projects, that require
|
46
|
+
#other files, etc.
|
47
|
+
class Project
|
48
|
+
#Create a new Project.
|
49
|
+
def initialize
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
include StructureElements
|
2
|
+
include TextElements
|
3
|
+
|
4
|
+
#A collection of shortcut methods for reparcs
|
5
|
+
module Shortcuts
|
6
|
+
|
7
|
+
#A shortcut for creating a anchor
|
8
|
+
#takes the url, and the text as parameter
|
9
|
+
def shortcut_anchor(href, text)
|
10
|
+
anchor = Anchor.new({:href => href})
|
11
|
+
anchor.append(text)
|
12
|
+
return anchor
|
13
|
+
end
|
14
|
+
|
15
|
+
#A shortcut for creating a header
|
16
|
+
#takes the header size, and the header text as parameters.
|
17
|
+
def shortcut_header(size, heading)
|
18
|
+
head = Header.new(size)
|
19
|
+
head.append(heading)
|
20
|
+
return head
|
21
|
+
end
|
22
|
+
|
23
|
+
#A shortcut for creating a unordered list 'ul'
|
24
|
+
#takes an array of elements or strings for the list items.
|
25
|
+
def shortcut_unordered_list(array)
|
26
|
+
ul = UnorderedList.new
|
27
|
+
array.each do |i|
|
28
|
+
li = ListItem.new
|
29
|
+
li.append(i)
|
30
|
+
ul.append(li)
|
31
|
+
end
|
32
|
+
return ul
|
33
|
+
end
|
34
|
+
|
35
|
+
#A shortcut for creating a select '<select></select>'
|
36
|
+
#takes a hash object as parameter.
|
37
|
+
def shortcut_select(hash)
|
38
|
+
select = Select.new
|
39
|
+
hash.each do |key, val|
|
40
|
+
option = Option.new({:value => val})
|
41
|
+
option.append(key)
|
42
|
+
select.append(option)
|
43
|
+
end
|
44
|
+
return select
|
45
|
+
end
|
46
|
+
|
47
|
+
#A shortcut for creating a script '<script type="text/javascript"></script>'
|
48
|
+
#takes the javascipt code as parameter
|
49
|
+
def shortcut_script(code)
|
50
|
+
script = Script.new({:type => 'text/javascript'})
|
51
|
+
script.append(code)
|
52
|
+
return script
|
53
|
+
end
|
54
|
+
|
55
|
+
#A shortcut for creating a style '<style type="text/css"></style>
|
56
|
+
#takes the css code as parameter
|
57
|
+
def shortcut_style(css)
|
58
|
+
style = Style.new({:type => 'text/css'})
|
59
|
+
style.append(css)
|
60
|
+
return style
|
61
|
+
end
|
62
|
+
|
63
|
+
#A shortcut for creating a title, takes the titles text as parameter.
|
64
|
+
def shortcut_title(text)
|
65
|
+
title = Title.new
|
66
|
+
title.append(text)
|
67
|
+
return title
|
68
|
+
end
|
69
|
+
|
70
|
+
#A shortcut for creating a meta data element '<meta http-equiv="?" conten="?" />
|
71
|
+
#takes the http-equiv type, and the content as parameters
|
72
|
+
def shortcut_meta(equiv, content)
|
73
|
+
meta = Meta.new({:content => content})
|
74
|
+
meta.set_attribute("http-equiv", equiv)
|
75
|
+
return meta
|
76
|
+
end
|
77
|
+
|
78
|
+
#A shortcut for creating a table of data,
|
79
|
+
#takes an array of headers, and a multidimensional array
|
80
|
+
# of the table data.
|
81
|
+
def shortcut_table(headers, data)
|
82
|
+
tbl = Table.new
|
83
|
+
tbl_hdrs = TableHeader.new
|
84
|
+
tbl_hdr_row = TableRow.new
|
85
|
+
headers.each do |h|
|
86
|
+
tc = TableHeaderCell.new
|
87
|
+
tc.append(h)
|
88
|
+
tbl_hdr_row.append(tc)
|
89
|
+
end
|
90
|
+
tbl_hdrs.append(tbl_hdr_row)
|
91
|
+
tbl.append(tbl_hdrs)
|
92
|
+
tbl_bdy = TableBody.new
|
93
|
+
data.each do |r|
|
94
|
+
tr = TableRow.new
|
95
|
+
r.each do |c|
|
96
|
+
tc = TableCell.new
|
97
|
+
tc.append(c)
|
98
|
+
tr.append(tc)
|
99
|
+
end
|
100
|
+
tbl_bdy.append(tr)
|
101
|
+
end
|
102
|
+
tbl.append(tbl_bdy)
|
103
|
+
return tbl
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
data/lib/reparcs.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'reparcs/base'
|
2
|
+
|
3
|
+
require 'reparcs/elements/base_elements'
|
4
|
+
require 'reparcs/elements/structure_elements'
|
5
|
+
require 'reparcs/elements/text_elements'
|
6
|
+
require 'reparcs/elements/hypertext_elements'
|
7
|
+
require 'reparcs/elements/link_elements'
|
8
|
+
require 'reparcs/elements/list_elements'
|
9
|
+
require 'reparcs/elements/object_elements'
|
10
|
+
require 'reparcs/elements/presentation_elements'
|
11
|
+
require 'reparcs/elements/edit_elements'
|
12
|
+
require 'reparcs/elements/form_elements'
|
13
|
+
require 'reparcs/elements/table_elements'
|
14
|
+
require 'reparcs/elements/image_elements'
|
15
|
+
require 'reparcs/elements/meta_elements'
|
16
|
+
require 'reparcs/elements/scripting_elements'
|
17
|
+
require 'reparcs/elements/stylesheet_elements'
|
18
|
+
|
19
|
+
require 'reparcs/xml_entities'
|
20
|
+
require 'reparcs/projects'
|
21
|
+
require 'reparcs/utilities'
|
22
|
+
require 'reparcs/shortcuts'
|
23
|
+
|
24
|
+
include Projects
|
25
|
+
|
26
|
+
include BaseElements
|
27
|
+
include StructureElements
|
28
|
+
include TextElements
|
29
|
+
include HypertextElements
|
30
|
+
include LinkElements
|
31
|
+
include ListElements
|
32
|
+
include ObjectElements
|
33
|
+
include PresentationElements
|
34
|
+
include EditElements
|
35
|
+
include FormElements
|
36
|
+
include TableElements
|
37
|
+
include ImageElements
|
38
|
+
include MetaElements
|
39
|
+
include ScriptingElements
|
40
|
+
include StylesheetElements
|
41
|
+
|
42
|
+
include Shortcuts
|
43
|
+
|
44
|
+
module Reparcs
|
45
|
+
VERSION = "0.1.0"
|
46
|
+
end
|