htmlgrid 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/lib/htmlgrid/booleanvalue.rb +14 -14
  3. data/lib/htmlgrid/button.rb +9 -9
  4. data/lib/htmlgrid/centeredcomposite.rb +21 -20
  5. data/lib/htmlgrid/component.rb +214 -199
  6. data/lib/htmlgrid/composite.rb +332 -301
  7. data/lib/htmlgrid/datevalue.rb +12 -12
  8. data/lib/htmlgrid/div.rb +9 -9
  9. data/lib/htmlgrid/divcomposite.rb +44 -43
  10. data/lib/htmlgrid/divform.rb +8 -8
  11. data/lib/htmlgrid/divlist.rb +17 -19
  12. data/lib/htmlgrid/divtemplate.rb +6 -6
  13. data/lib/htmlgrid/dojotoolkit.rb +54 -48
  14. data/lib/htmlgrid/errormessage.rb +47 -43
  15. data/lib/htmlgrid/form.rb +70 -62
  16. data/lib/htmlgrid/formlist.rb +14 -14
  17. data/lib/htmlgrid/grid.rb +111 -67
  18. data/lib/htmlgrid/image.rb +17 -16
  19. data/lib/htmlgrid/infomessage.rb +15 -14
  20. data/lib/htmlgrid/input.rb +34 -32
  21. data/lib/htmlgrid/inputcheckbox.rb +13 -13
  22. data/lib/htmlgrid/inputcurrency.rb +9 -9
  23. data/lib/htmlgrid/inputdate.rb +11 -11
  24. data/lib/htmlgrid/inputfile.rb +13 -12
  25. data/lib/htmlgrid/inputradio.rb +9 -9
  26. data/lib/htmlgrid/inputtext.rb +10 -10
  27. data/lib/htmlgrid/javascript.rb +17 -16
  28. data/lib/htmlgrid/label.rb +53 -49
  29. data/lib/htmlgrid/labeltext.rb +8 -8
  30. data/lib/htmlgrid/link.rb +31 -27
  31. data/lib/htmlgrid/list.rb +121 -110
  32. data/lib/htmlgrid/namedcomponent.rb +28 -25
  33. data/lib/htmlgrid/pass.rb +11 -11
  34. data/lib/htmlgrid/passthru.rb +20 -17
  35. data/lib/htmlgrid/popuplink.rb +41 -39
  36. data/lib/htmlgrid/reset.rb +8 -8
  37. data/lib/htmlgrid/richtext.rb +22 -20
  38. data/lib/htmlgrid/select.rb +28 -26
  39. data/lib/htmlgrid/span.rb +9 -9
  40. data/lib/htmlgrid/spancomposite.rb +18 -18
  41. data/lib/htmlgrid/spanlist.rb +9 -9
  42. data/lib/htmlgrid/staticinput.rb +14 -13
  43. data/lib/htmlgrid/submit.rb +9 -9
  44. data/lib/htmlgrid/template.rb +120 -105
  45. data/lib/htmlgrid/text.rb +9 -9
  46. data/lib/htmlgrid/textarea.rb +19 -17
  47. data/lib/htmlgrid/ulcomposite.rb +22 -22
  48. data/lib/htmlgrid/ullist.rb +9 -9
  49. data/lib/htmlgrid/urllink.rb +38 -36
  50. data/lib/htmlgrid/value.rb +9 -9
  51. data/lib/htmlgrid/version.rb +2 -2
  52. data/test/stub/cgi.rb +10 -7
  53. data/test/suite.rb +3 -3
  54. data/test/test_add_row.rb +12 -13
  55. data/test/test_component.rb +121 -100
  56. data/test/test_composite.rb +85 -46
  57. data/test/test_datevalue.rb +28 -24
  58. data/test/test_divlist.rb +126 -0
  59. data/test/test_dojotoolkit.rb +41 -27
  60. data/test/test_form.rb +89 -73
  61. data/test/test_formlist.rb +77 -65
  62. data/test/test_grid.rb +256 -208
  63. data/test/test_input.rb +37 -31
  64. data/test/test_interaction_list.rb +106 -70
  65. data/test/test_label.rb +91 -77
  66. data/test/test_list.rb +110 -95
  67. data/test/test_select.rb +35 -30
  68. data/test/test_template.rb +63 -55
  69. data/test/test_text.rb +36 -31
  70. metadata +17 -2
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: utf-8
2
+
3
3
  #
