htmlgrid 1.1.6 → 1.2.1

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 (72) hide show
  1. checksums.yaml +4 -4
  2. data/TooltipDialog.txt +73 -0
  3. data/interaction_no_inline.txt +1216 -0
  4. data/lib/htmlgrid/booleanvalue.rb +14 -14
  5. data/lib/htmlgrid/button.rb +9 -9
  6. data/lib/htmlgrid/centeredcomposite.rb +21 -20
  7. data/lib/htmlgrid/component.rb +214 -197
  8. data/lib/htmlgrid/composite.rb +332 -301
  9. data/lib/htmlgrid/datevalue.rb +12 -12
  10. data/lib/htmlgrid/div.rb +9 -9
  11. data/lib/htmlgrid/divcomposite.rb +44 -43
  12. data/lib/htmlgrid/divform.rb +8 -8
  13. data/lib/htmlgrid/divlist.rb +17 -19
  14. data/lib/htmlgrid/divtemplate.rb +6 -6
  15. data/lib/htmlgrid/dojotoolkit.rb +86 -53
  16. data/lib/htmlgrid/errormessage.rb +47 -43
  17. data/lib/htmlgrid/form.rb +70 -62
  18. data/lib/htmlgrid/formlist.rb +14 -14
  19. data/lib/htmlgrid/grid.rb +111 -67
  20. data/lib/htmlgrid/image.rb +17 -16
  21. data/lib/htmlgrid/infomessage.rb +15 -14
  22. data/lib/htmlgrid/input.rb +34 -32
  23. data/lib/htmlgrid/inputcheckbox.rb +13 -13
  24. data/lib/htmlgrid/inputcurrency.rb +9 -9
  25. data/lib/htmlgrid/inputdate.rb +11 -11
  26. data/lib/htmlgrid/inputfile.rb +13 -12
  27. data/lib/htmlgrid/inputradio.rb +9 -9
  28. data/lib/htmlgrid/inputtext.rb +10 -10
  29. data/lib/htmlgrid/javascript.rb +17 -16
  30. data/lib/htmlgrid/label.rb +53 -49
  31. data/lib/htmlgrid/labeltext.rb +8 -8
  32. data/lib/htmlgrid/link.rb +31 -27
  33. data/lib/htmlgrid/list.rb +121 -110
  34. data/lib/htmlgrid/namedcomponent.rb +28 -25
  35. data/lib/htmlgrid/pass.rb +11 -11
  36. data/lib/htmlgrid/passthru.rb +20 -17
  37. data/lib/htmlgrid/popuplink.rb +41 -39
  38. data/lib/htmlgrid/reset.rb +8 -8
  39. data/lib/htmlgrid/richtext.rb +22 -20
  40. data/lib/htmlgrid/select.rb +28 -26
  41. data/lib/htmlgrid/span.rb +9 -9
  42. data/lib/htmlgrid/spancomposite.rb +18 -18
  43. data/lib/htmlgrid/spanlist.rb +9 -9
  44. data/lib/htmlgrid/staticinput.rb +14 -13
  45. data/lib/htmlgrid/submit.rb +9 -9
  46. data/lib/htmlgrid/template.rb +124 -112
  47. data/lib/htmlgrid/text.rb +9 -9
  48. data/lib/htmlgrid/textarea.rb +19 -17
  49. data/lib/htmlgrid/ulcomposite.rb +22 -22
  50. data/lib/htmlgrid/ullist.rb +9 -9
  51. data/lib/htmlgrid/urllink.rb +38 -36
  52. data/lib/htmlgrid/value.rb +9 -9
  53. data/lib/htmlgrid/version.rb +2 -2
  54. data/test/stub/cgi.rb +10 -7
  55. data/test/suite.rb +3 -3
  56. data/test/test_add_row.rb +12 -13
  57. data/test/test_component.rb +141 -91
  58. data/test/test_composite.rb +85 -46
  59. data/test/test_datevalue.rb +28 -24
  60. data/test/test_divlist.rb +126 -0
  61. data/test/test_dojotoolkit.rb +41 -26
  62. data/test/test_form.rb +89 -73
  63. data/test/test_formlist.rb +77 -65
  64. data/test/test_grid.rb +256 -208
  65. data/test/test_input.rb +37 -31
  66. data/test/test_interaction_list.rb +106 -70
  67. data/test/test_label.rb +91 -77
  68. data/test/test_list.rb +110 -95
  69. data/test/test_select.rb +35 -30
  70. data/test/test_template.rb +66 -55
  71. data/test/test_text.rb +36 -31
  72. metadata +20 -3
