cyberweb 0.12.35 → 0.13.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +220 -124
  3. data/bin/cyberweb_sanitize +1 -1
  4. data/bin/images_from_this_webpage +1 -1
  5. data/doc/README.gen +209 -98
  6. data/doc/configuration/configuration.md +7 -4
  7. data/doc/todo/todo_for_the_cyberweb_project.md +123 -133
  8. data/examples/html/underlined_text_example/underlined_text_example.html +40 -0
  9. data/examples/misc/table_example.rb +19 -17
  10. data/examples/objectified/objectified_caesar_cipher.cgi +73 -0
  11. data/images/cyberweb_theme.png +0 -0
  12. data/lib/cyberweb/REST/constants.rb +1 -1
  13. data/lib/cyberweb/base/base.rb +19 -27
  14. data/lib/cyberweb/base_module/base_module/base_module.rb +31 -16
  15. data/lib/cyberweb/base_module/colours/colours.rb +0 -8
  16. data/lib/cyberweb/cascading_style_sheets/margin.css +4 -0
  17. data/lib/cyberweb/cascading_style_sheets/misc.css +15 -0
  18. data/lib/cyberweb/cgi/cookie.rb +160 -156
  19. data/lib/cyberweb/cgi/core.rb +7 -7
  20. data/lib/cyberweb/cgi/query_extension.rb +1 -1
  21. data/lib/cyberweb/cgi/session/memory_store.rb +1 -1
  22. data/lib/cyberweb/cgi/session/pstore.rb +2 -2
  23. data/lib/cyberweb/cgi/session.rb +1 -1
  24. data/lib/cyberweb/cgi/util.rb +4 -1
  25. data/lib/cyberweb/cmd/cmd.rb +12 -10
  26. data/lib/cyberweb/coloured_tags/coloured_tags.rb +1 -1
  27. data/lib/cyberweb/colours/colour_chart.rb +1 -2
  28. data/lib/cyberweb/colours/colours.rb +1 -1
  29. data/lib/cyberweb/commandline/commandline_interface.rb +1 -1
  30. data/lib/cyberweb/configuration/load_the_configuration.rb +3 -1
  31. data/lib/cyberweb/constants/http_status_codes.rb +4 -1
  32. data/lib/cyberweb/constants/misc.rb +8 -6
  33. data/lib/cyberweb/constants/registered_html_tags.rb +6 -5
  34. data/lib/cyberweb/constants/user_x.rb +7 -0
  35. data/lib/cyberweb/css_manager/css_manager.rb +5 -2
  36. data/lib/cyberweb/encoding/encoding.rb +1 -1
  37. data/lib/cyberweb/erb/test.rhtml +7 -2
  38. data/lib/cyberweb/experimental/html_template_powered_by_rack.rb +3 -1
  39. data/lib/cyberweb/foto_gallery/foto_gallery.rb +3 -0
  40. data/lib/cyberweb/generator/cgi.rb +1 -1
  41. data/lib/cyberweb/html_template/html_template.rb +262 -253
  42. data/lib/cyberweb/images/images.rb +2 -2
  43. data/lib/cyberweb/images/remove_this_substring_from_all_images.rb +5 -1
  44. data/lib/cyberweb/images/standard_images/standard_images.html +3 -4
  45. data/lib/cyberweb/information/README.md +2 -2
  46. data/lib/cyberweb/information/information.cgi +1 -1
  47. data/lib/cyberweb/javascript/dragula_collection.rb +4 -1
  48. data/lib/cyberweb/javascript/javascript_magic.rb +2 -2
  49. data/lib/cyberweb/javascript/on_click_change_opacity.rb +2 -1
  50. data/lib/cyberweb/javascript/popup.rb +8 -1
  51. data/lib/cyberweb/javascript/snoweffect.rb +5 -1
  52. data/lib/cyberweb/javascript_code/custom_functions.js +50 -32
  53. data/lib/cyberweb/objectified/html_tags/README.md +7 -9
  54. data/lib/cyberweb/objectified/html_tags/a.rb +62 -3
  55. data/lib/cyberweb/objectified/html_tags/abbr.rb +33 -3
  56. data/lib/cyberweb/objectified/html_tags/audio.rb +33 -3
  57. data/lib/cyberweb/objectified/html_tags/base.rb +661 -588
  58. data/lib/cyberweb/objectified/html_tags/blockquote.rb +33 -3
  59. data/lib/cyberweb/objectified/html_tags/body.rb +43 -3
  60. data/lib/cyberweb/objectified/html_tags/button.rb +75 -5
  61. data/lib/cyberweb/objectified/html_tags/canvas.rb +43 -3
  62. data/lib/cyberweb/objectified/html_tags/cite.rb +43 -3
  63. data/lib/cyberweb/objectified/html_tags/div.rb +70 -7
  64. data/lib/cyberweb/objectified/html_tags/embed.rb +43 -3
  65. data/lib/cyberweb/objectified/html_tags/fieldset.rb +43 -3
  66. data/lib/cyberweb/objectified/html_tags/figure.rb +43 -3
  67. data/lib/cyberweb/objectified/html_tags/form.rb +78 -3
  68. data/lib/cyberweb/objectified/html_tags/h1.rb +43 -3
  69. data/lib/cyberweb/objectified/html_tags/h2.rb +43 -3
  70. data/lib/cyberweb/objectified/html_tags/h3.rb +43 -3
  71. data/lib/cyberweb/objectified/html_tags/h4.rb +43 -3
  72. data/lib/cyberweb/objectified/html_tags/h5.rb +43 -3
  73. data/lib/cyberweb/objectified/html_tags/h6.rb +43 -3
  74. data/lib/cyberweb/objectified/html_tags/head.rb +34 -1
  75. data/lib/cyberweb/objectified/html_tags/i.rb +112 -0
  76. data/lib/cyberweb/objectified/html_tags/img.rb +65 -18
  77. data/lib/cyberweb/objectified/html_tags/input.rb +86 -2
  78. data/lib/cyberweb/objectified/html_tags/label.rb +103 -0
  79. data/lib/cyberweb/objectified/html_tags/legend.rb +129 -0
  80. data/lib/cyberweb/objectified/html_tags/li.rb +111 -0
  81. data/lib/cyberweb/objectified/html_tags/map.rb +43 -3
  82. data/lib/cyberweb/objectified/html_tags/meta.rb +13 -2
  83. data/lib/cyberweb/objectified/html_tags/nav.rb +111 -0
  84. data/lib/cyberweb/objectified/html_tags/object.rb +33 -3
  85. data/lib/cyberweb/objectified/html_tags/ol.rb +127 -0
  86. data/lib/cyberweb/objectified/html_tags/p.rb +33 -3
  87. data/lib/cyberweb/objectified/html_tags/pre.rb +41 -4
  88. data/lib/cyberweb/objectified/html_tags/progress.rb +43 -3
  89. data/lib/cyberweb/objectified/html_tags/section.rb +116 -0
  90. data/lib/cyberweb/objectified/html_tags/select.rb +34 -1
  91. data/lib/cyberweb/objectified/html_tags/span.rb +64 -5
  92. data/lib/cyberweb/objectified/html_tags/style.rb +9 -2
  93. data/lib/cyberweb/objectified/html_tags/table.rb +137 -3
  94. data/lib/cyberweb/objectified/html_tags/td.rb +135 -0
  95. data/lib/cyberweb/objectified/html_tags/textarea.rb +37 -3
  96. data/lib/cyberweb/objectified/html_tags/th.rb +114 -0
  97. data/lib/cyberweb/objectified/html_tags/thead.rb +114 -0
  98. data/lib/cyberweb/objectified/html_tags/title.rb +10 -2
  99. data/lib/cyberweb/objectified/html_tags/tr.rb +110 -0
  100. data/lib/cyberweb/objectified/html_tags/ul.rb +45 -4
  101. data/lib/cyberweb/objectified/shorter_helper_methods/shorter_helper_methods.rb +67 -46
  102. data/lib/cyberweb/oop.rb +9 -0
  103. data/lib/cyberweb/predefined_and_freeform_methods/hash_registered_extra_tags.rb +2 -0
  104. data/lib/cyberweb/predefined_and_freeform_methods/header.rb +4 -1
  105. data/lib/cyberweb/project/project.rb +0 -4
  106. data/lib/cyberweb/requires/remove_html.rb +1 -1
  107. data/lib/cyberweb/requires/require_the_cyberweb_project.rb +1 -9
  108. data/lib/cyberweb/route_handler/module/route_handler_module.rb +2 -1
  109. data/lib/cyberweb/standalone_classes/all_css_classes.rb +5 -2
  110. data/lib/cyberweb/standalone_classes/calculator.rb +3 -1
  111. data/lib/cyberweb/toplevel_methods/audio.rb +3 -1
  112. data/lib/cyberweb/toplevel_methods/csv.rb +1 -1
  113. data/lib/cyberweb/toplevel_methods/frames.rb +11 -3
  114. data/lib/cyberweb/toplevel_methods/greek_letters/greek_letters.rb +3 -0
  115. data/lib/cyberweb/toplevel_methods/hfin.rb +5 -1
  116. data/lib/cyberweb/toplevel_methods/html_tags/README.md +8 -7
  117. data/lib/cyberweb/toplevel_methods/html_tags/html_tags.rb +4211 -2827
  118. data/lib/cyberweb/toplevel_methods/html_tags/table.rb +1202 -0
  119. data/lib/cyberweb/toplevel_methods/javascript.rb +9 -1
  120. data/lib/cyberweb/toplevel_methods/jquery.rb +1 -1
  121. data/lib/cyberweb/toplevel_methods/{log_directory.rb → log_directory_and_logging.rb} +36 -1
  122. data/lib/cyberweb/toplevel_methods/params.rb +11 -11
  123. data/lib/cyberweb/toplevel_methods/random.rb +4 -3
  124. data/lib/cyberweb/toplevel_methods/registered_ids.rb +3 -0
  125. data/lib/cyberweb/toplevel_methods/return_head_start.rb +1 -3
  126. data/lib/cyberweb/toplevel_methods/return_html_start.rb +1 -3
  127. data/lib/cyberweb/toplevel_methods/sanitize_url.rb +2 -1
  128. data/lib/cyberweb/toplevel_methods/server_base_directory.rb +0 -1
  129. data/lib/cyberweb/toplevel_methods/textile.rb +2 -1
  130. data/lib/cyberweb/toplevel_methods/{misc.rb → toplevel_methods.rb} +1446 -807
  131. data/lib/cyberweb/toplevel_methods/video.rb +21 -3
  132. data/lib/cyberweb/toplevel_methods/write_what_into.rb +2 -2
  133. data/lib/cyberweb/utility_scripts/autogenerate_drop_shadow_rules/autogenerate_drop_shadow_rules.rb +2 -4
  134. data/lib/cyberweb/utility_scripts/booklet/booklet.rb +0 -4
  135. data/lib/cyberweb/utility_scripts/download_all_images_from_this_website.rb +1 -1
  136. data/lib/cyberweb/utility_scripts/{download_balloon_css.rb → download_balloon_css/download_balloon_css.rb} +1 -1
  137. data/lib/cyberweb/utility_scripts/images_to_html/images_to_html.rb +3 -0
  138. data/lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb +183 -71
  139. data/lib/cyberweb/utility_scripts/pdf_to_html/pdf_to_html.rb +160 -65
  140. data/lib/cyberweb/version/version.rb +2 -2
  141. data/lib/cyberweb/web_images/map_symbol_to_image_location.rb +13 -2
  142. data/lib/cyberweb/web_object/web_object.rb +62 -20
  143. data/lib/cyberweb/web_scraper/scrape_this_url.rb +3 -1
  144. data/lib/cyberweb/webmin/biology_server.cgi +1 -1
  145. data/lib/cyberweb/webmin/calculator.cgi +1 -1
  146. data/lib/cyberweb/webmin/colour_chart.cgi +1 -1
  147. data/lib/cyberweb/webmin/comments.cgi +2 -2
  148. data/lib/cyberweb/webmin/constants.rb +1 -1
  149. data/lib/cyberweb/webmin/dictionary.cgi +2 -2
  150. data/lib/cyberweb/webmin/simple_forum/index.cgi +2 -2
  151. data/lib/cyberweb/webmin/sys_info.cgi +3 -3
  152. data/lib/cyberweb/webmin/webforum.cgi +1 -1
  153. data/lib/cyberweb/yaml/registered_html_tags.yml +3 -1
  154. data/test/simple_tests/testing_return_dataset_without_any_comments.rb +1 -1
  155. metadata +23 -57
  156. data/lib/cyberweb/html_tags/README.md +0 -3
  157. data/lib/cyberweb/html_tags/a.rb +0 -67
  158. data/lib/cyberweb/html_tags/accesskey.rb +0 -25
  159. data/lib/cyberweb/html_tags/blockquote.rb +0 -56
  160. data/lib/cyberweb/html_tags/body.rb +0 -14
  161. data/lib/cyberweb/html_tags/br.rb +0 -19
  162. data/lib/cyberweb/html_tags/button.rb +0 -150
  163. data/lib/cyberweb/html_tags/canvas.rb +0 -59
  164. data/lib/cyberweb/html_tags/chtml.rb +0 -14
  165. data/lib/cyberweb/html_tags/div.rb +0 -170
  166. data/lib/cyberweb/html_tags/fieldset.rb +0 -69
  167. data/lib/cyberweb/html_tags/figure.rb +0 -72
  168. data/lib/cyberweb/html_tags/form.rb +0 -203
  169. data/lib/cyberweb/html_tags/h1.rb +0 -77
  170. data/lib/cyberweb/html_tags/h2.rb +0 -81
  171. data/lib/cyberweb/html_tags/h3.rb +0 -60
  172. data/lib/cyberweb/html_tags/h4.rb +0 -66
  173. data/lib/cyberweb/html_tags/h5.rb +0 -64
  174. data/lib/cyberweb/html_tags/h6.rb +0 -60
  175. data/lib/cyberweb/html_tags/hr.rb +0 -22
  176. data/lib/cyberweb/html_tags/html_tags.rb +0 -267
  177. data/lib/cyberweb/html_tags/i.rb +0 -52
  178. data/lib/cyberweb/html_tags/img.rb +0 -294
  179. data/lib/cyberweb/html_tags/input.rb +0 -354
  180. data/lib/cyberweb/html_tags/label.rb +0 -65
  181. data/lib/cyberweb/html_tags/legend.rb +0 -56
  182. data/lib/cyberweb/html_tags/li.rb +0 -67
  183. data/lib/cyberweb/html_tags/map.rb +0 -38
  184. data/lib/cyberweb/html_tags/nav.rb +0 -63
  185. data/lib/cyberweb/html_tags/object.rb +0 -57
  186. data/lib/cyberweb/html_tags/ol.rb +0 -57
  187. data/lib/cyberweb/html_tags/option.rb +0 -64
  188. data/lib/cyberweb/html_tags/p.rb +0 -88
  189. data/lib/cyberweb/html_tags/pre.rb +0 -162
  190. data/lib/cyberweb/html_tags/section.rb +0 -33
  191. data/lib/cyberweb/html_tags/select.rb +0 -104
  192. data/lib/cyberweb/html_tags/span.rb +0 -344
  193. data/lib/cyberweb/html_tags/strong.rb +0 -42
  194. data/lib/cyberweb/html_tags/table.rb +0 -284
  195. data/lib/cyberweb/html_tags/tbody.rb +0 -26
  196. data/lib/cyberweb/html_tags/td.rb +0 -212
  197. data/lib/cyberweb/html_tags/textarea.rb +0 -173
  198. data/lib/cyberweb/html_tags/th.rb +0 -70
  199. data/lib/cyberweb/html_tags/thead.rb +0 -41
  200. data/lib/cyberweb/html_tags/tr.rb +0 -99
  201. data/lib/cyberweb/html_tags/ul.rb +0 -51
  202. data/lib/cyberweb/requires/require_html_tags_files.rb +0 -23
  203. data/lib/cyberweb/toplevel_methods/logging.rb +0 -42
  204. data/lib/cyberweb/web_base/web_base.rb +0 -33