4
4
  # HtmlGrid -- HyperTextMarkupLanguage Framework
5
5
  # Copyright (C) 2003 ywesee - intellectual capital connected
@@ -24,120 +24,135 @@
24
24
  #
25
25
  # Template -- htmlgrid -- 19.11.2002 -- hwyss@ywesee.com
26
26
 
27
- require 'htmlgrid/composite'
28
- require 'uri'
27
+ require "htmlgrid/composite"
28
+ require "uri"
29
29
 
30
30
  module HtmlGrid
31
- module TemplateMethods
32
- CONTENT = nil
33
- FOOT = nil
34
- HEAD = nil
35
- META_TAGS = []
36
- LEGACY_INTERFACE = true
37
- CSS_FILES = []
38
- JAVASCRIPTS = []
39
- @@local_doc_dir = File.join(Dir.pwd, 'doc')
40
- def TemplateMethods.get_inline(ressource)
31
+ module TemplateMethods
32
+ CONTENT = nil
33
+ FOOT = nil
34
+ HEAD = nil
35
+ META_TAGS = []
36
+ LEGACY_INTERFACE = true
37
+ CSS_FILES = []
38
+ JAVASCRIPTS = []
39
+ @@local_doc_dir = File.join(Dir.pwd, "doc")
40
+ def self.get_inline(ressource)
41
41
  return nil unless ressource
42
42
  local_file = File.join(@@local_doc_dir, URI(ressource).path)
43
43
  File.exist?(local_file) ? File.read(local_file) : nil
44
44
  end
45
- def css_link(context, path=@lookandfeel.resource(:css))
46
- properties = {
47
- "rel" => "stylesheet",
48
- "type" => "text/css",
49
- "async" => "true",
50
- 'href' => path,
51
- }
45
+
46
+ def css_link(context, path = @lookandfeel.resource(:css))
47
+ properties = {
48
+ "rel" => "stylesheet",
49
+ "type" => "text/css",
50
+ "async" => "true",
51
+ "href" => path
52
+ }
52
53
  if (content = TemplateMethods.get_inline(path))
53
- properties.delete('href')
54
+ properties.delete("href")
54
55
  context.style(properties) { content }
55
56
  else
56
57
  context.link(properties)
57
58
  end
