cyberweb 0.4.174

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of cyberweb might be problematic. Click here for more details.

Files changed (573) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +3259 -0
  3. data/bin/cyberweb +27 -0
  4. data/cyberweb.gemspec +119 -0
  5. data/doc/AUTHORS.md +12 -0
  6. data/doc/CONVENTIONS.md +7 -0
  7. data/doc/CYBERWEB_TUTORIAL.cgi +43 -0
  8. data/doc/DOCUMENTATION_FOR_CYBERSPRAWL.md +50 -0
  9. data/doc/FUTURE_DESIGN_GOAL_CONSIDERATIONS.md +13 -0
  10. data/doc/JQUERY.md +122 -0
  11. data/doc/MOUSE.md +80 -0
  12. data/doc/README.gen +3231 -0
  13. data/doc/RENDER_WEB_BASE.md +46 -0
  14. data/doc/USAGE.md +246 -0
  15. data/doc/configuration/configuration.md +23 -0
  16. data/doc/deprecations.md +32 -0
  17. data/doc/html_characters.md +15 -0
  18. data/doc/todo/TODO_FOR_THE_CYBERWEB_PROJECT.md +1089 -0
  19. data/examples/README.md +4 -0
  20. data/examples/advanced/delayed_update_of_the_body_via_javascript.cgi +38 -0
  21. data/examples/advanced/hybrid_experiment.cgi +108 -0
  22. data/examples/advanced/larger_image_on_mouse_over_example.cgi +35 -0
  23. data/examples/advanced/no_right_click.cgi +26 -0
  24. data/examples/advanced/objectified_html_tags.cgi +35 -0
  25. data/examples/advanced/simple_calculator.cgi +42 -0
  26. data/examples/advanced/simple_form_example.cgi +38 -0
  27. data/examples/css/blue_border.html +28 -0
  28. data/examples/css/caret_colour_example.html +22 -0
  29. data/examples/css/css_border_spacing_example.html +69 -0
  30. data/examples/css/css_bubbles.html +43 -0
  31. data/examples/css/css_clock.html +344 -0
  32. data/examples/css/css_drag_and_drop.html +89 -0
  33. data/examples/css/css_neon_glow_effects.html +317 -0
  34. data/examples/css/css_text_decoration_example.html +70 -0
  35. data/examples/css/css_tooltip.html +44 -0
  36. data/examples/css/fade_in_and_fade_out_effect.html +66 -0
  37. data/examples/css/font_size_examples.html +40 -0
  38. data/examples/css/letter_spacing_example.cgi +36 -0
  39. data/examples/css/meter_example.html +31 -0
  40. data/examples/css/on_mouse_button_pressed.html +41 -0
  41. data/examples/css/planets.html +187 -0
  42. data/examples/css/scale_example.html +25 -0
  43. data/examples/css/shadow_example_in_CSS.cgi +30 -0
  44. data/examples/css/sticky_div_example.html +56 -0
  45. data/examples/css/stitched_div.html +36 -0
  46. data/examples/csv/README.md +1 -0
  47. data/examples/csv/sample.csv +10 -0
  48. data/examples/example1.rb +7 -0
  49. data/examples/flip_card_example/flip_card_example.html +72 -0
  50. data/examples/frames/frame_left.html +1 -0
  51. data/examples/frames/frame_right.html +1 -0
  52. data/examples/html/README.md +1 -0
  53. data/examples/html/abbr_example.html +25 -0
  54. data/examples/html/base64_image_example.html +26 -0
  55. data/examples/html/colour_wheel.html +1389 -0
  56. data/examples/html/column_width_example.html +34 -0
  57. data/examples/html/custom_cursor.html +103 -0
  58. data/examples/html/draggable_paragraph.html +12 -0
  59. data/examples/html/fieldset_example.html +25 -0
  60. data/examples/html/frames_example.html +7 -0
  61. data/examples/html/glyph_example.html +43 -0
  62. data/examples/html/hbox_and_vbox_example.html +65 -0
  63. data/examples/html/href_examples.html +27 -0
  64. data/examples/html/input_autofocus_example.html +16 -0
  65. data/examples/html/larger_image_on_mouse_over_example.html +30 -0
  66. data/examples/html/ordered_and_unordered_bulletsin.html +33 -0
  67. data/examples/html/play_video_example.html +13 -0
  68. data/examples/html/readonly_textarea_example.html +23 -0
  69. data/examples/html/remote_image_example.html +10 -0
  70. data/examples/html/simple_unordered_list.html +16 -0
  71. data/examples/html/table_with_header_example.html +27 -0
  72. data/examples/html/two_columns_flex_example.html +39 -0
  73. data/examples/javascript/README.md +2 -0
  74. data/examples/javascript/arrays/arrays_example_in_javascript.html +16 -0
  75. data/examples/javascript/delay_example/delay_example.html +46 -0
  76. data/examples/javascript/drag_support/drag_support.html +37 -0
  77. data/examples/javascript/jquery_drag_and_drop/drag_and_drop_image_example.html +33 -0
  78. data/examples/javascript/on_click_event_hello_world/on_click_event_hello_world.html +21 -0
  79. data/examples/javascript/rgb_to_hex/rgb_to_hex.html +15 -0
  80. data/examples/javascript/screen_resolution/screen_resolution.html +20 -0
  81. data/examples/javascript/select_everything/select_everything.html +14 -0
  82. data/examples/javascript/write_into_a_file/write_into_a_file.html +39 -0
  83. data/examples/rack/README.md +4 -0
  84. data/examples/rack/example_with_html_template.rb +123 -0
  85. data/examples/rack/example_with_rack_and_cyberweb_showing_how_to_use_images.rb +56 -0
  86. data/examples/rack/hello_world_example_with_rack.rb +45 -0
  87. data/examples/rack/lobster.rb +79 -0
  88. data/examples/rack/rack_env.rb +10 -0
  89. data/examples/rack/standalone_example.rb +26 -0
  90. data/examples/show_greek_letters.rb +3 -0
  91. data/examples/simple/on_click_event_hello_world.cgi +34 -0
  92. data/examples/sinatra/001_your_ip_address_is.rb +8 -0
  93. data/examples/sinatra/002_the_request_object.rb +16 -0
  94. data/examples/sinatra/003_hello_world_example.rb +82 -0
  95. data/examples/sinatra/004_splat_example.rb +10 -0
  96. data/examples/sinatra/005_attachment_example.rb +11 -0
  97. data/examples/sinatra/006_outer_self_example.rb +8 -0
  98. data/examples/sinatra/007_mime_type_example.rb +17 -0
  99. data/examples/sinatra/008_post_example.rb +55 -0
  100. data/examples/table_example.rb +37 -0
  101. data/images/cyberweb_favicon.png +0 -0
  102. data/images/cyberweb_logo.png +0 -0
  103. data/images/cyberweb_theme.png +0 -0
  104. data/lib/cyberweb/and_sinatra_base.rb +9 -0
  105. data/lib/cyberweb/autoinclude.rb +20 -0
  106. data/lib/cyberweb/autoinclude_webobject.rb +14 -0
  107. data/lib/cyberweb/base/base.rb +41 -0
  108. data/lib/cyberweb/base/colours.rb +69 -0
  109. data/lib/cyberweb/base/constants.rb +18 -0
  110. data/lib/cyberweb/base/encoding.rb +19 -0
  111. data/lib/cyberweb/base/misc.rb +239 -0
  112. data/lib/cyberweb/base/reset.rb +23 -0
  113. data/lib/cyberweb/base/save_file.rb +22 -0
  114. data/lib/cyberweb/cascading_style_sheets/README.md +4 -0
  115. data/lib/cyberweb/cascading_style_sheets/admonition.css +33 -0
  116. data/lib/cyberweb/cascading_style_sheets/balloon.css +344 -0
  117. data/lib/cyberweb/cascading_style_sheets/border.css +202 -0
  118. data/lib/cyberweb/cascading_style_sheets/code.css +58 -0
  119. data/lib/cyberweb/cascading_style_sheets/colours.css +476 -0
  120. data/lib/cyberweb/cascading_style_sheets/default.css +1836 -0
  121. data/lib/cyberweb/cascading_style_sheets/div.css +26 -0
  122. data/lib/cyberweb/cascading_style_sheets/fonts.css +365 -0
  123. data/lib/cyberweb/cascading_style_sheets/links.css +207 -0
  124. data/lib/cyberweb/cascading_style_sheets/margin.css +677 -0
  125. data/lib/cyberweb/cascading_style_sheets/menu.css +37 -0
  126. data/lib/cyberweb/cascading_style_sheets/message_boxes.css +48 -0
  127. data/lib/cyberweb/cascading_style_sheets/misc.css +162 -0
  128. data/lib/cyberweb/cascading_style_sheets/popup.css +63 -0
  129. data/lib/cyberweb/cascading_style_sheets/rpg.css +51 -0
  130. data/lib/cyberweb/cascading_style_sheets/ruby_regexes.css +33 -0
  131. data/lib/cyberweb/cascading_style_sheets/template2.css +18 -0
  132. data/lib/cyberweb/cascading_style_sheets/text_shadow.css +19 -0
  133. data/lib/cyberweb/cascading_style_sheets/tooltip.css +36 -0
  134. data/lib/cyberweb/cgi/README.md +6 -0
  135. data/lib/cyberweb/cgi/cgi.rb +340 -0
  136. data/lib/cyberweb/cgi/constants.rb +121 -0
  137. data/lib/cyberweb/cgi/cookie.rb +218 -0
  138. data/lib/cyberweb/cgi/core.rb +638 -0
  139. data/lib/cyberweb/cgi/exceptions.rb +223 -0
  140. data/lib/cyberweb/cgi/html.rb +1025 -0
  141. data/lib/cyberweb/cgi/mod_ruby_exception_printer.rb +40 -0
  142. data/lib/cyberweb/cgi/query_extension.rb +431 -0
  143. data/lib/cyberweb/cgi/session/file_store.rb +131 -0
  144. data/lib/cyberweb/cgi/session/memory_store.rb +90 -0
  145. data/lib/cyberweb/cgi/session/pstore.rb +127 -0
  146. data/lib/cyberweb/cgi/session.rb +444 -0
  147. data/lib/cyberweb/cgi/tag_maker.rb +94 -0
  148. data/lib/cyberweb/cgi/util.rb +239 -0
  149. data/lib/cyberweb/charts/README.md +2 -0
  150. data/lib/cyberweb/charts/google_charts.rb +51 -0
  151. data/lib/cyberweb/classes/simple_form.rb +55 -0
  152. data/lib/cyberweb/classes/tooltips.rb +169 -0
  153. data/lib/cyberweb/coloured_tags/coloured_tags.rb +3099 -0
  154. data/lib/cyberweb/colours/colour_chart.rb +117 -0
  155. data/lib/cyberweb/colours/colours.rb +50 -0
  156. data/lib/cyberweb/colours/random_colour.rb +28 -0
  157. data/lib/cyberweb/colours/sanitize_for_colours.rb +95 -0
  158. data/lib/cyberweb/commandline/commandline_interface.rb +49 -0
  159. data/lib/cyberweb/configuration/configuration.rb +66 -0
  160. data/lib/cyberweb/configuration/load_the_configuration_file.rb +73 -0
  161. data/lib/cyberweb/constants/array_images.rb +21 -0
  162. data/lib/cyberweb/constants/array_local_css_files.rb +35 -0
  163. data/lib/cyberweb/constants/array_predefined_constants.rb +23 -0
  164. data/lib/cyberweb/constants/configuration_file.rb +33 -0
  165. data/lib/cyberweb/constants/constants.rb +9 -0
  166. data/lib/cyberweb/constants/file_constants.rb +16 -0
  167. data/lib/cyberweb/constants/http_status_codes.rb +42 -0
  168. data/lib/cyberweb/constants/nl.rb +22 -0
  169. data/lib/cyberweb/constants/project_constants.rb +99 -0
  170. data/lib/cyberweb/constants/roebe.rb +28 -0
  171. data/lib/cyberweb/constants/standalone_constants.rb +309 -0
  172. data/lib/cyberweb/controller/README.md +4 -0
  173. data/lib/cyberweb/controller/webobject_controller.rb +50 -0
  174. data/lib/cyberweb/csv/README.md +2 -0
  175. data/lib/cyberweb/csv/csv.rb +58 -0
  176. data/lib/cyberweb/cybersprawl +1 -0
  177. data/lib/cyberweb/debug/debug.rb +69 -0
  178. data/lib/cyberweb/encoding/encoding.rb +84 -0
  179. data/lib/cyberweb/erb/test.rhtml +81 -0
  180. data/lib/cyberweb/erb/test_template.erb +9 -0
  181. data/lib/cyberweb/evaluate_from_the_same_named_file_then_serve.rb +9 -0
  182. data/lib/cyberweb/favicon/favicon.rb +196 -0
  183. data/lib/cyberweb/generator/README.md +2 -0
  184. data/lib/cyberweb/generator/cgi.rb +201 -0
  185. data/lib/cyberweb/generator/class.rb +25 -0
  186. data/lib/cyberweb/generator/static_webpage.rb +162 -0
  187. data/lib/cyberweb/generator/webpage_for_images.rb +553 -0
  188. data/lib/cyberweb/help/help.rb +29 -0
  189. data/lib/cyberweb/html_codes/README.md +15 -0
  190. data/lib/cyberweb/html_codes/greek_letters.rb +204 -0
  191. data/lib/cyberweb/html_tags/README.md +3 -0
  192. data/lib/cyberweb/html_tags/a.rb +65 -0
  193. data/lib/cyberweb/html_tags/accesskey.rb +25 -0
  194. data/lib/cyberweb/html_tags/blockquote.rb +56 -0
  195. data/lib/cyberweb/html_tags/body.rb +14 -0
  196. data/lib/cyberweb/html_tags/br.rb +19 -0
  197. data/lib/cyberweb/html_tags/button.rb +110 -0
  198. data/lib/cyberweb/html_tags/canvas.rb +59 -0
  199. data/lib/cyberweb/html_tags/chtml.rb +14 -0
  200. data/lib/cyberweb/html_tags/div.rb +163 -0
  201. data/lib/cyberweb/html_tags/fieldset.rb +67 -0
  202. data/lib/cyberweb/html_tags/figure.rb +72 -0
  203. data/lib/cyberweb/html_tags/form.rb +203 -0
  204. data/lib/cyberweb/html_tags/h1.rb +75 -0
  205. data/lib/cyberweb/html_tags/h2.rb +73 -0
  206. data/lib/cyberweb/html_tags/h3.rb +58 -0
  207. data/lib/cyberweb/html_tags/h4.rb +60 -0
  208. data/lib/cyberweb/html_tags/h5.rb +54 -0
  209. data/lib/cyberweb/html_tags/h6.rb +54 -0
  210. data/lib/cyberweb/html_tags/hr.rb +22 -0
  211. data/lib/cyberweb/html_tags/html_tags.rb +240 -0
  212. data/lib/cyberweb/html_tags/i.rb +50 -0
  213. data/lib/cyberweb/html_tags/img.rb +294 -0
  214. data/lib/cyberweb/html_tags/input.rb +345 -0
  215. data/lib/cyberweb/html_tags/label.rb +63 -0
  216. data/lib/cyberweb/html_tags/legend.rb +56 -0
  217. data/lib/cyberweb/html_tags/li.rb +67 -0
  218. data/lib/cyberweb/html_tags/map.rb +31 -0
  219. data/lib/cyberweb/html_tags/nav.rb +63 -0
  220. data/lib/cyberweb/html_tags/object.rb +56 -0
  221. data/lib/cyberweb/html_tags/ol.rb +56 -0
  222. data/lib/cyberweb/html_tags/option.rb +61 -0
  223. data/lib/cyberweb/html_tags/p.rb +90 -0
  224. data/lib/cyberweb/html_tags/pre.rb +164 -0
  225. data/lib/cyberweb/html_tags/section.rb +33 -0
  226. data/lib/cyberweb/html_tags/select.rb +100 -0
  227. data/lib/cyberweb/html_tags/span.rb +338 -0
  228. data/lib/cyberweb/html_tags/strong.rb +39 -0
  229. data/lib/cyberweb/html_tags/table.rb +273 -0
  230. data/lib/cyberweb/html_tags/tbody.rb +24 -0
  231. data/lib/cyberweb/html_tags/td.rb +214 -0
  232. data/lib/cyberweb/html_tags/textarea.rb +138 -0
  233. data/lib/cyberweb/html_tags/th.rb +68 -0
  234. data/lib/cyberweb/html_tags/thead.rb +36 -0
  235. data/lib/cyberweb/html_tags/tr.rb +97 -0
  236. data/lib/cyberweb/html_tags/ul.rb +51 -0
  237. data/lib/cyberweb/html_template/html_template.rb +352 -0
  238. data/lib/cyberweb/images/embed_this_image.rb +37 -0
  239. data/lib/cyberweb/images/images.rb +58 -0
  240. data/lib/cyberweb/images/is_image.rb +22 -0
  241. data/lib/cyberweb/images/path_to_images.rb +60 -0
  242. data/lib/cyberweb/images/real/README.md +6 -0
  243. data/lib/cyberweb/images/remove_this_substring_from_all_images.rb +44 -0
  244. data/lib/cyberweb/images/standalone_drag_and_drop_this_image.rb +64 -0
  245. data/lib/cyberweb/images/string_image.rb +399 -0
  246. data/lib/cyberweb/images_base64_encoded/AUSRUFUNGSZEICHEN.png.md +1 -0
  247. data/lib/cyberweb/images_base64_encoded/BLUEARROW.png.md +1 -0
  248. data/lib/cyberweb/images_base64_encoded/BUBBLE.png.md +1 -0
  249. data/lib/cyberweb/images_base64_encoded/CAT.png.md +1 -0
  250. data/lib/cyberweb/images_base64_encoded/CAUTION.png.md +1 -0
  251. data/lib/cyberweb/images_base64_encoded/CHEERING_PERSON.png.md +1 -0
  252. data/lib/cyberweb/images_base64_encoded/CURSOR.png.md +1 -0
  253. data/lib/cyberweb/images_base64_encoded/DOT_01.png.md +5 -0
  254. data/lib/cyberweb/images_base64_encoded/DUCKY.png.md +1 -0
  255. data/lib/cyberweb/images_base64_encoded/ELEPHANT.png.md +1 -0
  256. data/lib/cyberweb/images_base64_encoded/HALLOWEEN.png.md +1 -0
  257. data/lib/cyberweb/images_base64_encoded/HANGING_MONKEY.png.md +1 -0
  258. data/lib/cyberweb/images_base64_encoded/LENS.png.md +1 -0
  259. data/lib/cyberweb/images_base64_encoded/README.md +2 -0
  260. data/lib/cyberweb/images_base64_encoded/TU_WIEN_LOGO.png.md +1 -0
  261. data/lib/cyberweb/images_base64_encoded/VOGEL.png.md +1 -0
  262. data/lib/cyberweb/io/README.md +1 -0
  263. data/lib/cyberweb/io/io.rb +19 -0
  264. data/lib/cyberweb/javascript/drag_and_drop.rb +105 -0
  265. data/lib/cyberweb/javascript/dragula_collection.rb +54 -0
  266. data/lib/cyberweb/javascript/javascript.rb +211 -0
  267. data/lib/cyberweb/javascript/javascript_bundle.rb +223 -0
  268. data/lib/cyberweb/javascript/javascript_clock.rb +69 -0
  269. data/lib/cyberweb/javascript/javascript_last_modified.rb +27 -0
  270. data/lib/cyberweb/javascript/javascript_magic.rb +150 -0
  271. data/lib/cyberweb/javascript/javascript_selectable.rb +24 -0
  272. data/lib/cyberweb/javascript/jquery.rb +30 -0
  273. data/lib/cyberweb/javascript/on_click_change_opacity.rb +97 -0
  274. data/lib/cyberweb/javascript/on_click_hide.rb +63 -0
  275. data/lib/cyberweb/javascript/popup.rb +80 -0
  276. data/lib/cyberweb/javascript/print_javascript.rb +33 -0
  277. data/lib/cyberweb/javascript/registered_javascript_methods.rb +30 -0
  278. data/lib/cyberweb/javascript/resize.rb +28 -0
  279. data/lib/cyberweb/javascript/return_javascript.rb +48 -0
  280. data/lib/cyberweb/javascript/scroll.rb +17 -0
  281. data/lib/cyberweb/javascript/snoweffect.rb +122 -0
  282. data/lib/cyberweb/javascript_code/README.md +6 -0
  283. data/lib/cyberweb/javascript_code/chmod_displayer.js +74 -0
  284. data/lib/cyberweb/javascript_code/custom_functions.js +267 -0
  285. data/lib/cyberweb/javascript_code/jquery/jquery-3.6.0.js +10881 -0
  286. data/lib/cyberweb/javascript_code/jquery/jquery-ui-1.12.1.js +18706 -0
  287. data/lib/cyberweb/javascript_code/rgb_to_hex.js +14 -0
  288. data/lib/cyberweb/javascript_code/select_even_numbers.js +7 -0
  289. data/lib/cyberweb/javascript_code/select_everything.js +22 -0
  290. data/lib/cyberweb/javascript_code/simple_calculator.js +15 -0
  291. data/lib/cyberweb/javascript_code/sleep.js +3 -0
  292. data/lib/cyberweb/javascript_code/to_celsius.js +8 -0
  293. data/lib/cyberweb/mouse/README.md +3 -0
  294. data/lib/cyberweb/mouse/libxdo.rb +321 -0
  295. data/lib/cyberweb/mouse/mouse.rb +264 -0
  296. data/lib/cyberweb/objectified_html_tags/README.md +8 -0
  297. data/lib/cyberweb/objectified_html_tags/a.rb +129 -0
  298. data/lib/cyberweb/objectified_html_tags/abbr.rb +84 -0
  299. data/lib/cyberweb/objectified_html_tags/base.rb +376 -0
  300. data/lib/cyberweb/objectified_html_tags/button.rb +135 -0
  301. data/lib/cyberweb/objectified_html_tags/combobox.rb +165 -0
  302. data/lib/cyberweb/objectified_html_tags/div.rb +129 -0
  303. data/lib/cyberweb/objectified_html_tags/embed.rb +161 -0
  304. data/lib/cyberweb/objectified_html_tags/form.rb +129 -0
  305. data/lib/cyberweb/objectified_html_tags/h1.rb +129 -0
  306. data/lib/cyberweb/objectified_html_tags/h2.rb +129 -0
  307. data/lib/cyberweb/objectified_html_tags/h3.rb +129 -0
  308. data/lib/cyberweb/objectified_html_tags/h4.rb +129 -0
  309. data/lib/cyberweb/objectified_html_tags/h5.rb +129 -0
  310. data/lib/cyberweb/objectified_html_tags/h6.rb +129 -0
  311. data/lib/cyberweb/objectified_html_tags/hbox.rb +71 -0
  312. data/lib/cyberweb/objectified_html_tags/img.rb +202 -0
  313. data/lib/cyberweb/objectified_html_tags/input.rb +185 -0
  314. data/lib/cyberweb/objectified_html_tags/p.rb +129 -0
  315. data/lib/cyberweb/objectified_html_tags/pre.rb +129 -0
  316. data/lib/cyberweb/objectified_html_tags/span.rb +92 -0
  317. data/lib/cyberweb/objectified_html_tags/table.rb +174 -0
  318. data/lib/cyberweb/objectified_html_tags/textarea.rb +173 -0
  319. data/lib/cyberweb/objectified_html_tags/title.rb +82 -0
  320. data/lib/cyberweb/objectified_html_tags/window.rb +79 -0
  321. data/lib/cyberweb/predefined_and_freeform_methods/README.md +1 -0
  322. data/lib/cyberweb/predefined_and_freeform_methods/frage.rb +45 -0
  323. data/lib/cyberweb/predefined_and_freeform_methods/freeform_methods.rb +93 -0
  324. data/lib/cyberweb/predefined_and_freeform_methods/hash_css_class_to_use.rb +55 -0
  325. data/lib/cyberweb/predefined_and_freeform_methods/hash_registered_extra_tags.rb +29 -0
  326. data/lib/cyberweb/predefined_and_freeform_methods/header.rb +81 -0
  327. data/lib/cyberweb/predefined_and_freeform_methods/predefined_methods.rb +413 -0
  328. data/lib/cyberweb/project/project.rb +85 -0
  329. data/lib/cyberweb/rack/README.md +1 -0
  330. data/lib/cyberweb/rack/request.rb +31 -0
  331. data/lib/cyberweb/requires/README.md +4 -0
  332. data/lib/cyberweb/requires/do_require_web_object_files.rb +9 -0
  333. data/lib/cyberweb/requires/remove_html.rb +9 -0
  334. data/lib/cyberweb/requires/require_cgi.rb +16 -0
  335. data/lib/cyberweb/requires/require_charts.rb +20 -0
  336. data/lib/cyberweb/requires/require_generators.rb +23 -0
  337. data/lib/cyberweb/requires/require_html_tags_files.rb +23 -0
  338. data/lib/cyberweb/requires/require_javascript_files.rb +23 -0
  339. data/lib/cyberweb/requires/require_kimurai.rb +13 -0
  340. data/lib/cyberweb/requires/require_objectified_html_tags_files.rb +23 -0
  341. data/lib/cyberweb/requires/require_sinatra.rb +7 -0
  342. data/lib/cyberweb/requires/require_the_constants.rb +26 -0
  343. data/lib/cyberweb/requires/require_the_cyberweb_project.rb +172 -0
  344. data/lib/cyberweb/requires/require_the_html_template.rb +7 -0
  345. data/lib/cyberweb/requires/require_the_toplevel_methods_files.rb +24 -0
  346. data/lib/cyberweb/requires/require_web_images.rb +7 -0
  347. data/lib/cyberweb/requires/require_web_object_files.rb +25 -0
  348. data/lib/cyberweb/requires/require_yaml.rb +11 -0
  349. data/lib/cyberweb/sinatra/README.md +11 -0
  350. data/lib/cyberweb/sinatra/base.rb +145 -0
  351. data/lib/cyberweb/sinatra/custom_extensions.rb +131 -0
  352. data/lib/cyberweb/standalone_classes/all_css_classes.rb +255 -0
  353. data/lib/cyberweb/standalone_classes/calculator.rb +127 -0
  354. data/lib/cyberweb/standalone_classes/correct_image_entries_in_html_file.rb +207 -0
  355. data/lib/cyberweb/standalone_classes/input_focus.rb +97 -0
  356. data/lib/cyberweb/standalone_classes/tag_prototype.rb +43 -0
  357. data/lib/cyberweb/standalone_classes/turn_html_into_cyberweb.rb +174 -0
  358. data/lib/cyberweb/svg/blue_rect.svg +12 -0
  359. data/lib/cyberweb/svg/butterfly.svg +15 -0
  360. data/lib/cyberweb/svg/chemical_molecule.svg +192 -0
  361. data/lib/cyberweb/svg/circles_on_background.svg +29 -0
  362. data/lib/cyberweb/svg/ellipse.svg +12 -0
  363. data/lib/cyberweb/svg/five_circles.svg +26 -0
  364. data/lib/cyberweb/svg/flag_germany.svg +10 -0
  365. data/lib/cyberweb/svg/gaussian_blur.svg +20 -0
  366. data/lib/cyberweb/svg/gradient_circle.svg +18 -0
  367. data/lib/cyberweb/svg/green_butterfly.svg +18 -0
  368. data/lib/cyberweb/svg/green_tilted_lines.svg +25 -0
  369. data/lib/cyberweb/svg/lion.svg +161 -0
  370. data/lib/cyberweb/svg/one_circle.svg +12 -0
  371. data/lib/cyberweb/svg/pie_chart.svg +130 -0
  372. data/lib/cyberweb/svg/svg.cgi +61 -0
  373. data/lib/cyberweb/svg/tetris.svg +487 -0
  374. data/lib/cyberweb/svg/three_circles.svg +18 -0
  375. data/lib/cyberweb/svg/tiger.svg +732 -0
  376. data/lib/cyberweb/svg/tilted_arcs.svg +74 -0
  377. data/lib/cyberweb/svg/transparent_rect.svg +12 -0
  378. data/lib/cyberweb/svg/yellow_fe_blending.svg +42 -0
  379. data/lib/cyberweb/toplevel_methods/a.rb +131 -0
  380. data/lib/cyberweb/toplevel_methods/anmerkung.rb +67 -0
  381. data/lib/cyberweb/toplevel_methods/audio.rb +59 -0
  382. data/lib/cyberweb/toplevel_methods/bold.rb +65 -0
  383. data/lib/cyberweb/toplevel_methods/cgi.rb +65 -0
  384. data/lib/cyberweb/toplevel_methods/charsets.rb +52 -0
  385. data/lib/cyberweb/toplevel_methods/clear.rb +30 -0
  386. data/lib/cyberweb/toplevel_methods/close.rb +62 -0
  387. data/lib/cyberweb/toplevel_methods/consider_serving_the_web_object.rb +41 -0
  388. data/lib/cyberweb/toplevel_methods/css.rb +732 -0
  389. data/lib/cyberweb/toplevel_methods/date.rb +71 -0
  390. data/lib/cyberweb/toplevel_methods/dictionary.rb +48 -0
  391. data/lib/cyberweb/toplevel_methods/disable.rb +49 -0
  392. data/lib/cyberweb/toplevel_methods/document.rb +56 -0
  393. data/lib/cyberweb/toplevel_methods/dot.rb +182 -0
  394. data/lib/cyberweb/toplevel_methods/download_webpage.rb +18 -0
  395. data/lib/cyberweb/toplevel_methods/edit_configuration_file.rb +26 -0
  396. data/lib/cyberweb/toplevel_methods/ee.rb +44 -0
  397. data/lib/cyberweb/toplevel_methods/env.rb +44 -0
  398. data/lib/cyberweb/toplevel_methods/escape_html.rb +54 -0
  399. data/lib/cyberweb/toplevel_methods/fields.rb +46 -0
  400. data/lib/cyberweb/toplevel_methods/filename.rb +33 -0
  401. data/lib/cyberweb/toplevel_methods/frames.rb +131 -0
  402. data/lib/cyberweb/toplevel_methods/glob.rb +30 -0
  403. data/lib/cyberweb/toplevel_methods/google.rb +35 -0
  404. data/lib/cyberweb/toplevel_methods/hardware_information.rb +90 -0
  405. data/lib/cyberweb/toplevel_methods/hfin.rb +56 -0
  406. data/lib/cyberweb/toplevel_methods/html_comment.rb +48 -0
  407. data/lib/cyberweb/toplevel_methods/html_mode.rb +39 -0
  408. data/lib/cyberweb/toplevel_methods/html_tables.rb +818 -0
  409. data/lib/cyberweb/toplevel_methods/input.rb +54 -0
  410. data/lib/cyberweb/toplevel_methods/jquery.rb +82 -0
  411. data/lib/cyberweb/toplevel_methods/last_modified.rb +39 -0
  412. data/lib/cyberweb/toplevel_methods/links.rb +426 -0
  413. data/lib/cyberweb/toplevel_methods/listing.rb +96 -0
  414. data/lib/cyberweb/toplevel_methods/localhost.rb +18 -0
  415. data/lib/cyberweb/toplevel_methods/log_directory.rb +84 -0
  416. data/lib/cyberweb/toplevel_methods/logging.rb +42 -0
  417. data/lib/cyberweb/toplevel_methods/logo.rb +30 -0
  418. data/lib/cyberweb/toplevel_methods/markdown.rb +112 -0
  419. data/lib/cyberweb/toplevel_methods/mathml.rb +130 -0
  420. data/lib/cyberweb/toplevel_methods/message_boxes.rb +140 -0
  421. data/lib/cyberweb/toplevel_methods/misc.rb +1398 -0
  422. data/lib/cyberweb/toplevel_methods/name_of_img_dir.rb +51 -0
  423. data/lib/cyberweb/toplevel_methods/padlem_and_marlem.rb +107 -0
  424. data/lib/cyberweb/toplevel_methods/params.rb +57 -0
  425. data/lib/cyberweb/toplevel_methods/path.rb +69 -0
  426. data/lib/cyberweb/toplevel_methods/pdf.rb +103 -0
  427. data/lib/cyberweb/toplevel_methods/process_content.rb +102 -0
  428. data/lib/cyberweb/toplevel_methods/progress.rb +42 -0
  429. data/lib/cyberweb/toplevel_methods/quote.rb +44 -0
  430. data/lib/cyberweb/toplevel_methods/random.rb +70 -0
  431. data/lib/cyberweb/toplevel_methods/rds.rb +35 -0
  432. data/lib/cyberweb/toplevel_methods/read_and_display.rb +284 -0
  433. data/lib/cyberweb/toplevel_methods/readlines.rb +31 -0
  434. data/lib/cyberweb/toplevel_methods/redirect.rb +29 -0
  435. data/lib/cyberweb/toplevel_methods/registered_ids.rb +178 -0
  436. data/lib/cyberweb/toplevel_methods/remove_html.rb +32 -0
  437. data/lib/cyberweb/toplevel_methods/remove_newlines.rb +28 -0
  438. data/lib/cyberweb/toplevel_methods/return_head_start.rb +33 -0
  439. data/lib/cyberweb/toplevel_methods/return_html_fin.rb +34 -0
  440. data/lib/cyberweb/toplevel_methods/return_html_header.rb +35 -0
  441. data/lib/cyberweb/toplevel_methods/return_html_start.rb +24 -0
  442. data/lib/cyberweb/toplevel_methods/return_html_to_head_start.rb +42 -0
  443. data/lib/cyberweb/toplevel_methods/return_meta_collection.rb +54 -0
  444. data/lib/cyberweb/toplevel_methods/return_pwd.rb +23 -0
  445. data/lib/cyberweb/toplevel_methods/return_strict_doctype.rb +51 -0
  446. data/lib/cyberweb/toplevel_methods/roebe.rb +43 -0
  447. data/lib/cyberweb/toplevel_methods/s2.rb +30 -0
  448. data/lib/cyberweb/toplevel_methods/sanitize_url.rb +57 -0
  449. data/lib/cyberweb/toplevel_methods/sbr.rb +170 -0
  450. data/lib/cyberweb/toplevel_methods/server_base_directory.rb +148 -0
  451. data/lib/cyberweb/toplevel_methods/show_and_display.rb +215 -0
  452. data/lib/cyberweb/toplevel_methods/show_configuration.rb +83 -0
  453. data/lib/cyberweb/toplevel_methods/sitemap.rb +111 -0
  454. data/lib/cyberweb/toplevel_methods/spacer.rb +119 -0
  455. data/lib/cyberweb/toplevel_methods/string_body_start.rb +65 -0
  456. data/lib/cyberweb/toplevel_methods/string_content.rb +35 -0
  457. data/lib/cyberweb/toplevel_methods/svg.rb +66 -0
  458. data/lib/cyberweb/toplevel_methods/tag.rb +237 -0
  459. data/lib/cyberweb/toplevel_methods/temp_directory.rb +73 -0
  460. data/lib/cyberweb/toplevel_methods/test_css.rb +24 -0
  461. data/lib/cyberweb/toplevel_methods/textile.rb +45 -0
  462. data/lib/cyberweb/toplevel_methods/title.rb +125 -0
  463. data/lib/cyberweb/toplevel_methods/umlaute.rb +90 -0
  464. data/lib/cyberweb/toplevel_methods/video.rb +352 -0
  465. data/lib/cyberweb/toplevel_methods/view_source.rb +50 -0
  466. data/lib/cyberweb/toplevel_methods/web_object.rb +42 -0
  467. data/lib/cyberweb/toplevel_methods/write_what_into.rb +27 -0
  468. data/lib/cyberweb/utility_scripts/README.md +4 -0
  469. data/lib/cyberweb/utility_scripts/create_coloured_tags.rb +172 -0
  470. data/lib/cyberweb/utility_scripts/download_balloon_css.rb +160 -0
  471. data/lib/cyberweb/utility_scripts/hyperlink_all_images_from.rb +148 -0
  472. data/lib/cyberweb/version/version.rb +25 -0
  473. data/lib/cyberweb/web_base/web_base.rb +28 -0
  474. data/lib/cyberweb/web_images/array_listing_all_project_images.rb +52 -0
  475. data/lib/cyberweb/web_images/map_symbol_to_image_location.rb +1661 -0
  476. data/lib/cyberweb/web_images/web_images.rb +270 -0
  477. data/lib/cyberweb/web_object/css.rb +627 -0
  478. data/lib/cyberweb/web_object/evaluate.rb +126 -0
  479. data/lib/cyberweb/web_object/favicon.rb +160 -0
  480. data/lib/cyberweb/web_object/html_related_tags.rb +320 -0
  481. data/lib/cyberweb/web_object/images.rb +693 -0
  482. data/lib/cyberweb/web_object/initialize.rb +51 -0
  483. data/lib/cyberweb/web_object/input_related_functionality.rb +414 -0
  484. data/lib/cyberweb/web_object/javascript.rb +427 -0
  485. data/lib/cyberweb/web_object/languages.rb +172 -0
  486. data/lib/cyberweb/web_object/links.rb +228 -0
  487. data/lib/cyberweb/web_object/misc.rb +5159 -0
  488. data/lib/cyberweb/web_object/params.rb +289 -0
  489. data/lib/cyberweb/web_object/reset.rb +192 -0
  490. data/lib/cyberweb/web_object/run.rb +44 -0
  491. data/lib/cyberweb/web_object/sinatra_related_functionality.rb +30 -0
  492. data/lib/cyberweb/web_object/sitemap.rb +176 -0
  493. data/lib/cyberweb/web_object/table.rb +378 -0
  494. data/lib/cyberweb/web_object/web_object.rb +126 -0
  495. data/lib/cyberweb/web_scraper/README.md +8 -0
  496. data/lib/cyberweb/web_scraper/scrape_this_url.rb +183 -0
  497. data/lib/cyberweb/webmin/biology_server.cgi +256 -0
  498. data/lib/cyberweb/webmin/calculator.cgi +52 -0
  499. data/lib/cyberweb/webmin/colour_chart.cgi +33 -0
  500. data/lib/cyberweb/webmin/comments.cgi +137 -0
  501. data/lib/cyberweb/webmin/comments_data +18 -0
  502. data/lib/cyberweb/webmin/constants.rb +46 -0
  503. data/lib/cyberweb/webmin/dictionary.cgi +39 -0
  504. data/lib/cyberweb/webmin/sys_info.cgi +26 -0
  505. data/lib/cyberweb/webmin/webforum.cgi +58 -0
  506. data/lib/cyberweb/webmin/webmin.cgi +679 -0
  507. data/lib/cyberweb/yaml/autogenerated_system_settings.yml +14 -0
  508. data/lib/cyberweb/yaml/custom_tags.yml +7 -0
  509. data/lib/cyberweb/yaml/debug.yml +1 -0
  510. data/lib/cyberweb/yaml/html5_global_attributes.yml +12 -0
  511. data/lib/cyberweb/yaml/html5_new_elements.yml +108 -0
  512. data/lib/cyberweb/yaml/html_tag_legend.yml +12 -0
  513. data/lib/cyberweb/yaml/http_status_codes.yml +38 -0
  514. data/lib/cyberweb/yaml/js_files_to_load.yml +28 -0
  515. data/lib/cyberweb/yaml/project_configuration.yml +229 -0
  516. data/lib/cyberweb/yaml/video_attributes.yml +35 -0
  517. data/lib/cyberweb/yaml/web_images.yml +306 -0
  518. data/lib/cyberweb.rb +5 -0
  519. data/test/README.md +5 -0
  520. data/test/complex_tests/all_tests_in_one_page.cgi +666 -0
  521. data/test/complex_tests/simple_sinatra_example_using_cyberweb/simple.rb +60 -0
  522. data/test/complex_tests/sinatra_or_cyberweb/sinatra_or_cyberweb.cgi +7 -0
  523. data/test/complex_tests/sinatra_or_cyberweb/sinatra_or_cyberweb.rb +23 -0
  524. data/test/complex_tests/sinatra_or_cyberweb/sinatra_or_cyberweb.sinatra +65 -0
  525. data/test/complex_tests/testing_frames.cgi +42 -0
  526. data/test/complex_tests/testing_objectified_html_tags.rb +82 -0
  527. data/test/complex_tests/testing_style_variants/README.md +2 -0
  528. data/test/complex_tests/testing_style_variants/show_coloured_boxes.cgi +58 -0
  529. data/test/complex_tests/testing_tables.cgi +67 -0
  530. data/test/complex_tests/testing_the_cyberweb_shell.rb +188 -0
  531. data/test/complex_tests/testing_web_object.rb +94 -0
  532. data/test/css/README.md +5 -0
  533. data/test/css/return_the_content_of_these_css_classes.rb +7 -0
  534. data/test/css/testing_css_effects.cgi +159 -0
  535. data/test/css/testing_css_masking.cgi +36 -0
  536. data/test/dummy.pdf +0 -0
  537. data/test/hello_world/hello_world.cgi +25 -0
  538. data/test/javascript/README.md +2 -0
  539. data/test/javascript/testing_cheerleader_javascript.cgi +0 -0
  540. data/test/javascript/testing_drag_and_drop_support.cgi +33 -0
  541. data/test/javascript/testing_on_click_change_opacity.cgi +26 -0
  542. data/test/javascript/testing_snowflakes.cgi +20 -0
  543. data/test/simple_tests/README.md +3 -0
  544. data/test/simple_tests/ad-hoc-test.cgi +55 -0
  545. data/test/simple_tests/commandline_tests.rb +70 -0
  546. data/test/simple_tests/display_this_file.cgi +11 -0
  547. data/test/simple_tests/simple_html_example.cgi +29 -0
  548. data/test/simple_tests/simple_status_page.cgi +52 -0
  549. data/test/simple_tests/string_s2_test.rb +11 -0
  550. data/test/simple_tests/test_simple_string_as_input.rb +12 -0
  551. data/test/simple_tests/testing_base64_images.cgi +26 -0
  552. data/test/simple_tests/testing_dragging_an_image.cgi +23 -0
  553. data/test/simple_tests/testing_editable_text.cgi +16 -0
  554. data/test/simple_tests/testing_email.cgi +31 -0
  555. data/test/simple_tests/testing_embedding_a_pdf_file.cgi +32 -0
  556. data/test/simple_tests/testing_google_charts.cgi +24 -0
  557. data/test/simple_tests/testing_html_forms.cgi +31 -0
  558. data/test/simple_tests/testing_html_template.rb +13 -0
  559. data/test/simple_tests/testing_popup_div.cgi +22 -0
  560. data/test/simple_tests/testing_return_dataset_without_any_comments.rb +11 -0
  561. data/test/simple_tests/testing_the_cap_box.cgi +20 -0
  562. data/test/simple_tests/testing_the_div_tag.cgi +21 -0
  563. data/test/simple_tests/testing_the_headers_tag.cgi +36 -0
  564. data/test/simple_tests/testing_the_html_colours.cgi +19 -0
  565. data/test/simple_tests/testing_the_info_box.cgi +19 -0
  566. data/test/simple_tests/testing_the_li_tag.cgi +24 -0
  567. data/test/simple_tests/testing_the_s2_method.rb +7 -0
  568. data/test/simple_tests/testing_the_select_tag.cgi +23 -0
  569. data/test/simple_tests/testing_the_span_tag.cgi +36 -0
  570. data/test/simple_tests/testing_web_images.rb +12 -0
  571. data/test/testing_html_tags/README.md +7 -0
  572. data/test/testing_html_tags/button_example.cgi +42 -0
  573. metadata +759 -0