@@ -0,0 +1,1202 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'cyberweb/toplevel_methods/html_tags/table.rb'
6
+ # =========================================================================== #
7
+ module Cyberweb
8
+
9
+ # ========================================================================= #
10
+ # === @array_tables
11
+ #
12
+ # All table-strings are stored in this Array as well.
13
+ # ========================================================================= #
14
+ @array_tables = []
15
+
16
+ # ========================================================================= #
17
+ # === Cyberweb.array_tables?
18
+ # ========================================================================= #
19
+ def self.array_tables?
20
+ @array_tables
21
+ end; self.instance_eval { alias tables? array_tables? } # === Cyberweb.tables?
22
+
23
+ # ========================================================================= #
24
+ # === Cyberweb.append_to_tables
25
+ # ========================================================================= #
26
+ def self.append_to_tables(i = nil)
27
+ @array_tables << i if i
28
+ end; self.instance_eval { alias add_this_to_the_registered_tables append_to_tables } # === Cyberweb.add_this_to_the_registered_tables
29
+
30
+ # ========================================================================= #
31
+ # === Cyberweb.string_ctable
32
+ #
33
+ # This returns a properly closed </table> tag.
34
+ # ========================================================================= #
35
+ def self.string_ctable
36
+ HtmlTags.ctable
37
+ end
38
+
39
+ # ========================================================================= #
40
+ # === string_ctable
41
+ #
42
+ # This returns a properly closed </table> tag.
43
+ # ========================================================================= #
44
+ def string_ctable
45
+ ::Cyberweb.ctable
46
+ end
47
+
48
+ # ========================================================================= #
49
+ # === table_with_caption
50
+ #
51
+ # This is a table with a leading "caption".
52
+ # ========================================================================= #
53
+ def table_with_caption(
54
+ caption = 'README',
55
+ css_class = Table.to_s,
56
+ the_id = '',
57
+ css_style = ''
58
+ )
59
+ fieldset(style: 'width: 70%; margin-left: 1em'){ # This is the leading caption.
60
+ legend caption
61
+ table(css_class, the_id, css_style) { yield if block_given? }
62
+ }
63
+ end
64
+
65
+ # ========================================================================= #
66
+ # === Cyberweb.ctable
67
+ # ========================================================================= #
68
+ def self.ctable
69
+ eclose :table
70
+ end
71
+
72
+ # ========================================================================= #
73
+ # === ctable
74
+ # ========================================================================= #
75
+ def ctable
76
+ ::Cyberweb.ctable
77
+ end
78
+
79
+ # ========================================================================= #
80
+ # === Cyberweb.table (table tag)
81
+ #
82
+ # This will simply create a <table> tag.
83
+ #
84
+ # You can optionally pass a block, which will then be used as input for
85
+ # the method (its dataset). We need an array for it to work.
86
+ #
87
+ # In case the input is a Hash, we convert it into array format first.
88
+ #
89
+ # Usage example:
90
+ #
91
+ # Cyberweb.table('mars1em','test_table','border:1px solid rand') { %w( abc def ghi jkl ) }
92
+ #
93
+ # ========================================================================= #
94
+ def self.table(
95
+ css_class = Table.css_class?,
96
+ the_id = '',
97
+ css_style = '',
98
+ &block
99
+ )
100
+ css_class = Table.css_class? if css_class == 'DEF' # Use default here.
101
+ result = ''.dup
102
+ result << HtmlTags.table(nil, css_class, the_id, css_style, &block) # nil for default empty '' String.
103
+ ee result # Output the result too.
104
+ end
105
+
106
+ # ========================================================================= #
107
+ # === table
108
+ #
109
+ # The last argument allows us to easily pass blocks to the parent method.
110
+ #
111
+ # Usage example:
112
+ #
113
+ # table('mars1em','test_table','border:1px solid rand') { %w( abc def ghi jkl ) }
114
+ #
115
+ # ========================================================================= #
116
+ def table(
117
+ a = Table.css_class?.to_s,
118
+ b = '',
119
+ c = '', &block
120
+ )
121
+ ::Cyberweb.table(a,b,c, &block)
122
+ end
123
+
124
+ # ========================================================================= #
125
+ # === Cyberweb.string_table2
126
+ #
127
+ # This returns the string form of a <table> tag.
128
+ #
129
+ # Arguments to this method could look like this:
130
+ #
131
+ # Cyberweb.string_table2('mars1em') { an_array_here } # To pass an array as the main dataset.
132
+ # Cyberweb.string_table2('mars1em') { [1,2,3,4,5,6] } # ^^^ as stated above
133
+ #
134
+ # ========================================================================= #
135
+ def self.string_table2(
136
+ css_class = '',
137
+ id = '',
138
+ css_style = '',
139
+ *content,
140
+ &block
141
+ )
142
+ # ======================================================================= #
143
+ # === apply_this_special_style
144
+ #
145
+ # The next variable can have any of these values:
146
+ #
147
+ # nil
148
+ # :left_side_is_bold
149
+ # :right_side_is_bold
150
+ # :both_sides_are_bold
151
+ #
152
+ # ======================================================================= #
153
+ apply_this_special_style = nil
154
+ content = content.flatten.compact # Make it more useful to our case.
155
+ # ======================================================================= #
156
+ # === Handle blocks next
157
+ # ======================================================================= #
158
+ if block_given?
159
+ yielded = yield
160
+ # ===================================================================== #
161
+ # === Handle Hashes past this point
162
+ # ===================================================================== #
163
+ if yielded.is_a? Hash
164
+ # =================================================================== #
165
+ # === :with_this_data
166
+ # =================================================================== #
167
+ if yielded.has_key? :with_this_data
168
+ content = yielded.delete(:with_this_data)
169
+ # =================================================================== #
170
+ # === :use_this_dataset
171
+ # =================================================================== #
172
+ elsif yielded.has_key? :use_this_dataset
173
+ content = yielded.delete(:use_this_dataset)
174
+ end
175
+ # =================================================================== #
176
+ # === :apply_this_special_style
177
+ # =================================================================== #
178
+ if yielded.has_key? :apply_this_special_style
179
+ apply_this_special_style = yielded.delete(:apply_this_special_style)
180
+ end
181
+ # =================================================================== #
182
+ # === :read_in_this_file
183
+ # =================================================================== #
184
+ if yielded.has_key?(:read_in_this_file) or yielded.has_key?(:read_this_file)
185
+ this_file = yielded.delete(:read_in_this_file) if yielded.has_key?(:read_in_this_file)
186
+ this_file = yielded.delete(:read_this_file) if yielded.has_key?(:read_this_file)
187
+ if File.exist? this_file
188
+ if this_file.end_with?('.yml')
189
+ content = YAML.load_file(this_file)
190
+ if content.is_a? Hash
191
+ content.reject! {|key, value| key.include? ' [DONE]' } # <- Ad-hoc for my system.
192
+ content = Array[*content].flatten # Trying this since as of October 2023.
193
+ end
194
+ else
195
+ content = File.readlines(this_file, encoding: 'UTF-8')
196
+ end
197
+ # =============================================================== #
198
+ # === :split_at
199
+ # =============================================================== #
200
+ if yielded.has_key?(:split_at)
201
+ split_at = yielded.delete(:split_at)
202
+ content.map! {|entry|
203
+ entry = entry.split(split_at) if entry.include?('|')
204
+ entry
205
+ }
206
+ content.flatten! if content.respond_to?(:flatten!)
207
+ end
208
+ end
209
+ end
210
+ end
211
+ # ===================================================================== #
212
+ # If content is empty then we will replace the content with the
213
+ # value of the passed block next.
214
+ # ===================================================================== #
215
+ if content.empty? and !yielded.empty?
216
+ content = yielded
217
+ end
218
+ end
219
+ css_class = css_class.to_s
220
+
221
+ _ = '<table'.dup
222
+ _ << return_css_class(css_class)
223
+ _ << return_the_id(id)
224
+ _ << return_css_style(css_style)
225
+ _ << '>'
226
+ _ << "\n"
227
+
228
+ content.each_with_index { |item, index|
229
+ if index % 2 == 0
230
+ _ << '<tr>'+N # Begin a new row.
231
+ case apply_this_special_style
232
+ # =================================================================== #
233
+ # === :left_side_is_bold
234
+ # =================================================================== #
235
+ when :left_side_is_bold
236
+ _ << " <td><b>#{item}</b></td>#{N}"
237
+ else # this is the default
238
+ _ << " <td>#{item}</td>#{N}"
239
+ end
240
+ else
241
+ _ << " <td>#{item}</td>#{N}</tr>#{N}"
242
+ end
243
+ }
244
+ _ << ::Cyberweb.string_ctable.to_s
245
+ return _
246
+ end; self.instance_eval { alias string_table string_table2 } # === Cyberweb.string_table
247
+
248
+ # ========================================================================= #
249
+ # === Cyberweb.string_table9
250
+ #
251
+ # This returns the string form of a <table> tag.
252
+ # ========================================================================= #
253
+ def self.string_table9(
254
+ css_class = '',
255
+ id = '',
256
+ css_style = '',
257
+ *content
258
+ )
259
+ content = content.flatten.compact # Make it more useful to our case.
260
+ _ = '<table'.dup
261
+ _ << return_css_class(css_class)
262
+ _ << return_the_id(id)
263
+ _ << return_css_style(css_style) unless css_style.empty?
264
+ _ << '>'
265
+ _ << "\n"
266
+ content.each_with_index { |item, index|
267
+ result = index % 9
268
+ _ << '<tr>'+N if result == 0 # 0 means to add a '<tr>' tag first.
269
+ # when 0, 1, 2, 3
270
+ _ << '<td>'+item+'</td>'+N
271
+ _ << '</tr>'+N if result == 8 # This must be 1 less.
272
+ }
273
+ _ << ::Cyberweb.string_ctable.to_s
274
+ return _
275
+ end
276
+
277
+ # ========================================================================= #
278
+ # === Cyberweb.string_table8
279
+ #
280
+ # This returns the string form of a <table> tag.
281
+ # ========================================================================= #
282
+ def self.string_table8(
283
+ css_class = '',
284
+ id = '',
285
+ css_style = '',
286
+ *content
287
+ )
288
+ content = content.flatten.compact # Make it more useful to our case.
289
+ _ = '<table'.dup
290
+ _ << return_css_class(css_class)
291
+ _ << return_the_id(id)
292
+ _ << return_css_style(css_style) unless css_style.empty?
293
+ _ << '>'
294
+ _ << "\n"
295
+ content.each_with_index { |item, index|
296
+ result = index % 8
297
+ _ << '<tr>'+N if result == 0 # 0 means to add a '<tr>' tag first.
298
+ # when 0, 1, 2, 3
299
+ _ << '<td>'+item+'</td>'+N
300
+ _ << '</tr>'+N if result == 7 # This must be 1 less.
301
+ }
302
+ _ << ::Cyberweb.string_ctable.to_s
303
+ return _
304
+ end
305
+
306
+ # ========================================================================= #
307
+ # === Cyberweb.string_table6
308
+ #
309
+ # This returns the string form of a <table> tag.
310
+ # ========================================================================= #
311
+ def self.string_table6(
312
+ css_class = '',
313
+ id = '',
314
+ css_style = '',
315
+ *content
316
+ )
317
+ content = content.flatten.compact # Make it more useful to our case.
318
+ _ = '<table'.dup
319
+ _ << return_css_class(css_class)
320
+ _ << return_the_id(id)
321
+ _ << return_css_style(css_style) unless css_style.empty?
322
+ _ << '>'
323
+ _ << "\n"
324
+ content.each_with_index { |item, index|
325
+ result = index % 6
326
+ _ << '<tr>'+N if result == 0 # 0 means to add a '<tr>' tag first.
327
+ # when 0, 1, 2, 3
328
+ _ << '<td>'+item+'</td>'+N
329
+ _ << '</tr>'+N if result == 5 # This must be 1 less.
330
+ }
331
+ _ << ::Cyberweb.string_ctable.to_s
332
+ return _
333
+ end
334
+
335
+ # ========================================================================= #
336
+ # === Cyberweb.string_table5
337
+ #
338
+ # This returns the string form of a <table> tag.
339
+ # ========================================================================= #
340
+ def self.string_table5(
341
+ css_class = '',
342
+ id = '',
343
+ css_style = '',
344
+ *content
345
+ )
346
+ content = content.flatten.compact # Make it more useful to our case.
347
+ _ = '<table'.dup
348
+ _ << return_css_class(css_class)
349
+ _ << return_the_id(id)
350
+ _ << return_css_style(css_style) unless css_style.empty?
351
+ _ << '>'
352
+ _ << "\n"
353
+ content.each_with_index { |item, index|
354
+ result = index % 5
355
+ _ << '<tr>'+N if result == 0 # 0 means to add a '<tr>' tag first.
356
+ # when 0, 1, 2, 3
357
+ _ << '<td>'+item+'</td>'+N
358
+ _ << '</tr>'+N if result == 4 # This must be 1 less.
359
+ }
360
+ _ << ::Cyberweb.string_ctable.to_s
361
+ return _
362
+ end
363
+
364
+ # ========================================================================= #
365
+ # === Cyberweb.string_table3
366
+ #
367
+ # This returns the string form of a <table> tag.
368
+ # ========================================================================= #
369
+ def self.string_table3(
370
+ css_class = '',
371
+ id = '',
372
+ css_style = '',
373
+ *content,
374
+ &block
375
+ )
376
+ content = content.flatten.compact # Make it more useful to our case.
377
+ # ======================================================================= #
378
+ # === Handle blocks next
379
+ # ======================================================================= #
380
+ if block_given?
381
+ yielded = yield
382
+ if yielded.is_a? Hash
383
+ # =================================================================== #
384
+ # === :with_this_data
385
+ # =================================================================== #
386
+ if yielded.has_key? :with_this_data
387
+ content = yielded.delete(:with_this_data)
388
+ end
389
+ # =================================================================== #
390
+ # === :read_in_this_file
391
+ # =================================================================== #
392
+ if yielded.has_key?(:read_in_this_file)
393
+ this_file = yielded.delete(:read_in_this_file)
394
+ if File.exist? this_file
395
+ content = File.readlines(this_file, encoding: 'UTF-8')
396
+ # =============================================================== #
397
+ # === :split_at
398
+ # =============================================================== #
399
+ if yielded.has_key?(:split_at)
400
+ split_at = yielded.delete(:split_at)
401
+ content.map! {|entry|
402
+ entry = entry.split(split_at) if entry.include?('|')
403
+ entry
404
+ }
405
+ content.flatten!
406
+ end
407
+ end
408
+ end
409
+ end
410
+ end
411
+ _ = '<table'.dup
412
+ _ << return_css_class(css_class)
413
+ _ << return_the_id(id)
414
+ _ << return_css_style(css_style)
415
+ _ << '>'
416
+ _ << "\n"
417
+ content.each_with_index { |item, index|
418
+ if index % 3 == 0
419
+ _ << '<tr>'+N+' <td>'+item+'</td>'+N
420
+ elsif index % 3 == 2
421
+ _ << ' <td>'+item+'</td>'+N+'</tr>'+N
422
+ else
423
+ _ << ' <td>'+item+'</td>'+N+N
424
+ end
425
+ }
426
+ _ << ::Cyberweb.string_ctable.to_s
427
+ end
428
+
429
+ # ========================================================================= #
430
+ # === Cyberweb.string_table2_with_heading
431
+ #
432
+ # This variant makes use of two header-entries, via the <th> tag of the
433
+ # given table. The first two arguments passed into the content variable,
434
+ # which starts at argument #4, will become the table header.
435
+ # ========================================================================= #
436
+ def self.string_table2_with_heading(
437
+ css_class = '',
438
+ id = '',
439
+ css_style = '',
440
+ *content,
441
+ &block
442
+ )
443
+ content = content.flatten.compact # Make it more useful to our case.
444
+ # ======================================================================= #
445
+ # === Handle blocks next
446
+ # ======================================================================= #
447
+ if block_given?
448
+ yielded = yield
449
+ # ===================================================================== #
450
+ # If content is empty then we will replace the content with the
451
+ # value of the passed block next.
452
+ # ===================================================================== #
453
+ if content.empty? and !yielded.empty?
454
+ content = yielded
455
+ end
456
+ end
457
+ _ = '<table'.dup
458
+ _ << return_css_class(css_class)
459
+ _ << return_the_id(id)
460
+ _ << return_css_style(css_style)
461
+ _ << '>'
462
+ _ << "\n"
463
+ first_header = content.shift
464
+ _ << '<tr>
465
+ <th>'+first_header.to_s+'</th>'
466
+ second_header = content.shift
467
+ _ << '<th>'+second_header.to_s+'</th></tr>'
468
+ content.each_with_index { |item, index|
469
+ case index % 2
470
+ when 0
471
+ _ << '<tr>'+N+' <td>'+item+'</td>'+N
472
+ else
473
+ _ << ' <td>'+item+'</td>'+N+'</tr>'+N
474
+ end
475
+ }
476
+ _ << ::Cyberweb.string_ctable.to_s
477
+ end
478
+
479
+ # ========================================================================= #
480
+ # === Cyberweb.string_table4_with_heading
481
+ # ========================================================================= #
482
+ def self.string_table4_with_heading(
483
+ css_class = '',
484
+ id = '',
485
+ css_style = '',
486
+ *content
487
+ )
488
+ content = content.flatten.compact # Make it more useful to our case.
489
+ _ = '<table'.dup
490
+ _ << return_css_class(css_class)
491
+ _ << return_the_id(id)
492
+ _ << return_css_style(css_style)
493
+ _ << '>'
494
+ _ << "\n"
495
+ first_header = content.shift
496
+ _ << '<tr>
497
+ <th>'+first_header.to_s+'</th>'
498
+ second_header = content.shift
499
+ _ << "<th>#{second_header}</th>#{N}"
500
+ third_header = content.shift
501
+ _ << "<th>#{third_header}</th>#{N}"
502
+ fourth_header = content.shift
503
+ _ << "<th>#{fourth_header}</th>#{N}"
504
+ content.each_with_index { |item, index|
505
+ td_tag = '<td>'
506
+ if item.to_s.start_with? '#ALIGN_RIGHT#'
507
+ td_tag = '<td align="right">'
508
+ item = item.to_s.sub(/#ALIGN_RIGHT#/,'')
509
+ end
510
+ case index % 4
511
+ when 0 # New row.
512
+ _ << '<tr>'+N+' '+td_tag+item+'</td>'+N
513
+ when 3 # End row.
514
+ _ << N+' '+td_tag+item+'</td>'+N+'</tr>'
515
+ else # else it is a simple td-entry.
516
+ _ << ' '+td_tag+item+'</td>'+N
517
+ end
518
+ }
519
+ _ << ::Cyberweb.string_ctable.to_s
520
+ end
521
+
522
+ # ========================================================================= #
523
+ # === table4_with_heading
524
+ # ========================================================================= #
525
+ def table4_with_heading(
526
+ css_class = '',
527
+ id = '',
528
+ css_style = '',
529
+ *content,
530
+ &block
531
+ )
532
+ addnl(
533
+ Cyberweb.string_table4_with_heading(
534
+ css_class, id, css_style, *content, &block
535
+ )
536
+ )
537
+ end
538
+
539
+ # ========================================================================= #
540
+ # === table4
541
+ # ========================================================================= #
542
+ def table4(
543
+ css_class = '',
544
+ id = '',
545
+ css_style = '',
546
+ *content,
547
+ &block
548
+ )
549
+ customized_table(
550
+ 4, css_class, id, css_style, *content, &block
551
+ )
552
+ end
553
+
554
+ # ========================================================================= #
555
+ # === Cyberweb.string_table5_with_heading
556
+ # ========================================================================= #
557
+ def self.string_table5_with_heading(
558
+ css_class = '',
559
+ id = '',
560
+ css_style = '',
561
+ *content
562
+ )
563
+ content = content.flatten.compact # Make it more useful to our case.
564
+ _ = '<table'.dup
565
+ _ << return_css_class(css_class)
566
+ _ << return_the_id(id)
567
+ _ << return_css_style(css_style)
568
+ _ << '>'
569
+ _ << "\n"
570
+ first_header = content.shift
571
+ _ << '<tr>
572
+ <th>'+first_header.to_s+'</th>'
573
+ second_header = content.shift
574
+ _ << "<th>#{second_header}</th>#{N}"
575
+ third_header = content.shift
576
+ _ << "<th>#{third_header}</th>#{N}"
577
+ fourth_header = content.shift
578
+ _ << "<th>#{fourth_header}</th>#{N}"
579
+ fifth_header = content.shift
580
+ _ << "<th>#{fifth_header}</th></tr>"
581
+ content.each_with_index { |item, index|
582
+ td_tag = '<td>'
583
+ if item.to_s.start_with? '#ALIGN_RIGHT#'
584
+ td_tag = '<td align="right">'
585
+ item = item.to_s.sub(/#ALIGN_RIGHT#/,'')
586
+ end
587
+ case index % 5
588
+ when 0 # New row.
589
+ _ << '<tr>'+N+' '+td_tag+item+'</td>'+N
590
+ when 4 # End row.
591
+ _ << N+' '+td_tag+item+'</td>'+N+'</tr>'
592
+ else # else it is a simple td-entry.
593
+ _ << ' '+td_tag+item+'</td>'+N
594
+ end
595
+ }
596
+ _ << ::Cyberweb.string_ctable.to_s
597
+ end
598
+
599
+ # ========================================================================= #
600
+ # === Cyberweb.string_table11_with_heading
601
+ # ========================================================================= #
602
+ def self.string_table11_with_heading(
603
+ css_class = '',
604
+ id = '',
605
+ css_style = '',
606
+ *content
607
+ )
608
+ content = content.flatten.compact # Make it more useful to our case.
609
+ _ = '<table'.dup
610
+ _ << return_css_class(css_class)
611
+ _ << return_the_id(id)
612
+ _ << return_css_style(css_style)
613
+ _ << '>'
614
+ _ << "\n"
615
+ first_header = content.shift
616
+ _ << '<tr>
617
+ <th>'+first_header.to_s+'</th>'
618
+ second_header = content.shift
619
+ _ << "<th>#{second_header}</th>#{N}"
620
+ third_header = content.shift
621
+ _ << "<th>#{third_header}</th>#{N}"
622
+ fourth_header = content.shift
623
+ _ << "<th>#{fourth_header}</th>#{N}"
624
+ fifth_header = content.shift
625
+ _ << "<th>#{fifth_header}</th>#{N}"
626
+ header_six = content.shift
627
+ _ << "<th>#{header_six}</th>#{N}"
628
+ header_seven = content.shift
629
+ _ << "<th>#{header_seven}</th>#{N}"
630
+ header_eight = content.shift
631
+ _ << "<th>#{header_eight}</th>#{N}"
632
+ header_nine = content.shift
633
+ _ << "<th>#{header_nine}</th>#{N}"
634
+ header_ten = content.shift
635
+ _ << "<th>#{header_ten}</th>#{N}"
636
+ header_eleven = content.shift
637
+ _ << "<th>#{header_eleven}</th></tr>"
638
+ content.each_with_index { |item, index|
639
+ td_tag = '<td>'
640
+ if item.to_s.start_with? '#ALIGN_RIGHT#'
641
+ td_tag = '<td align="right">'
642
+ item = item.to_s.sub(/#ALIGN_RIGHT#/,'')
643
+ end
644
+ case index % 11
645
+ when 0 # New row.
646
+ _ << '<tr>'+N+' '+td_tag+item+'</td>'+N
647
+ when 10 # End row.
648
+ _ << N+' '+td_tag+item+'</td>'+N+'</tr>'
649
+ else # else it is a simple td-entry.
650
+ _ << ' '+td_tag+item+'</td>'+N
651
+ end
652
+ }
653
+ _ << ::Cyberweb.string_ctable.to_s
654
+ end
655
+
656
+ # ========================================================================= #
657
+ # === Cyberweb.string_table12_with_heading
658
+ # ========================================================================= #
659
+ def self.string_table12_with_heading(
660
+ css_class = '',
661
+ id = '',
662
+ css_style = '',
663
+ *content
664
+ )
665
+ content = content.flatten.compact # Make it more useful to our case.
666
+ _ = '<table'.dup
667
+ _ << return_css_class(css_class)
668
+ _ << return_the_id(id)
669
+ _ << return_css_style(css_style)
670
+ _ << '>'
671
+ _ << "\n"
672
+ first_header = content.shift
673
+ _ << '<tr>
674
+ <th>'+first_header.to_s+'</th>'
675
+ second_header = content.shift
676
+ _ << "<th>#{second_header}</th>#{N}"
677
+ third_header = content.shift
678
+ _ << "<th>#{third_header}</th>#{N}"
679
+ fourth_header = content.shift
680
+ _ << "<th>#{fourth_header}</th>#{N}"
681
+ fifth_header = content.shift
682
+ _ << "<th>#{fifth_header}</th>#{N}"
683
+ header_six = content.shift
684
+ _ << "<th>#{header_six}</th>#{N}"
685
+ header_seven = content.shift
686
+ _ << "<th>#{header_seven}</th>#{N}"
687
+ header_eight = content.shift
688
+ _ << "<th>#{header_eight}</th>#{N}"
689
+ header_nine = content.shift
690
+ _ << "<th>#{header_nine}</th>#{N}"
691
+ header_ten = content.shift
692
+ _ << "<th>#{header_ten}</th>#{N}"
693
+ header_eleven = content.shift
694
+ _ << "<th>#{header_eleven}</th>#{N}"
695
+ header_twelve = content.shift
696
+ _ << "<th>#{header_twelve}</th></tr>"
697
+ content.each_with_index { |item, index|
698
+ td_tag = '<td>'
699
+ if item.to_s.start_with? '#ALIGN_RIGHT#'
700
+ td_tag = '<td align="right">'
701
+ item = item.to_s.sub(/#ALIGN_RIGHT#/,'')
702
+ end
703
+ case index % 12
704
+ when 0 # New row.
705
+ _ << '<tr>'+N+' '+td_tag+item+'</td>'+N
706
+ when 11 # End row.
707
+ _ << N+' '+td_tag+item+'</td>'+N+'</tr>'
708
+ else # else it is a simple td-entry.
709
+ _ << ' '+td_tag+item+'</td>'+N
710
+ end
711
+ }
712
+ _ << ::Cyberweb.string_ctable.to_s
713
+ end
714
+
715
+ # ========================================================================= #
716
+ # === Cyberweb.string_table4
717
+ #
718
+ # This returns the string form of a <table> tag.
719
+ # ========================================================================= #
720
+ def self.string_table4(
721
+ css_class = '',
722
+ id = '',
723
+ css_style = '',
724
+ *content,
725
+ &block
726
+ )
727
+ content = content.flatten.compact # Make it more useful to our case.
728
+ # ======================================================================= #
729
+ # === Handle blocks next
730
+ # ======================================================================= #
731
+ if block_given?
732
+ yielded = yield
733
+ # ===================================================================== #
734
+ # If content is empty then we will replace the content with the
735
+ # value of the passed block next.
736
+ # ===================================================================== #
737
+ if content.empty? and !yielded.empty?
738
+ content = yielded
739
+ end
740
+ end
741
+ _ = '<table'.dup
742
+ _ << return_css_class(css_class)
743
+ _ << return_the_id(id)
744
+ _ << return_css_style(css_style) unless css_style.empty?
745
+ _ << '>'
746
+ _ << "\n"
747
+ content.each_with_index { |item, index|
748
+ position = (index % 4)
749
+ case position
750
+ when 0
751
+ _ << '<tr>'+N+' <td>'+item+'</td>'+N
752
+ else
753
+ _ << " <td>#{item}</td>#{N}"
754
+ _ << '</tr>'+N if position == 3
755
+ end
756
+ }
757
+ _ << ::Cyberweb.string_ctable.to_s
758
+ return _
759
+ end
760
+
761
+ # ========================================================================= #
762
+ # === Cyberweb.string_table7
763
+ # ========================================================================= #
764
+ def self.string_table7(
765
+ css_class = '',
766
+ id = '',
767
+ css_style = '',
768
+ *content
769
+ )
770
+ content = content.flatten.compact # Make it more useful to our case.
771
+ _ = '<table'.dup
772
+ _ << return_css_class(css_class)
773
+ _ << return_the_id(id)
774
+ _ << return_css_style(css_style) unless css_style.empty?
775
+ _ << '>'
776
+ _ << "\n"
777
+ content.each_with_index { |item, index|
778
+ result = index % 7
779
+ _ << '<tr>'+N if result == 0 # 0 means to add a '<tr>' tag first.
780
+ # when 0, 1, 2, 3, 4, 5, 6
781
+ _ << "<td>#{item}</td>#{N}"
782
+ _ << '</tr>'+N if result == 6 # This must be 1 less.
783
+ }
784
+ _ << ::Cyberweb.string_ctable.to_s
785
+ return _
786
+ end
787
+
788
+ # ========================================================================= #
789
+ # === customized_table (customized_table tag)
790
+ #
791
+ # This is a "feature-rich" table.
792
+ #
793
+ # If we yield true to this method then we will assume it is a table
794
+ # with headers - in that case, the first two contents will be treated
795
+ # as denoting the header.
796
+ # ========================================================================= #
797
+ def customized_table(
798
+ how_many_rows = 1,
799
+ css_class = '',
800
+ id = '',
801
+ css_style = '',
802
+ *content,
803
+ &block
804
+ )
805
+ # ======================================================================= #
806
+ # Build up the string that is to be returned, into the variable
807
+ # table_string.
808
+ # ======================================================================= #
809
+ table_string = '<table'.dup
810
+ table_string << return_css_class(css_class)
811
+ table_string << return_the_id(id)
812
+ table_string << return_css_style(css_style)
813
+ table_string << ">#{N}"
814
+ ee table_string
815
+ if block_given?
816
+ if content.empty?
817
+ content << yield
818
+ end
819
+ end
820
+ content.flatten.each_with_index { |item, index|
821
+ _ = index % how_many_rows
822
+ ee '<tr>'+N if _ == 0
823
+ # ===================================================================== #
824
+ # === Table Headers
825
+ #
826
+ # Right now we assume that the block given to this method is just
827
+ # "true". In the future this assumption may perhaps change.
828
+ #
829
+ # In that case when a block is issued, we will use table headers.
830
+ #
831
+ # At 18.09.2015 I have changed this approach - now we need to
832
+ # pass a symbol such as :use_headers instead.
833
+ # ===================================================================== #
834
+ if block_given? and (index < how_many_rows) and (yield == :use_headers)
835
+ th item
836
+ else
837
+ td item
838
+ end
839
+ if ( index % how_many_rows ) == (how_many_rows - 1)
840
+ ee string_ctr+N
841
+ end
842
+ }
843
+ ctable
844
+ ::Cyberweb.add_this_to_the_registered_tables(table_string)
845
+ end
846
+
847
+ # ========================================================================= #
848
+ # === string_table2
849
+ #
850
+ # This returns the string form of a <table> tag.
851
+ # ========================================================================= #
852
+ def string_table2(
853
+ css_class = '',
854
+ id = '',
855
+ css_style = '',
856
+ *content
857
+ )
858
+ ::Cyberweb.string_table2(css_class, id, css_style, *content)
859
+ end
860
+
861
+ # ========================================================================= #
862
+ # === string_table3
863
+ #
864
+ # This returns the string form of a <table> tag.
865
+ # ========================================================================= #
866
+ def string_table3(
867
+ css_class = '',
868
+ id = '',
869
+ css_style = '',
870
+ *content,
871
+ &block
872
+ )
873
+ ::Cyberweb.string_table3(
874
+ css_class, id, css_style, *content,
875
+ &block
876
+ )
877
+ end
878
+
879
+ # ========================================================================= #
880
+ # === table3
881
+ # ========================================================================= #
882
+ def table3(
883
+ css_class = '', id = '', css_style = '', *content
884
+ )
885
+ customized_table(
886
+ 3, css_class, id, css_style, *content
887
+ ) { yield if block_given? }
888
+ end
889
+
890
+ # ========================================================================= #
891
+ # === Cyberweb.parse_table
892
+ #
893
+ # This can be used to parse a string into a html table.
894
+ #
895
+ # Right now the only allowed delimiter is the '|' character, so this
896
+ # is hardcoded. See the usage example below.
897
+ #
898
+ # Usage example:
899
+ #
900
+ # Cyberweb.parse_table('Name|Typus|Wo?|Wann?')
901
+ #
902
+ # ========================================================================= #
903
+ def self.parse_table(*args)
904
+ delimiter = '|'
905
+ _ = '<table'.dup
906
+ # ======================================================================= #
907
+ # === Add Table css information next
908
+ # ======================================================================= #
909
+ unless Table.to_s.to_s.empty?
910
+ _ << return_css_class(Table.to_s)
911
+ end
912
+ _ << '>'
913
+ args.flatten!
914
+ args.each {|line|
915
+ splitted = line.split(delimiter)
916
+ _ << '<tr>'
917
+ _ << '<td'
918
+ _ << ' class="'+Td.to_s+'"' unless Td.to_s.empty?
919
+ _ << '>'
920
+ _ << N
921
+ _ << splitted.join('</td><td>')+N
922
+ _ << '</td></tr>'+N
923
+ }
924
+ _ << '</table>'
925
+ return _ # Return our String finally.
926
+ end
927
+
928
+ # ========================================================================= #
929
+ # === Cyberweb.populate_html_table
930
+ #
931
+ # This method can be used to generate a html table with data.
932
+ #
933
+ # Usage example:
934
+ #
935
+ # dataset = CsvParadise["/home/x/games/magic_the_gathering/Kartenliste_mit_Preisen.csv"]
936
+ # dataset = Cyberweb.populate_html_table(dataset.result?); pp dataset; ''
937
+ #
938
+ # ========================================================================= #
939
+ def self.populate_html_table(
940
+ use_this_dataset = nil
941
+ )
942
+ if use_this_dataset
943
+ yielded = use_this_dataset
944
+ else
945
+ if block_given?
946
+ yielded = yield
947
+ else
948
+ yielded = []
949
+ end
950
+ end
951
+ _ = ''.dup # Our return string. We will build it up next.
952
+ _ << '<table>'
953
+ yielded.each {|line|
954
+ _ << '<tr><td>'+
955
+ line.join('</td><td>')+'</td></tr>'+N
956
+ }
957
+ _ << '</table>'
958
+ return _
959
+ end
960
+
961
+ # ========================================================================= #
962
+ # === table2_with_headers
963
+ #
964
+ # This method will invoke customized_table() with a block
965
+ # variable called :use_headers.
966
+ # ========================================================================= #
967
+ def table2_with_headers(
968
+ css_class = '',
969
+ id = '',
970
+ css_style = '',
971
+ *content
972
+ )
973
+ customized_table(
974
+ 2, css_class, id, css_style, *content
975
+ ) { :use_headers }
976
+ end
977
+
978
+ # ========================================================================= #
979
+ # === table5
980
+ #
981
+ # A table with 5 rows.
982
+ # ========================================================================= #
983
+ def table5(
984
+ css_class = '', id = '', css_style = '', *content
985
+ )
986
+ customized_table(
987
+ 5, css_class, id, css_style, *content
988
+ ) { yield if block_given? }
989
+ end
990
+
991
+ # ========================================================================= #
992
+ # === table6
993
+ #
994
+ # A table with 6 rows.
995
+ # ========================================================================= #
996
+ def table6(
997
+ css_class = '', id = '', css_style = '', *content
998
+ )
999
+ customized_table(
1000
+ 6, css_class, id, css_style, *content
1001
+ ) { yield if block_given? }
1002
+ end
1003
+
1004
+ # ========================================================================= #
1005
+ # === table7
1006
+ #
1007
+ # A table with 7 rows.
1008
+ # ========================================================================= #
1009
+ def table7(
1010
+ css_class = '', id = '', css_style = '', *content
1011
+ )
1012
+ customized_table(7, css_class, id, css_style, *content) { yield if block_given? }
1013
+ end
1014
+
1015
+ # ========================================================================= #
1016
+ # === table8
1017
+ #
1018
+ # A table with 8 rows.
1019
+ # ========================================================================= #
1020
+ def table8(
1021
+ css_class = '', id = '', css_style = '', *content
1022
+ )
1023
+ customized_table(8, css_class, id, css_style, *content) { yield if block_given? }
1024
+ end
1025
+
1026
+ # ========================================================================= #
1027
+ # === table9
1028
+ #
1029
+ # A table with 9 rows.
1030
+ # ========================================================================= #
1031
+ def table9(
1032
+ css_class = '', id = '', css_style = '', *content
1033
+ )
1034
+ customized_table(9, css_class, id, css_style, *content) { yield if block_given? }
1035
+ end
1036
+
1037
+ # ========================================================================= #
1038
+ # === table10
1039
+ #
1040
+ # A table with 10 rows.
1041
+ # ========================================================================= #
1042
+ def table10(
1043
+ css_class = '', id = '', css_style = '', *content
1044
+ )
1045
+ customized_table(10, css_class, id, css_style, *content) { yield if block_given? }
1046
+ end
1047
+
1048
+ # ========================================================================= #
1049
+ # === table11
1050
+ #
1051
+ # A table with 11 rows.
1052
+ # ========================================================================= #
1053
+ def table11(
1054
+ css_class = '', id = '', css_style = '', *content
1055
+ )
1056
+ customized_table(11, css_class, id, css_style, *content) { yield if block_given? }
1057
+ end
1058
+
1059
+ # ========================================================================= #
1060
+ # === table12
1061
+ #
1062
+ # A table with 12 rows.
1063
+ # ========================================================================= #
1064
+ def table12(
1065
+ css_class = '', id = '', css_style = '', *content
1066
+ )
1067
+ customized_table(12, css_class, id, css_style, *content) { yield if block_given? }
1068
+ end
1069
+
1070
+ # ========================================================================= #
1071
+ # === table13
1072
+ #
1073
+ # A table with 13 rows.
1074
+ # ========================================================================= #
1075
+ def table13(
1076
+ css_class = '', id = '', css_style = '', *content
1077
+ )
1078
+ customized_table(13, css_class, id, css_style, *content) { yield if block_given? }
1079
+ end
1080
+
1081
+ # ========================================================================= #
1082
+ # === table14
1083
+ #
1084
+ # A table with 14 rows.
1085
+ # ========================================================================= #
1086
+ def table14(
1087
+ css_class = '', id = '', css_style = '', *content
1088
+ )
1089
+ customized_table(14, css_class, id, css_style, *content) { yield if block_given? }
1090
+ end
1091
+
1092
+ # ========================================================================= #
1093
+ # === simple_table2
1094
+ #
1095
+ # Pass it an array. It will then create a HTML table.
1096
+ #
1097
+ # You can also use css-class options etc... after that Array.
1098
+ # ========================================================================= #
1099
+ def simple_table2(
1100
+ array,
1101
+ optional_css_class = '',
1102
+ optional_id = '',
1103
+ optional_css_style = ''
1104
+ )
1105
+ table(optional_css_class, optional_id, optional_css_style)
1106
+ # Display our links here.
1107
+ array.each_with_index { |a_link, index|
1108
+ case (index % 2)
1109
+ when 0
1110
+ trtd
1111
+ ee(a_link)
1112
+ ctd
1113
+ when 1
1114
+ td
1115
+ ee(a_link)
1116
+ ctdctr
1117
+ end
1118
+ }
1119
+ ctable
1120
+ end
1121
+
1122
+ # ========================================================================= #
1123
+ # === table2
1124
+ #
1125
+ # Also known as the "zebra table".
1126
+ # ========================================================================= #
1127
+ def table2(
1128
+ css_class = '',
1129
+ id = '',
1130
+ css_style = '',
1131
+ *content
1132
+ )
1133
+ customized_table(
1134
+ 2, css_class, id, css_style, *content
1135
+ ) { yield if block_given? }
1136
+ end; alias zebra_table table2 # Courtesy of Ox0dea - he wanted to have a zebra-table.
1137
+
1138
+ # ========================================================================= #
1139
+ # === string_table11_with_heading
1140
+ # ========================================================================= #
1141
+ def string_table11_with_heading(
1142
+ css_class = '',
1143
+ id = '',
1144
+ css_style = '',
1145
+ *content
1146
+ )
1147
+ ::Cyberweb.string_table11_with_heading(css_class, id, css_style, *content)
1148
+ end
1149
+
1150
+ # ========================================================================= #
1151
+ # === string_table12_with_heading
1152
+ # ========================================================================= #
1153
+ def string_table12_with_heading(
1154
+ css_class = '',
1155
+ id = '',
1156
+ css_style = '',
1157
+ *content
1158
+ )
1159
+ ::Cyberweb.string_table12_with_heading(
1160
+ css_class, id, css_style, *content
1161
+ )
1162
+ end
1163
+
1164
+ # ========================================================================= #
1165
+ # === string_table5_with_heading
1166
+ # ========================================================================= #
1167
+ def string_table5_with_heading(
1168
+ css_class = '',
1169
+ id = '',
1170
+ css_style = '',
1171
+ *content
1172
+ )
1173
+ ::Cyberweb.string_table5_with_heading(css_class, id, css_style, *content)
1174
+ end
1175
+
1176
+ # ========================================================================= #
1177
+ # === string_table2_with_heading
1178
+ # ========================================================================= #
1179
+ def string_table2_with_heading(
1180
+ css_class = '',
1181
+ id = '',
1182
+ css_style = '',
1183
+ *content
1184
+ )
1185
+ ::Cyberweb.string_table2_with_heading(css_class, id, css_style, *content)
1186
+ end
1187
+
1188
+ # ========================================================================= #
1189
+ # === string_table4
1190
+ #
1191
+ # This returns the string form of a <table> tag.
1192
+ # ========================================================================= #
1193
+ def string_table4(
1194
+ css_class = '',
1195
+ id = '',
1196
+ css_style = '',
1197
+ *content
1198
+ )
1199
+ ::Cyberweb.string_table4(css_class, id, css_style, *content)
1200
+ end
1201
+
1202
+ end