58
- end
59
- def css_links(context, path=@lookandfeel.resource(:css))
60
- links = self.class.const_get(:CSS_FILES).collect { |key|
61
- css_link(context, @lookandfeel.resource(key))
62
- }
63
- links.push(css_link(context, path)) if(path)
64
- links.join
65
- end
66
- def content(model, session=nil)
67
- __standard_component(model, self::class::CONTENT)
68
- end
69
- def dynamic_html_headers(context)
70
- ''
71
- end
72
- def foot(model, session=nil)
73
- __standard_component(model, self::class::FOOT)
74
- end
75
- def head(model, session=nil)
76
- __standard_component(model, self::class::HEAD)
77
- end
78
- def __standard_component(model, klass)
79
- if(klass.is_a?(Class))
80
- klass.new(model, @session, self)
81
- end
82
- end
83
- def html_head(context, &block)
84
- context.head {
85
- if(block_given?)
86
- block.call
87
- end
59
+ end
60
+
61
+ def css_links(context, path = @lookandfeel.resource(:css))
62
+ links = self.class.const_get(:CSS_FILES).collect { |key|
63
+ css_link(context, @lookandfeel.resource(key))
64
+ }
65
+ links.push(css_link(context, path)) if path
66
+ links.join
67
+ end
68
+
69
+ def content(model, session = nil)
70
+ __standard_component(model, self.class::CONTENT)
71
+ end
72
+
73
+ def dynamic_html_headers(context)
74
+ ""
75
+ end
76
+
77
+ def foot(model, session = nil)
78
+ __standard_component(model, self.class::FOOT)
79
+ end
80
+
81
+ def head(model, session = nil)
82
+ __standard_component(model, self.class::HEAD)
83
+ end
84
+
85
+ def __standard_component(model, klass)
86
+ if klass.is_a?(Class)
87
+ klass.new(model, @session, self)
88
+ end
89
+ end
90
+
91
+ def html_head(context, &block)
92
+ context.head {
93
+ block&.call
88
94
  context.head << title(context) <<
89
- meta_tags(context) <<
90
- other_html_headers(context) <<
91
- css_links(context) <<
92
- javascripts(context)
93
- }
94
- end
95
- def javascripts(context)
96
- jscripts = self.class.const_get(:JAVASCRIPTS).collect { |key|
97
- properties = {
98
- "language" => "JavaScript",
99
- "type" => "text/javascript",
100
- "src" => @lookandfeel.resource_global(:javascript, "#{key}.js"),
101
- }
102
- context.script(properties)
103
- }
104
- jscripts.join
105
- end
106
- def meta_tags(context)
107
- self::class::META_TAGS.inject('') { |inj, properties|
108
- inj << context.meta(properties)
109
- }
110
- end
111
- def onload=(script)
112
- @attributes['onload'] = script
113
- end
114
- def other_html_headers(context)
115
- dynamic_html_headers(context)
116
- end
117
- def template_html(context, &block)
118
- args = {}
119
- if(dtd = @lookandfeel.lookup(:DOCTYPE))
120
- args.store('DOCTYPE', dtd)
121
- end
122
- context.html(args) {
123
- html_head(context) << context.body(@attributes) {
124
- template_tags(context, &block)
125
- }
126
- }
127
- end
128
- def template_tags(context, &block)
129
- block.call
130
- end
131
- def title(context)
132
- context.title { @lookandfeel.lookup(:html_title) }
133
- end
134
- def to_html(context)
135
- template_html(context) {
136
- super(context)
137
- }
138
- end
139
- end
140
- class Template < Composite
141
- include TemplateMethods
142
- end
95
+ meta_tags(context) <<
96
+ other_html_headers(context) <<
97
+ css_links(context) <<
98
+ javascripts(context)
99
+ }
100
+ end
101
+
102
+ def javascripts(context)
103
+ jscripts = self.class.const_get(:JAVASCRIPTS).collect { |key|
104
+ properties = {
105
+ "language" => "JavaScript",
106
+ "type" => "text/javascript",
107
+ "src" => @lookandfeel.resource_global(:javascript, "#{key}.js")
108
+ }
109
+ context.script(properties)
110
+ }
111
+ jscripts.join
112
+ end
113
+
114
+ def meta_tags(context)
115
+ self.class::META_TAGS.inject("") { |inj, properties|
116
+ inj << context.meta(properties)
117
+ }
118
+ end
119
+
120
+ def onload=(script)
121
+ @attributes["onload"] = script
122
+ end
123
+
124
+ def other_html_headers(context)
125
+ dynamic_html_headers(context)
126
+ end
127
+
128
+ def template_html(context, &block)
129
+ args = {}
130
+ if (dtd = @lookandfeel.lookup(:DOCTYPE))
131
+ args.store("DOCTYPE", dtd)
132
+ end
133
+ context.html(args) {
134
+ html_head(context) << context.body(@attributes) {
135
+ template_tags(context, &block)
136
+ }
137
+ }
138
+ end
139
+
140
+ def template_tags(context, &block)
141
+ block.call
142
+ end
143
+
144
+ def title(context)
145
+ context.title { @lookandfeel.lookup(:html_title) }
146
+ end
147
+
148
+ def to_html(context)
149
+ template_html(context) {
150
+ super(context)
151
+ }
152
+ end
153
+ end
154
+
155
+ class Template < Composite
156
+ include TemplateMethods
157
+ end
143
158
  end
