htmlgrid 1.1.7 → 1.2.2

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/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 -197
  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 +121 -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 +141 -91
  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 -26
  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 +66 -55
  69. data/test/test_text.rb +36 -31
  70. metadata +17 -4
  71. data/TooltipDialog.txt +0 -73
  72. data/interaction_no_inline.txt +0 -1216
@@ -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,119 +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
+ return nil unless ressource
41
42
  local_file = File.join(@@local_doc_dir, URI(ressource).path)
42
43
  File.exist?(local_file) ? File.read(local_file) : nil
43
44
  end
44
- def css_link(context, path=@lookandfeel.resource(:css))
45
- properties = {
46
- "rel" => "stylesheet",
47
- "type" => "text/css",
48
- "async" => "true",
49
- 'href' => path,
50
- }
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
+ }
51
53
  if (content = TemplateMethods.get_inline(path))
52
- properties.delete('href')
54
+ properties.delete("href")
53
55
  context.style(properties) { content }
54
56
  else
55
57
  context.link(properties)
56
58
  end
57
- end
58
- def css_links(context, path=@lookandfeel.resource(:css))
59
- links = self.class.const_get(:CSS_FILES).collect { |key|
60
- css_link(context, @lookandfeel.resource(key))
61
- }
62
- links.push(css_link(context, path)) if(path)
63
- links.join
64
- end
65
- def content(model, session=nil)
66
- __standard_component(model, self::class::CONTENT)
67
- end
68
- def dynamic_html_headers(context)
69
- ''
70
- end
71
- def foot(model, session=nil)
72
- __standard_component(model, self::class::FOOT)
73
- end
74
- def head(model, session=nil)
75
- __standard_component(model, self::class::HEAD)
76
- end
77
- def __standard_component(model, klass)
78
- if(klass.is_a?(Class))
79
- klass.new(model, @session, self)
80
- end
81
- end
82
- def html_head(context, &block)
83
- context.head {
84
- if(block_given?)
85
- block.call
86
- 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
87
94
  context.head << title(context) <<
88
- meta_tags(context) <<
89
- other_html_headers(context) <<
90
- css_links(context) <<
91
- javascripts(context)
92
- }
93
- end
94
- def javascripts(context)
95
- jscripts = self.class.const_get(:JAVASCRIPTS).collect { |key|
96
- properties = {
97
- "language" => "JavaScript",
98
- "type" => "text/javascript",
99
- "src" => @lookandfeel.resource_global(:javascript, "#{key}.js"),
100
- }
101
- context.script(properties)
102
- }
103
- jscripts.join
104
- end
105
- def meta_tags(context)
106
- self::class::META_TAGS.inject('') { |inj, properties|
107
- inj << context.meta(properties)
108
- }
109
- end
110
- def onload=(script)
111
- @attributes['onload'] = script
112
- end
113
- def other_html_headers(context)
114
- dynamic_html_headers(context)
115
- end
116
- def template_html(context, &block)
117
- args = {}
118
- if(dtd = @lookandfeel.lookup(:DOCTYPE))
119
- args.store('DOCTYPE', dtd)
120
- end
121
- context.html(args) {
122
- html_head(context) << context.body(@attributes) {
123
- template_tags(context, &block)
124
- }
125
- }
126
- end
127
- def template_tags(context, &block)
128
- block.call
129
- end
130
- def title(context)
131
- context.title { @lookandfeel.lookup(:html_title) }
132
- end
133
- def to_html(context)
134
- template_html(context) {
135
- super(context)
136
- }
137
- end
138
- end
139
- class Template < Composite
140
- include TemplateMethods
141
- 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
142
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