data/README.md ADDED
@@ -0,0 +1,3259 @@
1
+ [![forthebadge](http://forthebadge.com/images/badges/built-with-love.svg)](https://www.gobolinux.org/)
2
+ [![forthebadge](http://forthebadge.com/images/badges/made-with-ruby.svg)](https://www.ruby-lang.org/en/)
3
+ [![Gem Version](https://badge.fury.io/rb/cyberweb.svg)](https://badge.fury.io/rb/cyberweb)
4
+
5
+ This gem was <b>last updated</b> on the <span style="color: darkblue; font-weight: bold">14.10.2021</span> (dd.mm.yyyy notation), at <span style="color: steelblue; font-weight: bold">01:25:01</span> o'clock.
6
+
7
+ <img src="https://i.imgur.com/GatV3S5.png" style="margin-left: 0.5em">
8
+ <img src="http://shevy.bplaced.net/cyberweb_theme.png" style="margin-left: 0.5em">
9
+
10
+ ## The History of the Cyberweb project
11
+
12
+ This project was created a very long time ago, in PHP - in the year
13
+ 2004 or so, give or take. (I used to think it was in 2002, but looking
14
+ at old notes, it was more likely started in early 2004.)
15
+
16
+ I was using custom functions to regulate serving web-related content
17
+ back then, written in PHP.
18
+
19
+ The original **class WebObject**, for example, was written a very long time
20
+ ago, perhaps in the year **2004** or something like this, when I
21
+ transitioned away from PHP into ruby. I took all the old PHP code
22
+ and adapted it at that point.
23
+
24
+ The Cyberweb-project was rewritten several times, so it may not be
25
+ very similar to the old code from ~almost 20 years ago. The important
26
+ core methods, though, may still be quite similar. For example, I
27
+ was using div() in PHP already, and I am using div() in ruby too.
28
+
29
+ Ruby allows for more functionality out of the box, though, so I
30
+ can do:
31
+
32
+ div {
33
+ }
34
+
35
+ In PHP this is not easily possible, so ruby is better in this regard -
36
+ more flexible.
37
+
38
+ During that transition phase, from **php** to **ruby**, the project
39
+ was renamed several times - first to **web_foundation**, then to
40
+ **cybersprawl**, then to **Cyberweb**, then to **web_object** and
41
+ then back to **Cyberweb** again. I think the name **Cyberweb**
42
+ is best among these alternatives. While **web_object** is the
43
+ more technically correct and accurate term, as everything related
44
+ to the www is handled via that object, I prefer the name
45
+ **Cyberweb** in general for the whole project - it sounds
46
+ futuristic. The name **WebObject** is a good name too, though,
47
+ as we attempt to describe a particular "web-page" as a
48
+ "web-object", basically.
49
+
50
+ **class WebObject** was originally the very main class I was
51
+ using in PHP to describe my local knowledge base, an "app" where
52
+ I kept useful information bits about linux, and ruby, and other
53
+ parts together. The code for this project in PHP was simpler, and
54
+ also uglier though, and less flexible. (Actually the name was
55
+ not even WebObject back then, but let's not make this too overly
56
+ complicated and convoluted; it's already a fairly messy history.)
57
+
58
+ When I switched to **ruby**, I rewrote all my PHP code in ruby,
59
+ as stated; and eventually put the web-specific parts into a project
60
+ called <b>web_foundation</b>, which was the actual **predecessor**
61
+ to <b>Cyberweb</b> (with cybersprawl being part of it, but mostly
62
+ the idea here for **cybersprawl** being a custom **webforum**;
63
+ lateron cybersprawl became an incomplete **webmin clone**, which
64
+ I still want to finish one day. The wish to have a web-forum
65
+ is still retained, though).
66
+
67
+ The original <b>Cyberweb project</b> was "officially" started on
68
+ **13.06.2012** (13th June in the year 2012) - that is, the name
69
+ was first used in the year **2012**. In 2020 it came to an end
70
+ and was replaced with the <b>WebObject</b> project, but in May
71
+ 2021 the original name was re-instated. Quite confusing!
72
+
73
+ The project called <b>html_tags</b> was created at about the same
74
+ time back then, in the year **2012**, in order to keep the code
75
+ base of the newly generated project somewhat cleaner and smaller.
76
+ **WebFoundation** was thus renamed to Cyberweb, but there still
77
+ was a directory called **foundation/**. Old gem releases of **cyberweb**
78
+ may still show that, back when I kept these old releases.
79
+
80
+ In **August 2018**, I removed the **foundation/** subdirectory and
81
+ integrated the code into other parts of the project instead.
82
+
83
+ The transition phase in **2012** happened to some extent because
84
+ I was still using ruby 1.8.x and had to make several changes to
85
+ the old web-foundation project, in order to have my code work on
86
+ **ruby 1.9.3** anyway.
87
+
88
+ The rewrite would allow me to change some design decisions I made earlier
89
+ on, which were not that ideal - in other words, to allow me to discard
90
+ some of the old code at the same time (which again happened in 2018,
91
+ when I cleaned up the cyberweb project, after many years of
92
+ "semi-activity" only).
93
+
94
+ The **rewrite** step worked for the most part, even though it took me
95
+ longer than expected. While the code base is still not "perfect", it is
96
+ quite ok and also to some extent documented this time - at the least much
97
+ better than it used to be in the old code before. I will continue to
98
+ improve the documentation slowly over time.
99
+
100
+ In my opinion, it is quite common to rewrite web-related projects in ruby
101
+ in general- see manveru's old **Ramaze** project, for instance, which
102
+ unfortunately was abandoned at a later time. (Innate was created prior
103
+ to that **→** https://github.com/Ramaze/innate.)
104
+
105
+ Essentially **cyberweb** integrates what I learned over the years, so
106
+ I built some sort of "framework" for the web. It is actually not
107
+ necessarily a framework only as such but more a tool-set project for
108
+ the www. There won't be a lot of idioms used such as could be seen
109
+ in rails - because the cyberweb project is way too simple to make use
110
+ of complicated idioms. You can even call it a dumb project, too, on
111
+ purpose. I do not like the proliferation of complication and complexity
112
+ that the modern web-era induced onto developers - just look at the
113
+ amount of JavaScript frameworks that emerge and disappear over the
114
+ years. Anyone still remember Mochikit? Or the era before Mochikit?
115
+
116
+ The **cyberweb project** has combined, and thus integrated, the
117
+ following **older components** that have existed at various
118
+ moments in time or may still exist:
119
+
120
+ - web foundation
121
+ - Ruby-CGI (a snapshot, including the excellent cgi-exceptions functionality)
122
+ - cybersprawl
123
+ - sinatra mapping
124
+
125
+ This may not be hugely important to know, but it explains a bit of
126
+ the historic origin for the cyberweb project.
127
+
128
+ ## Aim, Goals and Scope of the Cyberweb project
129
+
130
+ This subsection will detail some of the goals of the Cyberweb project.
131
+
132
+ Before describing the **cyberweb** project in more detail, please keep in
133
+ mind that the project is fairly incomplete, not even in an early beta stage;
134
+ and that it is presently catered to my own use cases, so it may not work for
135
+ you. Consider it more as a proof-of-concept project than something you
136
+ may want to use for production. Sinatra may be a much better choice for
137
+ the latter.
138
+
139
+ At any rate, let's next see for the aims and goals of the **web_object**
140
+ project.
141
+
142
+ The **Cyberweb** project is both a collection of web-related tools
143
+ (thus, **a toolset project**) and a web "framework". Both terms
144
+ will be defined next.
145
+
146
+ What is meant with a "set of web-related tools"? This means that there
147
+ will be code, written in ruby, that aims to solve problems related to
148
+ the **world wide web**, ranging from small to medium-sized issues.
149
+
150
+ This may also include formatters and linters for e. g. JavaScript in
151
+ principle, but it can also include file-generators or related to
152
+ managing files, directories, css files, javascript files, and so
153
+ forth. A **set of tools**.
154
+
155
+ The other part of the Cyberweb project is to act as a "framework",
156
+ that is - to provide code that can be used for higher abstractions
157
+ when creating **web-apps**.
158
+
159
+ Note that the Cyberweb project itself is not necessarily extremely
160
+ opinionated. Different strategies may be used, be it **MVC** (model,
161
+ view, controller), be it plain oldschool .cgi or be it modern
162
+ microservices and REST APIs as such, such as used in rack and
163
+ sinatra/padrino. All can be combined and mixed together - in theory.
164
+ In practice, Cyberweb is of course limited mostly by my own time
165
+ investment, so different parts of the project will be more
166
+ comprehensive (and better) than other parts. The bottom line is
167
+ that there is "**no single strategy to rule them all**", as far
168
+ as the cyberweb project is concerned.
169
+
170
+ It is true that the Cyberweb project is, in itself, very traditionally
171
+ focused on the .cgi centric ways to develop web-apps. In theory, a
172
+ .cgi page could also be thought of as a **WebApp**. Nothing prevents
173
+ this really, other than some old assumptions about CGI.
174
+
175
+ In the long run, expect the Cyberweb project to become more general and
176
+ hopefully more "modern" as well, as I work on improving the documentation
177
+ in the next step (no possibility to have more users without **high
178
+ quality documentation**).
179
+
180
+ Since June 2021 two new goals were added to this project:
181
+
182
+ - It will contain documentation in regards to useful CSS knowledge.
183
+ - It will contain documentation in regards to useful JavaScript knowledge.
184
+
185
+ There are two reasons for this. The more important reason was that I
186
+ wanted to bundle web-related stuff into one project, and just use
187
+ that project, rather than dilute this to many separate projects.
188
+
189
+ The second reason was that I have collected a lot of knowledge over
190
+ the years about CSS and JavaScript, and wanted to keep them
191
+ presented (and presentable) in a single project as well. This means
192
+ that there may be pure CSS, pure HTML and pure JavaScript
193
+ examples distributed within the Cyberweb project as well.
194
+
195
+ ## Features
196
+
197
+ For a more complete documentation of the above features, please check
198
+ out the file FEATURES.
199
+
200
+ - You can select various different default CSS templates. They will be
201
+ stored in the CSS/ directory by default. To use them, pass a symbol
202
+ to the method invocation for css_style=(). They are numbered in
203
+ succession, so template1, template2 etc..
204
+
205
+ Example for this on the main w object:
206
+
207
+ w.css_style = :template1
208
+
209
+ This will default to the template1.
210
+
211
+ Currently the way to add new templates is to expand the case menu.
212
+
213
+ ## CSS templates
214
+
215
+ CSS templates can be designated by assigning to a symbol, such as
216
+ this:
217
+
218
+ w.css_style = :template1
219
+
220
+ The templates are stored in the cascading_style_sheets/ subdirectory.
221
+
222
+ Other templates are :default and :code.
223
+
224
+ Note that it is currently (2021) unsure whether templates will be
225
+ expanded. They will probably be retained, but may have to be
226
+ reviewed again to determine whether they are sufficiently useful
227
+ or not.
228
+
229
+ ## Cyberweb.set_path_to_images
230
+
231
+ The method **Cyberweb.set_path_to_images()** can be used to set the
232
+ path to a global image directory, that is - a directory that holds all
233
+ images. On my home system this defaults to **/home/x/data/images/**.
234
+
235
+ I put almost all images into this directory, but there are exceptions
236
+ to this.
237
+
238
+ Note that this directory will only be of relevance if the configuration
239
+ options for web_object were set up to use such a directory in the
240
+ first place. Only image-related methods are affected by this
241
+ setting anyway.
242
+
243
+ ## Images
244
+
245
+ If an image is not existing, but used within the Cyberweb
246
+ framework, then a a red border and a red text will be
247
+ displayed around that (non-existing) image.
248
+
249
+ This way, the user is being encouraged to fix the problem at hand.
250
+
251
+ However had, it may also be annoying to see it if the user can NOT
252
+ fix/change this.
253
+
254
+ This is why the red warning or warnings in general, can be reduced
255
+ or disabled - have a look at the configuration file for this.
256
+
257
+ If warnings are set to verbose, then the web_object project will
258
+ display the above notification for images not found. If it is set
259
+ to normal or lower than that, the web_object project will not
260
+ display that warning.
261
+
262
+ ## Balloon.css
263
+
264
+ You can download the **balloon.css** file via class
265
+ **DownloadBalloonCss** (**Cyberweb::DownloadBalloonCss**).
266
+
267
+ This file resides at the location
268
+ <b>web_object/utility_scripts/download_balloon_css.rb</b>.
269
+
270
+ It presently (May 2018) does not do much other than download
271
+ that remote .css file.
272
+
273
+ I needed a small "pop-up" for displaying additional information
274
+ to some entries in a table, which is how I found **Balloon.css**.
275
+
276
+ ## Proper (default) order of arguments to many methods in the Cyberweb project
277
+
278
+ The Cyberweb project uses quite a few methods that have more than 4
279
+ or 5 parameters.
280
+
281
+ The typical order for these methods is the following:
282
+
283
+ (**1**) the content belonging to the tag at hand
284
+ (**2**) the css class that is to be used for that tag (defaults to class WebTag)
285
+ (**3**) the id to that HTML element (optional)
286
+ (**4**) the css style for that tag (optional)
287
+ (**5**) javascript code to that tag (optional)
288
+
289
+ ## Greek letters
290
+
291
+ The old greek letters are specified via shortcuts such as <b>&sigma;</b>
292
+ in HTML. The **&sigma;** variant would display the small sigma
293
+ character; the constant SIGMA_SMALL or just SIGMA will allow you to
294
+ refer to this constant within the Cyberweb project.
295
+
296
+ You can output a table with all available greek letters by issugin
297
+ the following command:
298
+
299
+ Cyberweb.show_greek_letters
300
+
301
+ ## SVG
302
+
303
+ If you wish to make use of SVG it is recommended to install the
304
+ **svg_paradise** project. Then, you can use it through Cyberweb
305
+ such as in the following case:
306
+
307
+ ee Cyberweb.circle
308
+
309
+ This will output a SVG circle. Do note that this can be customized;
310
+ simply have a look for the SVG Paradise project for more
311
+ documentation pertaining to this part.
312
+
313
+ ## Javascript-support in the Cyberweb project
314
+
315
+ Have a look at the subdirectory called **javascript/**.
316
+
317
+ If a new javascript-component is added, it should be registered
318
+ in one of the .rb files in said directory.
319
+
320
+ ## Commandline usage
321
+
322
+ A commandline program exists, at <b>bin/cyberweb</b>.
323
+
324
+ This file allows you to generate a new file-skeleton, such as
325
+ via:
326
+
327
+ cyberweb foo.cgi
328
+ cyberweb index.cgi
329
+
330
+ You can also get some feedback over what it can do, via
331
+ "cyberweb --help".
332
+
333
+ ## The interactive web_object-shell
334
+
335
+ There also exists an interactive **cyberweb-shell**, which may be
336
+ used to test out various things - but it is fairly unfinished, so I
337
+ do not recommend anyone to use it as of yet (2018).
338
+
339
+ The idea is to have this work as some kind of developer-console
340
+ where web-related activities can be tested.
341
+
342
+ ## HtmlTags
343
+
344
+ Since as of cyberweb version 0.0.5, a dependency exists on a
345
+ project called **html_tags**, which was created in order to
346
+ separate the generation of HTML tags out from the rest of
347
+ the framework.
348
+
349
+ The idea is to hold a full HTML page in a special object, the so
350
+ called "web_object", and to then .serve() said object when it is
351
+ required. Which essentially is done through a .cgi page.
352
+
353
+ Since as of **April 2019**, the old .cgi approach will be extended;
354
+ while .cgi will be always supported in the Cyberweb project, an
355
+ approach similar to **sinatra** will eventually be adopted as well.
356
+
357
+ ## Include the cyberweb project on a website
358
+
359
+ To include the cyberweb project on a website, in your .cgi script
360
+ for instance, do use this line:
361
+
362
+ require 'cyberweb/autoinclude'
363
+
364
+ You can then populate the @web_object object, which resides in the
365
+ main Cyberweb-namespace, and which is also aliased through a
366
+ convenience method called w(). If you autoinclude Cyberweb
367
+ then you can use the w() method directly.
368
+
369
+ This allows you to describe a webpage, such as by issuing the
370
+ following code:
371
+
372
+ w {
373
+ title 'My first homepage'
374
+ body_css 'mar1em'
375
+ h2 'Hello World!'
376
+ use_jquery
377
+ }
378
+
379
+ Note that this should happen on separate lines - the description
380
+ here for the gem does not replace newlines with the html <br> tag.
381
+
382
+ Inside **w {}** you can issue special instructions, such as use_jquery
383
+ or disable_webimages. The former allows us to use jquery, the latter
384
+ disables webimages. (Webimages are small icons that I find myself
385
+ to use a lot. If you wish to use these images, have a look at
386
+
387
+ http://shevegen.square7.ch/STD.tar.xz
388
+
389
+ )
390
+
391
+ ## Configuration - and editing the configuration file (which is a yaml file)
392
+
393
+ Keep in mind that you can modify a lot of the configuration that
394
+ the Cyberweb project uses, through the yaml files stored in the
395
+ <b>configuration/</b> subdirectory.
396
+
397
+ If you need to display the configuration settings via web-page,
398
+ you can always use the method .show_config(), on the main
399
+ Cyberweb, such as via either of the following code:
400
+
401
+ w.show_config
402
+ div('mars3em') { w.show_config }
403
+
404
+ You can also just show the configuration setting without depending
405
+ on the web-object, through this module-level method:
406
+
407
+ Cyberweb.show_configuration_settings
408
+
409
+ The main **configuration file**, a .yml file, can also be modified
410
+ through a commandline "interface", via:
411
+
412
+ cyberweb edit
413
+
414
+ This presently uses a hardcoded value (towards the editor
415
+ called **vim**).
416
+
417
+ You can also query the current configuration via appending **config?**
418
+ such as in:
419
+
420
+ http://localhost/DATA/personal/sitemap.cgi?config?
421
+
422
+ ## HTML Tables and the Cyberweb project
423
+
424
+ The method table() is the primary entry point for table-related
425
+ tags. The first three arguments are:
426
+
427
+ css class to use
428
+ ID of the table
429
+ css style to use
430
+
431
+ You can also, optionally, pass in a dataset to the table,
432
+ such as an Array, via a block argument.
433
+
434
+ The following example shows how to do that:
435
+
436
+ table('mars1em','test_table1','border:1px solid rand') { %w(
437
+ this is a test table1 with every individual
438
+ entry becoming populated into the table
439
+ )}
440
+
441
+ The part after the {} constitutes the Array that is passed into
442
+ the table.
443
+
444
+ By default this will use two td-elements, aka table data elements.
445
+ The third element goes on a new line, aka via a closing **tr**
446
+ tag (in HTML parlance).
447
+
448
+ Note that you can use variants of table() if you need a different
449
+ amount of **td** tags.
450
+
451
+ For example, **table4()** can be used to denote a table with
452
+ 4 elements per row:
453
+
454
+ table4('mars1em','test_table1','border:1px solid rand') { array_goes_here }
455
+
456
+ You can also set global CSS classes to class Table:
457
+
458
+ Table.set_css_class 'bblack5 pink_border3 marl2em mart1em'
459
+
460
+ For a longer explanation of that .set_css_class() functionality, have a
461
+ look at the link here at **HTML Tables and the Cyberweb project**.
462
+
463
+ Note that you do not have to supply any arguments to table() aside
464
+ from the dataset given into it as block - a simple Array will suffice:
465
+
466
+ table { pass_array_here }
467
+
468
+ You can also style each **td** element, such as by tagging them
469
+ with a block border:
470
+
471
+ Td.set_css_class 'bblack1'
472
+ table('mars2em') { %w(
473
+ This is just an example Array
474
+ )}
475
+ Td.set_css_class ''
476
+
477
+ The last line of code will again clear the default set to **Td**.
478
+
479
+ ## The name cyberweb
480
+
481
+ You may wonder why the name used to be **cyberweb**.
482
+
483
+ There is not a single good reason for this other than, firstly, I
484
+ thought it was related to the web - so I included web. And
485
+ cyber? Well, I like science fiction; and cyber sort of fits
486
+ to the www too, at the least to some parts.
487
+
488
+ The idea for a "social" web, from the point of view of the
489
+ older web-foundation project (the predecessor to the
490
+ cyberweb project), was to call this the "cybersprawl".
491
+ The name **cybersprawl** would indicate a **virtual
492
+ meet-up place for people**.
493
+
494
+ This may sound a bit confusing but it is sort of how the name
495
+ gradually evolved - and eventually became **cyberweb**,
496
+ before it was renamed to **web_object** in 2020. And at
497
+ a later time back to **cyberweb** - yup, I change
498
+ the project names way too quickly. But the name used to
499
+ by cyberweb in the past, so I am slowly getting used to
500
+ that name.
501
+
502
+ ## Creating input-buttons in a HTML-form field
503
+
504
+ <form>
505
+ <input type="button" class="BG_GRAYSTD bblack1" value="Default" name="foo" onClick="test1(this.form)">
506
+ </form>
507
+
508
+ <form>
509
+ <input class="BG_GRAYSTD bblack1" type="button" value="Default" name="foo" onClick="test1(this.form)">
510
+ </form>
511
+
512
+ ## HTML Entities
513
+
514
+ If you wish to remove HTML entities from a given input string
515
+ at hand, you can use **Cyberweb.escape_html()** or one of its
516
+ alias.
517
+
518
+ Example:
519
+
520
+ Cyberweb.escape_html('abc') # => 'abc'
521
+ x = '<p>this is (&nbsp;) a test</p><div> Ok -&amp; outcome will be </div>'; y = Cyberweb.html_entities(x) # => "&lt;p&gt;this is (&amp;nbsp;) a test&lt;/p&gt;&lt;div&gt; Ok -&amp;amp; outcome will be &lt;/div&gt;"
522
+
523
+ ## Specifying a monospace font to use
524
+
525
+ The Cyberweb has a method that allows you to use a monospace font.
526
+
527
+ Within your Cyberweb instance, such as:
528
+
529
+ w {
530
+ }
531
+
532
+ You can add any of the following two lines:
533
+
534
+ use_monospace_font
535
+ monospace_font
536
+
537
+ This will use a monospaced font. I needed this functionality because
538
+ I sometimes use the pre-tag, and display numbers in a table-fashion,
539
+ for where it may be useful to use a monospaced font, so that the
540
+ alignment of the text is easier.
541
+
542
+ ## Setting a title on a webobject
543
+
544
+ You can set a title on the default webobject via:
545
+
546
+ set_title()
547
+
548
+ You can omit this call, in which case we will default to
549
+ the filename of the page in question, such as for a
550
+ file named **foobar.cgi**, the corresponding title
551
+ would simply be "foobar".
552
+
553
+ You can also use markdown files if you want to. I personally
554
+ use a file such as **TITLE.md** or **TITEL.md**. The method
555
+ call will try to read in the file content, and then use
556
+ that as the title, **if the file exists**.
557
+
558
+ ## The default image directory
559
+
560
+ The default image directory is defined in default_image_directory.yml
561
+
562
+ At least the name of the image directory.
563
+
564
+ ## Viewing the source of a webpage
565
+
566
+ Use the view_source() method to add a javascript button,
567
+ to view the source of a page. The method view_source()
568
+ is defined in the file shared.rb.
569
+
570
+ ## Modify the input tag
571
+
572
+ You can modify the <input> tag within that via css by using:
573
+
574
+ input.view_css {}
575
+
576
+ ## HTML IDs
577
+
578
+ All HTML ids are registered into an array. To then show whether
579
+ you have duplicated IDs in a page, do this:
580
+
581
+ show_duplicated_ids()
582
+
583
+ Or in a more general way, use the #debug method, like so:
584
+
585
+ w.debug
586
+
587
+ This will report whether you have a duplicated ID or not.
588
+ When the page is served, we will also display a little error
589
+ message in case we have found duplicated IDs. This way we
590
+ can notify the developer that there is some mistake in his
591
+ page and we can correct this mistake then.
592
+
593
+ ## The table-tag
594
+
595
+ The tag table() now supports blocks. That means you can use arrays
596
+ in tables:
597
+
598
+ table { %w( one two three for ) }
599
+
600
+ Or styled with CSS:
601
+
602
+ table('s1em bblack1') { %w(one two three for) }
603
+
604
+ You can combine fieldset with table and a caption, by doing:
605
+
606
+ table_with_caption('title of caption goes in here')
607
+
608
+ ## Global CSS classes
609
+
610
+ In general, every HTML tag has **a representative ruby
611
+ class**, with the first character being upcased.
612
+
613
+ For example, the div tag can be accessed, in some ways,
614
+ through **class Div**. An example follows next.
615
+
616
+ Say that you wish to colourize all div tags on the
617
+ given webpage with the colour red. The following code
618
+ will do that:
619
+
620
+ Div.set_css_class 'red' # Now all divs are red.
621
+
622
+ This will still require a CSS class defined called .red,
623
+ which has the content **{ color: red; }**. However had,
624
+ in a future release, Cyberweb may do this automatically,
625
+ at the least for colours (we need to keep in mind that
626
+ code should not be ambiguous).
627
+
628
+ The point of the above code is to provide you with a
629
+ simple way to quickly style all HTML tags in some
630
+ way. You may not want to find this too overly useful,
631
+ but at the least the functionality exists for when
632
+ you **may** need this.
633
+
634
+ Do note that you can remove the above via:
635
+
636
+ Div.clear
637
+
638
+ again.
639
+
640
+ This works for **all** HTML tags by the way, for when
641
+ it makes sense for such a tag to have that possibility.
642
+
643
+ An alternative may be:
644
+
645
+ Cyberweb.clear :div
646
+
647
+ This would clear any predefined-css-class for any tag.
648
+ Both Div.clear and Cyberweb.clear :div are equivalent -
649
+ use whatever seems better or easier for you.
650
+
651
+ Let's give another example - say that you want to modify
652
+ the default CSS class for the html table tag:
653
+
654
+ Table.set_css_class 'bblack5 pink_border3 marl2em mart1em'
655
+ Cyberweb::Table.set_css_class 'bblack5 pink_border3 marl2em mart1em'
656
+
657
+ (The second variant is necessary if you did not do
658
+ **include Cyberweb** before.)
659
+
660
+ After this was done, you can always query the css class via:
661
+
662
+ Table.to_s
663
+
664
+ In fact, this is used as default argument to arguments in
665
+ method definitions (with the corresponding name of the
666
+ html tag).
667
+
668
+ Cyberweb also has some pre-defined tags, and CSS classes that
669
+ can be used across different projects.
670
+
671
+ One such method is **cmd()** - this originally stood for
672
+ "command", and was used to display commands that the user
673
+ could input into a terminal/shell, on Linux.
674
+
675
+ The method cmd() has a pre-defined CSS class that can be
676
+ queried like this:
677
+
678
+ Cyberweb.css_for_cmd? # => "marl1em BOLD"
679
+
680
+ These are two CSS classes. **marl1em** means **margin-left: 1em**,
681
+ and **BOLD** means, well, **font-style: bold**.
682
+
683
+ This query method exists primarily due to convenience. In November
684
+ 2019 I needed to query the old default, change it, then re-assign
685
+ it to the main CSS class in use there.
686
+
687
+ You can also designate another default, like by this way:
688
+
689
+ Cyberweb.css_for_cmd = 'marl1em steelblue BOLD'
690
+
691
+ ## Hiding / disabling scrollbars
692
+
693
+ You can use:
694
+
695
+ hide_scrollbars
696
+
697
+ in the **main web_object** to hide the scrollbar, by making use
698
+ of CSS. I recommend against this, because it may annoy some
699
+ users, but it was enabled because sometimes there may be use
700
+ cases to NOT have a scrollbar at all.
701
+
702
+ The idea was taken from:
703
+
704
+ https://www.w3schools.com/howto/howto_css_hide_scrollbars.asp
705
+
706
+ ## Showing the source code of a particular file
707
+
708
+ By default every file that is part of the cyberweb project can
709
+ show its source to the visitor, by appending:
710
+
711
+ ?source
712
+ ?view_source
713
+
714
+ to the URL.
715
+
716
+ For example, on my home system I make use of this like so:
717
+
718
+ http://localhost/data/video/play_this_video_file.cgi?source
719
+
720
+ Evidently this is not always wanted and will, in the future,
721
+ have means to disable this (or selectively enable it in the
722
+ configuration file). But for the time being (January 2020)
723
+ this is the way how things work - after all, even with
724
+ criticism about this functionality, it **is** a feature
725
+ too.
726
+
727
+ ## HTML header tags
728
+
729
+ HTML has, by default, different header tags, starting with **h**.
730
+
731
+ For example we have:
732
+
733
+ <h1>This is h1</h1>
734
+ <h2>This is h2</h2>
735
+ <h3>This is h3</h3>
736
+ <h4>This is h4</h4>
737
+ <h5>This is h5</h5>
738
+ <h6>This is h6</h6>
739
+
740
+ The corresponding generator in Cyberweb is:
741
+
742
+ h1 'This is h1'
743
+ h2 'This is h2'
744
+ h3 'This is h3'
745
+ h4 'This is h4'
746
+ h5 'This is h5'
747
+ h6 'This is h6'
748
+
749
+ If you also wish to make the content displayed there as
750
+ the id="" setting, then you can use:
751
+
752
+ h1_id 'This is h1'
753
+ h2_id 'This is h2'
754
+ h3_id 'This is h3'
755
+ h4_id 'This is h4'
756
+ h5_id 'This is h5'
757
+ h6_id 'This is h6'
758
+
759
+ The **id** at hand will be the content, so this is more
760
+ useful for short header-entries, such as "Goals" or
761
+ "Aims" or "Introduction" and so forth. The latter
762
+ functionality purely exists due to convenience - I wanted
763
+ to quickly generate the default id entry for a sitemap.
764
+
765
+ ## JavaScript clock
766
+
767
+ If you wish to display a small JavaScript "clock" that just
768
+ shows the time, you could use this:
769
+
770
+ display_clock('pad1em') { :larger_font_size }
771
+
772
+ The block argument just increases the font-size a bit; it can
773
+ be omitted of course, as can all arguments, too:
774
+
775
+ display_clock
776
+
777
+ ## Redirecting to another page
778
+
779
+ You can combine BeautifulUrl, and Cyberweb, to redirect
780
+ to another page.
781
+
782
+ Example:
783
+
784
+ http://localhost/DATA/misc/sitemap.cgi?redirect_to=ruby_todo
785
+
786
+ This would redirect me to my local todo-file in ruby. In fact:
787
+ that was the primary reason why the code was added, so that I
788
+ can use the web-server as a pseudo file system.
789
+
790
+ Evidently not everyone may want this feature, so in the long
791
+ run this may have to be modified - but for now it will remain
792
+ as it is. It can be used to quickly "jump" to another page,
793
+ both a local page or a remote page.
794
+
795
+ ## Viewing the content of any file
796
+
797
+ You can view the content of any file via:
798
+
799
+ http://localhost/DATA/misc/sitemap.cgi?view_file=ruby_todo
800
+
801
+ This can be disabled since as of **May 2021, by setting the
802
+ **view_file: true** in the project configuration .yml file.
803
+ I recommend to do so, as you probably don't need this
804
+ functionality. I needed it for my local webserver, to
805
+ quickly test things, and view local files in the browser,
806
+ no matter where they reside (which is handled by another
807
+ gem, which is not published, as it is for internal use
808
+ only).
809
+
810
+ ## dropdown()
811
+
812
+ You can use the dropdown() method to use several &lt;select>
813
+ statements.
814
+
815
+ Examples:
816
+
817
+ dropdown( %w( a b c ) )
818
+ dropdown( %w( a b c ) ) {{ selected: 2 }}
819
+ dropdown( %w( a b c ) ) {{ selected: 3 }}
820
+
821
+ The latter variant will have the second entry selected as default;
822
+ we begin to count at 1 here, not 0.
823
+
824
+ ## Cyberweb.display_all_files_in_this_directory
825
+
826
+ The method **Cyberweb.display_all_files_in_this_directory()**
827
+ can be used to simply and quickly display the content of
828
+ all files in the given (target) directory.
829
+
830
+ Example:
831
+
832
+ Cyberweb.display_all_files_in_this_directory '/tmp'
833
+
834
+ I needed this functionality because I had many standalone
835
+ .py files holding matplotlib code and I needed to display
836
+ them, so this functionality was added in **May 2020**.
837
+
838
+ ## Register on-click events
839
+
840
+ If you want to register an on-click event and change the opacity value
841
+ of an element, you can use this method:
842
+
843
+ on_click_change_opacity '#drag_notepad','0.95'
844
+
845
+ The first argument is the ID of the target element, and the second value
846
+ is the opacity value - the lower that value is, the higher the opacity
847
+ (and thus, the highlighting).
848
+
849
+ Note that you can also combine this with a drag-action. For instance,
850
+ the symbol :drag_and_highlight means that we will combine both
851
+ actions here, thus allowing a drag-object action, and also a
852
+ on-click-highlighting action on the same object.
853
+
854
+ ## Body id
855
+
856
+ To set a body-id for the Cyberweb, you can use something like this:
857
+
858
+ body_id 'foobar'
859
+ set_body_id 'foobar'
860
+
861
+ This is equivalent to:
862
+
863
+ <body id="foobar">
864
+
865
+ Not a huge saving *per se*, but if you just want to keep a separate
866
+ entry for the id of the body, you can use this method on a
867
+ web_object instance.
868
+
869
+ ## Default CSS classes
870
+
871
+ The Cyberweb comes with some CSS classes pre-defined.
872
+
873
+ I am aware that not everyone may want this, but it is simpler
874
+ to bundle my css-classes into this project - both for my own
875
+ personal use case, but also because other people may see
876
+ how the project works. Furthermore, these CSS classes can
877
+ be quite convenient, allowing us to make use of shortcuts
878
+ to style elements on a given webpage.
879
+
880
+ ## Editable text
881
+
882
+ HTML5 allows the visitor to modify text on a webpage (although
883
+ not persistently).
884
+
885
+ The Cyberweb project also allows this. Example:
886
+
887
+ e('Type something here.') { :editable }
888
+
889
+ This would make a span-tag, following by a br-tag,
890
+ and the attribute that this is editable.
891
+
892
+ ## CSS helper code and how it relates to the Cyberweb project
893
+
894
+ This subsection attempts to detail how the **cyberweb** project
895
+ relates (and makes use of) **CSS**.
896
+
897
+ All my custom CSS rules are distributed in the subdirectory called
898
+ **cascading_style_sheets/**. You can find files such as **colours.css**
899
+ or **default.css** and so forth. Furthermore I have a local
900
+ directory at **/home/x/data/CSS/** which contains symlinks to the
901
+ subdirectory **cascading_style_sheets/**. This was done mostly
902
+ because it saves me some typing-work on the commandline.
903
+
904
+ **CSS** can, in principle, be accessed through the predefined global
905
+ object named **@css**.
906
+
907
+ This object can be accessed via "css" or via the helper method
908
+ called **css()**. (Remember that you can omit the () in ruby).
909
+
910
+ A specific usage example would look like this:
911
+
912
+ css.foobar
913
+
914
+ The idea here was that we could treat all the CSS code in any given
915
+ web-app as an object too, and manipulate it if needed.
916
+
917
+ Additionally, we would also be able to modify default CSS assignments
918
+ given to some methods, redefine them and so on.
919
+
920
+ Do note that since as of 2020, I am no longer as convinced that
921
+ this is really that useful. So consider this a bit of
922
+ **work-in-progress** rather than a finished solution that other
923
+ people should use.
924
+
925
+ For instance, to change the default for the HTML tag **h4**, the
926
+ following code could be used:
927
+
928
+ css.h4.custom_css = 'padl1em'
929
+
930
+ The idea here was to be able to re-define which custom CSS class is to
931
+ be used. (padl1em is my abbreviation for **padding-left: 1em**)
932
+
933
+ An alternative syntax exists as well - this is the better way, in my
934
+ opinion, and **should be used**:
935
+
936
+ Table.set_css_class 'bblack5 pink_border'
937
+ Div.set_css_class 'mar3em'
938
+
939
+ I personally like explicit setters like the above, but the following
940
+ variants are equivalent:
941
+
942
+ Table.css_class = 'bblack5 pink_border'
943
+ Div.css_class = 'mar3em'
944
+
945
+ ## CSS Basics
946
+
947
+ This short subsection just keeps some information about CSS, in the
948
+ event I forget stuff, or need to look it up quickly, or other people
949
+ may read something new.
950
+
951
+ A style sheet in CSS can be broken down into the following smaller
952
+ bits:
953
+
954
+ ➤ Style sheet
955
+ ➤ Rule
956
+ ➤ Selector
957
+ ➤ Declaration
958
+ ➤ Property
959
+ ➤ Value
960
+
961
+ When more than one selector appears in the same rule, they are said
962
+ to be <b>grouped</b>.
963
+
964
+ An example for grouping in CSS is shown next:
965
+
966
+ th, td { padding: 0 10px 0 0; }
967
+
968
+ You can space out the selectors onto different lines, such as via
969
+ this way:
970
+
971
+ th,
972
+ td {
973
+ padding: 0 10px 0 0;
974
+ }
975
+
976
+ Use whatever style you prefer.
977
+
978
+ HTML elements may treat CSS-width differently. The <table> element,
979
+ for instance, only expands horizontally to accommodate its data,
980
+ which is also called "shrink-to-fit". The <div> element, on the other
981
+ hand, expands horizontally as far as there is space, which is
982
+ called "expand-to-fit".
983
+
984
+ If you encounter a CSS rule with a <b>!important</b> classifier
985
+ then this rule can not be overruled. It became a fixed rule.
986
+
987
+ The hexadecimal notation #FFF is a short hand for #FFFFFF (which
988
+ is actually white).
989
+
990
+ RGB values in CSS may also be represented using percentages.
991
+
992
+ Example for this:
993
+
994
+ body {
995
+ background-color: rgb(50%, 50%, 50%);
996
+ }
997
+
998
+ A class-selector looks like this:
999
+
1000
+ .foobar {
1001
+ margin: 10px 0; # And similar comments
1002
+ }
1003
+
1004
+ The **.** indicates that we want to use a class-selector definition.
1005
+
1006
+ The above class-selector is valid for every HTML tag that wants to
1007
+ use it. You can limit this and confine it to only some elements.
1008
+
1009
+ For example, to limited this only to div-tags, use:
1010
+
1011
+ div.foobar {
1012
+ }
1013
+
1014
+ Interestingly you can also chain class names together such as:
1015
+
1016
+ .foo.bar {
1017
+ background-image: url(foobar.jpg);
1018
+ }
1019
+
1020
+ This means that it will only apply to any element that
1021
+ has both foo and bar as classes.
1022
+
1023
+ ID selectors in CSS can be used like this:
1024
+
1025
+ <style type="text/css">
1026
+ #foobar {
1027
+ background-image: url(foobar.jpg);
1028
+ }
1029
+ </style>
1030
+ <div class="planet" id="foobar">
1031
+ <h2>Foobar</h2>
1032
+ </div>
1033
+
1034
+ The **universal selector** in CSS is an asterisk. When used
1035
+ alone, the **universal selector** tells the CSS interpreter to
1036
+ **apply the CSS rule to all elements in the document**.
1037
+
1038
+ An example showing this follows next:
1039
+
1040
+ * {
1041
+ font-family: Arial, Helvetica,sans-serif;
1042
+ }
1043
+
1044
+ In CSS, **descendant** refers to an element that is a
1045
+ child of another element.
1046
+
1047
+ To target an element based on its ancestor the CSS should be
1048
+ written in this way:
1049
+
1050
+ div.foobar h2 {
1051
+ font-size: 18px;
1052
+ margin-top: 0;
1053
+ }
1054
+
1055
+ CSS pseudo-classes are used to represent dynamic events, a change
1056
+ in state, or a more general condition present in the document
1057
+ that is not easily accomplished through other means. Unlike normal
1058
+ classes, pseudo-classes have a single colon before the
1059
+ pseudo-class property.
1060
+
1061
+ Some browsers will apply the :link pseudo class styles to all links.
1062
+ Therefore it may be prudent to define the same properties in :link
1063
+ and :visited, so that the correct styles are applied.
1064
+
1065
+ For keyboard-focus you can use the pseudo-element **:focus**:
1066
+
1067
+ a:focus {
1068
+ text-decoration: underline;
1069
+ }
1070
+
1071
+ ## Cyberweb.string_image()
1072
+
1073
+ The method **Cyberweb.string_image()** can be used to return
1074
+ a proper HTML img tag, as String. This can then be used to
1075
+ embed it into some website.
1076
+
1077
+ The input to this method will be an Array, since we use
1078
+ *args there. The first entry should be the URL to the
1079
+ image at hand - this can be a local URL or a remote URL.
1080
+
1081
+ A Hash can also be given. Such a Hash should have a key
1082
+ called **:url** to denote the image.
1083
+
1084
+ Note that the method **Cyberweb.string_image()** is quite
1085
+ long, in order to cover for different use cases. The
1086
+ document here will not detail all these options, but a
1087
+ few may be explained next:
1088
+
1089
+ :guess_id # This means that the ID will be "guessed" based on the filename at hand.
1090
+ :guess_draggable_id # This is as above, but will prepend the string 'drag_' before, to allow for dragging the image at hand.
1091
+
1092
+ Personally I use **:guess_draggable_id** usually, as it helps me
1093
+ remember what this is doing. :-)
1094
+
1095
+ To make all images draggable, use this API:
1096
+
1097
+ all_images_will_be_draggable
1098
+
1099
+ ## Future goals for the Cyberweb project
1100
+
1101
+ There are a tons of things I always wanted to add or have
1102
+ available in a web-toolkit - a simple webforum; a blog engine
1103
+ and system for managing the content therein; the possibility
1104
+ to easily scrape remote websites, with code that is simple
1105
+ to understand, write, use (via a web-interface) and maintain.
1106
+ And many more goals - in short, to use the browser as the
1107
+ main tool.
1108
+
1109
+ Inertia and laziness is one (or two) reason(s) why these goals have
1110
+ not yet been implemented, largely because I find myself facing
1111
+ non-web related issues more often than web-related issues.
1112
+ So naturally, more of my time goes into non-web related
1113
+ issues. Furthermore, I really dislike JavaScript - if only
1114
+ we could describe everything via Ruby instead ...
1115
+
1116
+ For the design of the Cyberweb project (and I am aware that
1117
+ a LOT of it could be improved here), I am wondering whether
1118
+ it would not be better to actually replace all of the
1119
+ dichotomy out there in regards to the www, with "**one language
1120
+ to rule them all**" as a solution. I don't even refer to ruby
1121
+ primarily as such, even though Cyberweb is evidently written
1122
+ in ruby - but what I mean is ... **consider the following** ...
1123
+
1124
+ Why do we have to write JavaScript?
1125
+ Why do we have to write CSS?
1126
+
1127
+ Why can't we let our computers actually generate the "logic"
1128
+ behind these programming languages or markup languages?
1129
+
1130
+ For example, take:
1131
+
1132
+ set_font 16
1133
+
1134
+ This could mean a (any) font with 16 pixels in size.
1135
+
1136
+ It's quite simple to use this from within Cyberweb:
1137
+
1138
+ w {
1139
+ set_font 16
1140
+ }
1141
+
1142
+ Done!
1143
+
1144
+ We could even get rid of the '_' there perhaps:
1145
+
1146
+ w {
1147
+ set font 16
1148
+ }
1149
+
1150
+ Don't mind the "set_font" name; we could easily use
1151
+ this (or allow several aliases):
1152
+
1153
+ w {
1154
+ fontsize 16
1155
+ }
1156
+
1157
+ Or:
1158
+
1159
+ w {
1160
+ font size 16
1161
+ }
1162
+
1163
+ (The **w** is a shortcut to tap into the web-object
1164
+ instance.)
1165
+
1166
+ The primary thing of note here is - why would we **HAVE**
1167
+ to use CSS in order to style a webpage? Why not use, in
1168
+ this case, Ruby? Or any other language for that matter?
1169
+ Ideally one language to describe all these disparate
1170
+ languages (**HTML/CSS/JavaScript**) and the logic found
1171
+ in them.
1172
+
1173
+ Based on this thinking, when you apply this on everything,
1174
+ including JavaScript, you actually should be able to
1175
+ write something that is simple and works - and have
1176
+ ruby interprete it correctly. Or perhaps another language,
1177
+ similar to how LLVM works or perhaps the WebAssembly
1178
+ project, to some extent.
1179
+
1180
+ So, for example:
1181
+
1182
+ on_mouse_click highlight_id('mouse_pic')
1183
+ on_mouse_click highlight_id(:mouse_pic)
1184
+
1185
+ Now, if you as the visitor are to click on this, say, a
1186
+ button or some other container element, you would highlight
1187
+ the element that has the **mouse_pic** id. This is quite
1188
+ easy to do via jquery as-is, but why even have to
1189
+ think about JavaScript at all?
1190
+
1191
+ I would like to have **a platform** where I can do simple
1192
+ manipulations, without having to worry about the
1193
+ underlying code implementation **AT ALL**.
1194
+
1195
+ So, this would constitute one **future goal** for web_object -
1196
+ to be able to do tasks, from Ruby, and have it applied
1197
+ to the whole **Cyberweb component**.
1198
+
1199
+ Note that WASM is in some ways a bit similar to this, in the
1200
+ sense that we become **less dependent** on JavaScript than
1201
+ before, since we can also use **other** languages. Of course
1202
+ this is still a far cry away from using just one format to
1203
+ describe everything, but still, it helps break up the monopoly
1204
+ of JavaScript, which is good that this happens. That way we
1205
+ aren't as imposed by the constraints that JavaScript puts
1206
+ onto us here anymore (in theory, at least).
1207
+
1208
+ ## Saving (storing) the content of the main web_object into a local file
1209
+
1210
+ You can save the main string into a file quickly, by using:
1211
+
1212
+ save
1213
+ # or
1214
+ web_object?.save
1215
+
1216
+ Note that this will save into the temp-directory. Your webserver
1217
+ needs to have access to it, as otherwise no file can be saved.
1218
+
1219
+ It may be simpler to use the last option, because of the main
1220
+ doc {} clause that is only finished after the w {} has completed.
1221
+
1222
+ That toplevel web_object? call taps into the main web-object.
1223
+
1224
+ ## Favicons
1225
+
1226
+ Favicons are **small images** that may be shown in the tab of
1227
+ the browser. I consider them potentially cute and even useful,
1228
+ as it may allow the user to quickly look for specific images
1229
+ through the browser-tabs.
1230
+
1231
+ According to this blog https://getkiss.org/blog/20191004a
1232
+ all among the major browsers will request a favicon, even
1233
+ if one has not been set. This evidently wastes a tiny
1234
+ bit of bandwith.
1235
+
1236
+ If you wish to avoid this then you can simply inline a
1237
+ favicon. The smallest "inline" favicon which
1238
+ which ensures zero HTTP requests is the following:
1239
+
1240
+ <link href=data:, rel=icon>
1241
+
1242
+ You can do so in Cyberweb too, as part of the
1243
+ **Cyberweb class**, via:
1244
+
1245
+ favicon :inline
1246
+ favicon :minimal
1247
+ favicon :none
1248
+
1249
+ Use any of these three variants and it will lead to the above
1250
+ minimal "inline" favicon. This is admittedly not too overly
1251
+ useful, but the functionality was added nonetheless simply as
1252
+ a proof-of-principle. And, who knows - perhaps the web_object
1253
+ project will one day also offer support for "minimal
1254
+ webpages".
1255
+
1256
+ ## rem units in CSS
1257
+
1258
+ In the past, the **em** unit was quite popular in .css files.
1259
+
1260
+ Since some years, such as 2011, **rem** units are increasingly
1261
+ more popular - see articles such as
1262
+ https://www.sitepoint.com/understanding-and-using-rem-units-in-css/.
1263
+
1264
+ I have not yet decided whether to use rem units or not, but
1265
+ I am aware of the differences. I may be too used toward **em**
1266
+ to transition into **rem**, and add more complexity that
1267
+ way - but for the time being (August 2020) nothing changes
1268
+ in this regard.
1269
+
1270
+ ## The td_row() method
1271
+
1272
+ The Cyberweb project has support for &lt;td> tags, via td() method
1273
+ calls.
1274
+
1275
+ Since inputting an Array of values padded with a td-tag is
1276
+ quite tedious, the method td_row() was added.
1277
+
1278
+ An example may be simplest to demonstrate this method:
1279
+
1280
+ td_row( %w( 256 128 64 32 16 8 4 2 1 ) )
1281
+
1282
+ This will generate valid td-tags for each of the given Array
1283
+ member, thus shortening the HTML code generated.
1284
+
1285
+ ## The WebImages components
1286
+
1287
+ **WebImages** are essentially just a small component of the
1288
+ Cyberweb project, available under the namespace
1289
+ **Cyberweb::WebImages**.
1290
+
1291
+ Since as of July 2020 the web_images component resides under
1292
+ the subdirectory at **web_object/images/**.
1293
+
1294
+ WebImages provide a way to map certain symbols, such as **:big_star**
1295
+ or **:rainbow_circle**, to **a corresponding image**.
1296
+
1297
+ To give another example for this: the symbol called **:alert** could
1298
+ be interpreted as **showing a small icon that is useful for
1299
+ notification towards the end user**. This is usually tied to a
1300
+ particular image, which is displayed on the webpage.
1301
+
1302
+ In the past, up until September 2020, these images were not
1303
+ distributed with the **web_object gem** for various reasons -
1304
+ one was that the **.gem** would become quite bigger. In
1305
+ September 2020 this approach was changed, and the WebImages
1306
+ are now also distributed as images. Some of these images were
1307
+ autogenerated via ruby code; others were "hand"-drawn in
1308
+ photoshop, kolourpaint or gimp, and others were re-used from
1309
+ permissive sources/licences. The licence for the images is
1310
+ different for the code: CC BY 4.0 (Attribution 4.0 International;
1311
+ see the following URL
1312
+ https://creativecommons.org/licenses/by/4.0/
1313
+ ).
1314
+
1315
+ Do note that even prior to September 2020, in **May 2019** I modified
1316
+ the prior assumption that no images are bundled within the
1317
+ web_object project slightly - some images were distributed within
1318
+ the **web_object project**, but not as an "actual" image; instead,
1319
+ they were (and still are) available as **base64-encoded
1320
+ Strings**. The following subsection describes how to make
1321
+ use of such base64-encoded Strings.
1322
+
1323
+ First, we have to **limit** the above statement - not all images will
1324
+ be distributed as base64-encoded Strings, only those that may be
1325
+ **somewhat useful** to lots of different people. Simple elements
1326
+ such as a dot, or an arrow-image - the latter could be used to
1327
+ indicate which hyperlinks could be clicked on a website, for
1328
+ instance. (You can also use the Unicode symbols in general,
1329
+ of course, which does not require any .png file or base64-encoded
1330
+ String. In some ways, Unicode has actually made it a lot easier
1331
+ to work on web-projects without needing to bundle specific images as such.)
1332
+
1333
+ Note that some websites claim that **Base64-encoded Strings** load up
1334
+ faster than e. g. loading up .png files. This may or may not be the
1335
+ case, but what we do know is that base64-encoded strings will be
1336
+ **somewhat larger** than the corresponding binary image. So I think
1337
+ this statement about a speed gain is really only true for smaller
1338
+ images at best - which is an advice that is repeated on the www in
1339
+ general, small is beautiful, and fast. So we will limit this approach
1340
+ mostly to **smaller images** in this context; this makes it a bit
1341
+ simpler to distribute the **web_object** gem as well.
1342
+
1343
+ If you want to see the available images, you can use this method to
1344
+ help you:
1345
+
1346
+ Cyberweb.display_the_registered_base64_images
1347
+
1348
+ In September 2020, this would tap onto this Array:
1349
+
1350
+ ["AUSRUFUNGSZEICHEN", "BLUEARROW", "BUBBLE", "CAT", "CAUTION",
1351
+ "CHEERING_PERSON", "CURSOR", "DUCKY", "DOT_01", "ELEPHANT",
1352
+ "HALLOWEEN", "HANGING_MONKEY", "LENS", "TU_WIEN_LOGO",
1353
+ "VOGEL"]
1354
+
1355
+ So, 15 images are so far made available as base64 string-encoded
1356
+ images.
1357
+
1358
+ Note that the images can be found under this directory:
1359
+
1360
+ web_object/images/real/
1361
+
1362
+ Unfortunately a major design constraint (aka a major bug) was
1363
+ discovered on 18.09.2020 (September 2020), leading to the
1364
+ reversion of this change. I may at a later time re-evaluate
1365
+ this; in the long run I really want to include these images
1366
+ too, by default. But since that change broke a lot of
1367
+ code in my own web-apps, I had to revert this for the time
1368
+ being. This will eventually be fixed, but it requires some
1369
+ larger rewrite, and I don't quite have the time commitment
1370
+ for this right now (it will include some architecture
1371
+ changes in the web_object library as well).
1372
+
1373
+ In June 2021 experimental support for arbitrarily converting
1374
+ image files to base64 strings was added to the Cyberweb
1375
+ project. This currently depends on imagemagick, so make
1376
+ sure to install it first. This is highly experimental, so
1377
+ do not yet use it. The idea is that we will simply convert
1378
+ any image to base64 if the user wants to do so.
1379
+
1380
+ The API currently looks like this:
1381
+
1382
+ img_base64 'STD/ZAUBERHUT.png'
1383
+
1384
+ This refers to my base directory for images; and then the
1385
+ path within that base directory.
1386
+
1387
+ This is currently only tested on my home system. At a later
1388
+ time I'll add support for any image-conversion, and most
1389
+ likely a cache system, to not have to decode all these
1390
+ images again and again and again. Instead, to just convert
1391
+ it once; right now Cyberweb always converts this, as that
1392
+ was easier to do in code.
1393
+
1394
+ You can also make this image draggable via:
1395
+
1396
+ draggable_img_base64(path_to_the_image_goes_in_here)
1397
+
1398
+ ## The Application Root
1399
+
1400
+ A typical web-related project needs to define and designate
1401
+ the **starting-point directory**. This is often called the
1402
+ "**application root**". The Cyberweb project will also refer
1403
+ to the base directory as the application root.
1404
+
1405
+ Presently Cyberweb uses a hardcoded approach mostly (sorry),
1406
+ but eventually it will transition into a more flexible
1407
+ approach.
1408
+
1409
+ ## Buttons
1410
+
1411
+ The following should work, in principle:
1412
+
1413
+ button {}
1414
+
1415
+ My long-term goal is to make this DSL work in web-applications
1416
+ as well as toolkits such as ruby-gtk.
1417
+
1418
+ ## How to vertically align any element via CSS
1419
+
1420
+ You can use:
1421
+
1422
+ display: flex
1423
+
1424
+ **display: flex** specifies a Flexbox layout for the element.
1425
+
1426
+ You can also use **align-items: center**, which would take
1427
+ care of the **vertical centering** in a container-element.
1428
+
1429
+ The CSS property **shape-outside** can be used to allow
1430
+ geometric shapes to be set, in order to define an area
1431
+ for text to flow around.
1432
+
1433
+ Example:
1434
+
1435
+ .shape {
1436
+ width: 500px;
1437
+ float: left;
1438
+ shape-outside: circle(50%);
1439
+ }
1440
+
1441
+ You do not need to use the flexbox, though. An older way is to define
1442
+ three div elements, such as by using these CSS classes:
1443
+
1444
+ .left {
1445
+ display: inline-block;
1446
+ width: 30%;
1447
+ height: auto;
1448
+ }
1449
+
1450
+ .middle {
1451
+ display: inline-block;
1452
+ width: 30%;
1453
+ height: auto;
1454
+ }
1455
+
1456
+ .right {
1457
+ display: inline-block;
1458
+ width: 30%;
1459
+ float: right;
1460
+ height: auto;
1461
+ }
1462
+
1463
+ Use the variant that more suits your way to think about things. I
1464
+ actually prefer the oldschool div-CSS approach and avoid flexbox
1465
+ altogether. Keep it simple! \o/
1466
+
1467
+ This is not equivalent to a grid, though, in particular if you
1468
+ want a layout such as 3x3. In that case I recommend to use a
1469
+ grid. Example for this can be seen here:
1470
+
1471
+ https://codepen.io/chris__sev/pen/bYmpxw
1472
+
1473
+ ## Working with Frames
1474
+
1475
+ You can use Frames.
1476
+
1477
+ This example shows how, in the main frame:
1478
+
1479
+ w.frame_left 'foo.cgi' # specify frame to the left
1480
+ w.frame_right 'bar.cgi' # specify frame to the right
1481
+ w.use_frames
1482
+ w.serve
1483
+
1484
+ ## Working with Grids in HTML/CSS
1485
+
1486
+ You can add padding between the grid containers using grid padding or
1487
+ row-gap and column-gap.
1488
+
1489
+ Examples:
1490
+
1491
+ gap
1492
+ row-gap
1493
+ column-gap
1494
+
1495
+ row-gap: 6px;
1496
+ column-gap: 6px;
1497
+
1498
+ ## Colours and the Colour chart in the Cyberweb project
1499
+
1500
+ If you wish to show a HTML colour chart, you can use
1501
+ the following method:
1502
+
1503
+ Cyberweb.show_html_colour_chart
1504
+
1505
+ If you want to return a random HTML colour, as a String, you
1506
+ can use this toplevel method:
1507
+
1508
+ Cyberweb.random_colour?
1509
+
1510
+ ## CSS colour gradient
1511
+
1512
+ You can "create" a colour gradient via:
1513
+
1514
+ colour_gradient_left_to_right(:steelblue, :darkgreen)
1515
+
1516
+ The third argument will be the name of the generated CSS class,
1517
+ defaulting to **.gradient1**.
1518
+
1519
+ You can then use this in a div-element like this:
1520
+
1521
+ add_to_css_class(
1522
+ colour_gradient_left_to_right(:steelblue, :darkgreen)
1523
+ )
1524
+
1525
+ # And then later:
1526
+ div('gradient1') {
1527
+ h4 'Hello'
1528
+ }
1529
+
1530
+ ## Show directories
1531
+
1532
+ If you wish to display directories from somewhere, use the method:
1533
+
1534
+ display_directories()
1535
+
1536
+ ## Predefined methods
1537
+
1538
+ - Some commonly used methods are predefined, such as:
1539
+
1540
+ question()
1541
+ answer()
1542
+ frage()
1543
+ antwort()
1544
+
1545
+ This is mostly because I use them quite often personally.
1546
+
1547
+ They are defined in:
1548
+
1549
+ $CYBERWEB/predefined_methods.rb
1550
+
1551
+ ## Disabling web images
1552
+
1553
+ You can disable the webimages component even in an URL by issuing:
1554
+
1555
+ ?disable_webimages
1556
+
1557
+ Of course you can also disable them through a configuration setting,
1558
+ in the configuration file - see the other command "**cyberweb edit**"
1559
+ how to edit that file. The idea is to allow several ways to achieve
1560
+ the same effect.
1561
+
1562
+ ## Modifying the configuration of the cyberweb project
1563
+
1564
+ The configuration is stored in a single yaml file. This file can be
1565
+ edited by issuing:
1566
+
1567
+ cyberweb edit
1568
+
1569
+ For a full listing of options, issue:
1570
+
1571
+ cyberweb --help
1572
+
1573
+ or
1574
+
1575
+ cyberweb HELP
1576
+
1577
+ ## The base directory
1578
+
1579
+ The base directory can be defined through the yaml file, with the
1580
+ entry called base_directory.
1581
+
1582
+ ## Standalone .cgi files
1583
+
1584
+ You can load standalone .cgi files, by supplying the path to the .cgi
1585
+ file in question.
1586
+
1587
+ Be careful however, we will use eval() to load that code.
1588
+
1589
+ Usage example for this:
1590
+
1591
+ load_cgi('bla.cgi')
1592
+
1593
+ or the alias:
1594
+
1595
+ run_cgi 'bla.cgi'
1596
+
1597
+ ## Support for markdown
1598
+
1599
+ You can use markdown formatting via the method **markdown()**.
1600
+
1601
+
1602
+ Example how to use markdown:
1603
+
1604
+ markdown(i = '/home/x/data/PC/MARKDOWN/example.md')
1605
+
1606
+ ## Tables with alternate backgrounds
1607
+
1608
+ You can use **tables with alternate background** such as by doing
1609
+ the following:
1610
+
1611
+ Table.alternate_backgrounds(%w( one two three four ))
1612
+
1613
+ The following partial screenshot shows how this may look like,
1614
+ via an additional black border, to indicate where the table
1615
+ begins and starts:
1616
+
1617
+ <img src="https://i.imgur.com/DeASwyg.png" style="margin-left: 2em">
1618
+
1619
+ The two classes are currently (**September 2021**) called
1620
+ **dark_background** and **light_background**, respectively.
1621
+ Never mind the name - if you want to style them differently
1622
+ then simply modify these classes in your web-page. Right
1623
+ now this is not trivial if you re-use the distributed .css
1624
+ files; at another moment in time the API may be changed to
1625
+ allow you to re-define the CSS class as-is.
1626
+
1627
+ ## Input fields with a different background colour
1628
+
1629
+ You can use input fields with a different background colour upon
1630
+ a mouse-focus event.
1631
+
1632
+ Examples for this would be:
1633
+
1634
+ input :text, 'Hello world!', :focus_with_salmon_background
1635
+ input :text, 'Hello World!', :focus_with_salmon_background, :select_on_click
1636
+
1637
+ ## Editing content on a webpage
1638
+
1639
+ You can make some content editable. This currently (**March 2017**)
1640
+ only works for the e() tag, which creates a span-tag.
1641
+
1642
+ The command for this is:
1643
+
1644
+ { :editable }
1645
+
1646
+ To do this, try:
1647
+
1648
+ p {
1649
+ e('This text should now be editable.') { :editable }
1650
+ }
1651
+
1652
+ ## Specify javascript files
1653
+
1654
+ You can specify a specific javascript file via:
1655
+
1656
+ w.javascript_file = '../../CODE/JS/FADER.js'
1657
+ w.javascript_file = :fader
1658
+
1659
+ As you can see, both a string version giving the full path, and a
1660
+ Symbol shortcut, will work - provided that the Symbol was registered.
1661
+
1662
+ I recommend to use the Symbol version for two reasons: first, it is
1663
+ less to type. Second, it is trivial to change the path lateron.
1664
+
1665
+ ## Configuration
1666
+
1667
+ All meaningful options that can be configured, can be configured
1668
+ via a yaml file. Settings such as the global font size and so on.
1669
+
1670
+ This is stored in the file **cyberweb_configuration.yml**.
1671
+
1672
+ ## Do simple counting via list()
1673
+
1674
+ Do simple counting via list().
1675
+
1676
+ list "one"
1677
+ list "two"
1678
+ list "three"
1679
+
1680
+ To reset it again, do:
1681
+
1682
+ clear_list
1683
+
1684
+ or:
1685
+
1686
+ reset_listing
1687
+
1688
+ To use a specific CSS style for these listings, do something like:
1689
+
1690
+ Cyberweb.listing_css = '<b class="red">'
1691
+
1692
+ ## Link in pages via link()
1693
+
1694
+ You can link in other pages via the method link().
1695
+
1696
+ This method also accepts '*', in which case we will
1697
+ try to use Dir.glob (or more accurately, Dir[])
1698
+
1699
+ Specific Usage Example:
1700
+
1701
+ link 'BIOCH*/BIOCHE*.cgi'
1702
+
1703
+ ## The licence of the Cyberweb project
1704
+
1705
+ Since as of **May 2021** the cyberweb project is using the MIT licence.
1706
+
1707
+ You can read the requirements for this licence here:
1708
+
1709
+ https://opensource.org/licenses/MIT
1710
+
1711
+ Before **May 2021**, cyberweb used the GPLv2 licence. The reason as
1712
+ to why the licence was changed was mostly because I consider the
1713
+ cyberweb project to be not extremely "important" in regards to
1714
+ mandating that the GPL-specific restrictions should apply. I
1715
+ ultimately don't quite care about the licence in regards to the
1716
+ cyberweb project. If others find the project useful then this is
1717
+ fine. If they want to contribute code, that's fine - and if they
1718
+ don't want to, that's fine as well, as far as the cyberweb
1719
+ project is concerned.
1720
+
1721
+ ## Simple JavaScript Calculator
1722
+
1723
+ Use:
1724
+
1725
+ add_simple_javascript_calculator
1726
+
1727
+ You may need to style the input-tag a bit.
1728
+
1729
+ See the following file for a working example:
1730
+
1731
+ cyberweb/examples/advanced/simple_calculator.cgi
1732
+
1733
+ ## Drag and drop support in general and drag-and-drop support via Dragula
1734
+
1735
+ Via the new attribute **draggable="true"** it is possible to drag any
1736
+ element in HTML. An image can simply contain set this attribute.
1737
+
1738
+ The JavaScript library **Dragula** is used, aside from jquery,
1739
+ for drag-and-drop support.
1740
+
1741
+ If you wish to make use of it, keep the dragula-related
1742
+ entry set to true in the file <b>project_configuration.yml</b>.
1743
+
1744
+ Example:
1745
+
1746
+ use_dragula: true
1747
+
1748
+ Keep in mind that the ID for a HTML tag has to have a certain format.
1749
+ For instance, using a '.' dot is not allowed as part of an ID; this
1750
+ is why cyberweb will automatically replace this via a '_' character
1751
+ instead.
1752
+
1753
+ ## Sinatra interface
1754
+
1755
+ The Cyberweb project is **a toolset project**, so there is also a class
1756
+ called **Cyberweb::Sinatra**. This can be used to quickly write a
1757
+ subclass for use as a web-page, based on sinatra.
1758
+
1759
+ To use this in your own code, do subclass from it such as via this
1760
+ variant:
1761
+
1762
+ require 'cyberweb/requires/require_sinatra.rb'
1763
+
1764
+ class Foo < Cyberweb::Sinatra
1765
+
1766
+ **@root_string** will carry the content (aka the **index**) of the main
1767
+ **/** route by default. A few other projects make use of class
1768
+ Cyberweb::Sinatra, such as the studium gem or the
1769
+ beautiful_url gem - see files such as
1770
+ **studium/lib/studium/www/sinatra_main_entry.rb**
1771
+ or
1772
+ **beautiful_url/lib/beautiful_url/www/app.rb**.
1773
+
1774
+ Since as of **June 2021** I am changing the old approach in regards to
1775
+ **.cgi** files. While I will retain support for .cgi files, I am
1776
+ also exploring offering the very same content via sinatra for some
1777
+ of the files - at the least in the roebe project, as a test-project
1778
+ for now. My idea here is that the Cyberweb project can already
1779
+ handle all HTML, CSS or JavaScript-related part that I may need.
1780
+ On Windows, using .cgi is somewhat annoying (but possible - I use
1781
+ lighttpd for this), whereas using sinatra is a lot simpler. So my
1782
+ idea is that I will slowly add and extend support for both .cgi and
1783
+ sinatra, and re-purpose the cyberweb project to achieve this. This
1784
+ currently lacks documentation, but eventually I'll add more
1785
+ documentation in how to solve this.
1786
+
1787
+ You can designate that Cyberweb::WebObject is serving a
1788
+ sinatra application right now via the following method
1789
+ invocation:
1790
+
1791
+ is_a_sinatra_application
1792
+
1793
+ And to query the state:
1794
+
1795
+ is_a_sinatra_application?
1796
+
1797
+ If you use a file extension such as **.sinatra** then this is
1798
+ automatically done. In fact that was the reason why I added
1799
+ this functionality in June 2021. The idea in the long run
1800
+ is to be able to do sinatra-specific calls that enable or
1801
+ disable certain things, in particular in regards to images,
1802
+ and have images work properly at the least on my home
1803
+ setup.
1804
+
1805
+ ## JQuery
1806
+
1807
+ The Cyberweb framework/toolset favours the use of jquery. Presently,
1808
+ since **May 2021**, the version that is to be used by default will be
1809
+ for jquery <b>3.6.0</b>. This may change at a later time.
1810
+
1811
+ In the event that it is changed and the documentation here is not
1812
+ updated, you can always rely on the following method call to yield
1813
+ the correct version of jquery to be used:
1814
+
1815
+ Cyberweb.jquery_version?
1816
+
1817
+ For example, the above method called would yield **3.6.0** in
1818
+ **May 2021**. Personally I always use the latest stable
1819
+ version of jquery.
1820
+
1821
+ You can also query the jquery-ui version in use, via:
1822
+
1823
+ Cyberweb.jquery_ui_version?
1824
+
1825
+ Again, this also has to be synced manually, via the
1826
+ .yml file called **project_configuration.yml**.
1827
+
1828
+ Since as of **May 2021**, the cyberweb will also bundle this
1829
+ corresponding version of jquery and jquery-ui into the
1830
+ **javascript_code/jquery/** subdirectory of the gem. This
1831
+ is solely done to simplify the use of jquery so that, for
1832
+ example, dragging an object becomes simpler and available
1833
+ by default, even if access to the www is unavailable at
1834
+ the current time.
1835
+
1836
+ You can also call this method on a **Cyberweb::WebObject**
1837
+ instance via the following method:
1838
+
1839
+ report_the_jquery_version_in_use
1840
+
1841
+ Both jquery-ui and jquery use the same licence as the Cyberweb
1842
+ project (MIT licence). See also this wikipedia entry if
1843
+ you want to read more about jquery and its history:
1844
+
1845
+ https://en.wikipedia.org/wiki/JQuery
1846
+
1847
+ To make a container **resizable** via the mouse, by using
1848
+ jquery, try this method:
1849
+
1850
+ jquery_resizable_via_the_mouse(id: :resizable_via_the_mouse)
1851
+
1852
+ As **id** you simply pass in the id of the HTML element at hand.
1853
+ In this case, the symbol called :resizable_via_the_mouse.
1854
+
1855
+ See also the file **JQUERY.md** for a more thorough reference.
1856
+
1857
+ Note that in **May 2021**, support for jquery is actually mildly
1858
+ deprecated. This is not set in stone and it does not mean that
1859
+ jquery support will be removed, as far as the cyberweb project
1860
+ is concerned; it is more that I want to see whether we have
1861
+ better or simpler alternatives, without being tied into jquery
1862
+ too closely.
1863
+
1864
+ The basic syntax for jquery, in javascript, goes like this:
1865
+
1866
+ $(selector).action()
1867
+
1868
+ The general rules for JQuery go along these lines, in JavaScript:
1869
+
1870
+ $(this).hide() # hides the current element.
1871
+ $("p").hide() # hides all <p> elements.
1872
+ $(".test").hide() # hides all elements with class="test".
1873
+ $("#test").hide() # hides the element with id="test".
1874
+
1875
+ ## draggable_image() and the HTML draggable attribute
1876
+
1877
+ HTML added the draggable global attribute. This can be
1878
+ either true or false. A value of true indicates that the
1879
+ element can be dragged.
1880
+
1881
+ So, for example, in HTML:
1882
+
1883
+ <img src="cat.png" draggable="true">
1884
+
1885
+ This should enable drag-support for that image.
1886
+
1887
+ The default value is **auto**, which means that drag behaviour
1888
+ will default to the given browser behaviour. Only text
1889
+ selections, images, and links can be dragged by default. For
1890
+ other elements, the event ondragstart must be set for
1891
+ drag and drop to work.
1892
+
1893
+ ## in_dir_image()
1894
+
1895
+ To quickly display an in-dir image, that is an image that resides
1896
+ within the current directory, you can try the following API:
1897
+
1898
+ in_dir_image 'foobar.png', 'marl3em bblack1'
1899
+
1900
+ ## Textarea in HTML
1901
+
1902
+ You can make a textarea HTML tag readonly via readonly.
1903
+
1904
+ Example for this:
1905
+
1906
+ <textarea readonly>
1907
+ Foobar.
1908
+ </textarea>
1909
+
1910
+ To prevent a textarea from being resized by the user, use a CSS rule such
1911
+ as:
1912
+
1913
+ textarea {
1914
+ resize: none;
1915
+ }
1916
+
1917
+ ## CSS first-line rule
1918
+
1919
+ The **first-line** rule can be used to style the first line in a given
1920
+ HTML tag (the specified selector), such as the p (paragraph).
1921
+
1922
+ Example:
1923
+
1924
+ p:first-line
1925
+ {
1926
+ color:#ff0000;
1927
+ font-size: 30em;
1928
+ font-variant:small-caps;
1929
+ }
1930
+
1931
+ The first line would then appear larger and in another colour.
1932
+
1933
+ Several properties can be modified within the :first-line
1934
+ rule, such as **font properties**, **color properties**,
1935
+ **background properties**, **word-spacing**, **letter-spacing**,
1936
+ **text-decoration**, **vertical-align**, **text-transform**,
1937
+ **line-height** or **clear**.
1938
+
1939
+ ## CSS text-transform properties
1940
+
1941
+ The three main variants are:
1942
+
1943
+ div.a { text-transform: uppercase; }
1944
+ div.b { text-transform: lowercase; }
1945
+ div.c { text-transform: capitalize; }
1946
+
1947
+ ## CSS, text-shadow support and drop-shadow support
1948
+
1949
+ If you want to have shadows added to a given text then the text-shadow
1950
+ CSS property may be useful. Be careful when using this, though, because
1951
+ it can make the text harder to read.
1952
+
1953
+ Let's look at an example for the h1 HTML tag:
1954
+
1955
+ h1 {text-shadow:2px 2px #FF0000;}
1956
+
1957
+ Syntax used here (and in general):
1958
+
1959
+ text-shadow: h-shadow, v-shadow, blur, color
1960
+ text-shadow: 2px 5px tomato;
1961
+
1962
+ Another example, for a CSS rule:
1963
+
1964
+ .red_text_shadow {
1965
+ text-shadow: red 0 -2px;
1966
+ }
1967
+
1968
+ Strangely enough you can also re-arrange the arguments a litte:
1969
+
1970
+ /* colour | offset-x | offset-y | blur-radius */
1971
+ text-shadow: #fc0 1px 0 10px;
1972
+
1973
+ /* offset-x | offset-y | blur-radius | colour */
1974
+ text-shadow: 1px 1px 2px black; # This is my preferred style.
1975
+
1976
+ I do not know why they went that route, but I recommend to just
1977
+ stick to one style, and avoid the other.
1978
+
1979
+ Note that text-shadow is not the only way you can use to modify
1980
+ text. drop-shadow is another example.
1981
+
1982
+ In CSS the rule would be like this:
1983
+
1984
+ drop-shadow(2px 4px 8px #585858);
1985
+
1986
+ In cyberweb, you can use this API:
1987
+
1988
+ generate_drop_shadow :red, :default, 'drop_shadow_red'
1989
+ div('drop_shadow_red') {
1990
+ h3 'This part should show a drop-shadow effect - but in red'
1991
+ }
1992
+
1993
+ This would yield the following text (shown as image):
1994
+
1995
+ <img src="https://i.imgur.com/lSDl3qt.png" style="margin-left:2em">
1996
+
1997
+ ## CSS letter-spacing property
1998
+
1999
+ <b>letter-spacing</b> can be used to decrease or increase the
2000
+ distance between texts within a given text.
2001
+
2002
+ Example:
2003
+
2004
+ <div style="letter-spacing: 5px"><h2>Hello world!</div>
2005
+
2006
+ ## CSS and the border-spacing property for HTML tables
2007
+
2008
+ You can style HTML tables via CSS, by making use of
2009
+ <b class="steelblue">border-spacing</b>.
2010
+
2011
+ Example:
2012
+
2013
+ border-spacing: 20pt
2014
+
2015
+ The values for border-spacing can be: <b>length|initial|inherit</b>.
2016
+
2017
+ ## IDs for use in HTML tags
2018
+
2019
+ An ID may occur only once on a given webpage.
2020
+
2021
+ ## CSS text-decoration
2022
+
2023
+ Via <b>text-decoration</b> you can modify text such as by
2024
+ underlining it or line-through the text.
2025
+
2026
+ Examples for this:
2027
+
2028
+ h1 {
2029
+ text-decoration: overline;
2030
+ }
2031
+ h2 {
2032
+ text-decoration: line-through;
2033
+ }
2034
+ h3 {
2035
+ text-decoration: underline;
2036
+ }
2037
+ h4 {
2038
+ text-decoration: underline overline;
2039
+ }
2040
+ h5 {
2041
+ text-decoration: underline overline dotted red;
2042
+ }
2043
+ h6 {
2044
+ text-decoration: underline overline wavy blue;
2045
+ }
2046
+
2047
+ As you can see from the last example, you can combine several
2048
+ values for the same modifier, e. g. both **underline** and
2049
+ **overline**.
2050
+
2051
+ The allowed values for text-decoration are:
2052
+
2053
+ inherit
2054
+ none
2055
+ underline
2056
+ overline
2057
+ line-through
2058
+ blink
2059
+
2060
+ ## HTML Frames
2061
+
2062
+ HTML frames are rarely used nowadays. Syntax-wise they may be defined
2063
+ like this:
2064
+
2065
+ <frameset rows="100,*,60"> <frame ...></frameset>
2066
+
2067
+ Two frames:
2068
+
2069
+ <frameset cols="200,*">'),'default'
2070
+ <frame src="contents_of_frame1.html">
2071
+ <frame src="contents_of_frame2.html">
2072
+ </frameset>
2073
+
2074
+ ## HTML accesskeys
2075
+
2076
+ You can use an accesskey in HTML like so:
2077
+
2078
+ <input type="button" value="Button (accesskey is b)" accesskey="b">
2079
+ <button accesskey="f">Foobar</button>
2080
+
2081
+ The attribute <b>accesskey</b> is allowed in the following tags:
2082
+
2083
+ input
2084
+ textarea
2085
+ label
2086
+ legend und button
2087
+
2088
+ ## CSS ::before and CSS ::after
2089
+
2090
+ Via <b>:before</b> it is possible to insert elements before another
2091
+ element. Even graphics can be inserted.
2092
+
2093
+ Let's look at a simple example:
2094
+
2095
+ p::before {
2096
+ content: "Read this: ";
2097
+ }
2098
+
2099
+ As you can see, the text that should be inserted comes after the
2100
+ **content:** part.
2101
+
2102
+ This can also be used to play audio files:
2103
+
2104
+ h1::before {
2105
+ content: url(beep.wav)
2106
+ }
2107
+
2108
+ Now a slightly more convoluted example:
2109
+
2110
+ h2::before {
2111
+ content: "";
2112
+ width: 10px;
2113
+ height: 10px;
2114
+ border-radius: 50%;
2115
+ background: hotpink;
2116
+ displEvolution_of_Metabolic_Pathways-2000.pdfay: inline-block;
2117
+ vertical-align: middle;
2118
+ margin-right: 10px;
2119
+ }
2120
+
2121
+ To make use of an image, you can use something like:
2122
+
2123
+ img:before {
2124
+ content:url(https://example.com/image.png);
2125
+ }
2126
+
2127
+ CSS2 used the **:before** notation, but this was changed to **:before**
2128
+ in CSS3. I was a bit surprised to see ::before, because I used to
2129
+ use :before only.
2130
+
2131
+ The same exists for appending text, called ::after.
2132
+
2133
+ Example:
2134
+
2135
+ p::after {
2136
+ content: "»";
2137
+ color: red;
2138
+ }
2139
+
2140
+ ## CSS input autofocus
2141
+
2142
+ You can modify <input> elements by setting the focus onto
2143
+ them the moment a page loads.
2144
+
2145
+ Example:
2146
+
2147
+ <form action="/action_page.php">
2148
+ <label for="fname">First name:</label>
2149
+ <input type="text" id="fname" name="fname" autofocus><br>
2150
+ <label for="lname">Last name:</label>
2151
+ <input type="text" id="lname" name="lname"><br><br>
2152
+ <input type="submit">
2153
+ </form>
2154
+
2155
+ This is a bit similar to ruby-gtk3, e. g. .do_focus or .set_focus(true).
2156
+
2157
+ ## CSS grouping and CSS selectors
2158
+
2159
+ CSS selectors, such as the typeselector, can be used to refer to
2160
+ specific HTML tags. This can be used to style these HTML tags
2161
+ via CSS rules.
2162
+
2163
+ The following example shows how to use a margin of 10 pixels for
2164
+ each p tag:
2165
+
2166
+ p { margin: 10 px; }
2167
+
2168
+ This is fairly convenient and elegant. It is also quite flexible
2169
+ in that you can group several selectors together, and apply
2170
+ the same CSS rules to each element listed therein.
2171
+
2172
+ You have to use a ',' as separator between the individual elements
2173
+ in order for this to work.
2174
+
2175
+ An example for this follows:
2176
+
2177
+ h1,h2,h3,h4,h5,h6
2178
+ {
2179
+ color: green;
2180
+ }
2181
+
2182
+ Now all **HTML headers** (h1 up to h6) will be displayed in
2183
+ a green colour.
2184
+
2185
+ This can be extended for particular tags that occur as part
2186
+ of other tags as well.
2187
+
2188
+ For example, in order to colourize all h2 headers that occur
2189
+ within the ID called #nav, use the following:
2190
+
2191
+ #nav h2 {
2192
+ color: tomato;
2193
+ }
2194
+
2195
+ In plain HTML this would be used via code like this:
2196
+
2197
+ <div id="nav">
2198
+ <h2>Hello world!</h2>
2199
+ </div>
2200
+
2201
+ This allows you to use conditional rules in CSS. Don't forget
2202
+ to use the correct ID; in this case #nav.
2203
+
2204
+ ## CSS box-shadow effects
2205
+
2206
+ How does <b>box-shadow</b> work in CSS?
2207
+
2208
+ The general syntax may look like this:
2209
+
2210
+ div {
2211
+ box-shadow: 10px 10px 5px #888888;
2212
+ }
2213
+ div('Black','box_shadow_one'){
2214
+ h3 'Hier die obige Box'
2215
+ }
2216
+
2217
+ See also: http://www.w3schools.com/cssref/css3_pr_box-shadow.asp
2218
+
2219
+ The allowed values to box-shadow are:
2220
+
2221
+ box-shadow: none|h-shadow v-shadow blur spread color |inset|initial|inherit;
2222
+
2223
+ <b>h-shadow</b> refers to a <b>horizontal shadow</b>, whereas
2224
+ <b>v-shadow</b> refers to a <b>vertical shadow</b>.
2225
+
2226
+ A <b>box-shadow Generator</b> can be used as shown on the following
2227
+ webpage:
2228
+
2229
+ http://www.cssmatic.com/box-shadow
2230
+
2231
+ ## Add a .js file, as-is
2232
+
2233
+ The following API can be used to ad-hoc add a .js javascript file:
2234
+
2235
+ link_in_javascript 'app.js'
2236
+
2237
+ ## CSS Cursors
2238
+
2239
+ To use a different cursor, set a CSS style rule such as:
2240
+
2241
+ cursor: pointer;
2242
+ cursor: auto;
2243
+
2244
+ Alternatively use a defined CSS class such as:
2245
+
2246
+ .crosshair { cursor: crosshair; }
2247
+
2248
+ And then in HTML:
2249
+
2250
+ <p class="crosshair">crosshair</p>
2251
+
2252
+ Valid cursors include:
2253
+
2254
+ auto
2255
+ crosshair
2256
+ default
2257
+ e-resize
2258
+ grab
2259
+ help
2260
+ move
2261
+ n-resize
2262
+ ne-resize
2263
+ nw-resize
2264
+ pointer
2265
+ progress
2266
+ s-resize
2267
+ se-resize
2268
+ sw-resize
2269
+ text
2270
+ w-resize
2271
+ wait
2272
+ not-allowed
2273
+ no-drop
2274
+
2275
+ ## Removing child elements in JavaScript
2276
+
2277
+ An element can be removed via JavaScript by issueing:
2278
+
2279
+ this.parentNode.removeChild(this)
2280
+
2281
+ ## Default parameters to functions in JavaScript
2282
+
2283
+ You can use default values to functions in JavaScript.
2284
+
2285
+ Example:
2286
+
2287
+ function multiply(a, b = 1) {
2288
+ return a * b;
2289
+ }
2290
+
2291
+ console.log(multiply(5, 2));
2292
+ console.log(multiply(5));
2293
+
2294
+ Alternatively you could also use || inside of the function
2295
+ body, to simulate default values.
2296
+
2297
+ It may then look like this inside of a function:
2298
+
2299
+ bar = bar || "Default Value";
2300
+
2301
+ ## Using language-specific files as content of a webpage
2302
+
2303
+ The typical way how I describe the main content of a web-page
2304
+ is via:
2305
+
2306
+ doc {
2307
+ }
2308
+
2309
+ This **doc** refers to document and is ultimately just a <div>
2310
+ tag. So I put my web-applications into a big <div> tag
2311
+ ultimately.
2312
+
2313
+ Since late 2020 I am also using language variants such as:
2314
+
2315
+ english {
2316
+ }
2317
+ # or
2318
+ german {
2319
+ }
2320
+
2321
+ To denote a webpage in german, or in english. Not as
2322
+ replacement for doc {}, but as the start point in
2323
+ general.
2324
+
2325
+ In June 2021 this was extended in that I added the method
2326
+ called:
2327
+
2328
+ doc_skeleton
2329
+
2330
+ The word <b>skeleton</b> refers to a separate file, the
2331
+ skeleton of the web-application.
2332
+
2333
+ Say that you have five called index.rb, index.cgi,
2334
+ index.sinatra, index_english.md and index.german.md.
2335
+
2336
+ This allows us to read in either the english or the german
2337
+ language.
2338
+
2339
+ To let the cyberweb project guess on its own, consider
2340
+ using a variant via the following Symbol:
2341
+
2342
+ doc_skeleton(:english_or_german)
2343
+
2344
+ This currently defaults to german. You can pass ?use_english
2345
+ or ?english to the .cgi page to overrule this and force
2346
+ the web-application to view the english content instead.
2347
+
2348
+ In order for this to work, the corresponding .md file must
2349
+ exist, e. g. **index_english.md** or **index_german.md**.
2350
+
2351
+ Note that this is currently (June 2021) quite experimental,
2352
+ but I wanted to add the feature that we can offer different
2353
+ languages. In the long run I may adapt this approach, to
2354
+ make it easier to use different languages on any given
2355
+ weba-application, but for now I only use this in the
2356
+ **roebe** gem. For example, luft.cfg under **roebe/www/luft/**
2357
+ will show this. It may not work on your home system,
2358
+ though, as it is catered to my home setup. But it shows
2359
+ how this could be done in theory. So, who knows - in the
2360
+ long run I may integrate this as a 'default' feature.
2361
+
2362
+ Note that **?use_german** will work as well, to force
2363
+ the **_german.md** file to be read.
2364
+
2365
+ ## Obtaining user input in JavaScript
2366
+
2367
+ The following code example shows how to obtain user input via JavScript:
2368
+
2369
+ var x, y;
2370
+ x = prompt("Gib mal eine Zahl ein","")
2371
+ y = prompt("Gib mir noch eine Zahl","")
2372
+ alert(Number(x)+Number(y)
2373
+
2374
+ So the primary way to obtain user through JavaScript goes via
2375
+ <b>window.prompt</b>. The second argument to that method
2376
+ specifies the default value of the input-field.
2377
+
2378
+ ## CSS border-style property
2379
+
2380
+ CSS gives you the possibility to style borders via different properties,
2381
+ through **border-style**.
2382
+
2383
+ Let's showcase some examples for this:
2384
+
2385
+ p.solid { border-style: solid;}
2386
+ p.dotted { border-style: dotted;}
2387
+ p.dashed { border-style: dashed;}
2388
+ p.double { border-style: double;}
2389
+ p.groove { border-style: groove;}
2390
+ p.ridge { border-style: ridge;}
2391
+ p.inset { border-style: inset;}
2392
+ p.outset { border-style: outset;}
2393
+ p.none { border-style: none;}
2394
+ p.hidden { border-style: hidden;}
2395
+ p.mix { border-style: dotted dashed solid double;}
2396
+
2397
+ Personally I like **solid** the most, followed by **dotted**, then **dashed**.
2398
+
2399
+ The other properties may be useful in some cases, e. g. when you
2400
+ wish to indicate some button-like element - but visually, I think
2401
+ the first three styles are by far the most appealing ones.
2402
+
2403
+ ## CSS first-letter
2404
+
2405
+ CSS allows us to modify the first-letter in, for example, a
2406
+ HTML paragraph. This is enabled via the so-called
2407
+ **:first-letter selector**.
2408
+
2409
+ In CSS rule this will look like this:
2410
+
2411
+ .fl:first-letter { font-size: 120%; }
2412
+
2413
+ The ':' is the important identifier.
2414
+
2415
+ Some time ago this was modified though. It is now required
2416
+ to use two ':' rather than one.
2417
+
2418
+ Example:
2419
+
2420
+ p::first-letter {
2421
+ font-size: 150%;
2422
+ color: steelblue;
2423
+ }
2424
+
2425
+ Take note that this is limited to block-level elements, so
2426
+ by default the span tag is unable to make use of this, unless
2427
+ it is turned into a block-level element as well.
2428
+
2429
+ ## CSS and Hovering
2430
+
2431
+ CSS allows us to make use of
2432
+ <b style="color: gold; padding: 3px; background-color:black">:hover</b>
2433
+ in order to have certain effects happen when the mouse cursor
2434
+ hovers over an element.
2435
+
2436
+ The general API respectively syntax for <b>CSS hover</b>
2437
+ goes like this:
2438
+
2439
+ .NAME_OF_ELEMENT:hover { background: COLOUR_HERE; }
2440
+
2441
+ .NAME_OF_ELEMENT:hover { background: COLOUR_HERE; }
2442
+ .test:hover { background: green; }
2443
+ .button:hover {opacity: 1;}
2444
+
2445
+ To then test this via cyberweb:
2446
+
2447
+ p('hover_test2 mart1px','') {
2448
+ ee sg(:pfeil_rechts,'marl1em marr6px')+
2449
+ 'Hier drüberfahren'
2450
+ }
2451
+
2452
+ To make all HTML links, aka the **a** tag, change the colour
2453
+ when the mouse hovers over them, the following CSS
2454
+ rule should work just fine:
2455
+
2456
+ a:hover {
2457
+ background-color: yellow;
2458
+ }
2459
+
2460
+ You can style several tags in one go, via:
2461
+
2462
+ p:hover, h1:hover, a:hover {
2463
+ background-color: lightblue;
2464
+ }
2465
+
2466
+ This also works inline.
2467
+
2468
+ ## Shortcomings of JavaScript
2469
+
2470
+ This subsection lists some shortcomings of JavaScript. This may be
2471
+ subject to change, as JavaScript changes as well. It is not a rant
2472
+ as such either - the focus will be on syntax.
2473
+
2474
+ - You can not use inline JavaScript if it contains the end
2475
+ part </script>, such as:
2476
+
2477
+ <script>
2478
+ function foobar() {
2479
+ console.log("</script>");
2480
+ }
2481
+ </script>
2482
+
2483
+ ## Including external .css files
2484
+
2485
+ The syntax for adding external (standalone) .css files is as shown in
2486
+ the following examples:
2487
+
2488
+ <link rel="stylesheet" type="text/css" href="name_of_the_css_file_goes_in_here.css">
2489
+ <link rel="stylesheet" type="text/css" href="base.css">
2490
+
2491
+ ## Embeddable Interfaces
2492
+
2493
+ Since as of June 2021 I am experimenting with **embeddable interfaces**
2494
+ in regards to web-related components - most importantly sinatra.
2495
+
2496
+ The basic idea here is that we can easily make available additional
2497
+ routes for other applications. Let's explain this by using an
2498
+ example.
2499
+
2500
+ The PdfParadise project defines a route such as **/view**. This
2501
+ entry will become **/pdf/view** if I want to use it within the
2502
+ Roebe::Controller - my master-class for controlling all the
2503
+ various web-APIs that I use locally.
2504
+
2505
+ To enable this functionality, I decided to settle for a module
2506
+ name called **EmbeddableInterface**. I am trying to use this
2507
+ consistently for my own projects. Different details may change,
2508
+ but ultimately this should be used when I want to extend
2509
+ functionality of the core controller.
2510
+
2511
+ This module then typically looks like this:
2512
+
2513
+ module EmbeddableInterface # === Wetter::EmbeddableInterface
2514
+
2515
+ begin
2516
+ require 'html_tags'
2517
+ include HtmlTags::BaseModule
2518
+ rescue LoadError; end
2519
+
2520
+ begin
2521
+ require 'cyberweb/sinatra/custom_extensions.rb'
2522
+ include Cyberweb::Sinatra::CustomExtensions
2523
+ rescue LoadError; end
2524
+
2525
+ # Some methods defined next
2526
+
2527
+ end
2528
+ def self.embeddable_interface
2529
+ object = Object.new
2530
+ object.extend(Wetter::EmbeddableInterface)
2531
+ return object
2532
+ end
2533
+
2534
+ That's the skeleton for it right now, roughly.
2535
+
2536
+ In the future this may be simplified, but for now this is
2537
+ the way it is.
2538
+
2539
+ You can use the following toplevel method for merging new routes into
2540
+ an application; again, for the time being, this is a bit hackish. It
2541
+ may take a while before this becomes officially endorsed.
2542
+
2543
+ The API is:
2544
+
2545
+ Cyberweb::Sinatra::CustomExtensions.merge_interface
2546
+
2547
+ Arguments should be:
2548
+
2549
+ Cyberweb::Sinatra::CustomExtensions.merge_interface(
2550
+ i, # Should be an Array of routes that are to be used.
2551
+ prepend_this_to_the_route = '/',
2552
+ namespace_to_use # For example, PdfParadise or Repackage.
2553
+ )
2554
+
2555
+ Some methods are assumed to exist within module EmbeddableInterface.
2556
+ This may be subject to change in the future, but for now simply
2557
+ look at the **repackage gem** to find out how this is done.
2558
+ Documentation is missing in this regard, but will be added over
2559
+ the next weeks slowly.
2560
+
2561
+ ## JavaScript variables
2562
+
2563
+ The variables in JavaScript are by default global. You can make
2564
+ them local if you attach the **var** keyword to them.
2565
+
2566
+ You can also define several variables in one go, via:
2567
+
2568
+ var message = "hi",
2569
+ found = false,
2570
+ age = 29;
2571
+
2572
+ The keyword **let** has the lowest scope, even less than when
2573
+ compared to **var**.
2574
+
2575
+ ## Including CSS into a webpage
2576
+
2577
+ If you want to include CSS into a webpage, use the following HTML tag:
2578
+
2579
+ <style type="text/css"></style>
2580
+
2581
+ ## Including external .js files into a HTML (web)page
2582
+
2583
+ The syntax for adding standalone .js files goes like this:
2584
+
2585
+ <script type="text/javascript" src="path/to/javascript/file.js"></script>
2586
+
2587
+ # or simpler:
2588
+
2589
+ <script src="path/to/javascript/file.js"></script>
2590
+
2591
+ ## CSS comments
2592
+
2593
+ If you want to use comments in a CSS file, use something like this:
2594
+
2595
+ /* This is a CSS comment. */
2596
+
2597
+ ## JavaScript comments
2598
+
2599
+ The simplest way to use comments in JavaScript, in my opinion, is
2600
+ via:
2601
+
2602
+ /* This is a comment */
2603
+
2604
+ ## JavaScript loops
2605
+
2606
+ To do a loop in "modern" JavaScript, try:
2607
+
2608
+ for (let i = 0; i < 5; ++i) {
2609
+ /* do stuff here */
2610
+ }
2611
+
2612
+ The index variable **i** will remain completely local to the
2613
+ block, and not appear outside of it.
2614
+
2615
+ ## CSS font-face property (in CSS3)
2616
+
2617
+ Via the <b>@font-face</b> property it is possible to make use of
2618
+ different (custom) fonts. This font can be loaded from
2619
+ a remote server, or it can be provided on the local system,
2620
+ thus a locally installed font on the user's computer.
2621
+
2622
+ An URL should be given as argument.
2623
+
2624
+ The syntax rules for this goes as follows:
2625
+
2626
+ (1) first give the name of the font
2627
+ (2) provide the path to the font
2628
+
2629
+ If you then wish to make use of that font you can declare
2630
+ this in CSS.
2631
+
2632
+ An example for this follows:
2633
+
2634
+ @font-face {
2635
+ font-family: myFirstFont;
2636
+ src: url("sansation_light.woff"); # Here you can provide the URL
2637
+ }
2638
+
2639
+ Another example:
2640
+
2641
+ @font-face {
2642
+ font-family: "Open Sans";
2643
+ src: url("/fonts/OpenSans-Regular-webfont.woff2") format("woff2"),
2644
+ url("/fonts/OpenSans-Regular-webfont.woff") format("woff");
2645
+ }
2646
+
2647
+ ## Lazy loading of images
2648
+
2649
+ You can use **loading=lazy** to defer the loading of that image
2650
+ until the user scrolls to the image.
2651
+
2652
+ Example in HTML:
2653
+
2654
+ <img src='foobar.jpg' loading='lazy' alt='Alternative Text'>
2655
+
2656
+ ## JavaScript for-in and for-of loops:
2657
+
2658
+ Just examples for each:
2659
+
2660
+ for (const key in {a: 1, b: 2}) {
2661
+ console.log(key);
2662
+ }
2663
+ // a, b
2664
+
2665
+ for (const value of [1,2,3,4,5]) {
2666
+ console.log(value);
2667
+ }
2668
+ // 1, 2, 3, 4, 5
2669
+
2670
+ ## Data Types in JavaScript (ECMAScript)
2671
+
2672
+ There are six simple data types:
2673
+
2674
+ Undefined
2675
+ Null
2676
+ Boolean
2677
+ Number
2678
+ String
2679
+ Symbol
2680
+
2681
+ ## How to use the typeof() operator in JavaScript
2682
+
2683
+ The typeof operator is called like this:
2684
+
2685
+ let x = "some string";
2686
+ typeof(x) # "string"
2687
+ typeof(95) # "number"
2688
+
2689
+ Note that the () for typeof() could be omitted, as typeof is
2690
+ an operator and not a function - but it seems simpler to use
2691
+ the () just as it is used for other functions in JavaScript
2692
+ as well.
2693
+
2694
+ ## Use image-checkbox (on and off)
2695
+
2696
+ Examples:
2697
+
2698
+ show_image_checkbox :on, 'posab','top:10em;right:18%'
2699
+ show_image_checkbox :off, 'posab','top:10em;right:18%'
2700
+
2701
+ ## CSS zoom-on-hover effect
2702
+
2703
+ This can be done like this:
2704
+
2705
+ .images {
2706
+ display: flex;
2707
+ width: 100vw;
2708
+ juftify-content: center;
2709
+ align-items: center;
2710
+ }
2711
+
2712
+ img {
2713
+ width: 400px;
2714
+ }
2715
+
2716
+ img:hover {
2717
+ transform: scale(1.3);
2718
+ }
2719
+
2720
+ The important part is the **transform: scale** specification.
2721
+
2722
+ I typically put this into a special CSS class such as:
2723
+
2724
+ .enlarge_this_image_on_hover:hover {
2725
+ transform: scale(1.1);
2726
+ }
2727
+
2728
+ ## Valid values for CSS font-size:
2729
+
2730
+ xx-small
2731
+ x-small
2732
+ small
2733
+ smaller
2734
+ medium
2735
+ large
2736
+ x-large
2737
+ xx-large
2738
+ larger
2739
+
2740
+ ## Useful quotes when designing websites and web-apps
2741
+
2742
+ "When you are creating a website, the primary goal as a designer
2743
+ should be to get rid of the question marks users have when
2744
+ visiting that site."
2745
+
2746
+ "The most important thing a designer can do is to understand
2747
+ the basic principle of eliminating question marks that a user
2748
+ has when visiting a website. Keep things simple."
2749
+
2750
+ "If you can not make something self-evident, you should at the
2751
+ least make it self-explanatory."
2752
+
2753
+ "If a web page is going to be effective, it has to work most
2754
+ of its beautiful magic at a single glance."
2755
+
2756
+ "The average visitor rarely spends much time reading all
2757
+ content on a given web page, so focus on designing fewer
2758
+ elements that can be easily navigated, without too much
2759
+ distracting clutter."
2760
+
2761
+ "If your design forces a visitor to incur a small learning
2762
+ curve, make sure that the added value from this design
2763
+ change leads to it being worth that additional learning
2764
+ curve."
2765
+
2766
+ "Clarity trumps consistency."
2767
+
2768
+ "Each webpage should have a clear visual hierarchy."
2769
+
2770
+ "Components in a webpage that are related logically
2771
+ should also be related visually."
2772
+
2773
+ "In order to make a website 'scan-friendly', make good use of
2774
+ headings having a larger font size. The headings should
2775
+ indicate what a subsection is about."
2776
+
2777
+ "When using a heading, make them visually somewhat closer
2778
+ to the section they belong to, rather than equally spaced
2779
+ to the preceding paragraph."
2780
+
2781
+ "If you need the visitor to make a difficult choice, provide as
2782
+ much guidance as necessary - but not more. Be succinct here
2783
+ and provide only the smallest amount of information that
2784
+ will help the user."
2785
+
2786
+ "Omit needless words. Vigorous writing is concise."
2787
+
2788
+ "Try to make everything on a web-site self-explanatory or as
2789
+ close to it as possible."
2790
+
2791
+ "Navigation should ideally remain clear, simple, and consistent."
2792
+
2793
+ "It may be useful to consider using an identifier, such as a logo
2794
+ or an image, for the website, and display this e. g. on the
2795
+ upper left corner. This may help visitors identify where they
2796
+ are, in particular if they tend to use several tabs in their
2797
+ browser."
2798
+
2799
+ "If your website makes use of a menu-bar or navigation-bar,
2800
+ consider highlighting the current location that the user
2801
+ has or uses on that website."
2802
+
2803
+ "Ideally a website should convey the big picture, and make it
2804
+ clear what the site is about."
2805
+
2806
+ "If possible consider to use visual identifiers on the
2807
+ whole web-application at hand, to give visitors the
2808
+ right idea about this being a cohesive and integrated
2809
+ unit."
2810
+
2811
+ "Changing a website at a later time is not necessarily trivial.
2812
+ Some percentage of users that have grown accustomed to a
2813
+ layout will resist almost any kind of change, and even
2814
+ apparently simple changes often turn out to have
2815
+ far-reaching effects."
2816
+
2817
+ "Focus ruthlessly on fixing the most serious problems first."
2818
+
2819
+ ## Cyberweb::Header
2820
+
2821
+ Examples:
2822
+
2823
+ Cyberweb::Header.size = 'h3' # Set to a smaller header.
2824
+ Cyberweb::Header.reset
2825
+
2826
+ Not sure if this is still necessary in 2021; at a later time
2827
+ it will be decided whether to keep this or not. If it is kept
2828
+ then this subsection will be expanded.
2829
+
2830
+ ## Working with HTML form elements
2831
+
2832
+ Within a HTML form tag, the following tags are valid or have a
2833
+ special meaning:
2834
+
2835
+ button
2836
+ input
2837
+ select
2838
+ textarea
2839
+
2840
+ ## CSS ::before rule
2841
+
2842
+ You can add content via CSS like this:
2843
+
2844
+ .some_class::before {
2845
+ content: "Only today offer ";
2846
+ font-size: larger;
2847
+ color: red;
2848
+ }
2849
+
2850
+ <p class="some_class">Wood only € 4.95</p>
2851
+
2852
+ I don't think this is too overly useful when you can dynamically
2853
+ generate the web-app as-is, though.
2854
+
2855
+ ## Cyberweb::HtmlTemplate
2856
+
2857
+ class **Cyberweb::HtmlTemplate** can be used to fill it with HTML
2858
+ specific content. More documentation will be added here eventually;
2859
+ for now, let's just show a simple example how I tend to use this
2860
+ class:
2861
+
2862
+ Cyberweb::HtmlTemplate[
2863
+ title: 'Status',
2864
+ body: '<pre style="font-size:150%">'+
2865
+ ::EnvironmentInformation.return_the_most_important_info+
2866
+ '</pre>'
2867
+ ].to_s
2868
+
2869
+ It is possible since as of 18.06.2021 to pass CSS classes into this,
2870
+ via:
2871
+
2872
+ css_classes:
2873
+
2874
+ For example, passing 'darkblue' to that key means that the CSS
2875
+ class 'darkblue' will be available, which ultimately comes down
2876
+ to <b>color: darkblue</b>.
2877
+
2878
+ I needed this functionality to pull in only the CSS classes that
2879
+ I use on a particular page generated by class Cyberweb::HtmlTemplate.
2880
+
2881
+ Various additional entries are available. For example, if
2882
+ you want to modify the css-style in use for the body tag
2883
+ then you can use the following variant:
2884
+
2885
+ body_css_style: 'background-color:#DFD1FF'
2886
+
2887
+ In the long run the goal is to extend class HtmlTemplate in
2888
+ such a way that all html-generation used within the Cyberweb
2889
+ project can be handled by it.
2890
+
2891
+ ## Embed youtube videos and videos in general
2892
+
2893
+ You can embed youtube videos, thanks to the MultimediaParadise
2894
+ project, by issuing this:
2895
+
2896
+ youtube_embedder 'https://www.youtube.com/watch?v=7L6uEstbd9Y',250
2897
+
2898
+ The second argument tells us the width to use for this video.
2899
+
2900
+ More generally, to embed videos in HTML5, you can use code like this:
2901
+
2902
+ <video controls width="250">
2903
+ <source src="/media/cc0-videos/flower.webm" type="video/webm">
2904
+ <source src="/media/cc0-videos/flower.mp4" type="video/mp4">
2905
+ </video>
2906
+
2907
+ ## How to work with form-elements
2908
+
2909
+ This subsection was added because I tend to forget how to work with
2910
+ &lt;form> elements in **HTML**.
2911
+
2912
+ **HTML** allows us to make use of &lt;form> elements.
2913
+
2914
+ Any such &lt;form> element is typically associated with an action,
2915
+ which is determined via **action=""**.
2916
+
2917
+ This may look like this:
2918
+
2919
+ <form action="/foobar.php">
2920
+ </form>
2921
+
2922
+ The attribute **action** determines the recipient, that is,
2923
+ the one who will receive the transmitted data from the
2924
+ &lt;form> element. In the example above, the file called
2925
+ **foobar.php**.
2926
+
2927
+ The attribute <b>method</b> determines **how** the data will
2928
+ be transmitted. If omitted then the <b>default</b> is
2929
+ **get**.
2930
+
2931
+ You can also send this to an email, such as via this:
2932
+
2933
+ <form action="mailto:foo@bar.org" method="post" enctype="text/plain">
2934
+
2935
+ Within any such given element, we can use &lt;input>, as in:
2936
+
2937
+ &lt;input type="text" id="first_name" name="first_name">
2938
+
2939
+ To use a web-form via **cyberweb**, try:
2940
+
2941
+ form('SELF', :post, 'mars2em') {
2942
+ }
2943
+
2944
+ ## simple_table2
2945
+
2946
+ Since as of **24 Aug 2011** we can also use the method
2947
+ **simple_table2()** which is stored in the file
2948
+ html_tables.rb.
2949
+
2950
+ Example for this:
2951
+
2952
+ simple_table2(ARRAY_ALL_LINKS)
2953
+
2954
+ This will simple make a 2 data-cell table, and accepts an Array
2955
+ as its input. Very easy way to make tables!
2956
+
2957
+ ## Sitemaps
2958
+
2959
+ A sitemap is a navigational tool, displaying to the user which links
2960
+ may exist on a given webpage.
2961
+
2962
+ If you want to use a sitemap via the Cyberweb project, do something
2963
+ like this here:
2964
+
2965
+ sitemap :h4, 'Schnelles Abnehmen'
2966
+ autogenerated_sitemap
2967
+
2968
+ If you also want to autogenerate a sitemap, as-is, then you can
2969
+ use the following method:
2970
+
2971
+ header_for_sitemap 'This is some generic header.'
2972
+
2973
+ ## Generating standalone webpages (.html files)
2974
+
2975
+ This subsection deals with the cyberweb project generating standalone
2976
+ .html files.
2977
+
2978
+ First, the general method to create a HTML dump is via:
2979
+
2980
+ .to_html
2981
+
2982
+ This is only possible on a WebObject instance. This alone will just
2983
+ return the HTML representation.
2984
+
2985
+ To store it into a local file use this method:
2986
+
2987
+ .create_standalone_html_page
2988
+
2989
+ This presently (**August 2021**) uses hardcoded file paths. In the
2990
+ future more flexibility will be added to the method, but for the
2991
+ time being it was only added to quickly do some ad-hoc testing.
2992
+
2993
+ ## Spinbuttons in HTML
2994
+
2995
+ Use something like:
2996
+
2997
+ <input type="number" value="1" min="1" max="999">
2998
+
2999
+ You may even style them via CSS like:
3000
+
3001
+ input[type=number]::-webkit-inner-spin-button {
3002
+ opacity: 0.3
3003
+ }
3004
+
3005
+ ## HTML-links
3006
+
3007
+ Since as of **19.02.2020** (19th February 2020), the
3008
+ **cyberweb project** now uses the **HtmlTags project** for
3009
+ generating **a href hyperlinks** (HTML hyperlinks).
3010
+
3011
+ While this led to some broken links on my home system, the code
3012
+ as well as the usage pattern for links is now more consistent,
3013
+ and simpler to use in the long run - I hope. Before that I used
3014
+ tons of different HTML-generating methods, all of which used
3015
+ different signatures. This was too confusing to maintain in
3016
+ the long run.
3017
+
3018
+ The typical API for use of such a HTML link may look like this:
3019
+
3020
+ a 'https://www.manualslib.de/manual/123/Gerät_xyz.html',
3021
+ content: 'Handbuch zum Gerät xyz',
3022
+ css_class: 'mars2em'
3023
+
3024
+ So essentially, you can describe the **HyperLink** as a **Hash**,
3025
+ where **content** is the content (the text you wish to display),
3026
+ **css_class** is the CSS class to use for that link, and so on
3027
+ and so forth.
3028
+
3029
+ For the actual CSS code, I recommend to group the a-related
3030
+ tags together, such as via:
3031
+
3032
+ a:link, a:visited, a:active { color: #3366FF; text-decoration: none; }
3033
+
3034
+ The hover-action should be styled separately:
3035
+
3036
+ a:hover { color: #006699; text-decoration: underline; }
3037
+
3038
+ To globally style all HTML hyperlinks, you can use CSS style such as
3039
+ the following:
3040
+
3041
+ <style>
3042
+ a {
3043
+ color: steelblue;
3044
+ }
3045
+ </style>
3046
+
3047
+ ## The br-tag
3048
+
3049
+ The br-tag can be used in HTML to add a linebreak.
3050
+
3051
+ You can style the height of the line break via CSS such as:
3052
+
3053
+ br {
3054
+ line-height: 30%;
3055
+ }
3056
+
3057
+ I needed this on a webpage to control the distance between
3058
+ individual HREF-links, and I did not want to use div-tags
3059
+ or p-tags as such. So using the <b>line-height</b> property
3060
+ was very useful.
3061
+
3062
+ ## Remote images versus local images
3063
+
3064
+ I use various www-related projects, including local webpages.
3065
+
3066
+ Some of these pages lateron became available for everyone,
3067
+ such as in the roebe gem, via the www/ subdirectory.
3068
+
3069
+ However had, images are normally not distributed for these
3070
+ webpages - it would inflate the gem size way too much.
3071
+
3072
+ This in turn means that a visitor does not see any image,
3073
+ when some of these images are important or helpful. This
3074
+ is not an ideal situation.
3075
+
3076
+ So, in September 2021 I decided to add a new API, called:
3077
+
3078
+ drag_local_image_or_remote_image()
3079
+ drag_local_image_or_remote_image('foo/bar.png')
3080
+ drag_local_image_or_remote_image('foo/bar.png','www.some_page.com/yo/foo/bar.png')
3081
+
3082
+ The idea here is to default to my local image, but to
3083
+ provide a second argument as well, containing a remote URL
3084
+ to an image that can be used as a substitute, in the event
3085
+ that there is no local image available (such as when other
3086
+ users look at a webpage distributed in the roebe gem).
3087
+
3088
+ I tested this in September 2021 and it works, so in the
3089
+ future I expect a few more images to be made available.
3090
+ But this is quite experimental as of now, and probably
3091
+ still not too hugely useful for other users. In the
3092
+ event you may have a need case to document such a web-page
3093
+ via images, you can modify these API calls and supply
3094
+ your own images.
3095
+
3096
+ If you do not need drag-and-drop support then simply use:
3097
+
3098
+ local_image_or_remote_image()
3099
+
3100
+ If **drag_local_image_or_remote_image()** is too long to type,
3101
+ use the alias called **dimg2**.
3102
+
3103
+ ## Objectified HTML Tags
3104
+
3105
+ Objectified HTML tags are something like this:
3106
+
3107
+ puts Cyberweb::ObjectifiedHtmlTags::Span.new('hey there') # => "<span>hey there</span>"
3108
+ puts Cyberweb::ObjectifiedHtmlTags::Span.new('hey there').align_to_the_left # => "<span style="text-align: left;">hey there</span>"
3109
+
3110
+ In other words we may treat HTML tags as strings that can be
3111
+ embedded. The idea for this has been inspired by ruby-gtk,
3112
+ such as:
3113
+
3114
+ widget1.add(widget2)
3115
+
3116
+ I needed to add a lot of OOP-centric methods to the cyberweb
3117
+ framework. Objectified HTML tags may solve this issue.
3118
+
3119
+ As of now in September 2021 this is, however had, experimental.
3120
+ In due time it will be evaluated whether we could enable these
3121
+ tags for use in a unified code base in the future. Stay tuned.
3122
+
3123
+ In late September 2021, the textarea-tag was added.
3124
+
3125
+ Example:
3126
+
3127
+ textarea = Cyberweb::ObjectifiedHtmlTags::Textarea.new('content')
3128
+ # You can also use this instead:
3129
+ # textarea = html_textarea
3130
+ textarea.class = 'rounded_border_6px bblack1 FS2em pad8px'
3131
+ textarea.id = 'ask_a_question'
3132
+ textarea.name = 'ask_a_question'
3133
+ textarea.rows = 6
3134
+ textarea.cols = 90
3135
+
3136
+ Again - this is all highly experimental, but in the long run all
3137
+ HTML tags will become objectified, as an additional option. You
3138
+ need to decide for yourself whether you want to use this or not;
3139
+ the one-line approach in regular HTML is probably shorter.
3140
+
3141
+ The following table, alphabetically sorted, shows the currently
3142
+ (**September 2021**) available objectified HTML tags as part of
3143
+ the cyberweb project. More may be added in the future.
3144
+
3145
+ Name of the HTML tag | Implementation Status | True HTML tag
3146
+ ---------------------|--------------------------|--------------
3147
+ a | added | yes
3148
+ abb3 | added | yes
3149
+ button | added | yes
3150
+ combobox | added | no
3151
+ div | added | yes
3152
+ embed | added | yes
3153
+ form | added | yes
3154
+ h1 | added | yes
3155
+ h2 | added | yes
3156
+ h3 | added | yes
3157
+ h4 | added | yes
3158
+ h5 | added | yes
3159
+ h6 | added | yes
3160
+ hbox | added | no
3161
+ img | added | yes
3162
+ p | added | yes
3163
+ pre | added | yes
3164
+ span | added | yes
3165
+ table | added | yes
3166
+ textarea | added | yes
3167
+ title | added | yes
3168
+ window | added | no
3169
+
3170
+ Note that some of the above, such as window, hbox or combobox, are
3171
+ not directly HTML tags. Nonetheless these were added, largely to
3172
+ improve compatibility with ruby-gtk3 and other toolkits that make
3173
+ use of a more object-centric nature in how to handle such entities.
3174
+ Some aliases may exist to "simulate" dealing with "real HTML tags".
3175
+
3176
+ Table is a bit special in that you can feed it an array, and it
3177
+ will generate the proper <td> entries and <tr> entries - so it
3178
+ is a bit of a "meta"-tag in this regard.
3179
+
3180
+ You can also do some ad-hoc trickery with this.
3181
+
3182
+ Example:
3183
+
3184
+ _ = html_image('../../images/foobar.jpg')
3185
+ _.css_class 'bblack3'
3186
+ _.on_mouse_over {{
3187
+
3188
+ upscale: '+50%',
3189
+ delay: 1.0 # in seconds
3190
+
3191
+ }}
3192
+ e _
3193
+
3194
+ This would embed the image called foobar.jpg into the current
3195
+ website, and add an upscale effect of +50% when the mouse hovers
3196
+ over it.
3197
+
3198
+ This is not yet ideal; I am experimenting. But in the long run
3199
+ I want to try to combine an OOP approach for the www with the
3200
+ old variant that cyberweb used in the last 15 years. It is a
3201
+ bit too verbose for my taste still, but eventually I should
3202
+ have ironed this out.
3203
+
3204
+ ## Useful Links
3205
+
3206
+ This subsection just keeps a few useful resources. This may
3207
+ become obsolete over time, so don't expect all links to
3208
+ work or be very useful. It's just a random collection
3209
+ really, last updated in **May 2021**.
3210
+
3211
+ https://catswhocode.com/css-tricks/
3212
+ https://validator.w3.org/
3213
+ https://wiki.selfhtml.org/wiki/HTML/Tutorials/Formulare/Auswahllisten
3214
+ https://paletton.com/#uid=1000u0kllllaFw0g0qFqFg0w0aF
3215
+ https://meiert.com/en/indices/css-properties/
3216
+ https://webdesignerwall.com/tutorials/advanced-css-menu
3217
+ http://www.ericmeyeroncss.com/projects/01/
3218
+ http://www.selfhtml5.org/html5-tag-systematik/
3219
+ https://hyperstack.org/
3220
+
3221
+ HTML Tutorial (HTML for beginners): https://html.com/
3222
+
3223
+ Self-HTML: https://selfhtml.org/
3224
+
3225
+ Fancy Scrollbars: http://www.n-son.com/scripts/jsScrolling/example2.html
3226
+
3227
+ For a quick list (a table) of available HTML tags, you may want to visit:
3228
+
3229
+ https://way2tutorial.com/html/tag/index.php
3230
+
3231
+ (Obviously there are many other resources available in this regard.
3232
+ I only wanted to list one, so the above link is somewhat random.)
3233
+
3234
+
3235
+ ## Contact information
3236
+
3237
+ If your creative mind has ideas and specific suggestions to make this
3238
+ gem more useful in general, feel free to drop me an email at any
3239
+ time, via:
3240
+
3241
+ shevy@inbox.lt
3242
+
3243
+ Before that email I used an email account at Google gmail, but in **2021** I
3244
+ decided to slowly abandon gmail for various reasons. In part this is because
3245
+ the UI annoys me (on non-chrome browser loading takes too long), but also
3246
+ because of Google's attempt to establish mass surveillance via its
3247
+ federated cohorts sniffing (FLoC). I do not know what happened at Google,
3248
+ but enough is enough - there is only so much you can take while supporting
3249
+ greed. When it comes to data mining done by private groups, ultimately
3250
+ the user became the product.
3251
+
3252
+ Do keep in mind that responding to emails may take some time,
3253
+ depending on the amount of work I may have at that moment, due
3254
+ to reallife time constraints. I will, however had, read feedback
3255
+ eventually. Patches and code changes are welcome too, of course,
3256
+ as long as they are in the spirit of the project at hand, e. g.
3257
+ fitting to the general theme. For this I may make use of github
3258
+ as a discussion site, but this has a low priority right now.
3259
+