data/lib/htmlgrid/text.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: utf-8
2
+
3
3
  #
4
4
  # HtmlGrid -- HyperTextMarkupLanguage Framework
5
5
  # Copyright (C) 2003 ywesee - intellectual capital connected
@@ -22,15 +22,15 @@
22
22
  # ywesee - intellectual capital connected, Winterthurerstrasse 52, CH-8006 Zuerich, Switzerland
23
23
  # htmlgrid@ywesee.com, www.ywesee.com/htmlgrid
24
24
  #
25
- # Text -- htmlgrid -- 20.11.2002 -- hwyss@ywesee.com
25
+ # Text -- htmlgrid -- 20.11.2002 -- hwyss@ywesee.com
26
26
 
27
- require 'htmlgrid/namedcomponent'
27
+ require "htmlgrid/namedcomponent"
28
28
 
29
29
  module HtmlGrid
30
- class Text < NamedComponent
31
- def init
32
- super
33
- @value = @lookandfeel.lookup(@name)
34
- end
35
- end
30
+ class Text < NamedComponent
31
+ def init
32
+ super
33
+ @value = @lookandfeel.lookup(@name)
34
+ end
35
+ end
36
36
  end
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: utf-8
2
+
3
3
  #
4
4
  # HtmlGrid -- HyperTextMarkupLanguage Framework
5
5
  # Copyright (C) 2003 ywesee - intellectual capital connected
@@ -24,26 +24,28 @@
24
24
  #
25
25
  # Textarea -- htmlgrid -- 12.12.2002 -- benfay@ywesee.com
26
26
 
27
- require 'htmlgrid/input'
27
+ require "htmlgrid/input"
28
28
 
29
29
  module HtmlGrid
30
- class Textarea < Input
31
- attr_writer :value
30
+ class Textarea < Input
31
+ attr_writer :value
32
32
  attr_accessor :unescaped
33
- def to_html(context)
34
- context.textarea(@attributes) {
35
- _to_html(context, @value)
36
- }
37
- end
33
+ def to_html(context)
34
+ context.textarea(@attributes) {
35
+ _to_html(context, @value)
36
+ }
37
+ end
38
+
38
39
  def escape_value(elm)
39
40
  @unescaped ? elm.to_s : escape(elm.to_s)
40
41
  end
41
- def _to_html(context, value=@value)
42
- if(value.is_a?(Array))
43
- value.collect { |elm| escape_value elm }.join("\n")
44
- else
45
- escape_value value
46
- end.strip
47
- end
48
- end
42
+
43
+ def _to_html(context, value = @value)
44
+ if value.is_a?(Array)
45
+ value.collect { |elm| escape_value elm }.join("\n")
46
+ else
47
+ escape_value value
48
+ end.strip
49
+ end
50
+ end
49
51
  end
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: utf-8
2
+
3
3
  #
4
4
  # HtmlGrid -- HyperTextMarkupLanguage Framework
5
5
  # Copyright (C) 2003 ywesee - intellectual capital connected
@@ -22,28 +22,28 @@
22
22
  # ywesee - intellectual capital connected, Winterthurerstrasse 52, CH-8006 Zuerich, Switzerland
23
23
  # htmlgrid@ywesee.com, www.ywesee.com/htmlgrid
24
24
  #
25
- # Template -- htmlgrid -- 23.10.2002 -- hwyss@ywesee.com
25
+ # Template -- htmlgrid -- 23.10.2002 -- hwyss@ywesee.com
26
26
 
27
- require 'htmlgrid/composite'
27
+ require "htmlgrid/composite"
28
28
 
29
29
  module HtmlGrid