@@ -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,125 +22,137 @@
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 -- 19.11.2002 -- hwyss@ywesee.com
25
+ # Template -- htmlgrid -- 19.11.2002 -- hwyss@ywesee.com
26
26
 
27
- require 'htmlgrid/composite'
27
+ require "htmlgrid/composite"
28
+ require "uri"
28
29
 
29
30
  module HtmlGrid
30
- module TemplateMethods
31
- CONTENT = nil
32
- FOOT = nil
33
- HEAD = nil
34
- META_TAGS = []
35
- LEGACY_INTERFACE = true
36
- CSS_FILES = []
37
- JAVASCRIPTS = []
38
- @@local_doc_dir = File.join(Dir.pwd, 'doc')
39
- def 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
+ return nil unless ressource
40
42
  local_file = File.join(@@local_doc_dir, URI(ressource).path)
41
- if File.exist?(local_file)
42
- # puts "Reading #{ressource} #{local_file} #{File.size(local_file)}"
43
- File.read(local_file)
44
- else
45
- nil
46
- end
43
+ File.exist?(local_file) ? File.read(local_file) : nil
47
44
  end
48
- def css_link(context, path=@lookandfeel.resource(:css))
49
- properties = {
50
- "rel" => "stylesheet",
51
- "type" => "text/css",
52
- "async" => "true",
53
- 'href' => path,
54
- }
55
- if (content = get_inline(path))
56
- properties.delete('href')
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
+ }
53
+ if (content = TemplateMethods.get_inline(path))
54
+ properties.delete("href")
57
55
  context.style(properties) { content }
58
56
  else
59
57
  context.link(properties)
60
58
  end
61
- end
62
- def css_links(context, path=@lookandfeel.resource(:css))
63
- links = self.class.const_get(:CSS_FILES).collect { |key|
64
- css_link(context, @lookandfeel.resource(key))
65
- }
66
- links.push(css_link(context, path)) if(path)
67
- links.join
68
- end
69
- def content(model, session=nil)
70
- __standard_component(model, self::class::CONTENT)
71
- end
72
- def dynamic_html_headers(context)
73
- ''
74
- end
75
- def foot(model, session=nil)
76
- __standard_component(model, self::class::FOOT)
77
- end
78
- def head(model, session=nil)
79
- __standard_component(model, self::class::HEAD)
80
- end
81
- def __standard_component(model, klass)
82
- if(klass.is_a?(Class))
83
- klass.new(model, @session, self)
84
- end
85
- end
86
- def html_head(context, &block)
87
- context.head {
88
- if(block_given?)
89
- block.call
90
- 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
91
94
  context.head << title(context) <<
92
- meta_tags(context) <<
93
- other_html_headers(context) <<
94
- css_links(context) <<
95
- javascripts(context)
96
- }
97
- end
98
- def javascripts(context)
99
- jscripts = self.class.const_get(:JAVASCRIPTS).collect { |key|
100
- properties = {
101
- "language" => "JavaScript",
102
- "type" => "text/javascript",
103
- "src" => @lookandfeel.resource_global(:javascript, "#{key}.js"),
104
- }
105
- context.script(properties)
106
- }
107
- jscripts.join
108
- end
109
- def meta_tags(context)
110
- self::class::META_TAGS.inject('') { |inj, properties|
111
- inj << context.meta(properties)
112
- }
113
- end
114
- def onload=(script)
115
- @attributes['onload'] = script
116
- end
117
- def other_html_headers(context)
118
- dynamic_html_headers(context)
119
- end
120
- def template_html(context, &block)
121
- args = {}
122
- if(dtd = @lookandfeel.lookup(:DOCTYPE))
123
- args.store('DOCTYPE', dtd)
124
- end
125
- context.html(args) {
126
- html_head(context) << context.body(@attributes) {
127
- template_tags(context, &block)
128
- }
129
- }
130
- end
131
- def template_tags(context, &block)
132
- block.call
133
- end
134
- def title(context)
135
- context.title { @lookandfeel.lookup(:html_title) }
136
- end
137
- def to_html(context)
138
- template_html(context) {
139
- super(context)
140
- }
141
- end
142
- end
143
- class Template < Composite
144
- include TemplateMethods
145
- 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
146
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