30
- class UlComposite < TagComposite
31
- def to_html(context)
32
- res = ''
33
- res << context.ul(tag_attributes) {
34
- inner_res = ''
35
- @grid.each_with_index { |li, idx|
36
- inner_res << context.li(tag_attributes(idx)) {
37
- if(li.respond_to?(:to_html))
38
- li.to_html(context).force_encoding('utf-8')
39
- else
40
- li
41
- end
42
- }
43
- }
44
- inner_res
45
- }
46
- res
47
- end
48
- end
30
+ class UlComposite < TagComposite
31
+ def to_html(context)
32
+ res = ""
33
+ res << context.ul(tag_attributes) {
34
+ inner_res = ""
35
+ @grid.each_with_index { |li, idx|
36
+ inner_res << context.li(tag_attributes(idx)) {
37
+ if li.respond_to?(:to_html)
38
+ li.to_html(context).force_encoding("utf-8")
39
+ else
40
+ li
41
+ end
42
+ }
43
+ }
44
+ inner_res
45
+ }
46
+ res
47
+ end
48
+ end
49
49
  end
@@ -1,15 +1,15 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: utf-8
2
+
3
3
  # HtmlGrid::UlList -- davaz.com -- 25.04.2006 -- mhuggler@ywesee.com
4
4
 
5
- require 'htmlgrid/ulcomposite'
5
+ require "htmlgrid/ulcomposite"
6
6
 
7
7
  module HtmlGrid
8
- class UlList < HtmlGrid::UlComposite
9
- def compose(model=@model)
10
- @model.each { |item|
11
- super(item)
12
- }
13
- end
14
- end
8
+ class UlList < HtmlGrid::UlComposite
9
+ def compose(model = @model)
10
+ @model.each { |item|
11
+ super(item)
12
+ }
13
+ end
14
+ end
15
15
  end
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- # encoding: utf-8
2
+
3
3
  #
4
4
  # HtmlGrid -- HyperTextMarkupLanguage Framework
5
5
  # Copyright (C) 2003 ywesee - intellectual capital connected
@@ -24,42 +24,44 @@
24
24
  #
25
25
  # UrlLink -- htmlgrid -- 10.06.2003 -- aschrafl@ywesee.com
26
26
 
27
- require 'htmlgrid/link'
27
+ require "htmlgrid/link"
28
+
29
+ module HtmlGrid
30
+ class UrlLink < Link
31
+ def init
32
+ super
33
+ if @model.respond_to?(@name)
34
+ @value = @model.send(@name).to_s
35
+ end
36
+ compose_link
37
+ end
38
+ end
28
39
 
29
- module HtmlGrid
30
- class UrlLink < Link
31
- def init
32
- super
33
- if(@model.respond_to?(@name))
34
- @value = @model.send(@name).to_s
35
- end
36
- compose_link
37
- end
38
- end
39
- class HttpLink < UrlLink
40
+ class HttpLink < UrlLink
40
41
  @@http_ptrn = /^http:/
41
- LABEL = true
42
- def compose_link
43
- unless @value.nil?
44
- if @@http_ptrn.match(@value)
45
- self.href = @value
46
- else
47
- self.href = "http://" + @value
48
- end
49
- set_attribute('target', '_blank')
50
- end
51
- end
52
- end
53
- class MailLink < UrlLink
54
- LABEL = true
42
+ LABEL = true
43
+ def compose_link
44
+ unless @value.nil?
45
+ self.href = if @@http_ptrn.match(@value)
46
+ @value
47
+ else
48
+ "http://" + @value
49
+ end
50
+ set_attribute("target", "_blank")
51
+ end
52
+ end
53
+ end
54
+
55
+ class MailLink < UrlLink
56
+ LABEL = true
55
57
  @@mailto_ptrn = /^mailto:/
56
- def compose_link
57
- unless @value.empty?
58
- self.href = @value
59
- unless @@mailto_ptrn.match(@value)
60
- self.href = "mailto:"+@value
61
- end
62
- end
63
- end
64
- end
58
+ def compose_link
59
+ unless @value.empty?
60
+ self.href = @value
61
+ unless @@mailto_ptrn.match(@value)
62
+ self.href = "mailto:" + @value
63
+ end
64
+ end
65
+ end
66
+ end
65
67
  end