cyberweb 0.4.174 → 0.5.225

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 (625) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1782 -405
  3. data/bin/cyberweb_sanitize +10 -0
  4. data/bin/download_webpage +7 -0
  5. data/bin/html_to_cyberweb_converter +7 -0
  6. data/cyberweb.gemspec +25 -25
  7. data/doc/README.gen +1745 -383
  8. data/doc/USAGE.md +16 -16
  9. data/doc/{AUTHORS.md → authors.md} +0 -0
  10. data/doc/configuration/configuration.md +3 -1
  11. data/doc/deprecations.md +13 -7
  12. data/doc/{DOCUMENTATION_FOR_CYBERSPRAWL.md → documentation_for_cybersprawl.md} +7 -4
  13. data/doc/future_design_goals.md +33 -0
  14. data/doc/html_characters.md +7 -7
  15. data/doc/{JQUERY.md → jquery/jquery.md} +20 -12
  16. data/doc/{MOUSE.md → mouse.md} +1 -9
  17. data/doc/{RENDER_WEB_BASE.md → render_web_base.md} +11 -4
  18. data/doc/todo/todo_for_the_cyberweb_project.md +791 -0
  19. data/examples/advanced/animated_css_example/animated_css_example.html +47 -0
  20. data/examples/advanced/animated_submarine/animated_submarine.html +511 -0
  21. data/examples/advanced/animated_windmill/animated_windmill.html +468 -0
  22. data/examples/advanced/delayed_update_of_the_body_via_javascript.cgi +8 -5
  23. data/examples/advanced/draw_circle/draw_circle.cgi +36 -0
  24. data/examples/advanced/drop_shadow_examples.cgi +37 -0
  25. data/examples/advanced/games/snake/food.png +0 -0
  26. data/examples/advanced/games/snake/ground.png +0 -0
  27. data/examples/advanced/games/snake/snake.cgi +28 -0
  28. data/examples/advanced/games/tetris/tetris.cgi +7 -0
  29. data/examples/advanced/games/tetris/tetris.rb +17 -0
  30. data/examples/advanced/games/tetris/tetris.sinatra +58 -0
  31. data/examples/advanced/games/tic-tac-toe/tic-tac-toe.cgi +123 -0
  32. data/examples/advanced/get_some_coffee/get_some_coffee.html +293 -0
  33. data/examples/advanced/glow_on_hover_example/glow_on_hover_example.cgi +27 -0
  34. data/examples/advanced/hybrid_experiment.cgi +34 -12
  35. data/examples/advanced/images/global_css_rules_for_the_images.cgi +32 -0
  36. data/examples/advanced/larger_image_on_mouse_over_example.cgi +2 -2
  37. data/examples/advanced/no_right_click.cgi +4 -3
  38. data/examples/advanced/{objectified_html_tags.cgi → objectified_html_tags/objectified_html_tags.cgi} +12 -3
  39. data/examples/advanced/objectified_html_tags/testing_objectified_html_tags_with_the_webobject.cgi +28 -0
  40. data/examples/advanced/random_glow_effects.cgi +34 -0
  41. data/examples/advanced/select_everything_example/select_everything_example.cgi +25 -0
  42. data/examples/advanced/simple_calculator.cgi +13 -21
  43. data/examples/advanced/simple_form_example.cgi +11 -11
  44. data/examples/advanced/traffic_light/traffic_light.html +163 -0
  45. data/examples/advanced/weather_animation/weather_animation.html +560 -0
  46. data/examples/css/animated_3D_cube_example/animated_3D_cube_example.html +265 -0
  47. data/examples/css/animated_bird_example/animated_bird_example.html +207 -0
  48. data/examples/css/animated_desk_example/animated_desk_example.html +120 -0
  49. data/examples/css/animated_dog_example/animated_dog_example.html +432 -0
  50. data/examples/css/animated_submit_button.html +190 -0
  51. data/examples/css/animated_text_colour_change/animated_text_colour_change.html +41 -0
  52. data/examples/css/blue_border.html +3 -1
  53. data/examples/css/border_image_example/border_image_example.html +40 -0
  54. data/examples/css/box_shadow/box_shadow_example.html +18 -0
  55. data/examples/css/christmas_snow_globe_animation.html +596 -0
  56. data/examples/css/css_border_spacing_example.html +5 -5
  57. data/examples/css/css_bubbles.html +3 -1
  58. data/examples/css/css_checkboxes_example/css_checkboxes_example.html +110 -0
  59. data/examples/css/css_drag_and_drop.html +1 -5
  60. data/examples/css/css_grid_feline_style/css_grid_feline_style.html +161 -0
  61. data/examples/css/css_neon_glow_effects.html +1 -1
  62. data/examples/css/css_rotate_these_words.html +83 -0
  63. data/examples/css/css_text_decoration_example.html +7 -7
  64. data/examples/css/css_thermometer/css_thermometer.html +91 -0
  65. data/examples/css/{css_tooltip.html → css_tooltip/css_tooltip.html} +8 -6
  66. data/examples/css/css_typewriter_example/css_typewriter_example.html +226 -0
  67. data/examples/css/cyberweb_animated_logo/cyberweb_animated_logo.html +179 -0
  68. data/examples/css/daily_coffee/daily_coffee.html +1110 -0
  69. data/examples/css/different_colour_on_selected_text/different_colour_on_selected_text.html +31 -0
  70. data/examples/css/differentially_glowing_text_example/differentially_glowing_text_example.html +82 -0
  71. data/examples/css/fade_in_and_fade_out_effect.html +2 -2
  72. data/examples/css/flying_birds_example/flying_birds_example.html +171 -0
  73. data/examples/css/folding_cards_example/folding_cards_example.html +624 -0
  74. data/examples/css/font_size_examples.html +7 -5
  75. data/examples/css/glowing_on_hover_animation/glowing_on_hover_animation.html +90 -0
  76. data/examples/css/grow_example.html +31 -0
  77. data/examples/css/happy_toaster_example/happy_toaster_example.html +830 -0
  78. data/examples/css/landing_on_mars_animation/landing_on_mars_animation.html +374 -0
  79. data/examples/css/letter_spacing_example.cgi +18 -14
  80. data/examples/css/lighthouse_example/lighthouse_example.html +1161 -0
  81. data/examples/css/{meter_example.html → meter_example/meter_example.html} +0 -0
  82. data/examples/css/motorcycle_on_the_go/motorcycle_on_the_go.html +227 -0
  83. data/examples/css/on_hover_glow_effect/on_hover_glow_effect.html +50 -0
  84. data/examples/css/on_mouse_button_pressed.html +6 -4
  85. data/examples/css/our_solar_system/our_solar_system.html +441 -0
  86. data/examples/css/outline/outline_versus_border_example.html +57 -0
  87. data/examples/css/polaroid_card_effect_example/polaroid_card_effect_example.html +130 -0
  88. data/examples/css/responsive_image_gallery/responsive_image_gallery.html +97 -0
  89. data/examples/css/rotating_DNA/rotating_DNA.html +626 -0
  90. data/examples/css/rotating_sphere_example/rotating_sphere_example.html +112 -0
  91. data/examples/css/scale_example.html +4 -5
  92. data/examples/css/shadow_example_in_CSS/shadow_example_in_CSS.cgi +62 -0
  93. data/examples/css/shaking_shapes_example.html +133 -0
  94. data/examples/css/simple_stars_example/simple_stars_example.html +27 -0
  95. data/examples/css/slide_checkbox_example/slide_checkbox_example.html +564 -0
  96. data/examples/css/speak_bubble_quote_example/speak_bubble_quote_example.html +109 -0
  97. data/examples/css/speedy_truck_example/speedy_truck_example.html +168 -0
  98. data/examples/css/{sticky_div_example.html → sticky_div_example/sticky_div_example.html} +0 -0
  99. data/examples/css/stitched_div.html +9 -0
  100. data/examples/css/sun_and_clouds_animation/sun_and_clouds_animation.html +292 -0
  101. data/examples/css/talking_candles_example/talking_candles_example.html +550 -0
  102. data/examples/css/text_decoration_underline_example/text_decoration_underline_example.html +62 -0
  103. data/examples/css/this_is_a_cat/this_is_a_cat.html +219 -0
  104. data/examples/css/three_dots_indicating_page_loading.html +65 -0
  105. data/examples/css/user_select_example/user_select_example.html +24 -0
  106. data/examples/css/walking_cat/walking_cat.html +128 -0
  107. data/examples/css/water_wave_text_animation_effect/water_wave_text_animation_effect.html +86 -0
  108. data/examples/csv/README.md +2 -1
  109. data/examples/flip_card_example/flip_card_example.html +10 -3
  110. data/examples/games/README.md +3 -0
  111. data/examples/games/snake/images/food.png +0 -0
  112. data/examples/games/snake/images/ground.png +0 -0
  113. data/examples/games/snake/snake.html +16 -0
  114. data/examples/games/snake/snake.js +117 -0
  115. data/examples/games/tetris/smaller_tetris_game.html +518 -0
  116. data/examples/games/tetris/tetris.html +461 -0
  117. data/examples/games/tic-tac-toe/index.js +125 -0
  118. data/examples/games/tic-tac-toe/style.css +79 -0
  119. data/examples/games/tic-tac-toe/tic-tac-toe.html +39 -0
  120. data/examples/html/MathML/001_show_a_simple_quadratic_equation.html +22 -0
  121. data/examples/html/MathML/002_simple_equation.html +7 -0
  122. data/examples/html/MathML/003_function_of_example.html +17 -0
  123. data/examples/html/MathML/README.md +2 -0
  124. data/examples/html/abbr_example.html +2 -5
  125. data/examples/html/accordion/README.md +1 -0
  126. data/examples/html/accordion/accordion.html +56 -0
  127. data/examples/html/base64_image_example.html +8 -5
  128. data/examples/html/buttons_example.html +133 -0
  129. data/examples/html/canvas_drawing_example.html +54 -0
  130. data/examples/html/colour_wheel.html +441 -442
  131. data/examples/html/column_width_example.html +2 -2
  132. data/examples/html/custom_cursor.html +8 -5
  133. data/examples/html/cyberweb_logo/README.md +2 -0
  134. data/examples/html/cyberweb_logo/cyberweb_logo.html +11 -0
  135. data/examples/html/draggable_paragraph.html +1 -2
  136. data/examples/html/email_popup_example/email_popup_example.html +175 -0
  137. data/examples/html/fieldset_example.html +3 -1
  138. data/examples/html/font_examples/README.md +1 -0
  139. data/examples/html/font_examples/chancery_text.html +19 -0
  140. data/examples/html/font_examples/fantasy_text.html +19 -0
  141. data/examples/html/font_examples/georgia_text.html +19 -0
  142. data/examples/html/font_size_example/font_size_example.html +85 -0
  143. data/examples/html/glyph_example.html +0 -1
  144. data/examples/html/grayscale_filter_example/grayscale_filter_example.html +15 -0
  145. data/examples/html/html_links_example.html +61 -0
  146. data/examples/html/html_slider/html_slider.html +39 -0
  147. data/examples/html/input_autofocus_example.html +11 -7
  148. data/examples/html/input_placeholder_example.html +15 -0
  149. data/examples/html/larger_image_on_mouse_over_example.html +1 -1
  150. data/examples/html/ordered_and_unordered_bulletsin.html +4 -2
  151. data/examples/html/play_video_example.html +3 -2
  152. data/examples/html/remote_image_example.html +8 -2
  153. data/examples/html/select_everything_on_mouse_click_event.html +38 -0
  154. data/examples/html/selected_text_appears_in_another_colour_example.html +34 -0
  155. data/examples/html/send_email_hyperlink/send_email_hyperlink.html +8 -0
  156. data/examples/html/simple_unordered_list.html +3 -0
  157. data/examples/html/spinner_example/spinner.html +79 -0
  158. data/examples/html/table_with_header_example.html +26 -13
  159. data/examples/html/test_mkv_codec/test_mkv_codec.html +11 -0
  160. data/examples/html/two_columns_flex_example.html +4 -1
  161. data/examples/{javascript → javascript_and_jquery}/README.md +0 -0
  162. data/examples/{javascript → javascript_and_jquery}/arrays/arrays_example_in_javascript.html +0 -0
  163. data/examples/javascript_and_jquery/autocomplete_on_an_input_field/autocomplete_on_an_input_field.html +295 -0
  164. data/examples/javascript_and_jquery/change_the_background_colour_dynamically/change_the_background_colour_dynamically.html +41 -0
  165. data/examples/{javascript → javascript_and_jquery}/delay_example/delay_example.html +0 -0
  166. data/examples/{javascript → javascript_and_jquery}/drag_support/drag_support.html +0 -0
  167. data/examples/javascript_and_jquery/jquery_bubbling_header/bubbling_header.html +109 -0
  168. data/examples/{javascript → javascript_and_jquery}/jquery_drag_and_drop/drag_and_drop_image_example.html +0 -0
  169. data/examples/javascript_and_jquery/jquery_showcase/README.md +6 -0
  170. data/examples/javascript_and_jquery/jquery_showcase/jquery_001.cgi +23 -0
  171. data/examples/javascript_and_jquery/jquery_showcase/jquery_002.cgi +34 -0
  172. data/examples/javascript_and_jquery/jquery_showcase/jquery_003.cgi +24 -0
  173. data/examples/javascript_and_jquery/jquery_showcase/jquery_004.cgi +34 -0
  174. data/examples/javascript_and_jquery/on_change_event/on_change_event.html +29 -0
  175. data/examples/javascript_and_jquery/on_click_colour_change/on_click_colour_change.html +31 -0
  176. data/examples/javascript_and_jquery/on_click_display_random_number/on_click_display_random_number.html +43 -0
  177. data/examples/{javascript → javascript_and_jquery}/on_click_event_hello_world/on_click_event_hello_world.html +0 -0
  178. data/examples/javascript_and_jquery/on_mouse_wheel_event/on_mouse_wheel_event.html +37 -0
  179. data/examples/javascript_and_jquery/read_the_content_of_a_local_file/read_the_content_of_a_local_file.html +35 -0
  180. data/examples/{javascript → javascript_and_jquery}/rgb_to_hex/rgb_to_hex.html +0 -0
  181. data/examples/{javascript → javascript_and_jquery}/screen_resolution/screen_resolution.html +2 -1
  182. data/examples/{javascript → javascript_and_jquery}/select_everything/select_everything.html +1 -1
  183. data/examples/javascript_and_jquery/vue/README.md +1 -0
  184. data/examples/javascript_and_jquery/vue/showcasing_vue.html +80 -0
  185. data/examples/{javascript → javascript_and_jquery}/write_into_a_file/write_into_a_file.html +0 -0
  186. data/examples/rack/example_with_html_template.rb +5 -4
  187. data/examples/rack/example_with_rack_and_cyberweb_showing_how_to_use_images.rb +3 -2
  188. data/examples/rack/hello_world_example_with_rack.rb +3 -2
  189. data/examples/rack/lobster.rb +7 -5
  190. data/examples/rack/rack_env.rb +3 -3
  191. data/examples/{show_greek_letters.rb → show_greek_letters/show_greek_letters.rb} +0 -0
  192. data/examples/simple/input_example_with_coloured_focus.cgi +32 -0
  193. data/examples/simple/input_type_examples.cgi +51 -0
  194. data/examples/simple/on_click_event_hello_world.cgi +5 -5
  195. data/examples/simple/rotate_these_words.cgi +90 -0
  196. data/examples/{example1.rb → simple/show_how_to_set_a_title.rb} +0 -0
  197. data/examples/simple/simple_gradient.cgi +57 -0
  198. data/images/cyberweb_favicon.png +0 -0
  199. data/images/cyberweb_logo.png +0 -0
  200. data/images/cyberweb_theme.png +0 -0
  201. data/lib/cyberweb/REST/README.md +7 -0
  202. data/lib/cyberweb/REST/base/accept_entry.rb +94 -0
  203. data/lib/cyberweb/REST/base/application.rb +37 -0
  204. data/lib/cyberweb/REST/base/bad_request.rb +10 -0
  205. data/lib/cyberweb/REST/base/base.rb +1131 -0
  206. data/lib/cyberweb/REST/base/common_logger.rb +35 -0
  207. data/lib/cyberweb/REST/base/delegator.rb +75 -0
  208. data/lib/cyberweb/REST/base/error.rb +8 -0
  209. data/lib/cyberweb/REST/base/extended_rack.rb +66 -0
  210. data/lib/cyberweb/REST/base/helpers/helpers.rb +473 -0
  211. data/lib/cyberweb/REST/base/helpers/stream.rb +75 -0
  212. data/lib/cyberweb/REST/base/mime_type_entry.rb +67 -0
  213. data/lib/cyberweb/{constants/file_constants.rb → REST/base/not_found.rb} +10 -5
  214. data/lib/cyberweb/REST/base/request.rb +145 -0
  215. data/lib/cyberweb/REST/base/response.rb +94 -0
  216. data/lib/cyberweb/REST/base/templates/templates.rb +208 -0
  217. data/lib/cyberweb/REST/base/wrapper.rb +28 -0
  218. data/lib/cyberweb/{constants/nl.rb → REST/constants.rb} +8 -9
  219. data/lib/cyberweb/REST/main.rb +109 -0
  220. data/lib/cyberweb/REST/show_exceptions.rb +396 -0
  221. data/lib/cyberweb/and_sinatra_base.rb +0 -0
  222. data/lib/cyberweb/autoinclude.rb +0 -0
  223. data/lib/cyberweb/autoinclude_webobject.rb +0 -0
  224. data/lib/cyberweb/base/base.rb +9 -2
  225. data/lib/cyberweb/base/colours.rb +8 -6
  226. data/lib/cyberweb/base/constants.rb +8 -0
  227. data/lib/cyberweb/base/misc.rb +140 -53
  228. data/lib/cyberweb/base/save_file.rb +3 -0
  229. data/lib/cyberweb/base_module/base_module.rb +79 -0
  230. data/lib/cyberweb/cascading_style_sheets/admonition.css +0 -0
  231. data/lib/cyberweb/cascading_style_sheets/balloon.css +0 -0
  232. data/lib/cyberweb/cascading_style_sheets/border.css +107 -41
  233. data/lib/cyberweb/cascading_style_sheets/code.css +0 -0
  234. data/lib/cyberweb/cascading_style_sheets/colours.css +46 -23
  235. data/lib/cyberweb/cascading_style_sheets/css_reset.css +59 -0
  236. data/lib/cyberweb/cascading_style_sheets/cursors.css +14 -0
  237. data/lib/cyberweb/cascading_style_sheets/custom/animated_bike.css +199 -0
  238. data/lib/cyberweb/cascading_style_sheets/default.css +171 -136
  239. data/lib/cyberweb/cascading_style_sheets/div.css +18 -4
  240. data/lib/cyberweb/cascading_style_sheets/drop_shadow.css +154 -0
  241. data/lib/cyberweb/cascading_style_sheets/error_404_css_class.css +26 -0
  242. data/lib/cyberweb/cascading_style_sheets/fonts.css +60 -39
  243. data/lib/cyberweb/cascading_style_sheets/glow_effects.css +69 -0
  244. data/lib/cyberweb/cascading_style_sheets/gradient_effects.css +5 -0
  245. data/lib/cyberweb/cascading_style_sheets/hover.css +4212 -0
  246. data/lib/cyberweb/cascading_style_sheets/links.css +8 -8
  247. data/lib/cyberweb/cascading_style_sheets/margin.css +195 -178
  248. data/lib/cyberweb/cascading_style_sheets/menu.css +0 -0
  249. data/lib/cyberweb/cascading_style_sheets/message_boxes.css +0 -0
  250. data/lib/cyberweb/cascading_style_sheets/misc.css +51 -11
  251. data/lib/cyberweb/cascading_style_sheets/popup.css +0 -0
  252. data/lib/cyberweb/cascading_style_sheets/rpg.css +0 -0
  253. data/lib/cyberweb/cascading_style_sheets/ruby_regexes.css +12 -0
  254. data/lib/cyberweb/cascading_style_sheets/shapes.css +59 -0
  255. data/lib/cyberweb/cascading_style_sheets/template2.css +0 -0
  256. data/lib/cyberweb/cascading_style_sheets/text_shadow.css +21 -0
  257. data/lib/cyberweb/cascading_style_sheets/tooltip.css +0 -0
  258. data/lib/cyberweb/cgi/constants.rb +1 -2
  259. data/lib/cyberweb/cgi/exceptions.rb +1 -1
  260. data/lib/cyberweb/coloured_tags/coloured_tags.rb +1 -1
  261. data/lib/cyberweb/colours/colour_chart.rb +10 -56
  262. data/lib/cyberweb/colours/colours.rb +149 -4
  263. data/lib/cyberweb/commandline/commandline_interface.rb +13 -8
  264. data/lib/cyberweb/configuration/load_the_configuration_file.rb +1 -1
  265. data/lib/cyberweb/constants/constants.rb +592 -2
  266. data/lib/cyberweb/controller/{webobject_controller.rb → controller.rb} +1 -1
  267. data/lib/cyberweb/css_manager/css_manager.rb +237 -0
  268. data/lib/cyberweb/databases/sqlite.rb +56 -0
  269. data/lib/cyberweb/debug/debug.rb +1 -1
  270. data/lib/cyberweb/encoding/encoding.rb +11 -0
  271. data/lib/cyberweb/erb/test.rhtml +0 -0
  272. data/lib/cyberweb/erb/test_template.erb +0 -0
  273. data/lib/cyberweb/evaluate_from_the_same_named_file_then_serve.rb +1 -1
  274. data/lib/cyberweb/favicon/favicon.rb +8 -7
  275. data/lib/cyberweb/forum/README.md +4 -0
  276. data/lib/cyberweb/foto_gallery/foto_gallery.rb +158 -0
  277. data/lib/cyberweb/generator/README.md +2 -2
  278. data/lib/cyberweb/generator/cgi.rb +22 -9
  279. data/lib/cyberweb/generator/static_webpage.rb +22 -12
  280. data/lib/cyberweb/html_tags/README.md +3 -3
  281. data/lib/cyberweb/html_tags/button.rb +10 -2
  282. data/lib/cyberweb/html_tags/h2.rb +6 -4
  283. data/lib/cyberweb/html_tags/html_tags.rb +17 -1
  284. data/lib/cyberweb/html_tags/input.rb +10 -5
  285. data/lib/cyberweb/html_tags/legend.rb +1 -1
  286. data/lib/cyberweb/html_tags/span.rb +10 -2
  287. data/lib/cyberweb/html_tags/table.rb +30 -19
  288. data/lib/cyberweb/html_template/html_template.rb +248 -85
  289. data/lib/cyberweb/images/embed_this_image.rb +3 -1
  290. data/lib/cyberweb/images/images.rb +2 -2
  291. data/lib/cyberweb/images/is_image.rb +2 -1
  292. data/lib/cyberweb/images/path_to_images.rb +2 -1
  293. data/lib/cyberweb/images/remove_this_substring_from_all_images.rb +1 -1
  294. data/lib/cyberweb/images/standalone_drag_and_drop_this_image.rb +3 -3
  295. data/lib/cyberweb/images/string_image.rb +6 -3
  296. data/lib/cyberweb/images_base64_encoded/404_ERROR.png.md +1 -0
  297. data/lib/cyberweb/images_base64_encoded/AUSRUFUNGSZEICHEN.png.md +0 -0
  298. data/lib/cyberweb/images_base64_encoded/BLUEARROW.png.md +0 -0
  299. data/lib/cyberweb/images_base64_encoded/BUBBLE.png.md +0 -0
  300. data/lib/cyberweb/images_base64_encoded/CAT.png.md +0 -0
  301. data/lib/cyberweb/images_base64_encoded/CAUTION.png.md +0 -0
  302. data/lib/cyberweb/images_base64_encoded/CHEERING_PERSON.png.md +0 -0
  303. data/lib/cyberweb/images_base64_encoded/CURSOR.png.md +0 -0
  304. data/lib/cyberweb/images_base64_encoded/DOT_01.png.md +0 -0
  305. data/lib/cyberweb/images_base64_encoded/DUCKY.png.md +0 -0
  306. data/lib/cyberweb/images_base64_encoded/ELEPHANT.png.md +0 -0
  307. data/lib/cyberweb/images_base64_encoded/HALLOWEEN.png.md +0 -0
  308. data/lib/cyberweb/images_base64_encoded/HANGING_MONKEY.png.md +0 -0
  309. data/lib/cyberweb/images_base64_encoded/LENS.png.md +0 -0
  310. data/lib/cyberweb/images_base64_encoded/README.md +0 -0
  311. data/lib/cyberweb/images_base64_encoded/SIX_SIDED_DICE.png.md +1 -0
  312. data/lib/cyberweb/images_base64_encoded/TU_WIEN_LOGO.png.md +0 -0
  313. data/lib/cyberweb/images_base64_encoded/VOGEL.png.md +0 -0
  314. data/lib/cyberweb/javascript/drag_and_drop.rb +17 -14
  315. data/lib/cyberweb/javascript/javascript.rb +79 -34
  316. data/lib/cyberweb/javascript/javascript_clock.rb +50 -14
  317. data/lib/cyberweb/javascript/javascript_helper/javascript_helper.rb +59 -0
  318. data/lib/cyberweb/javascript/jquery.rb +9 -5
  319. data/lib/cyberweb/javascript/on_click_change_opacity.rb +5 -1
  320. data/lib/cyberweb/javascript/on_click_hide.rb +2 -0
  321. data/lib/cyberweb/javascript/popup.rb +5 -2
  322. data/lib/cyberweb/javascript/resize.rb +4 -1
  323. data/lib/cyberweb/javascript_code/README.md +1 -1
  324. data/lib/cyberweb/javascript_code/custom_functions.js +51 -25
  325. data/lib/cyberweb/javascript_code/disable_right_click.js +5 -0
  326. data/lib/cyberweb/javascript_code/games/snake.js +113 -0
  327. data/lib/cyberweb/javascript_code/games/tetris.js +491 -0
  328. data/lib/cyberweb/javascript_code/games/tic-tac-toe.js +125 -0
  329. data/lib/cyberweb/javascript_code/html_colours.js +161 -0
  330. data/lib/cyberweb/javascript_code/jquery/jquery-3.6.1.js +10909 -0
  331. data/lib/cyberweb/javascript_code/select_everything_on_mouse_click_event.js +23 -0
  332. data/lib/cyberweb/javascript_code/simple_calculator.js +3 -3
  333. data/lib/cyberweb/javascript_code/simulate_a_dice.js +20 -0
  334. data/lib/cyberweb/javascript_code/sleep.js +3 -0
  335. data/lib/cyberweb/mouse/mouse.rb +4 -1
  336. data/lib/cyberweb/objectified/html_tags/README.md +13 -0
  337. data/lib/cyberweb/{objectified_html_tags → objectified/html_tags}/a.rb +17 -35
  338. data/lib/cyberweb/{objectified_html_tags → objectified/html_tags}/abbr.rb +18 -9
  339. data/lib/cyberweb/objectified/html_tags/base.rb +960 -0
  340. data/lib/cyberweb/objectified/html_tags/blockquote.rb +106 -0
  341. data/lib/cyberweb/{objectified_html_tags/span.rb → objectified/html_tags/body.rb} +25 -20
  342. data/lib/cyberweb/{objectified_html_tags → objectified/html_tags}/button.rb +26 -34
  343. data/lib/cyberweb/objectified/html_tags/canvas.rb +202 -0
  344. data/lib/cyberweb/objectified/html_tags/cite.rb +103 -0
  345. data/lib/cyberweb/{objectified_html_tags → objectified/html_tags}/combobox.rb +26 -34
  346. data/lib/cyberweb/objectified/html_tags/div.rb +155 -0
  347. data/lib/cyberweb/{objectified_html_tags → objectified/html_tags}/embed.rb +18 -33
  348. data/lib/cyberweb/objectified/html_tags/fieldset.rb +107 -0
  349. data/lib/cyberweb/objectified/html_tags/figure.rb +152 -0
  350. data/lib/cyberweb/objectified/html_tags/form.rb +155 -0
  351. data/lib/cyberweb/objectified/html_tags/h1.rb +176 -0
  352. data/lib/cyberweb/{objectified_html_tags → objectified/html_tags}/h2.rb +32 -40
  353. data/lib/cyberweb/{objectified_html_tags → objectified/html_tags}/h3.rb +30 -42
  354. data/lib/cyberweb/{objectified_html_tags → objectified/html_tags}/h4.rb +30 -42
  355. data/lib/cyberweb/{objectified_html_tags → objectified/html_tags}/h5.rb +31 -40
  356. data/lib/cyberweb/{objectified_html_tags → objectified/html_tags}/h6.rb +31 -41
  357. data/lib/cyberweb/{objectified_html_tags → objectified/html_tags}/hbox.rb +12 -10
  358. data/lib/cyberweb/objectified/html_tags/head.rb +126 -0
  359. data/lib/cyberweb/{objectified_html_tags → objectified/html_tags}/img.rb +47 -32
  360. data/lib/cyberweb/objectified/html_tags/include_objectified_html_tags.rb +49 -0
  361. data/lib/cyberweb/{objectified_html_tags → objectified/html_tags}/input.rb +50 -51
  362. data/lib/cyberweb/objectified/html_tags/map.rb +107 -0
  363. data/lib/cyberweb/{objectified_html_tags/div.rb → objectified/html_tags/meta.rb} +36 -47
  364. data/lib/cyberweb/{objectified_html_tags/h1.rb → objectified/html_tags/object.rb} +34 -42
  365. data/lib/cyberweb/{objectified_html_tags → objectified/html_tags}/p.rb +17 -32
  366. data/lib/cyberweb/{objectified_html_tags → objectified/html_tags}/pre.rb +28 -34
  367. data/lib/cyberweb/{objectified_html_tags/table.rb → objectified/html_tags/progress.rb} +99 -94
  368. data/lib/cyberweb/objectified/html_tags/span.rb +103 -0
  369. data/lib/cyberweb/objectified/html_tags/table.rb +257 -0
  370. data/lib/cyberweb/{objectified_html_tags → objectified/html_tags}/textarea.rb +25 -36
  371. data/lib/cyberweb/{objectified_html_tags → objectified/html_tags}/title.rb +11 -17
  372. data/lib/cyberweb/{objectified_html_tags/form.rb → objectified/html_tags/ul.rb} +45 -42
  373. data/lib/cyberweb/{objectified_html_tags → objectified/html_tags}/window.rb +15 -10
  374. data/lib/cyberweb/objectified/mask/README.md +8 -0
  375. data/lib/cyberweb/objectified/mask/compatibility_to_html_tags.rb +40 -0
  376. data/lib/cyberweb/objectified/mask/mask.rb +490 -0
  377. data/lib/cyberweb/objectified/web_object/README.md +4 -0
  378. data/lib/cyberweb/objectified/web_object/web_object.rb +119 -0
  379. data/lib/cyberweb/predefined_and_freeform_methods/frage.rb +4 -2
  380. data/lib/cyberweb/predefined_and_freeform_methods/freeform_methods.rb +30 -19
  381. data/lib/cyberweb/predefined_and_freeform_methods/hash_registered_extra_tags.rb +6 -0
  382. data/lib/cyberweb/predefined_and_freeform_methods/header.rb +2 -0
  383. data/lib/cyberweb/predefined_and_freeform_methods/predefined_methods.rb +10 -175
  384. data/lib/cyberweb/project/project.rb +9 -4
  385. data/lib/cyberweb/rack/request.rb +11 -11
  386. data/lib/cyberweb/raw_images/404.png +0 -0
  387. data/lib/cyberweb/raw_images/500.png +0 -0
  388. data/lib/cyberweb/raw_images/README.md +2 -0
  389. data/lib/cyberweb/raw_images/a_dice.png +0 -0
  390. data/lib/cyberweb/raw_images/food.png +0 -0
  391. data/lib/cyberweb/raw_images/ground.png +0 -0
  392. data/lib/cyberweb/requires/require_generators.rb +1 -1
  393. data/lib/cyberweb/requires/require_html_tags_files.rb +1 -1
  394. data/lib/cyberweb/requires/require_javascript_files.rb +1 -1
  395. data/lib/cyberweb/requires/require_objectified_html_tags_files.rb +29 -3
  396. data/lib/cyberweb/requires/require_the_constants.rb +3 -1
  397. data/lib/cyberweb/requires/require_the_cyberweb_project.rb +12 -31
  398. data/lib/cyberweb/requires/require_the_toplevel_methods_files.rb +1 -1
  399. data/lib/cyberweb/requires/require_web_object_files.rb +1 -1
  400. data/lib/cyberweb/requires/require_yaml.rb +3 -3
  401. data/lib/cyberweb/rest +1 -0
  402. data/lib/cyberweb/route_handler/class_based_test.rb +43 -0
  403. data/lib/cyberweb/route_handler/module/misc.rb +108 -0
  404. data/lib/cyberweb/route_handler/module/route_handler_module.rb +215 -0
  405. data/lib/cyberweb/route_handler/module/verbs.rb +53 -0
  406. data/lib/cyberweb/route_handler/route_handler.rb +56 -0
  407. data/lib/cyberweb/route_handler/test.rb +43 -0
  408. data/lib/cyberweb/{constants/array_predefined_constants.rb → sinatra/base/set_use_this_port.rb} +16 -9
  409. data/lib/cyberweb/sinatra/base/use_this_port.rb +40 -0
  410. data/lib/cyberweb/sinatra/base.rb +51 -36
  411. data/lib/cyberweb/sinatra/custom_extensions.rb +39 -14
  412. data/lib/cyberweb/standalone_classes/all_css_classes.rb +1 -1
  413. data/lib/cyberweb/standalone_classes/calculator.rb +7 -1
  414. data/lib/cyberweb/standalone_classes/correct_image_entries_in_html_file.rb +12 -7
  415. data/lib/cyberweb/standalone_classes/turn_html_into_cyberweb.rb +13 -11
  416. data/lib/cyberweb/svg/standalone/README.md +2 -0
  417. data/lib/cyberweb/svg/standalone/amusement_park.svg +738 -0
  418. data/lib/cyberweb/svg/svg.cgi +2 -3
  419. data/lib/cyberweb/toplevel_methods/a.rb +2 -1
  420. data/lib/cyberweb/toplevel_methods/anmerkung.rb +3 -0
  421. data/lib/cyberweb/toplevel_methods/audio.rb +1 -1
  422. data/lib/cyberweb/toplevel_methods/bold.rb +9 -3
  423. data/lib/cyberweb/toplevel_methods/charsets.rb +17 -13
  424. data/lib/cyberweb/toplevel_methods/consider_serving_the_web_object.rb +3 -3
  425. data/lib/cyberweb/toplevel_methods/css.rb +719 -25
  426. data/lib/cyberweb/{csv → toplevel_methods}/csv.rb +5 -3
  427. data/lib/cyberweb/{constants/roebe.rb → toplevel_methods/custom_error_page.rb} +10 -10
  428. data/lib/cyberweb/toplevel_methods/{date.rb → date_and_time.rb} +23 -10
  429. data/lib/cyberweb/toplevel_methods/disable.rb +7 -3
  430. data/lib/cyberweb/toplevel_methods/dot.rb +2 -2
  431. data/lib/cyberweb/toplevel_methods/download_webpage.rb +41 -3
  432. data/lib/cyberweb/toplevel_methods/edit_configuration_file.rb +1 -1
  433. data/lib/cyberweb/toplevel_methods/fields.rb +2 -0
  434. data/lib/cyberweb/toplevel_methods/filename.rb +3 -1
  435. data/lib/cyberweb/toplevel_methods/frames.rb +0 -2
  436. data/lib/cyberweb/toplevel_methods/google.rb +52 -0
  437. data/lib/cyberweb/{html_codes → toplevel_methods}/greek_letters.rb +22 -1
  438. data/lib/cyberweb/toplevel_methods/hardware_information.rb +2 -1
  439. data/lib/cyberweb/{help → toplevel_methods}/help.rb +3 -2
  440. data/lib/cyberweb/toplevel_methods/html_comment.rb +2 -2
  441. data/lib/cyberweb/toplevel_methods/html_tables.rb +401 -266
  442. data/lib/cyberweb/toplevel_methods/internal_hash.rb +173 -0
  443. data/lib/cyberweb/{io → toplevel_methods}/io.rb +1 -1
  444. data/lib/cyberweb/toplevel_methods/javascript.rb +42 -0
  445. data/lib/cyberweb/toplevel_methods/jquery.rb +8 -0
  446. data/lib/cyberweb/toplevel_methods/last_modified.rb +4 -0
  447. data/lib/cyberweb/toplevel_methods/links.rb +23 -7
  448. data/lib/cyberweb/toplevel_methods/listing.rb +2 -1
  449. data/lib/cyberweb/toplevel_methods/localhost.rb +3 -0
  450. data/lib/cyberweb/toplevel_methods/markdown.rb +3 -2
  451. data/lib/cyberweb/toplevel_methods/mathml.rb +5 -3
  452. data/lib/cyberweb/toplevel_methods/message_boxes.rb +6 -2
  453. data/lib/cyberweb/toplevel_methods/misc.rb +531 -79
  454. data/lib/cyberweb/toplevel_methods/padlem_and_marlem.rb +3 -0
  455. data/lib/cyberweb/toplevel_methods/path.rb +6 -1
  456. data/lib/cyberweb/toplevel_methods/pdf.rb +1 -1
  457. data/lib/cyberweb/toplevel_methods/process_content.rb +4 -7
  458. data/lib/cyberweb/toplevel_methods/progress.rb +6 -2
  459. data/lib/cyberweb/toplevel_methods/quote.rb +7 -1
  460. data/lib/cyberweb/toplevel_methods/random.rb +4 -1
  461. data/lib/cyberweb/toplevel_methods/rds.rb +14 -6
  462. data/lib/cyberweb/toplevel_methods/read_and_display.rb +3 -2
  463. data/lib/cyberweb/toplevel_methods/return_head_start.rb +1 -1
  464. data/lib/cyberweb/toplevel_methods/return_html_fin.rb +6 -3
  465. data/lib/cyberweb/toplevel_methods/return_html_header.rb +8 -3
  466. data/lib/cyberweb/toplevel_methods/return_html_start.rb +7 -2
  467. data/lib/cyberweb/toplevel_methods/return_meta_collection.rb +15 -4
  468. data/lib/cyberweb/toplevel_methods/return_pwd.rb +4 -0
  469. data/lib/cyberweb/toplevel_methods/return_strict_doctype.rb +8 -7
  470. data/lib/cyberweb/toplevel_methods/roebe.rb +6 -0
  471. data/lib/cyberweb/toplevel_methods/s2.rb +3 -1
  472. data/lib/cyberweb/toplevel_methods/sanitize_url.rb +7 -5
  473. data/lib/cyberweb/toplevel_methods/sbr.rb +7 -7
  474. data/lib/cyberweb/toplevel_methods/server_base_directory.rb +7 -3
  475. data/lib/cyberweb/toplevel_methods/show_and_display.rb +15 -15
  476. data/lib/cyberweb/toplevel_methods/show_configuration.rb +2 -2
  477. data/lib/cyberweb/toplevel_methods/spacer.rb +5 -2
  478. data/lib/cyberweb/toplevel_methods/svg.rb +62 -4
  479. data/lib/cyberweb/toplevel_methods/tag.rb +8 -2
  480. data/lib/cyberweb/toplevel_methods/temp_directory.rb +2 -2
  481. data/lib/cyberweb/toplevel_methods/textile.rb +2 -2
  482. data/lib/cyberweb/toplevel_methods/title.rb +14 -2
  483. data/lib/cyberweb/toplevel_methods/video.rb +3 -4
  484. data/lib/cyberweb/toplevel_methods/write_what_into.rb +2 -0
  485. data/lib/cyberweb/utility_scripts/README.md +3 -4
  486. data/lib/cyberweb/utility_scripts/autogenerate_drop_shadow_rules/autogenerate_drop_shadow_rules.rb +71 -0
  487. data/lib/cyberweb/utility_scripts/create_standalone_html_page.rb +223 -0
  488. data/lib/cyberweb/utility_scripts/download_all_images_from_this_website.rb +143 -0
  489. data/lib/cyberweb/utility_scripts/download_balloon_css.rb +1 -1
  490. data/lib/cyberweb/utility_scripts/fix_incorrect_links_to_locally_existing_images_in_this_file.rb +142 -0
  491. data/lib/cyberweb/utility_scripts/html_to_cyberweb_converter.rb +235 -0
  492. data/lib/cyberweb/utility_scripts/images_to_html/images_to_html.rb +878 -0
  493. data/lib/cyberweb/utility_scripts/images_to_html/misc.rb +62 -0
  494. data/lib/cyberweb/utility_scripts/new_tags.rb +105 -0
  495. data/lib/cyberweb/utility_scripts/simple_index/README.md +9 -0
  496. data/lib/cyberweb/utility_scripts/simple_index/simple_index.rb +149 -0
  497. data/lib/cyberweb/version/version.rb +2 -2
  498. data/lib/cyberweb/vue/README.md +2 -0
  499. data/lib/cyberweb/vue/vue.rb +91 -0
  500. data/lib/cyberweb/web_images/array_listing_all_project_images.rb +1 -1
  501. data/lib/cyberweb/web_images/map_symbol_to_image_location.rb +60 -4
  502. data/lib/cyberweb/web_images/web_images.rb +37 -20
  503. data/lib/cyberweb/{constants/array_images.rb → web_object/display_output_and_report.rb} +11 -10
  504. data/lib/cyberweb/web_object/english.rb +55 -0
  505. data/lib/cyberweb/web_object/favicon.rb +103 -22
  506. data/lib/cyberweb/web_object/html_tags.rb +1433 -0
  507. data/lib/cyberweb/web_object/images.rb +428 -398
  508. data/lib/cyberweb/web_object/{javascript.rb → javascript_and_jquery.rb} +174 -276
  509. data/lib/cyberweb/web_object/{links.rb → link.rb} +185 -83
  510. data/lib/cyberweb/web_object/misc.rb +3934 -3928
  511. data/lib/cyberweb/web_object/reset.rb +153 -67
  512. data/lib/cyberweb/web_object/run.rb +1 -1
  513. data/lib/cyberweb/web_object/web_object.rb +3690 -49
  514. data/lib/cyberweb/web_scraper/scrape_this_url.rb +4 -2
  515. data/lib/cyberweb/webmin/biology_server.cgi +14 -15
  516. data/lib/cyberweb/webmin/calculator.cgi +2 -2
  517. data/lib/cyberweb/webmin/colour_chart.cgi +4 -5
  518. data/lib/cyberweb/webmin/comments.cgi +8 -7
  519. data/lib/cyberweb/webmin/comments_data +0 -0
  520. data/lib/cyberweb/webmin/constants.rb +1 -2
  521. data/lib/cyberweb/webmin/dictionary.cgi +3 -4
  522. data/lib/cyberweb/webmin/sys_info.cgi +1 -2
  523. data/lib/cyberweb/webmin/webforum.cgi +1 -2
  524. data/lib/cyberweb/webmin/webmin.cgi +2 -3
  525. data/lib/cyberweb/yaml/autogenerated_system_settings.yml +10 -10
  526. data/lib/cyberweb/yaml/custom_tags.yml +1 -1
  527. data/lib/cyberweb/yaml/html5_global_attributes.yml +5 -1
  528. data/lib/cyberweb/yaml/html_tag_legend.yml +2 -0
  529. data/lib/cyberweb/yaml/http_status_codes.yml +4 -1
  530. data/lib/cyberweb/yaml/load_these_yaml_files_by_default.yml +29 -0
  531. data/lib/cyberweb/yaml/project_configuration.yml +42 -31
  532. data/lib/cyberweb/yaml/video_attributes.yml +2 -0
  533. data/lib/cyberweb/yaml/web_images.yml +1 -1
  534. data/test/REST/simple.rb +7 -0
  535. data/test/complex_tests/simple_sinatra_example_using_cyberweb/simple.rb +1 -1
  536. data/test/complex_tests/sinatra_or_cyberweb/sinatra_or_cyberweb.cgi +1 -1
  537. data/test/complex_tests/sinatra_or_cyberweb/sinatra_or_cyberweb.rb +4 -4
  538. data/test/complex_tests/sinatra_or_cyberweb/sinatra_or_cyberweb.sinatra +1 -2
  539. data/test/complex_tests/testing_frames.cgi +3 -5
  540. data/test/complex_tests/testing_objectified_html_tags/testing_objectified_html_tags.html +28 -0
  541. data/test/complex_tests/testing_objectified_html_tags/testing_objectified_html_tags.rb +175 -0
  542. data/test/complex_tests/testing_style_variants/show_coloured_boxes.cgi +11 -7
  543. data/test/complex_tests/testing_tables.cgi +3 -3
  544. data/test/complex_tests/testing_the_cyberweb_shell.rb +2 -0
  545. data/test/complex_tests/testing_web_object.rb +5 -2
  546. data/test/css/README.md +4 -3
  547. data/test/css/return_the_content_of_these_css_classes.rb +5 -1
  548. data/test/css/test_hover_css/test_hover_css.cgi +59 -0
  549. data/test/css/test_ordered_list/test_ordered_list.cgi +31 -0
  550. data/test/css/testing_css_effects.cgi +3 -4
  551. data/test/css/testing_css_masking.cgi +3 -4
  552. data/test/hello_world/hello_world.cgi +6 -4
  553. data/test/html_template/html_template.rb +15 -0
  554. data/test/javascript/testing_custom_functions.js +24 -0
  555. data/test/javascript/testing_drag_and_drop_support.cgi +1 -1
  556. data/test/javascript/testing_on_click_change_opacity.cgi +4 -5
  557. data/test/javascript/testing_snowflakes.cgi +2 -2
  558. data/test/simple_tests/ad-hoc-test.cgi +5 -2
  559. data/test/simple_tests/cgi/hello_world_with_cyberweb.cgi +14 -0
  560. data/test/simple_tests/commandline_tests.rb +21 -15
  561. data/test/simple_tests/display_this_file.cgi +2 -2
  562. data/test/simple_tests/simple_html_example.cgi +2 -1
  563. data/test/simple_tests/simple_html_test_page/simple_html_test_page.html +20 -0
  564. data/test/simple_tests/simple_status_page.cgi +2 -2
  565. data/test/simple_tests/string_s2_test.rb +5 -0
  566. data/test/simple_tests/test_simple_string_as_input.rb +3 -1
  567. data/test/simple_tests/testing_base64_images.cgi +3 -4
  568. data/test/simple_tests/testing_checkboxes.cgi +22 -0
  569. data/test/simple_tests/testing_dragging_an_image.cgi +5 -6
  570. data/test/simple_tests/testing_editable_text.cgi +2 -3
  571. data/test/simple_tests/testing_email.cgi +6 -7
  572. data/test/simple_tests/testing_embedding_a_pdf_file.cgi +5 -5
  573. data/test/simple_tests/testing_google_charts.cgi +3 -3
  574. data/test/simple_tests/testing_html_forms.cgi +3 -3
  575. data/test/simple_tests/testing_html_template.rb +2 -0
  576. data/test/simple_tests/testing_popup_div.cgi +2 -3
  577. data/test/simple_tests/testing_return_dataset_without_any_comments.rb +3 -1
  578. data/test/simple_tests/testing_the_cap_box.cgi +3 -4
  579. data/test/simple_tests/testing_the_div_tag.cgi +3 -4
  580. data/test/simple_tests/testing_the_headers_tag.cgi +3 -4
  581. data/test/simple_tests/testing_the_html_colours.cgi +2 -3
  582. data/test/simple_tests/testing_the_info_box.cgi +2 -3
  583. data/test/simple_tests/testing_the_li_tag.cgi +2 -1
  584. data/test/simple_tests/testing_the_s2_method.rb +6 -1
  585. data/test/simple_tests/testing_the_select_tag.cgi +16 -8
  586. data/test/simple_tests/testing_the_span_tag.cgi +2 -3
  587. data/test/simple_tests/testing_web_images.rb +4 -2
  588. data/test/testing_html_tags/button_example.cgi +6 -7
  589. metadata +345 -151
  590. data/doc/CONVENTIONS.md +0 -7
  591. data/doc/CYBERWEB_TUTORIAL.cgi +0 -43
  592. data/doc/FUTURE_DESIGN_GOAL_CONSIDERATIONS.md +0 -13
  593. data/doc/todo/TODO_FOR_THE_CYBERWEB_PROJECT.md +0 -1089
  594. data/examples/css/shadow_example_in_CSS.cgi +0 -30
  595. data/lib/cyberweb/charts/README.md +0 -2
  596. data/lib/cyberweb/charts/google_charts.rb +0 -51
  597. data/lib/cyberweb/colours/random_colour.rb +0 -28
  598. data/lib/cyberweb/colours/sanitize_for_colours.rb +0 -95
  599. data/lib/cyberweb/constants/array_local_css_files.rb +0 -35
  600. data/lib/cyberweb/constants/configuration_file.rb +0 -33
  601. data/lib/cyberweb/constants/http_status_codes.rb +0 -42
  602. data/lib/cyberweb/constants/project_constants.rb +0 -99
  603. data/lib/cyberweb/constants/standalone_constants.rb +0 -309
  604. data/lib/cyberweb/csv/README.md +0 -2
  605. data/lib/cyberweb/generator/webpage_for_images.rb +0 -553
  606. data/lib/cyberweb/html_codes/README.md +0 -15
  607. data/lib/cyberweb/images/real/README.md +0 -6
  608. data/lib/cyberweb/io/README.md +0 -1
  609. data/lib/cyberweb/javascript/scroll.rb +0 -17
  610. data/lib/cyberweb/objectified_html_tags/README.md +0 -8
  611. data/lib/cyberweb/objectified_html_tags/base.rb +0 -376
  612. data/lib/cyberweb/predefined_and_freeform_methods/hash_css_class_to_use.rb +0 -55
  613. data/lib/cyberweb/requires/require_charts.rb +0 -20
  614. data/lib/cyberweb/web_object/css.rb +0 -627
  615. data/lib/cyberweb/web_object/evaluate.rb +0 -126
  616. data/lib/cyberweb/web_object/html_related_tags.rb +0 -320
  617. data/lib/cyberweb/web_object/initialize.rb +0 -51
  618. data/lib/cyberweb/web_object/input_related_functionality.rb +0 -414
  619. data/lib/cyberweb/web_object/languages.rb +0 -172
  620. data/lib/cyberweb/web_object/params.rb +0 -289
  621. data/lib/cyberweb/web_object/sinatra_related_functionality.rb +0 -30
  622. data/lib/cyberweb/web_object/sitemap.rb +0 -176
  623. data/lib/cyberweb/web_object/table.rb +0 -378
  624. data/test/complex_tests/testing_objectified_html_tags.rb +0 -82
  625. data/test/javascript/testing_cheerleader_javascript.cgi +0 -0
@@ -5,18 +5,19 @@
5
5
  # === Cyberweb::WebObject
6
6
  #
7
7
  # The purpose of the class WebObject is to represent a web-object,
8
- # an object which is able to output a full HTML page - as a long
8
+ # an object that is able to output a full HTML page - as a long
9
9
  # string - to any client.
10
10
  #
11
- # This HTML dump is stored in the instance variable :result, which is
12
- # kept within @internal_hash. You can query its content via the method
13
- # result? or string?.
11
+ # This HTML dump (the long string mentioned already) is stored in the
12
+ # instance variable :html_string, which is kept within @internal_hash.
13
+ # You can query its content via the method result? or string? or
14
+ # html_string?.
14
15
  #
15
16
  # The best way to use this class is to simply require it, firstly,
16
17
  # like by doing so:
17
18
  #
18
19
  # require 'web_object'
19
- # web_object = Cyberweb::WebObject.new
20
+ # web_object = Cyberweb::WebObject.new(ARGV)
20
21
  #
21
22
  # Afterwards, you can set the specific slots that you want to use on
22
23
  # the object individually, or in a batch-variant by using a {} Hash.
@@ -28,6 +29,14 @@
28
29
  # Once you have initiated a new web-object, there are several different
29
30
  # ways how to use that web-object.
30
31
  # =========================================================================== #
32
+ # The typical layout of a .html page should be similar to this:
33
+ #
34
+ # <!DOCTYPE html>
35
+ # <html lang="en">
36
+ # <head>
37
+ # <meta charset="utf-8"/>
38
+ #
39
+ # =========================================================================== #
31
40
  # The global CSS object follows this API here:
32
41
  #
33
42
  # Cyberweb::WebObject.new {{
@@ -47,64 +56,3683 @@ require 'cyberweb/base/base.rb'
47
56
 
48
57
  module Cyberweb
49
58
 
50
- class WebObject < Base # === Cyberweb::WebObject
59
+ class WebObject < ::Cyberweb::Base # === Cyberweb::WebObject
51
60
 
52
61
  require 'stringio'
62
+ require 'cyberweb/requires/require_web_images.rb'
53
63
  require 'html_tags/base/base_module.rb'
54
- require 'cyberweb/constants/array_local_css_files.rb'
55
- require 'cyberweb/constants/nl.rb'
56
- require 'cyberweb/constants/standalone_constants.rb'
64
+ require 'cyberweb/coloured_tags/coloured_tags.rb'
57
65
  require 'cyberweb/configuration/load_the_configuration_file.rb'
58
- require 'cyberweb/web_object/evaluate.rb'
66
+ require 'cyberweb/constants/constants.rb'
67
+ require 'cyberweb/classes/tooltips.rb'
68
+ require 'cyberweb/debug/debug.rb'
69
+ require 'cyberweb/javascript/dragula_collection.rb'
70
+ require 'cyberweb/javascript/javascript.rb'
71
+ require 'cyberweb/html_tags/fieldset.rb'
72
+ require 'cyberweb/html_tags/form.rb'
73
+ require 'cyberweb/html_tags/img.rb'
74
+ require 'cyberweb/html_tags/input.rb'
75
+ require 'cyberweb/html_tags/table.rb'
76
+ require 'cyberweb/html_tags/textarea.rb'
77
+ require 'cyberweb/predefined_and_freeform_methods/predefined_methods.rb'
78
+ require 'cyberweb/requires/require_web_images.rb'
79
+ require 'cyberweb/requires/require_the_toplevel_methods_files.rb'
80
+ Cyberweb.require_toplevel_methods_files # Pull in all cyberweb/toplevel_methods/ here.
81
+ begin
82
+ require 'beautiful_url/toplevel_methods/local_menu.rb'
83
+ rescue LoadError; end
84
+ require 'cyberweb/web_object/display_output_and_report.rb'
85
+ require 'cyberweb/web_object/english.rb'
59
86
  require 'cyberweb/web_object/favicon.rb'
60
- require 'cyberweb/web_object/html_related_tags.rb'
87
+ require 'cyberweb/web_object/html_tags.rb'
61
88
  require 'cyberweb/web_object/images.rb'
62
- require 'cyberweb/web_object/initialize.rb'
63
- require 'cyberweb/web_object/input_related_functionality.rb'
64
- require 'cyberweb/web_object/javascript.rb'
65
- require 'cyberweb/web_object/languages.rb'
89
+ require 'cyberweb/web_object/link.rb'
90
+ require 'cyberweb/web_object/javascript_and_jquery.rb'
66
91
  require 'cyberweb/web_object/misc.rb'
67
- require 'cyberweb/web_object/params.rb'
68
92
  require 'cyberweb/web_object/reset.rb'
69
93
  require 'cyberweb/web_object/run.rb'
70
- require 'cyberweb/web_object/sinatra_related_functionality.rb'
71
- require 'cyberweb/web_object/sitemap.rb'
72
- require 'cyberweb/web_object/table.rb'
73
- require 'cyberweb/toplevel_methods/name_of_img_dir.rb'
74
- require 'cyberweb/toplevel_methods/listing.rb'
75
- require 'cyberweb/toplevel_methods/quote.rb'
76
- require 'cyberweb/toplevel_methods/pdf.rb'
77
- require 'cyberweb/toplevel_methods/misc.rb'
78
- require 'cyberweb/toplevel_methods/sanitize_url.rb'
79
- require 'cyberweb/toplevel_methods/title.rb'
80
- require 'cyberweb/toplevel_methods/pdf.rb'
81
- require 'cyberweb/toplevel_methods/svg.rb'
82
- require 'cyberweb/toplevel_methods/css.rb'
83
- require 'cyberweb/toplevel_methods/return_html_to_head_start.rb'
84
- require 'cyberweb/toplevel_methods/show_configuration.rb'
85
- require 'cyberweb/toplevel_methods/string_body_start.rb'
86
- require 'cyberweb/toplevel_methods/web_object.rb'
87
- require 'cyberweb/coloured_tags/coloured_tags.rb'
88
- require 'cyberweb/debug/debug.rb'
89
- require 'cyberweb/classes/tooltips.rb'
90
- require 'cyberweb/predefined_and_freeform_methods/predefined_methods.rb'
91
- require 'cyberweb/javascript/popup.rb'
92
- require 'cyberweb/javascript/javascript_bundle.rb'
93
- require 'cyberweb/javascript/drag_and_drop.rb'
94
- require 'cyberweb/requires/require_web_images.rb'
95
- require 'cyberweb/html_tags/img.rb'
96
- require 'cyberweb/html_tags/form.rb'
97
- require 'cyberweb/html_tags/textarea.rb'
98
- require 'cyberweb/html_tags/fieldset.rb'
94
+
95
+ # ========================================================================= #
96
+ # === NAMESPACE
97
+ # ========================================================================= #
98
+ NAMESPACE = inspect
99
+
100
+ # ========================================================================= #
101
+ # === initialize
102
+ #
103
+ # Do note that all the methods that must be run everytime a new
104
+ # web_object is instantiated, are bundled together in the method
105
+ # called run().
106
+ #
107
+ # As of March 2014 the option to pass an argument to this class
108
+ # was re-enabled again. This can be used to pass a HTML string
109
+ # into the class as-is.
110
+ #
111
+ # An invocation example for this follows:
112
+ #
113
+ # x = Cyberweb::WebObject.new('<html><head></head><body><h1>Hello world!</body></html>')
114
+ #
115
+ # ========================================================================= #
116
+ def initialize(
117
+ commandline_arguments = ARGV,
118
+ run_already = true,
119
+ &block
120
+ )
121
+ reset
122
+ set_commandline_arguments(
123
+ commandline_arguments
124
+ )
125
+ # ======================================================================= #
126
+ # Designate a default title, if the configuration option determines so.
127
+ # This should come BEFORE we handle blocks but AFTER we called
128
+ # set_commandline_arguments().
129
+ # ======================================================================= #
130
+ set_title('SELF_NO_EXT') if use_title_automatically?
131
+ if block_given?
132
+ # ===================================================================== #
133
+ # Handle all blocks given to this method. This should come after
134
+ # we called set_title().
135
+ # ===================================================================== #
136
+ handle_these_calls(yield)
137
+ end
138
+ # ======================================================================= #
139
+ # Next register this as the new web-object. This should come AFTER
140
+ # we handled block invocation via .handle_these_calls().
141
+ # ======================================================================= #
142
+ ::Cyberweb.set_web_object(self)
143
+ run if run_already
144
+ end
145
+
146
+ # ========================================================================= #
147
+ # === table3
148
+ # ========================================================================= #
149
+ def table3(
150
+ css_class = '',
151
+ id = '',
152
+ css_style = '',
153
+ *content,
154
+ &block
155
+ )
156
+ addn(
157
+ string_table3(
158
+ css_class,
159
+ id,
160
+ css_style,
161
+ content,
162
+ &block
163
+ )
164
+ )
165
+ end
166
+
167
+ # ========================================================================= #
168
+ # === string_table3
169
+ #
170
+ # We will delegate towards Cyberweb.string_table3 for the
171
+ # functionality here.
172
+ # ========================================================================= #
173
+ def string_table3(
174
+ css_class = '',
175
+ id = '',
176
+ css_style = '',
177
+ *content,
178
+ &block
179
+ )
180
+ ::Cyberweb.string_table3(
181
+ css_class,
182
+ id,
183
+ css_style,
184
+ content,
185
+ &block
186
+ )
187
+ end
188
+
189
+ # ========================================================================= #
190
+ # === string_table2
191
+ # ========================================================================= #
192
+ def string_table2(
193
+ css_class = '',
194
+ the_id = '',
195
+ css_style = '',
196
+ *content,
197
+ &block
198
+ )
199
+ ::Cyberweb.string_table2(
200
+ css_class,
201
+ the_id,
202
+ css_style,
203
+ content,
204
+ &block
205
+ )
206
+ end
207
+
208
+ # ========================================================================= #
209
+ # === string_table2_with_heading
210
+ # ========================================================================= #
211
+ def string_table2_with_heading(
212
+ css_class = '',
213
+ id = '',
214
+ css_style = '',
215
+ *content
216
+ )
217
+ ::Cyberweb.string_table2_with_heading(
218
+ css_class, id, css_style,
219
+ content
220
+ )
221
+ end
222
+
223
+ # ========================================================================= #
224
+ # === table2
225
+ #
226
+ # This variant maks a two-elements-per-row HTML table.
227
+ #
228
+ # The last variable is the content; keep it even, if possible, e. g
229
+ # 2 elements or 4 or 6 and so forth.
230
+ # ========================================================================= #
231
+ def table2(
232
+ css_class = '',
233
+ id = '',
234
+ css_style = '',
235
+ *content,
236
+ &block
237
+ )
238
+ addn(
239
+ string_table2(
240
+ css_class,
241
+ id,
242
+ css_style,
243
+ content.flatten,
244
+ &block
245
+ )
246
+ )
247
+ end
248
+
249
+ # ========================================================================= #
250
+ # === add_simple_javascript_calculator
251
+ # ========================================================================= #
252
+ def add_simple_javascript_calculator
253
+ add_javascript_file :simple_calculator
254
+ addnl(
255
+ ::Cyberweb.return_html_code_for_the_javascript_calculator
256
+ )
257
+ end
258
+
259
+ # ========================================================================= #
260
+ # === attach_these_constants
261
+ #
262
+ # This is an "alternative" to "include Foobar" code.
263
+ # ========================================================================= #
264
+ def attach_these_constants(i)
265
+ Object.send(:include, i)
266
+ end; alias fancy_extend attach_these_constants # === fancy_extend
267
+ alias make_available attach_these_constants # === make_available
268
+ alias smart_include attach_these_constants # === smart_include
269
+ alias adhoc_include attach_these_constants # === adhoc_include
270
+
271
+ # ========================================================================= #
272
+ # === cmd1
273
+ # ========================================================================= #
274
+ def cmd1(
275
+ i = '',
276
+ optional_css_class = ::Cyberweb.command1?,
277
+ &block
278
+ )
279
+ if block_given? and (yield == :no_break)
280
+ ee(
281
+ string_span(i, optional_css_class)
282
+ )
283
+ else
284
+ e(i, optional_css_class)
285
+ end
286
+ end; alias cmd cmd1 # === cmd
287
+
288
+ # ========================================================================= #
289
+ # === return_css_for_tetris
290
+ #
291
+ # This is the CSS that will be returned when we want to enable the small
292
+ # tetris-game that is distributed with the cyberweb project.
293
+ # ========================================================================= #
294
+ def return_css_for_tetris
295
+ return ::Cyberweb.return_css_for_tetris
296
+ end
297
+
298
+ # ========================================================================= #
299
+ # === oop_div
300
+ # ========================================================================= #
301
+ def oop_div(
302
+ a, b = nil, &block
303
+ )
304
+ addnl(
305
+ ::Cyberweb::Objectified::HtmlTags::Div.new(a, b, &block).to_s
306
+ )
307
+ end
308
+
309
+ # ========================================================================= #
310
+ # === serve_webpage (serve tag, main serve)
311
+ #
312
+ # This will do the actual serving the webpage part.
313
+ #
314
+ # It can only serve @result, so you should have built up your web_object
315
+ # already before calling this method here.
316
+ # ========================================================================= #
317
+ def serve_webpage(
318
+ also_display = true
319
+ )
320
+ case also_display
321
+ # ======================================================================= #
322
+ # === :default
323
+ # ======================================================================= #
324
+ when :default
325
+ also_display = true
326
+ # ======================================================================= #
327
+ # === :do_not_display_anything
328
+ # ======================================================================= #
329
+ when :do_not_display_anything
330
+ also_display = false
331
+ end
332
+ @internal_hash[:already_served] = true
333
+ check_syntax_then_compress_the_main_string_then_remove_newlines
334
+ _ = main_string?
335
+ display if also_display
336
+ return _ # We always return the main string here.
337
+ end; alias serve serve_webpage # === serve
338
+ alias serv serve_webpage # === serv
339
+ alias ser serve_webpage # === ser
340
+ alias start serve_webpage # === start
341
+ alias serve_again serve_webpage # === serve_again
342
+ alias do_serve serve_webpage # === do_serve
343
+
344
+ # ========================================================================= #
345
+ # === path?
346
+ #
347
+ # Reader method for the @fixed_path variable, which stores the relative
348
+ # path to our LOCALHOST.
349
+ # ========================================================================= #
350
+ def path?
351
+ ::Cyberweb.converted_path
352
+ end; alias fixed_path path? # === fixed_path
353
+
354
+ # ========================================================================= #
355
+ # === meta_collection?
356
+ # ========================================================================= #
357
+ def meta_collection?
358
+ @internal_hash[:meta_collection]
359
+ end
360
+
361
+ # ======================================================================= #
362
+ # === append_meta_collection
363
+ # ======================================================================= #
364
+ def append_meta_collection
365
+ append(
366
+ return_meta_collection
367
+ )
368
+ end; alias append_the_meta_collection append_meta_collection # === append_the_meta_collection
369
+
370
+ # ========================================================================= #
371
+ # === meta_description
372
+ #
373
+ # Usage example for this method:
374
+ #
375
+ # meta_description 'This is a sitemap.'
376
+ #
377
+ # ========================================================================= #
378
+ def meta_description(
379
+ i = '20.08.2021'
380
+ )
381
+ @internal_hash[:meta_collection] <<
382
+ '<meta name="description" content="'+i.to_s+'"/>'+"\n"
383
+ end
384
+
385
+ # ========================================================================= #
386
+ # === add_relevant_meta_entries
387
+ #
388
+ # This will instantly append onto @_.
389
+ # ========================================================================= #
390
+ def add_relevant_meta_entries(
391
+ honour_checks = true
392
+ )
393
+ case honour_checks
394
+ # === :ignore_checks
395
+ when :ignore_checks
396
+ honour_checks = false
397
+ end
398
+ if honour_checks and use_unicode?
399
+ add_unicode_charset
400
+ else
401
+ add_unicode_charset
402
+ end
403
+ end
404
+
405
+ # ======================================================================= #
406
+ # === return_html_to_head_start
407
+ #
408
+ # This method will delegate to a toplevel method and ultimately
409
+ # return a String such as:
410
+ #
411
+ # "Content-type: text/html\n\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n"
412
+ #
413
+ # ======================================================================= #
414
+ def return_html_to_head_start
415
+ ::Cyberweb.return_html_to_head_start
416
+ end
417
+
418
+ # ========================================================================= #
419
+ # === p_default
420
+ #
421
+ # This is similar to p(), but the implicit CSS class 'default' will
422
+ # be used.
423
+ # ========================================================================= #
424
+ def p_default(
425
+ optional_css_class = '',
426
+ the_id = '',
427
+ optional_css_style = '',
428
+ &block
429
+ )
430
+ if optional_css_class.is_a? Hash
431
+ if optional_css_class.has_key? :id
432
+ the_id = optional_css_class.delete(:id)
433
+ end
434
+ if optional_css_class.is_a?(Hash) and optional_css_class.empty?
435
+ optional_css_class = ''
436
+ end
437
+ end
438
+ optional_css_class = optional_css_class.to_s.dup
439
+ optional_css_class.prepend('default ') # Make it the first argument.
440
+ p(
441
+ optional_css_class.strip,
442
+ the_id,
443
+ optional_css_style,
444
+ &block
445
+ )
446
+ end
447
+
448
+ # ========================================================================= #
449
+ # === create_database
450
+ # ========================================================================= #
451
+ def create_database
452
+ case database?
453
+ when :sqlite
454
+ require 'sqlite3'
455
+ db = SQLite3::Database.new '/Depot/j/test.db' # Open a database
456
+ # ===================================================================== #
457
+ # Create a database
458
+ # ===================================================================== #
459
+ # rows = db.execute <<-SQL
460
+ db.execute <<-SQL
461
+ create table numbers (
462
+ name varchar(30),
463
+ val int
464
+ );
465
+ SQL
466
+ {
467
+ 'one' => 1,
468
+ 'two' => 2,
469
+ }.each { |pair|
470
+ db.execute 'insert into numbers values ( ?, ? )', pair
471
+ }
472
+ # Execute inserts with parameter markers
473
+ db.execute("INSERT INTO students (name, email, grade, blog)
474
+ VALUES (?, ?, ?, ?)", ['joe', 'hoe@hotmail.com', '5', 'yo'])
475
+ # Find a few rows
476
+ db.execute( "select * from numbers" ) do |row|
477
+ p row
478
+ end
479
+ end
480
+ end
481
+
482
+ # ========================================================================= #
483
+ # === slight_indent
484
+ # ========================================================================= #
485
+ def slight_indent(i = '', optional_css_class = '')
486
+ e i, "padl0_5em #{optional_css_class}"
487
+ end; alias slight_ind slight_indent # === slight_ind
488
+ alias sind slight_indent # === sind
489
+
490
+ # ========================================================================= #
491
+ # === frage
492
+ # ========================================================================= #
493
+ def frage(
494
+ i = '',
495
+ optional_css_class = ''
496
+ )
497
+ h2 i, optional_css_class
498
+ end
499
+
500
+ # ========================================================================= #
501
+ # === fragebr
502
+ # ========================================================================= #
503
+ def fragebr(
504
+ i = '',
505
+ optional_css_class = ''
506
+ )
507
+ frage(i, optional_css_class)
508
+ br
509
+ end
510
+
511
+ # ========================================================================= #
512
+ # === do_show_sys_info
513
+ #
514
+ # This method will show some system-related information about the
515
+ # environment.
516
+ # ========================================================================= #
517
+ def do_show_sys_info(
518
+ css_class = 'FS1_1em bblack1 pad1empx BG_Black White'
519
+ )
520
+ div(css_class,'','margin:0.25em'){
521
+ h2 sg(:wings,'marr8px')+'Displaying some Sys Info stuff:',
522
+ 'lightblue'
523
+ p('pad4px'){
524
+ uptime = `uptime`
525
+ e 'Uptime since:','lgreen BOLD'
526
+ br
527
+ e uptime,'yel padl1em'
528
+ }
529
+ p('pad4px'){
530
+ ruby_version = `ruby --version`
531
+ e 'Ruby version:','lgreen BOLD'
532
+ br
533
+ e ruby_version,'yel padl1em BOLD'
534
+ br
535
+ ruby_gem_version = `gem --version`
536
+ e 'Ruby gem version:','lgreen BOLD'
537
+ br
538
+ e ruby_gem_version,'yel padl1em BOLD'
539
+ br
540
+ path_to_the_rubygem_installation_directory = Gem.vendor_dir
541
+ e 'Ruby installation directory:','lgreen BOLD'
542
+ br
543
+ e path_to_the_rubygem_installation_directory,'yel padl1em'
544
+ ruby_user_home = Gem.user_home
545
+ br
546
+ e 'Ruby user home:','lgreen BOLD'
547
+ br
548
+ e ruby_user_home.to_s,'yel padl1em'
549
+ }
550
+ p('pad4px mart0_2em') {
551
+ e 'Free Memory:','lgreen BOLD'
552
+ free = `free -l`
553
+ pre free
554
+ }
555
+ begin
556
+ p('pad4px mart0_2em'){
557
+ e 'Hdparm Settings:','lgreen BOLD'
558
+ # bl $LINUX_YAML/*roeb*
559
+ festplatte = '/dev/sda1'
560
+ hdparm = `hdparm -Tt #{festplatte}`
561
+ e hdparm,'yel padl1em'
562
+ br
563
+ e 'CPU-Info:','lgreen BOLD'
564
+ if File.exist? '/proc/cpuinfo' # We can run this only when that file exists.
565
+ begin
566
+ cpuinfo = `cat /proc/cpuinfo`
567
+ pre cpuinfo,'default'
568
+ rescue; end
569
+ end
570
+ }
571
+ rescue; end
572
+ h4 sg(:black_dot, 'marr10px')+
573
+ 'LSPCI','yellow'
574
+ p('pad4px mart0_2em'){
575
+ lspci = `lspci -v 2>&1`
576
+ pre lspci if lspci
577
+ }
578
+ p('pad4px mart0_2em'){
579
+ e 'Vmstat Settings:','lgreen'
580
+ vmstat=`vmstat`
581
+ pre vmstat
582
+ e 'Disk Free:','lgreen'
583
+ df=`df -ha`
584
+ df.gsub!(/\/dev\/hda1/,'<b class="lightblue">
585
+ <a href="file:///dev/">/dev/hda1</a></b>')
586
+ pre df
587
+ }
588
+ }
589
+ end
590
+
591
+ # ========================================================================= #
592
+ # === enable (enable tag)
593
+ # ========================================================================= #
594
+ def enable(
595
+ what = 'scroll'
596
+ )
597
+ case what.to_s
598
+ # ======================================================================= #
599
+ # === predefine_squares
600
+ # ======================================================================= #
601
+ when 'predefine_squares','predefinesquares','squares'
602
+ predefine_squares
603
+ # ======================================================================= #
604
+ # === drag_all_images
605
+ # ======================================================================= #
606
+ when /drag(_|-)?all(_|-)?images$/,
607
+ 'all_images',
608
+ '+images',
609
+ 'images+'
610
+ enable_drag_all_images
611
+ # ======================================================================= #
612
+ # === scroll
613
+ # ======================================================================= #
614
+ when 'scroll','default'
615
+ enable_scrolling
616
+ end
617
+ end
618
+
619
+ # ========================================================================= #
620
+ # === oop_progress
621
+ #
622
+ # The progress element represents the completion progress of a task. The
623
+ # method here will simply delegate towards the corresponding objectified
624
+ # HTML tag.
625
+ # ========================================================================= #
626
+ def oop_progress(
627
+ n_percent,
628
+ &block
629
+ )
630
+ addnl(
631
+ ::Cyberweb::Objectified::HtmlTags::Progress.new(n_percent, &block).to_s
632
+ )
633
+ end; alias progress oop_progress # === progress
634
+
635
+ # ========================================================================= #
636
+ # === text
637
+ # ========================================================================= #
638
+ def text(i)
639
+ Cyberweb::Objectified::HtmlTags::Span.new(i)
640
+ end; alias label_text text # === label_text
641
+
642
+ # ========================================================================= #
643
+ # === label
644
+ #
645
+ # This may look like so:
646
+ #
647
+ # <label for="male">Male</label><br>
648
+ #
649
+ # ========================================================================= #
650
+ def label(i)
651
+ addnl(
652
+ "<label>#{i}</label>"
653
+ )
654
+ end
655
+
656
+ # ========================================================================= #
657
+ # === oop_abbr
658
+ #
659
+ # This method makes use of the OOP variant for the abbr-html-tag.
660
+ # ========================================================================= #
661
+ def oop_abbr(a, b = nil)
662
+ addnl(
663
+ ::Cyberweb::Objectified::HtmlTags::Abbr.new(a, b).to_s
664
+ )
665
+ end
666
+
667
+ # ========================================================================= #
668
+ # === return_css_style_for_the_triangle_isosceles_bubble
669
+ #
670
+ # This method will return two CSS classes, which can be used if you
671
+ # want to make use of CSS bubbles. Currently only the downwards-facing
672
+ # triangle is available.
673
+ #
674
+ # The original source has been adapted from here:
675
+ #
676
+ # http://nicolasgallagher.com/pure-css-speech-bubbles/demo/
677
+ #
678
+ # ========================================================================= #
679
+ def return_css_style_for_the_triangle_isosceles_bubble(
680
+ additional_css_rules = ''
681
+ )
682
+ if additional_css_rules and additional_css_rules.empty?
683
+ additional_css_rules = 'margin: 1em 0 3em;'
684
+ end
685
+ return '.triangle_isosceles_bubble {
686
+ position:relative;
687
+ padding:15px;
688
+ '+additional_css_rules.to_s+';
689
+ width:500px;
690
+ color:#000;
691
+ background:#f3961c; /* default background for browsers without gradient support */
692
+ /* css3 */
693
+ background:linear-gradient(#f9d835, #f3961c);
694
+ border-radius:10px;
695
+ border: 1px solid black;
696
+ }
697
+
698
+ /* This class creates the triangle that faces downwards */
699
+ .triangle_isosceles_bubble:after {
700
+ content:"";
701
+ position:absolute;
702
+ bottom:-13px; /* value = - border-top-width - border-bottom-width */
703
+ left:30px; /* controls the horizontal position */
704
+ border-width: 15px 15px 0; /* vary these values to change the angle of the vertex */
705
+ border-style: solid;
706
+ border-color: #f3961c transparent;
707
+ display:block;
708
+ width:0;
709
+ }'
710
+ end
711
+
712
+ # ========================================================================= #
713
+ # === colour_gradient_left_to_right
714
+ #
715
+ # This method will "return" a CSS class, for a colour-gradient left to
716
+ # right.
717
+ # ========================================================================= #
718
+ def colour_gradient_left_to_right(
719
+ colour1 = :steelblue,
720
+ colour2 = :darkgreen,
721
+ css_name_that_will_be_returned = '.gradient1'
722
+ )
723
+ return "#{css_name_that_will_be_returned} {
724
+ background: linear-gradient(to right, #{colour1}, #{colour2});
725
+ }"
726
+ end; alias colour_gradient colour_gradient_left_to_right # === colour_gradient
727
+
728
+ # ========================================================================= #
729
+ # === colour_gradient_right_to_left
730
+ #
731
+ # This method will "return" a CSS class, for a colour-gradient left to
732
+ # right.
733
+ # ========================================================================= #
734
+ def colour_gradient_right_to_left(
735
+ colour1 = :steelblue,
736
+ colour2 = :darkgreen,
737
+ css_name_that_will_be_returned = '.gradient1'
738
+ )
739
+ return "#{css_name_that_will_be_returned} {
740
+ background: linear-gradient(to left, #{colour1}, #{colour2});
741
+ }"
742
+ end
743
+
744
+ # ========================================================================= #
745
+ # === css_class_or_no_class
746
+ # ========================================================================= #
747
+ def css_class_or_no_class(i = '')
748
+ unless i.to_s.empty?
749
+ i = " class=\"#{i}\""
750
+ end
751
+ return i
752
+ end
753
+
754
+ # ========================================================================= #
755
+ # === use_monospace_font
756
+ #
757
+ # By default this will use the "Lucida Console" font.
758
+ # ========================================================================= #
759
+ def use_monospace_font(
760
+ use_this_font = '"Lucida Console", Monaco, monospace'
761
+ )
762
+ use_this_font = use_this_font.dup if use_this_font.frozen?
763
+ use_this_font << ';' unless use_this_font.end_with? ';'
764
+ append_to_css_style '
765
+ body {
766
+ font-family: '+use_this_font+'
767
+ }
768
+ '
769
+ end; alias monospace_font use_monospace_font # === monospace_font
770
+
771
+ # ========================================================================= #
772
+ # === add_this_remote_css_page
773
+ #
774
+ # Use this method in order to include a remote css file.
775
+ #
776
+ # The argument to this method should be the remote URL that
777
+ # you want to access.
778
+ #
779
+ # Please use use this method solely for remote URLs.
780
+ #
781
+ # Specific Usage Example:
782
+ #
783
+ # css_remote_url 'http://www.playgroundblues.com/media/stylesheets/screen.css'
784
+ #
785
+ # ========================================================================= #
786
+ def add_this_remote_css_page(i)
787
+ addnl(
788
+ '<link rel="stylesheet" href="'+i+'" type="text/css" media="screen">'
789
+ )
790
+ end; alias css_remote_url add_this_remote_css_page # === css_remote_url
791
+ alias external_stylesheet add_this_remote_css_page # === external_stylesheet
792
+ alias remote_css add_this_remote_css_page # === remote_css
793
+ alias add_remote_css_page add_this_remote_css_page # === add_remote_css_page
794
+ alias css_file= add_this_remote_css_page # === css_file=
795
+ alias add_css_file add_this_remote_css_page # === add_css_file
796
+ alias css_file add_this_remote_css_page # === css_file
797
+ alias external_style_sheet add_this_remote_css_page # === external_style_sheet
798
+
799
+ # ========================================================================= #
800
+ # === check_whether_to_show_the_source_code
801
+ #
802
+ # This is the method that can display the source code of a given .cgi
803
+ # page.
804
+ # ========================================================================= #
805
+ def check_whether_to_show_the_source_code
806
+ # ======================================================================= #
807
+ # We must also check whether the configuration file allows us to
808
+ # show the source code.
809
+ # ======================================================================= #
810
+ if show_source? and ::Cyberweb.config['may_show_source']
811
+ _ = this_file?(:full_path)
812
+ ee '<html>'
813
+ ee '<head>'
814
+ # ===================================================================== #
815
+ # Add the following in order to enable on-click highlight at a later time.
816
+ # ===================================================================== #
817
+ ee HtmlTags.style('.highlight {
818
+ background:yellow;
819
+ }')
820
+ ee '</head>'
821
+ ee '<body>'
822
+ ee 'Next displaying the source code of the file <b>'+_+'</b>'
823
+ # ===================================================================== #
824
+ # The following has not yet been enabled. It shall follow this
825
+ # here:
826
+ #
827
+ # http://jsfiddle.net/kB7u2/1/
828
+ #
829
+ # ===================================================================== #
830
+ if false
831
+ output_this_javascript "
832
+ $('.stripe_table').hover(
833
+ function() {
834
+ $(this).addClass('highlight');
835
+ }, function() {
836
+ $(this).removeClass('highlight');
837
+ }
838
+ )"
839
+ end
840
+ dataset = File.readlines(_)
841
+ n_lines = dataset.size
842
+ ee '<h4>'+n_lines.to_s+' lines</h4>'
843
+ ee '<pre>'
844
+ # ===================================================================== #
845
+ # Presently, we will always display the index-number.
846
+ # ===================================================================== #
847
+ dataset.each_with_index {|content, index|
848
+ index += 1
849
+ ee '<span class="line_'+index.to_s+'"><b>'+index.to_s.ljust(5)+'</b>'+content+'</span>'
850
+ }
851
+ ee '</pre>'
852
+ ee '</body></html>'
853
+ exit
854
+ end
855
+ end
856
+
857
+ # ========================================================================= #
858
+ # === display_this_file_without_comments
859
+ #
860
+ # This method is similar to the method defined above; it will
861
+ # read in the dataset, before it will then remove all parts
862
+ # after ' #' in a given line. Furthermore, any lines starting
863
+ # with '#' will also be removed entirely.
864
+ # ========================================================================= #
865
+ def display_this_file_without_comments(
866
+ this_file,
867
+ optional_css_class = '',
868
+ optional_the_id = '',
869
+ optional_css_style = '',
870
+ &block
871
+ )
872
+ display_this_file(
873
+ this_file,
874
+ optional_css_class = '',
875
+ optional_the_id = '',
876
+ optional_css_style
877
+ ) { :strip_the_parts_after_a_comment }
878
+ end
879
+
880
+ # ========================================================================= #
881
+ # === white_font
882
+ # ========================================================================= #
883
+ def white_font
884
+ add_this_css_style(
885
+ 'body { color: white; }'
886
+ )
887
+ end
888
+
889
+ # ========================================================================= #
890
+ # === listing_css
891
+ # ========================================================================= #
892
+ def listing_css(i)
893
+ ::Cyberweb.listing_css_object = i
894
+ end
895
+
896
+ # ========================================================================= #
897
+ # === created_when
898
+ #
899
+ # This method can be used to add a meta-tag to the web-object (web-page)
900
+ # at hand.
901
+ #
902
+ # To read more on that meta-tag, look here:
903
+ #
904
+ # https://dublincore.org/resources/userguide/publishing_metadata/#dcterms:created
905
+ #
906
+ # Usage example:
907
+ #
908
+ # created_when('22.10.2021')
909
+ #
910
+ # ========================================================================= #
911
+ def created_when(
912
+ i = '20.08.2021'
913
+ )
914
+ @internal_hash[:additional_meta_collection] =
915
+ '<meta name="DCTERMS.created" content="'+i.to_s+'"/>'
916
+ end; alias created_on created_when # === created_on
917
+
918
+ # ========================================================================= #
919
+ # === autotitle
920
+ #
921
+ # This will simply capitalize the title in use.
922
+ # ========================================================================= #
923
+ def autotitle
924
+ set_title :capitalized
925
+ end
926
+
927
+ # ========================================================================= #
928
+ # === black_background
929
+ # ========================================================================= #
930
+ def black_background
931
+ set_background(:black)
932
+ end
933
+
934
+ # ========================================================================= #
935
+ # === append_newline
936
+ # ========================================================================= #
937
+ def append_newline
938
+ append :newline
939
+ end
940
+
941
+ # ========================================================================= #
942
+ # === append_path_to_dragula_js_file
943
+ # ========================================================================= #
944
+ def append_path_to_dragula_js_file
945
+ append(
946
+ '<script src="'+path_to_data?+
947
+ 'CODE/javascript/dragula.js" type="text/javascript"></script>'+N
948
+ )
949
+ end
950
+
951
+ # ========================================================================= #
952
+ # === append_chead_tag
953
+ #
954
+ # Close the html <head> tag here. We also append a newline.
955
+ # ========================================================================= #
956
+ def append_chead_tag
957
+ append "</head>\n"
958
+ end
959
+
960
+ # ========================================================================= #
961
+ # === tag
962
+ # ========================================================================= #
963
+ def tag(
964
+ this_tag,
965
+ optional_css_class = '',
966
+ optional_the_id = '',
967
+ optional_css_style = '',
968
+ optional_javascript = ''
969
+ )
970
+ _ = '<'+this_tag.to_s+
971
+ css_class_or_no_class(optional_css_class)+
972
+ id_or_no_id(optional_the_id)+
973
+ css_style_or_no_style(optional_css_style).dup
974
+ if optional_javascript and !optional_javascript.empty?
975
+ _ << ' javascript="'+javascript+'"'
976
+ end
977
+ _ << '>'
978
+ addnl(_)
979
+ end
980
+
981
+
982
+ # ========================================================================= #
983
+ # === escape_html
984
+ #
985
+ # Simply delegate towards the class-method here.
986
+ # ========================================================================= #
987
+ def escape_html(i)
988
+ addnl(
989
+ htmlescape(i)
990
+ )
991
+ end; alias htmlsanitize escape_html # === htmlsanitize
992
+ alias return_htmlentities escape_html # === return_htmlentities
993
+ alias return_htmlsanitized escape_html # === return_htmlsanitized
994
+ alias html_ready escape_html # === html_ready
995
+ alias html_escape escape_html # === html_escape
996
+ alias htitties escape_html # === htitties
997
+
998
+ # ========================================================================= #
999
+ # === inject_this_onto_that
1000
+ #
1001
+ # This has been added specifically for SimpleWidgets support. Highly
1002
+ # experimental as of September 2021.
1003
+ # ========================================================================= #
1004
+ def inject_this_onto_that(
1005
+ this,
1006
+ that
1007
+ )
1008
+ position = that.to_s.index('</div>')
1009
+ that[position,0] = this
1010
+ return that
1011
+ end
1012
+
1013
+ # ========================================================================= #
1014
+ # === spacer (spacer tag)
1015
+ # ========================================================================= #
1016
+ def spacer(
1017
+ i = :middle,
1018
+ optional_css_class = ''
1019
+ )
1020
+ case i
1021
+ # ======================================================================= #
1022
+ # === :middle
1023
+ # ======================================================================= #
1024
+ when :middle,
1025
+ :center,
1026
+ :default
1027
+ result = sg(
1028
+ :spacer,
1029
+ optional_css_class,
1030
+ '',
1031
+ 'text-align: center;
1032
+ display: block;
1033
+ margin-left: auto;
1034
+ margin-right: auto;'
1035
+ )
1036
+ end
1037
+ addnl(
1038
+ result
1039
+ )
1040
+ end; alias trenner spacer # === trenner
1041
+ alias spalter spacer # === spalter
1042
+ alias space spacer # === space
1043
+ alias spacer_center spacer # === spacer_center
1044
+ alias beautiful_spacer spacer # === beautiful_spacer
1045
+ alias fancy_spacer spacer # === fancy_spacer
1046
+ alias fancy_separator spacer # === fancy_separator
1047
+
1048
+ # ========================================================================= #
1049
+ # === hspacer
1050
+ # ========================================================================= #
1051
+ def hspacer
1052
+ spacer(:center)
1053
+ end
1054
+
1055
+ # ========================================================================= #
1056
+ # === register_the_constants?
1057
+ # ========================================================================= #
1058
+ def register_the_constants?
1059
+ @internal_hash[:register_the_constants]
1060
+ end
1061
+
1062
+ # ========================================================================= #
1063
+ # === consider_loading_addons_based_on_the_config_file
1064
+ #
1065
+ # This presently only attempts to load prawn.
1066
+ # ========================================================================= #
1067
+ def consider_loading_addons_based_on_the_config_file
1068
+ if use_prawn?
1069
+ # ===================================================================== #
1070
+ # Then we try to load prawn. We are silent about this.
1071
+ # ===================================================================== #
1072
+ begin
1073
+ require 'prawn'
1074
+ rescue LoadError; end
1075
+ end
1076
+ end
1077
+
1078
+ # ========================================================================= #
1079
+ # === do_show_source
1080
+ # ========================================================================= #
1081
+ def do_show_source
1082
+ @internal_hash[:show_source] = true
1083
+ end
1084
+
1085
+ # ========================================================================= #
1086
+ # === show_source?
1087
+ # ========================================================================= #
1088
+ def show_source?
1089
+ @internal_hash[:show_source]
1090
+ end
1091
+
1092
+ # ========================================================================= #
1093
+ # === is_a_sinatra_application?
1094
+ # ========================================================================= #
1095
+ def is_a_sinatra_application?
1096
+ @internal_hash[:is_a_sinatra_application]
1097
+ end; alias uses_sinatra? is_a_sinatra_application? # === uses_sinatra?
1098
+ alias are_we_using_sinatra? is_a_sinatra_application? # === are_we_using_sinatra?
1099
+
1100
+ # ========================================================================= #
1101
+ # === is_a_sinatra_application
1102
+ #
1103
+ # Setter method to designate a given application as a sinatra-application.
1104
+ # ========================================================================= #
1105
+ def is_a_sinatra_application
1106
+ @internal_hash[:is_a_sinatra_application] = true
1107
+ end; alias enable_sinatra_application is_a_sinatra_application # === enable_sinatra_application
1108
+
1109
+ # ========================================================================= #
1110
+ # === set_web_const
1111
+ #
1112
+ # Easier, internal wrapper towards setting a constant.
1113
+ #
1114
+ # All constants will be registered inside the variable
1115
+ # @array_predefined_constants, and the method here will ensure that.
1116
+ #
1117
+ # Currently the css class which we will use is hardset. I am not sure
1118
+ # if we should be able to change this, and if so, how to alter it.
1119
+ # For now it will stay as it is.
1120
+ #
1121
+ # Notice that this method requires the string_img() method to exist,
1122
+ # aliased to sg(), which is defined as part of the module Cyberweb.
1123
+ #
1124
+ # The constant ARRAY_PREDEFINED_CONSTANTS is defined in the file
1125
+ # bl $CYBER/constants/constants.rb
1126
+ # ========================================================================= #
1127
+ def set_web_const(
1128
+ name_of_the_constant,
1129
+ symbol,
1130
+ css_class_to_use = 'marr4px'
1131
+ )
1132
+ array_predefined_constants = ::Cyberweb.array_predefined_constants?
1133
+ unless array_predefined_constants.include? name_of_the_constant
1134
+ # ===================================================================== #
1135
+ # The next line will store the constant in a top-level variable, the
1136
+ # one referenced by Cyberweb.array_predefined_constants?
1137
+ # We will set on the Cyberweb namespace.
1138
+ # ===================================================================== #
1139
+ array_predefined_constants << name_of_the_constant
1140
+ # ===================================================================== #
1141
+ # The following code was disabled as of 07.08.2018. We do not want to
1142
+ # pollute the main Object namespace, so the constants now reside
1143
+ # within the Cyberweb "namespace" instead.
1144
+ # ===================================================================== #
1145
+ # Object.const_set(
1146
+ # name_of_the_constant, ::Cyberweb.sg(symbol, css_class_to_use)
1147
+ # )
1148
+ # ===================================================================== #
1149
+ # The constants will typically be like:
1150
+ # Cyberweb::PFEIL_RECHTS
1151
+ # ===================================================================== #
1152
+ # In October 2021 the following "if use_jquery?" line was removed.
1153
+ # You now have to specifically enable 'drag_' for the image ID
1154
+ # if you need draggable images here.
1155
+ # ===================================================================== #
1156
+ # if use_jquery?
1157
+ # use_this_as_the_image = sg(symbol, css_class_to_use) { :drag }
1158
+ # else
1159
+ use_this_as_the_image = sg(symbol, css_class_to_use)
1160
+ # end
1161
+ ::Cyberweb.const_set(
1162
+ name_of_the_constant,
1163
+ use_this_as_the_image
1164
+ )
1165
+ end
1166
+ end
1167
+
1168
+ # ========================================================================= #
1169
+ # === register_constants (constants tag, const tag)
1170
+ #
1171
+ # This is a convenience method. It will register some constants
1172
+ # which can then be used in your web-app.
1173
+ #
1174
+ # This will set constants such as Cyberweb::ALERT or Cyberweb::HANGMAN.
1175
+ # ========================================================================= #
1176
+ def register_constants
1177
+ set_web_const 'ALERT', :ausrufungszeichen
1178
+ set_web_const 'AUSRUFUNG', :ausrufungszeichen
1179
+ set_web_const 'ANMERKUNG', :ausrufungszeichen
1180
+ set_web_const 'ANM', :ausrufungszeichen
1181
+ set_web_const 'WICHTIG', :ausrufungszeichen
1182
+ set_web_const 'HANGMAN', :hangman
1183
+ set_web_const 'HALLOWEEN', :halloween
1184
+ set_web_const 'EXTERNAL', :external
1185
+ set_web_const 'EXTERN', :external
1186
+ set_web_const 'DONE_IMAGE', :checkbox_on
1187
+ set_web_const 'DONE', :checkbox_on
1188
+ set_web_const 'DOT1', :dot1
1189
+ set_web_const 'DOT2', :dot2
1190
+ set_web_const 'DOT3', :dot3
1191
+ set_web_const 'DOT4', :dot4
1192
+ set_web_const 'DOT5', :dot5
1193
+ set_web_const 'DOT6', :dot6
1194
+ set_web_const 'DOT7', :dot7
1195
+ set_web_const 'DOT8', :dot8
1196
+ set_web_const 'DOT9', :dot9
1197
+ set_web_const 'DOT10', :dot10
1198
+ set_web_const 'DOT11', :dot11
1199
+ set_web_const 'DOT12', :dot12
1200
+ set_web_const 'LENS', :lens
1201
+ set_web_const 'LEAF', :leaf
1202
+ set_web_const 'LEAF2', :leaf2
1203
+ set_web_const 'MONEY', :money
1204
+ set_web_const 'NEW', :new
1205
+ set_web_const 'NEWS', :new
1206
+ set_web_const 'RUBY', :ruby
1207
+ set_web_const 'PFEIL1', :pfeil1
1208
+ set_web_const 'PFEIL2', :pfeil2
1209
+ set_web_const 'PFEIL3', :pfeil3
1210
+ set_web_const 'HTML_LINK_IMG', :pfeil3
1211
+ set_web_const 'PFEIL4', :pfeil4
1212
+ set_web_const 'PFEIL5', :pfeil5
1213
+ set_web_const 'PFEIL6', :pfeil6
1214
+ set_web_const 'PFEIL7', :pfeil7
1215
+ set_web_const 'PFEIL8', :pfeil8
1216
+ set_web_const 'PFEIL9', :pfeil9
1217
+ set_web_const 'PFEIL10', :pfeil10
1218
+ set_web_const 'PFEIL11', :pfeil11
1219
+ set_web_const 'PFEIL12', :pfeil12
1220
+ set_web_const 'PFEIL_RECHTS', :pfeil_rechts
1221
+ end; alias do_define_convenience_constants register_constants # === do_define_convenience_constants
1222
+
1223
+ # ========================================================================= #
1224
+ # === parse_from_this_html_file
1225
+ # ========================================================================= #
1226
+ def parse_from_this_html_file(
1227
+ i =
1228
+ '/home/x/programming/ruby/src/cyberweb/test/simple_tests/simple_html_test_page/simple_html_test_page.html',
1229
+ be_verbose = true
1230
+ )
1231
+ do_not_use_the_internal_CSS_files # The new .html file must be simple.
1232
+ if i.is_a? Array
1233
+ i = i.first
1234
+ end
1235
+ if File.exist? i
1236
+ if be_verbose
1237
+ puts 'Now parsing the file '+i+'.'
1238
+ end
1239
+ dataset = File.read(i)
1240
+ regex_for_the_title = /<title>([a-zA-Z0-9 \n]+)<\/title>/ # See: https://rubular.com/r/atTe48o6iPG1TU
1241
+ if dataset.include?('<title')
1242
+ dataset =~ regex_for_the_title
1243
+ set_title($1)
1244
+ end
1245
+ regex_for_the_body = /<body>([\s\S]+)<\/body>/ # See: https://rubular.com/r/MhMR6p3eylZVZo
1246
+ if dataset.include?('<body')
1247
+ dataset =~ regex_for_the_body
1248
+ set_body_content($1)
1249
+ end
1250
+ end
1251
+ @internal_hash[:save_into_this_html_page] = return_pwd+
1252
+ 'new_file_'+
1253
+ File.basename(i).delete_suffix('.html')+
1254
+ '.html'
1255
+ build_up_the_html_string
1256
+ end; alias parse_from_this_html_file= parse_from_this_html_file # === parse_from_this_html_file=
1257
+ alias parse_html_file= parse_from_this_html_file # === parse_html_file=
1258
+
1259
+ # ========================================================================= #
1260
+ # === append_body_tag
1261
+ #
1262
+ # Open up the body-tag.
1263
+ # ========================================================================= #
1264
+ def append_body_tag
1265
+ addnl(
1266
+ return_body_tag
1267
+ )
1268
+ end
1269
+
1270
+ # ========================================================================= #
1271
+ # === use_utf
1272
+ # ========================================================================= #
1273
+ def use_utf
1274
+ set_encoding_to_use :utf # ← Better to pass it through a method.
1275
+ end; alias use_utf8 use_utf # === use_utf8
1276
+ alias use_unicode use_utf # === use_unicode
1277
+ alias use_utf_encoding use_utf # === use_utf_encoding
1278
+
1279
+ # ========================================================================= #
1280
+ # === save (save tag)
1281
+ #
1282
+ # This method will store the "HTML" stored inside the main string at
1283
+ # the variable :html_string into a local file.
1284
+ #
1285
+ # The first argument denotes the name of the file at hand, stored as
1286
+ # a .html file always.
1287
+ # ========================================================================= #
1288
+ def save(
1289
+ what = html_string?,
1290
+ use_this_as_filename = title?.to_s,
1291
+ into = :default
1292
+ )
1293
+ log_dir = log_dir?
1294
+ case use_this_as_filename
1295
+ # ======================================================================= #
1296
+ # === :default
1297
+ # ======================================================================= #
1298
+ when :default
1299
+ use_this_as_filename = title?.to_s.tr(' ','_')
1300
+ end
1301
+ case into
1302
+ # ======================================================================= #
1303
+ # === :save_into_this_html_page
1304
+ # ======================================================================= #
1305
+ when :save_into_this_html_page
1306
+ into = save_into_this_html_page?
1307
+ # ======================================================================= #
1308
+ # === :default
1309
+ #
1310
+ # Build the filename here.
1311
+ # ======================================================================= #
1312
+ when :default
1313
+ into = log_dir+
1314
+ use_this_as_filename.to_s+'.html'
1315
+ end
1316
+ mkdir(log_dir) unless File.directory? log_dir
1317
+ message = "Storing into the file #{into}."
1318
+ puts message
1319
+ e message
1320
+ write_what_into(what, into)
1321
+ end
1322
+
1323
+ # ========================================================================= #
1324
+ # === espan_no_newline
1325
+ # ========================================================================= #
1326
+ def espan_no_newline(
1327
+ i = '',
1328
+ optional_css_class = '',
1329
+ optional_the_id = '',
1330
+ optional_css_style = ''
1331
+ )
1332
+ add(
1333
+ string_s2(
1334
+ i.to_s,
1335
+ optional_css_class,
1336
+ optional_the_id,
1337
+ optional_css_style
1338
+ )
1339
+ )
1340
+ end; alias eee espan_no_newline # === eee
1341
+
1342
+ # ========================================================================= #
1343
+ # === anm
1344
+ # ========================================================================= #
1345
+ def anm(
1346
+ i = '', # Should be an empty String.
1347
+ optional_css_class = '',
1348
+ optional_the_id = '',
1349
+ optional_css_style = ''
1350
+ )
1351
+ addn(
1352
+ sg(:anmerkung, 'marr5px')+
1353
+ string_span(
1354
+ i, optional_css_class, optional_the_id, optional_css_style
1355
+ )
1356
+ )
1357
+ end; alias anmerkung anm # === anmerkung
1358
+
1359
+ require 'cyberweb/toplevel_methods/markdown.rb'
1360
+ # ========================================================================= #
1361
+ # === markdown
1362
+ # ========================================================================= #
1363
+ def markdown(i = '')
1364
+ addnl(
1365
+ ::Cyberweb.markdown(i)
1366
+ )
1367
+ end; alias markdown_display_this_file markdown # === markdown_display_this_file
1368
+ alias read_and_display_markdown markdown # === read_and_display_markdown
1369
+ alias show_md markdown # === show_md
1370
+ alias display_markdown markdown # === display_markdown
1371
+
1372
+ # ========================================================================= #
1373
+ # === add_svg_table
1374
+ # ========================================================================= #
1375
+ def add_svg_table(
1376
+ i = 'fancy_table'
1377
+ )
1378
+ addnl(
1379
+ Cyberweb.return_svg_table(i)
1380
+ )
1381
+ end
1382
+
1383
+ # ========================================================================= #
1384
+ # === log (log tag)
1385
+ #
1386
+ # This is the general log-related method. For now it simply saves into
1387
+ # a default file.
1388
+ # ========================================================================= #
1389
+ def log(what)
1390
+ into = log_dir?+'default.log'
1391
+ save(what, :default, into)
1392
+ end
1393
+
1394
+ # ========================================================================= #
1395
+ # === save_into_this_html_page?
1396
+ # ========================================================================= #
1397
+ def save_into_this_html_page?
1398
+ @internal_hash[:save_into_this_html_page]
1399
+ end
1400
+
1401
+ # ========================================================================= #
1402
+ # === string_lateron?
1403
+ # ========================================================================= #
1404
+ def string_lateron?
1405
+ @internal_hash[:string_lateron]
1406
+ end
1407
+
1408
+ # ========================================================================= #
1409
+ # === add_javascript_file
1410
+ #
1411
+ # This will show the javascript-file as-is. It can only be used for
1412
+ # javascript code that is bundled within the cyberweb project, as-is.
1413
+ # ========================================================================= #
1414
+ def add_javascript_file(i)
1415
+ if i.is_a? Symbol
1416
+ case i
1417
+ # ===================================================================== #
1418
+ # === :simple_calculator
1419
+ # ===================================================================== #
1420
+ when :simple_calculator
1421
+ i = File.absolute_path(
1422
+ project_base_dir?+'javascript_code/simple_calculator.js'
1423
+ )
1424
+ end
1425
+ if i and File.exist?(i)
1426
+ i = File.read(i)
1427
+ end
1428
+ end
1429
+ addnl(
1430
+ "<script>\n"+
1431
+ i.to_s+
1432
+ "</script>\n"
1433
+ )
1434
+ end
1435
+
1436
+ # ========================================================================= #
1437
+ # === set_body_content
1438
+ # ========================================================================= #
1439
+ def set_body_content(i)
1440
+ @internal_hash[:body_content] = i.to_s.dup
1441
+ end
1442
+
1443
+ # ========================================================================= #
1444
+ # === body_content?
1445
+ # ========================================================================= #
1446
+ def body_content?
1447
+ @internal_hash[:body_content]
1448
+ end; alias body_string? body_content? # === body_string?
1449
+
1450
+ # ========================================================================= #
1451
+ # === cmd2
1452
+ # ========================================================================= #
1453
+ def cmd2(
1454
+ i = '',
1455
+ optional_css_class = ::Cyberweb.command2?
1456
+ )
1457
+ e(i, optional_css_class)
1458
+ end
1459
+
1460
+ # ========================================================================= #
1461
+ # === cmd3
1462
+ # ========================================================================= #
1463
+ def cmd3(
1464
+ i = '',
1465
+ optional_css_class = ::Cyberweb.command3?
1466
+ )
1467
+ e(i, optional_css_class)
1468
+ end
1469
+
1470
+ # ========================================================================= #
1471
+ # === cmd1_is
1472
+ # ========================================================================= #
1473
+ def cmd1_is(i)
1474
+ Cyberweb.internal_hash?[:cmd1] = i
1475
+ end; alias cmd_is cmd1_is # === cmd_is
1476
+
1477
+ # ========================================================================= #
1478
+ # === cmd2_is
1479
+ # ========================================================================= #
1480
+ def cmd2_is(i)
1481
+ Cyberweb.internal_hash?[:cmd2] = i
1482
+ end
1483
+
1484
+ # ========================================================================= #
1485
+ # === cmd3_is
1486
+ # ========================================================================= #
1487
+ def cmd3_is(i)
1488
+ Cyberweb.internal_hash?[:cmd3] = i
1489
+ end
1490
+
1491
+ # ========================================================================= #
1492
+ # === cmd_pre
1493
+ # ========================================================================= #
1494
+ def cmd_pre(i)
1495
+ splitted = i.split(N)
1496
+ splitted.each {|entry| cmd(entry) }
1497
+ end; alias pre_cmd cmd_pre # === pre_cmd
1498
+
1499
+ # ========================================================================= #
1500
+ # === col_cmd
1501
+ # ========================================================================= #
1502
+ def col_cmd(
1503
+ i = '',
1504
+ optional_id = ''
1505
+ )
1506
+ ee(
1507
+ i, ::Cyberweb.internal_hash?[:col_cmd], optional_id
1508
+ )
1509
+ end; alias col col_cmd # === col
1510
+
1511
+ # ========================================================================= #
1512
+ # === append_to_cmd1
1513
+ # ========================================================================= #
1514
+ def append_to_cmd1(i = '')
1515
+ ::Cyberweb.append_to_cmd1(i)
1516
+ end; alias append_cmd1 append_to_cmd1 # === append_cmd1
1517
+
1518
+ # ========================================================================= #
1519
+ # === append_to_cmd2
1520
+ # ========================================================================= #
1521
+ def append_to_cmd2(i = '')
1522
+ ::Cyberweb.append_to_cmd2(i)
1523
+ end
1524
+
1525
+ # ========================================================================= #
1526
+ # === append_to_cmd3
1527
+ # ========================================================================= #
1528
+ def append_to_cmd3(i = '')
1529
+ ::Cyberweb.append_to_cmd3(i)
1530
+ end
1531
+
1532
+ # ========================================================================= #
1533
+ # === random_linear_gradient_background
1534
+ #
1535
+ # This method generates gradients via linear-gradient().
1536
+ #
1537
+ # The first argument to linear-gradient() is the "degree".
1538
+ # ========================================================================= #
1539
+ def random_linear_gradient_background
1540
+ degree = (0..180).to_a.sample.to_s+'deg'
1541
+ return 'background: linear-gradient('+degree+', '+random_colour+', '+random_colour+', '+random_colour+');'
1542
+ end
1543
+
1544
+ # ========================================================================= #
1545
+ # === linear_gradient_background
1546
+ #
1547
+ # Usage examples:
1548
+ #
1549
+ # linear_gradient_background(90, :steelblue, :darkgreen, :tomato)
1550
+ # linear_gradient_background(90, :steelblue, :darkgreen, :royalblue)
1551
+ #
1552
+ # ========================================================================= #
1553
+ def linear_gradient_background(
1554
+ degree_to_use = (0..180).to_a.sample.to_s+'deg',
1555
+ colour1 = random_colour,
1556
+ colour2 = random_colour,
1557
+ colour3 = random_colour
1558
+ )
1559
+ degree_to_use = degree_to_use.to_s.dup
1560
+ unless degree_to_use.end_with? 'deg'
1561
+ degree_to_use << 'deg'
1562
+ end
1563
+ return 'background: linear-gradient('+
1564
+ degree_to_use+', '+
1565
+ colour1.to_s+', '+
1566
+ colour2.to_s+', '+
1567
+ colour3.to_s+
1568
+ ');'
1569
+ end
1570
+
1571
+ # ========================================================================= #
1572
+ # === header_for_sitemap
1573
+ #
1574
+ # This is a header that can be used to generate a sitemap.
1575
+ #
1576
+ # Note that if it is used it will also automatically generate
1577
+ # a sitemap on the top right of the page. This was one major
1578
+ # reason why this method was created - I wanted to automatically
1579
+ # use a sitemap if I use such a header.
1580
+ # ========================================================================= #
1581
+ def header_for_sitemap(i)
1582
+ id = i.tr(' ','_').delete('⁺')
1583
+ register_sitemap(i, id)
1584
+ h2(i, '',id)
1585
+ end
1586
+
1587
+ # ========================================================================= #
1588
+ # === register_sitemap
1589
+ #
1590
+ # Use only this method to register an id to a sitemap. This is
1591
+ # done automatically when we invoke the method sitemap().
1592
+ #
1593
+ # This method will delegate towards the toplevel-method, on the Cyberweb
1594
+ # namespace.
1595
+ #
1596
+ # If the second argument called `modify_input` is set to true, we
1597
+ # will replace all occurrences of '_' with ' '. The reason for
1598
+ # this is that HTML ids should not contain ' ' characters.
1599
+ # ========================================================================= #
1600
+ def register_sitemap(
1601
+ i, modify_input = false
1602
+ )
1603
+ if i.is_a? Array
1604
+ i.each {|entry|
1605
+ register_sitemap(entry, modify_input)
1606
+ }
1607
+ else
1608
+ # ===================================================================== #
1609
+ # Next simply delegate onto the toplevel method called
1610
+ # Cyberweb.register_sitemap().
1611
+ # ===================================================================== #
1612
+ ::Cyberweb.register_sitemap(i, modify_input)
1613
+ end
1614
+ end; alias add_to_sitemap register_sitemap # === register_sitemap
1615
+ alias sitemap register_sitemap # === sitemap
1616
+
1617
+ # ========================================================================= #
1618
+ # === array_for_sitemap?
1619
+ #
1620
+ # Accessor-method towards the array-constant.
1621
+ # ========================================================================= #
1622
+ def array_for_sitemap?
1623
+ ::Cyberweb.array_for_sitemap?
1624
+ end; alias array_for_sitemap array_for_sitemap? # === array_for_sitemap
1625
+
1626
+ # ========================================================================= #
1627
+ # === sitemap_array
1628
+ # ========================================================================= #
1629
+ def sitemap_array(
1630
+ *array
1631
+ )
1632
+ array = [array].flatten.compact
1633
+ register_sitemap(array)
1634
+ div('mars1em') {
1635
+ h2 'Sitemap','gold BG_Black pad8px'
1636
+ registered_sitemap?.each {|entry|
1637
+ abr_self('#'+entry.downcase)
1638
+ }
1639
+ }
1640
+ # autogenerated_sitemap # And call the autogenerated sitemap method at once.
1641
+ end
1642
+
1643
+ # ========================================================================= #
1644
+ # === autogenerated_sitemap
1645
+ #
1646
+ # This method will autogenerate a default Sitemap (an intralink).
1647
+ #
1648
+ # If the second argument for `optional_id` is :sort, then this method will
1649
+ # sort the result first before displaying it.
1650
+ # ========================================================================= #
1651
+ def autogenerated_sitemap(
1652
+ css_class = '',
1653
+ optional_id = '', # This could be :sort.
1654
+ optional_css_style = 'top: 2px; right: 2px; background-color: #eee;',
1655
+ append_css = true, # By default we will append more CSS rules.
1656
+ &block
1657
+ )
1658
+ # ======================================================================= #
1659
+ # Obtain the dataset first.
1660
+ # ======================================================================= #
1661
+ registered_sitemaps = ::Cyberweb.array_registered_sitemaps?
1662
+ css_for_li_elements = 'marl1px darkblue'
1663
+ default_css_class_to_use = 'pad5px bblack1 black posab'
1664
+ if block_given?
1665
+ yielded = yield
1666
+ # ===================================================================== #
1667
+ # === Handle Blocks next
1668
+ # ===================================================================== #
1669
+ if yielded.is_a? Hash
1670
+ # =================================================================== #
1671
+ # === :css_style
1672
+ # =================================================================== #
1673
+ if yielded.has_key? :css_style
1674
+ _ = yielded.delete :css_style
1675
+ default_css_class_to_use = ''
1676
+ optional_css_style = _
1677
+ end
1678
+ end
1679
+ end
1680
+ case optional_id
1681
+ # ======================================================================= #
1682
+ # === :sort
1683
+ # ======================================================================= #
1684
+ when :sort
1685
+ registered_sitemaps.sort!
1686
+ optional_id = ''
1687
+ end
1688
+ if css_class.empty?
1689
+ if append_css # This is the default.
1690
+ css_class = css_class.dup if css_class.frozen?
1691
+ css_class << " #{default_css_class_to_use}"
1692
+ end
1693
+ else # Else, user passed arguments here.
1694
+ css_class = css_class.dup if css_class.frozen?
1695
+ css_class << " #{default_css_class_to_use}"
1696
+ end
1697
+ # ======================================================================= #
1698
+ # Next comes the <div> that will hold our sitemap. For now this
1699
+ # will always be a <div> element.
1700
+ # ======================================================================= #
1701
+ div(css_class, optional_id, optional_css_style) {
1702
+ ee html_comment('Sitemap tag')
1703
+ h2 'Sitemap','black whi martb2px pad2px s4px yel mar1px',
1704
+ 'SitemapHeader',
1705
+ 'background-color:darkblue;'
1706
+ # ===================================================================== #
1707
+ # Build up the proper <ul> tag next.
1708
+ # ===================================================================== #
1709
+ ul(id: 'SitemapNavigation') {
1710
+ registered_sitemaps.each { |sitemap_id|
1711
+ ee '<li class="'+css_for_li_elements+'">'
1712
+ a '#'+sanitize_id(sitemap_id),
1713
+ content: sitemap_id,
1714
+ css_class: 'darkblue'
1715
+ ee '</li>'
1716
+ }
1717
+ }
1718
+ }
1719
+ end; alias show_sitemap autogenerated_sitemap # === show_sitemap
1720
+ alias display_sitemap autogenerated_sitemap # === display_sitemap
1721
+ alias asitemap autogenerated_sitemap # === asitemap
1722
+ alias add_sitemap autogenerated_sitemap # === add_sitemap
1723
+
1724
+ # ========================================================================= #
1725
+ # === random_colour
1726
+ #
1727
+ # This method will return a random HTML colour, such as 'steelblue' or
1728
+ # 'darkgreen'.
1729
+ # ========================================================================= #
1730
+ def random_colour
1731
+ ::Cyberweb.all_html_colours.sample
1732
+ end
1733
+
1734
+ # ========================================================================= #
1735
+ # === registered_sitemap?
1736
+ # ========================================================================= #
1737
+ def registered_sitemap?
1738
+ ::Cyberweb.array_registered_sitemaps?
1739
+ end
1740
+
1741
+ # ========================================================================= #
1742
+ # === colourize_ruby_code
1743
+ # ========================================================================= #
1744
+ def colourize_ruby_code(i)
1745
+ ::Cyberweb.colourize_ruby_code(i)
1746
+ end
1747
+
1748
+ # ========================================================================= #
1749
+ # === table7
1750
+ # ========================================================================= #
1751
+ def table7(
1752
+ css_class = '', id = '', css_style = '', *content
1753
+ )
1754
+ addn(
1755
+ string_table7(
1756
+ css_class, id, css_style, content
1757
+ )
1758
+ )
1759
+ end
1760
+
1761
+ # ========================================================================= #
1762
+ # === string_table7
1763
+ # ========================================================================= #
1764
+ def string_table7(
1765
+ css_class = '', id = '', css_style = '', *content
1766
+ )
1767
+ # ======================================================================= #
1768
+ # To test, try:
1769
+ #
1770
+ # puts ::Cyberweb.string_table5('','','',%w( ah asjhk avshvasjkh vajhksavjhk avsjhvashkjavs ))
1771
+ #
1772
+ # ======================================================================= #
1773
+ ::Cyberweb.string_table7(
1774
+ css_class, id, css_style, content
1775
+ )
1776
+ end
1777
+
1778
+ # ========================================================================= #
1779
+ # === string_table5
1780
+ # ========================================================================= #
1781
+ def string_table5(
1782
+ css_class = '', id = '', css_style = '', *content
1783
+ )
1784
+ # ======================================================================= #
1785
+ # To test, try:
1786
+ #
1787
+ # puts ::Cyberweb.string_table5('','','',%w( ah asjhk avshvasjkh vajhksavjhk avsjhvashkjavs ))
1788
+ #
1789
+ # ======================================================================= #
1790
+ ::Cyberweb.string_table5(
1791
+ css_class, id, css_style, content
1792
+ )
1793
+ end
1794
+
1795
+ # ========================================================================= #
1796
+ # === parse_table
1797
+ # ========================================================================= #
1798
+ def parse_table(*args)
1799
+ addnl(
1800
+ ::Cyberweb.parse_table(args)
1801
+ )
1802
+ end
1803
+
1804
+ # ========================================================================= #
1805
+ # === n_steps_to_the_base_directory?
1806
+ # ========================================================================= #
1807
+ def n_steps_to_the_base_directory?
1808
+ Cyberweb.n_slashes_towards_the_server_base_directory
1809
+ end
1810
+
1811
+ # ========================================================================= #
1812
+ # === id_or_no_id
1813
+ #
1814
+ # The second argument is in particular used for draggable images.
1815
+ # ========================================================================= #
1816
+ def id_or_no_id(
1817
+ i = '',
1818
+ optional_url = nil
1819
+ )
1820
+ if i.is_a?(Hash) and i.has_key?(:id)
1821
+ i = i.delete(:id)
1822
+ end
1823
+ unless i.to_s.empty?
1824
+ case i
1825
+ # =============================================================== #
1826
+ # === :guess_draggable_id
1827
+ # =============================================================== #
1828
+ when :guess_draggable_id
1829
+ i = 'drag_'+File.basename(optional_url).
1830
+ gsub(File.extname(optional_url),'')
1831
+ end
1832
+ i = i.to_s
1833
+ # ===================================================================== #
1834
+ # We enable drag-support next. Keep in mind that the input can be
1835
+ # a symbol such as :drag, so we must check for that leading
1836
+ # string.
1837
+ # ===================================================================== #
1838
+ if i.start_with?('drag')
1839
+ register_this_id(i)
1840
+ end
1841
+ i = " id=\"#{i}\""
1842
+ end
1843
+ i
1844
+ end
1845
+
1846
+ # ========================================================================= #
1847
+ # === embed_this_pdf
1848
+ #
1849
+ # This method can be used to embed a .pdf file into your page. Using
1850
+ # width and height values is recommended but not mandatory.
1851
+ #
1852
+ # For more documentation, see these resources:
1853
+ #
1854
+ # https://pdfobject.com/markup/
1855
+ #
1856
+ # ========================================================================= #
1857
+ def embed_this_pdf(
1858
+ i,
1859
+ also_enable_link = false
1860
+ )
1861
+ case also_enable_link
1862
+ # === :also_enable_link
1863
+ when :also_enable_link
1864
+ also_enable_link = true
1865
+ end
1866
+ if also_enable_link
1867
+ pdf_image = sg(:pdf,'marr6px','','width:28px') # The pdf image.
1868
+ abr(i, content: pdf_image+'SELF_BASENAME')
1869
+ end
1870
+ result = '<object data="'+i.to_s+'" type="application/pdf" width="100%" height="100%">'+"\n"+
1871
+ '</object>'
1872
+ addnl(
1873
+ result
1874
+ )
1875
+ end; alias embed_pdf embed_this_pdf # === embed_pdf
1876
+ alias add_pdf embed_this_pdf # === add_pdf
1877
+ alias embed_this_pdf_file embed_this_pdf # === embed_this_pdf_file
1878
+
1879
+ # ========================================================================= #
1880
+ # === show_pdf
1881
+ # ========================================================================= #
1882
+ def show_pdf(i)
1883
+ addnl(
1884
+ ::Cyberweb.embed_this_pdf(i)
1885
+ )
1886
+ end
1887
+
1888
+ # ========================================================================= #
1889
+ # === htmlescape
1890
+ # ========================================================================= #
1891
+ def htmlescape(i)
1892
+ return ::Cyberweb.escape_html(i)
1893
+ end; alias htmlentities htmlescape # === htmlentities
1894
+ alias hescape htmlescape # === hescape
1895
+ alias htmltitties htmlescape # === htmltitties
1896
+
1897
+ # ========================================================================= #
1898
+ # === table12_with_heading
1899
+ # ========================================================================= #
1900
+ def table12_with_heading(css_class = '', id = '', css_style = '', *content)
1901
+ addn(
1902
+ string_table12_with_heading(
1903
+ css_class, id, css_style, content
1904
+ )
1905
+ )
1906
+ end
1907
+
1908
+ # ========================================================================= #
1909
+ # === table11_with_heading
1910
+ # ========================================================================= #
1911
+ def table11_with_heading(css_class = '', id = '', css_style = '', *content)
1912
+ addn(
1913
+ string_table11_with_heading(
1914
+ css_class, id, css_style, content
1915
+ )
1916
+ )
1917
+ end
1918
+
1919
+ # ========================================================================= #
1920
+ # === string_table11_with_heading
1921
+ # ========================================================================= #
1922
+ def string_table11_with_heading(
1923
+ css_class = '', id = '', css_style = '', *content
1924
+ )
1925
+ ::Cyberweb.string_table11_with_heading(
1926
+ css_class, id, css_style,
1927
+ content
1928
+ )
1929
+ end
1930
+
1931
+ # ========================================================================= #
1932
+ # === string_table12_with_heading
1933
+ # ========================================================================= #
1934
+ def string_table12_with_heading(css_class = '', id = '', css_style = '', *content)
1935
+ ::Cyberweb.string_table12_with_heading(
1936
+ css_class, id, css_style,
1937
+ content
1938
+ )
1939
+ end
1940
+
1941
+ # ========================================================================= #
1942
+ # === string_table5_with_heading
1943
+ # ========================================================================= #
1944
+ def string_table5_with_heading(css_class = '', id = '', css_style = '', *content)
1945
+ ::Cyberweb.string_table5_with_heading(
1946
+ css_class, id, css_style,
1947
+ content
1948
+ )
1949
+ end
1950
+
1951
+ # ========================================================================= #
1952
+ # === table5_with_heading
1953
+ # ========================================================================= #
1954
+ def table5_with_heading(css_class = '', id = '', css_style = '', *content)
1955
+ addn(
1956
+ string_table5_with_heading(
1957
+ css_class, id, css_style, content
1958
+ )
1959
+ )
1960
+ end
1961
+
1962
+ # ========================================================================= #
1963
+ # === table_set_css_class
1964
+ # ========================================================================= #
1965
+ def table_set_css_class(
1966
+ i = 'marl2em'
1967
+ )
1968
+ ::Cyberweb::Table.set_css_class(i)
1969
+ end
1970
+
1971
+ # ========================================================================= #
1972
+ # === table_padding=
1973
+ # ========================================================================= #
1974
+ def table_padding=(i = 10)
1975
+ ::Cyberweb::Table.padding = i
1976
+ end
1977
+
1978
+ # ========================================================================= #
1979
+ # === table_clear
1980
+ # ========================================================================= #
1981
+ def table_clear
1982
+ ::Cyberweb::Table.clear
1983
+ end
1984
+
1985
+ # ========================================================================= #
1986
+ # === table_parse
1987
+ # ========================================================================= #
1988
+ def table_parse(*i)
1989
+ addnl(
1990
+ ::Cyberweb::Table.parse(i)
1991
+ )
1992
+ end
1993
+
1994
+ # ========================================================================= #
1995
+ # === table2_from_this_file
1996
+ #
1997
+ # This variant will read from an existing file, ideally a markdown file
1998
+ # .md. One row in the HTML table corresponds to one line in the original
1999
+ # markdown file.
2000
+ #
2001
+ # Note that currently we will split on ':' which is hardcoded; not
2002
+ # sure whether this will change in the future or not.
2003
+ # ========================================================================= #
2004
+ def table2_from_this_file(
2005
+ optional_css_class = '',
2006
+ optional_the_id = '',
2007
+ optional_css_style = '',
2008
+ this_file = 'games_timeline.md'
2009
+ )
2010
+ if File.exist? this_file
2011
+ dataset = File.readlines(this_file, encoding: 'UTF-8').reject {|line|
2012
+ line.start_with?('#') or line.strip.empty? # Ignore comments and empty lines.
2013
+ }
2014
+ splitted_dataset = dataset.map {|entry|
2015
+ if entry.include? ':'
2016
+ splitted = entry.split(':')
2017
+ entry = [
2018
+ splitted[0 .. -2].join(':'),
2019
+ splitted[-1].strip
2020
+ ]
2021
+ end
2022
+ entry
2023
+ }
2024
+ dataset = splitted_dataset
2025
+ table2(
2026
+ optional_css_class,
2027
+ optional_the_id,
2028
+ optional_css_style,
2029
+ *dataset
2030
+ )
2031
+ else
2032
+ e '(line 5806) No file exists at '+this_file
2033
+ end
2034
+ end
2035
+
2036
+ # ========================================================================= #
2037
+ # === table2_with_heading
2038
+ # ========================================================================= #
2039
+ def table2_with_heading(
2040
+ css_class = '',
2041
+ id = '',
2042
+ css_style = '',
2043
+ *content
2044
+ )
2045
+ addn(
2046
+ string_table2_with_heading(
2047
+ css_class,
2048
+ id,
2049
+ css_style,
2050
+ content
2051
+ )
2052
+ )
2053
+ end
2054
+
2055
+ # ========================================================================= #
2056
+ # === string_table4
2057
+ # ========================================================================= #
2058
+ def string_table4(
2059
+ css_class = '',
2060
+ the_id = '',
2061
+ css_style = '',
2062
+ *content,
2063
+ &block
2064
+ )
2065
+ # ======================================================================= #
2066
+ # To test, try:
2067
+ #
2068
+ # puts ::Cyberweb.string_table4('','','',%w( ah asjhk avshvasjkh vajhksavjhk avsjhvashkjavs ))
2069
+ #
2070
+ # ======================================================================= #
2071
+ ::Cyberweb.string_table4(
2072
+ css_class,
2073
+ the_id,
2074
+ css_style,
2075
+ content,
2076
+ &block
2077
+ )
2078
+ end
2079
+
2080
+
2081
+ # ========================================================================= #
2082
+ # === display_all_images
2083
+ #
2084
+ # Use this when you just want to display all images.
2085
+ #
2086
+ # The first argument should be the location towards the
2087
+ # directory that holds all images.
2088
+ # ========================================================================= #
2089
+ def display_all_images(
2090
+ dir = ::Cyberweb.return_pwd,
2091
+ optional_css = 'bblack1'
2092
+ )
2093
+ if dir.is_a? Hash
2094
+ dir = dir.delete(:from) if dir.has_key? :from
2095
+ end
2096
+ if dir.include? '$'
2097
+ dir = ConvertGlobalEnv[dir]
2098
+ end
2099
+ unless Dir.exist? dir
2100
+ e 'It seems as if the directory at `'+dir+'` does not exist.'
2101
+ end
2102
+ all_the_images = get_images_from(dir)
2103
+ all_the_images.each {|file|
2104
+ file = rds(file)
2105
+ h3 file, 'slateblue'
2106
+ imgbr(
2107
+ file,
2108
+ optional_css
2109
+ )
2110
+ }
2111
+ end; alias display_images_from display_all_images # === display_images_from
2112
+ alias display_images display_all_images # === display_images
2113
+
2114
+ # ========================================================================= #
2115
+ # === show_admin_icons
2116
+ # ========================================================================= #
2117
+ def show_admin_icons
2118
+ ::Cyberweb.show_admin_icons
2119
+ end
2120
+
2121
+ # ========================================================================= #
2122
+ # === table4
2123
+ # ========================================================================= #
2124
+ def table4(
2125
+ css_class = '',
2126
+ the_id = '',
2127
+ css_style = '',
2128
+ *content,
2129
+ &block
2130
+ )
2131
+ addn(
2132
+ string_table4(
2133
+ css_class,
2134
+ the_id,
2135
+ css_style,
2136
+ content,
2137
+ &block
2138
+ )
2139
+ )
2140
+ end
2141
+
2142
+ # ========================================================================= #
2143
+ # === css_template1
2144
+ #
2145
+ # Before this method was added in April 2022 I used to invoke the
2146
+ # method css_style() via :template1 as the first argument. Using
2147
+ # a single method instead, aka css_template1(), made more sense
2148
+ # though.
2149
+ # ========================================================================= #
2150
+ def css_template1
2151
+ css_style :template1
2152
+ end
2153
+
2154
+ # ========================================================================= #
2155
+ # === css_style
2156
+ #
2157
+ # Use this method to define the css style for the given web object.
2158
+ #
2159
+ # If the last four characters of the argument provided to this method
2160
+ # end with ".css" then this method will try to read the file specified
2161
+ # therein. (In this case we assume that it must be a .css file that
2162
+ # was passed into this method.)
2163
+ #
2164
+ # In order to use templates, do something like the following:
2165
+ #
2166
+ # css_style = :template1
2167
+ #
2168
+ # :symbol names can be used, such as :template1, :template2
2169
+ # and so forth. Alternatively, you can pass a String, or embed
2170
+ # the template-variants via a format such as '#TEMPLATE1#', which
2171
+ # will be substituted with whatever :template1 would normally
2172
+ # return.
2173
+ # ========================================================================= #
2174
+ def css_style(
2175
+ i = :default
2176
+ )
2177
+ # ======================================================================= #
2178
+ # === Special handling of Symbols given here
2179
+ # ======================================================================= #
2180
+ if i.is_a? Symbol
2181
+ case i
2182
+ # ===================================================================== #
2183
+ # === :default
2184
+ #
2185
+ # This can be used like in this way:
2186
+ #
2187
+ # css_style :template1
2188
+ #
2189
+ # ===================================================================== #
2190
+ when :default,
2191
+ :template,
2192
+ :template1,
2193
+ :css_template1
2194
+ i = css_comment("Generated via `#{i}`")+
2195
+ TEMPLATE1 # <- This is CSS/default.css
2196
+ # ===================================================================== #
2197
+ # === :template2
2198
+ # ===================================================================== #
2199
+ when :template2
2200
+ i = css_comment('Generated via `'+i.to_s+'`')+
2201
+ TEMPLATE2
2202
+ # ===================================================================== #
2203
+ # === :code
2204
+ # ===================================================================== #
2205
+ when :code
2206
+ i = css_comment('Generated via `'+i.to_s+'`')+
2207
+ CODE_TEMPLATE
2208
+ # ===================================================================== #
2209
+ # === :template_ruby_regex
2210
+ # ===================================================================== #
2211
+ when :template_ruby_regex
2212
+ i = css_comment('Generated via `'+i.to_s+'`')+
2213
+ TEMPLATE_RUBY_REGEX
2214
+ end
2215
+ i = i.join('') if i.is_a? Array # Join them all.
2216
+ end
2217
+ # ======================================================================= #
2218
+ # Next, substitute for #TEMPLATE1 macro.
2219
+ # ======================================================================= #
2220
+ if i.to_s.include? '#TEMPLATE1'
2221
+ i = i.dup if i.frozen?
2222
+ i.gsub!(/#TEMPLATE1/, TEMPLATE1)
2223
+ end
2224
+ # ======================================================================= #
2225
+ # Read in .css files here. This will only be done if a certain variable
2226
+ # was set to true (which it is by default).
2227
+ # ======================================================================= #
2228
+ if i and i.end_with?('.css') and use_the_internal_CSS_files? # assume we pass a .css file here.
2229
+ i = readlines(i).join('') if File.exist?(i)
2230
+ end
2231
+ # ======================================================================= #
2232
+ # Next, we will always append to the @css_style instance variable.
2233
+ # This allows os to build-up the CSS for a webpage.
2234
+ # ======================================================================= #
2235
+ add_with_newline(
2236
+ return_css_style(i)
2237
+ )
2238
+ end; alias main_css_style css_style # === main_css_style
2239
+ alias main_css css_style # === main_css
2240
+ alias main_style css_style # === main_style
2241
+ alias css_main_style css_style # === css_main_style
2242
+ alias css_class css_style # === css_class
2243
+ alias css_classes css_style # === css_classes
2244
+ alias c_style= css_style # === c_style=
2245
+ alias c_class= css_style # === c_class=
2246
+ alias css_style= css_style # === css_style=
2247
+ alias general_css= css_style # === general_css=
2248
+ alias css= css_style # === css=
2249
+ alias c1= css_style # === c1=
2250
+ alias c1 css_style # === c1
2251
+ alias css_template= css_style # === css_template=
2252
+ alias css_main css_style # === css_main
2253
+ alias css_main_class css_style # === css_main_class
2254
+ alias css_code css_style # === css_code
2255
+ alias main_css_class css_style # === main_css_class
2256
+ alias css_style css_style # === css_style
2257
+ alias inline_css css_style # === inline_css
2258
+ alias append_to_css_style css_style # === append_to_css_style
2259
+ alias append_this_css css_style # === append_this_css
2260
+ alias add_css_style css_style # === add_css_style
2261
+
2262
+ # ========================================================================= #
2263
+ # === draggable_img_base64
2264
+ #
2265
+ # This method has to respond to css_class and css_style as well. This
2266
+ # may also be provided via a Hash.
2267
+ # ========================================================================= #
2268
+ def draggable_img_base64(
2269
+ i,
2270
+ css_class = '',
2271
+ css_style = ''
2272
+ )
2273
+ if css_class.is_a? Hash
2274
+ # ===================================================================== #
2275
+ # === :css_style
2276
+ # ===================================================================== #
2277
+ if css_class.has_key? :css_style
2278
+ css_style = css_class.delete(:css_style)
2279
+ end
2280
+ # ===================================================================== #
2281
+ # === :css_class
2282
+ #
2283
+ # This variant must come last.
2284
+ # ===================================================================== #
2285
+ if css_class.has_key? :css_class
2286
+ css_class = css_class.delete(:css_class)
2287
+ end
2288
+ end
2289
+ absolute_path_to_the_image = File.absolute_path(
2290
+ path_to_the_main_image_directory?.to_s+
2291
+ i.to_s
2292
+ )
2293
+ use_this_id = 'drag_'+File.basename(
2294
+ absolute_path_to_the_image
2295
+ ).delete_suffix(
2296
+ File.extname(absolute_path_to_the_image)
2297
+ ).downcase
2298
+ dataset = convert_image_to_base64(absolute_path_to_the_image)
2299
+
2300
+ addnl(
2301
+ return_base64_image(
2302
+ dataset, :infer, css_class, use_this_id, css_style
2303
+ )
2304
+ )
2305
+ end; alias draggable_base64img draggable_img_base64 # === draggable_base64img
2306
+
2307
+ # ========================================================================= #
2308
+ # === local_image_or_remote_image
2309
+ #
2310
+ # This method can be used to add a substitute image in the event that
2311
+ # a local image could not be found. Otherwise it behaves exactly like
2312
+ # image() does.
2313
+ # ========================================================================= #
2314
+ def local_image_or_remote_image(
2315
+ local_image = '',
2316
+ remote_image_substitute = '', # This one should be the remote URL.
2317
+ optional_css_class = '',
2318
+ optional_the_id = '',
2319
+ optional_css_style = '',
2320
+ alt_text = '',
2321
+ &block
2322
+ )
2323
+ # ======================================================================= #
2324
+ # We first have to decide whether the image exists or whether it does
2325
+ # not exist, at the specified location. If it exists then we can use
2326
+ # the regular img() call; otherwise we have to use the second argument
2327
+ # to this method.
2328
+ # ======================================================================= #
2329
+ assumed_path = rds(
2330
+ path_to_the_image_directory?+
2331
+ local_image
2332
+ )
2333
+ if File.exist?(assumed_path) and !local_image.empty?
2334
+ img(
2335
+ local_image,
2336
+ optional_css_class,
2337
+ optional_the_id,
2338
+ optional_css_style,
2339
+ alt_text,
2340
+ &block
2341
+ )
2342
+ else
2343
+ # ===================================================================== #
2344
+ # else we use a remote URL or a rescue URL anyway.
2345
+ # ===================================================================== #
2346
+ remote_img(
2347
+ remote_image_substitute,
2348
+ {
2349
+ css_class: optional_css_class,
2350
+ id: optional_the_id,
2351
+ css_style: optional_css_style
2352
+ },
2353
+ &block
2354
+ # alt_text is currently not handled here.
2355
+ )
2356
+ end
2357
+ end
2358
+
2359
+ # ========================================================================= #
2360
+ # === alt_text_or_no_alt_text
2361
+ # ========================================================================= #
2362
+ def alt_text_or_no_alt_text(i)
2363
+ unless i.to_s.empty?
2364
+ i = " alt=\"#{i}\""
2365
+ end
2366
+ return i
2367
+ end
2368
+
2369
+ # ========================================================================= #
2370
+ # === ibr
2371
+ # ========================================================================= #
2372
+ def ibr(content, optional_css_class = '')
2373
+ i(content)
2374
+ br
2375
+ end
2376
+
2377
+ # ========================================================================= #
2378
+ # === string_bold
2379
+ # ========================================================================= #
2380
+ def string_bold(
2381
+ i = '', optional_css_class = '', optional_the_id = ''
2382
+ )
2383
+ optional_css_class = optional_css_class.to_s.dup
2384
+ optional_css_class << ' BOLD'
2385
+ string_s2(i, optional_css_class.strip, optional_the_id)
2386
+ end
2387
+
2388
+ # ========================================================================= #
2389
+ # === bold
2390
+ #
2391
+ # This method will "create" an equivalent to the bold-tag.
2392
+ #
2393
+ # It must also keep backwards compatibility to invocations such
2394
+ # as:
2395
+ #
2396
+ # b 'Foobar:','yel'
2397
+ #
2398
+ # ========================================================================= #
2399
+ def bold(
2400
+ i = '', optional_css_class = '', optional_the_id = ''
2401
+ )
2402
+ addnl(
2403
+ string_bold(i, optional_css_class, optional_the_id)
2404
+ )
2405
+ end; alias b bold # === bold
2406
+
2407
+ # ========================================================================= #
2408
+ # === ip_is_allowed?
2409
+ #
2410
+ # This will forbid serving the site to unallowed visitors.
2411
+ # ========================================================================= #
2412
+ def ip_is_allowed?
2413
+ exit unless ALLOWED_IPS.include? VISITOR_IP
2414
+ end; alias forbidden ip_is_allowed? # === forbidden
2415
+
2416
+ # ========================================================================= #
2417
+ # === do_use_in_dir_images
2418
+ # ========================================================================= #
2419
+ def do_use_in_dir_images
2420
+ @config['use_in_dir_images'] = true
2421
+ # ======================================================================= #
2422
+ # Also keep track of the new path.
2423
+ # ======================================================================= #
2424
+ ::Cyberweb.set_path_to_images('')
2425
+ end; alias use_in_dir_images do_use_in_dir_images # === use_in_dir_images
2426
+
2427
+ # ========================================================================= #
2428
+ # === return_only_duplicates
2429
+ #
2430
+ # This method will return only duplicates. The input should be an
2431
+ # array.
2432
+ # ========================================================================= #
2433
+ def return_only_duplicates(array)
2434
+ duplicates = []
2435
+ array.each {|member| duplicates << member if array.count(member) > 1}
2436
+ duplicates.reject! {|entry| entry.empty? }
2437
+ duplicates.uniq
2438
+ end
2439
+
2440
+ # ========================================================================= #
2441
+ # === append_frame_string
2442
+ # ========================================================================= #
2443
+ def append_frame_string
2444
+ append @internal_hash[:frame_string]
2445
+ end
2446
+
2447
+ # ========================================================================= #
2448
+ # === append_chtml_tag
2449
+ # ========================================================================= #
2450
+ def append_chtml_tag
2451
+ append '</html>'+N
2452
+ end
2453
+
2454
+ # ========================================================================= #
2455
+ # === append_cbody_tag
2456
+ # ========================================================================= #
2457
+ def append_cbody_tag
2458
+ append '</body>'+N
2459
+ end
2460
+
2461
+ # ========================================================================= #
2462
+ # === append_cbody_and_chtml_tags
2463
+ #
2464
+ # This method will combine </body> and </html>.
2465
+ # ========================================================================= #
2466
+ def append_cbody_and_chtml_tags
2467
+ append_cbody_tag
2468
+ append_chtml_tag
2469
+ end; alias finish append_cbody_and_chtml_tags # === finish
2470
+ alias finalize append_cbody_and_chtml_tags # === finalize
2471
+
2472
+ # ========================================================================= #
2473
+ # === try_to_generate_pdf_file
2474
+ #
2475
+ # Use this method to generate a dump from a .cgi page.
2476
+ #
2477
+ # Invocation example from the commandline:
2478
+ #
2479
+ # rf biotut ?pdf
2480
+ #
2481
+ # ========================================================================= #
2482
+ def try_to_generate_pdf_file
2483
+ # ======================================================================= #
2484
+ # The directory where to generate our .pdf file into.
2485
+ # ======================================================================= #
2486
+ base_dir = '/home/Temp/lighty/'
2487
+ h2 'We will next generate a .pdf document of this webpage.'
2488
+ which_file = base_dir+'hello_world.pdf'
2489
+ which_file = base_dir+::Cyberweb.name_of_served_page?
2490
+ this_pdf_file = which_file.gsub(/\.cgi/,'')+'.pdf'
2491
+ target = ::Cyberweb.localhost?.to_s+ENV['SCRIPT_NAME']
2492
+ begin
2493
+ require 'serve_local_page'
2494
+ rescue LoadError; end
2495
+ if Object.const_defined? :ServeLocalPage
2496
+ # ===================================================================== #
2497
+ # Next, we will delegate towards class ServeLocalPage.
2498
+ # ===================================================================== #
2499
+ dataset = ServeLocalPage.new(target, :dont_save).dataset?
2500
+ # ===================================================================== #
2501
+ # This dataset contains all the HTML tags, which is not nice.
2502
+ # So we will get rid of them. But this may be a problem
2503
+ # lateron, so for now we won't do so.
2504
+ # ===================================================================== #
2505
+ # dataset = ::Cyberweb.remove_html(dataset)
2506
+ delete_file(this_pdf_file) if File.exist? this_pdf_file
2507
+ what = dataset
2508
+ into = which_file.gsub(/\.pdf/,'').gsub(/\.cgi/,'')+'.html'
2509
+ h3 'Storing into the .html file, by using wkhtmltopdf:
2510
+ <b class="darkblue BG_White s5px">'+into+'</b>.'
2511
+ a into, 'SELF',1,'marl3em'
2512
+ # ===================================================================== #
2513
+ # Next, create /Depot/Temp/lighty unless it already exists.
2514
+ # ===================================================================== #
2515
+ unless File.directory? File.dirname(this_pdf_file)
2516
+ mkdir(File.dirname(this_pdf_file))
2517
+ end
2518
+ # ===================================================================== #
2519
+ # Store into the .html page next.
2520
+ # ===================================================================== #
2521
+ write_what_into(what, into)
2522
+ h3 'Storing into .pdf file: <b class="darkblue BG_White s5px">'+this_pdf_file+'</b>.'
2523
+ a(
2524
+ this_pdf_file, content: 'SELF', css_class: 'marl3em'
2525
+ )
2526
+ br
2527
+ # ===================================================================== #
2528
+ # We essentially have two ways to generate a .pdf file:
2529
+ #
2530
+ # (1) by using wkhtmltopdf
2531
+ # (2) by using prawn
2532
+ #
2533
+ # (1) is more robust.
2534
+ # ===================================================================== #
2535
+ use_wkhtmltopdf = true # Hack. :D
2536
+ if use_wkhtmltopdf
2537
+ _ = 'wkhtmltopdf '+into+' '+this_pdf_file
2538
+ system _ # We are silent here.
2539
+ # =================================================================== #
2540
+ # Next, keep a reference to the generated .pdf file.
2541
+ # =================================================================== #
2542
+ ::Cyberweb.set_path_to_last_generated_pdf_document(
2543
+ this_pdf_file
2544
+ )
2545
+ else # else use prawn.
2546
+ Prawn::Document.generate(this_pdf_file, :page_size => 'A4') {
2547
+ font 'Times-Roman'
2548
+ text 'Hello Prawn!'
2549
+ text(dataset)
2550
+ }
2551
+ end
2552
+ spacer
2553
+ e 'It is now available at `<b>'+which_file.gsub(/\.cgi/,'.html')+'</b>`.'
2554
+ # spacer
2555
+ end
2556
+ spacer
2557
+ end
2558
+
2559
+ # ========================================================================= #
2560
+ # === show_all_registered_ids
2561
+ # ========================================================================= #
2562
+ def show_all_registered_ids
2563
+ h2 "Now showing all registered IDs of this page ("\
2564
+ "#{name_of_served_page?}):"
2565
+ all_ids?.each { |entry|
2566
+ marl2em sg(:pfeil_rechts,'marr4px')+'`'+entry+'`', 'red'
2567
+ if entry.include? ' '
2568
+ anm('^^^ Please note that the entry above '+
2569
+ '('+entry.to_s+') is invalid!','large red')
2570
+ end
2571
+ }
2572
+ end
2573
+
2574
+ # ========================================================================= #
2575
+ # === return_google_search_field
2576
+ # ========================================================================= #
2577
+ def return_google_search_field
2578
+ ee '<div id="PC_CENTER" class="s5px padtb3px wid44 martb2px posab bordorange1px" style="left:16em">
2579
+ <form name="dict" method="GET" action="https://www.google.com/search" class="spads5px">
2580
+ <p class="mar0">
2581
+ <input type="text" name="q" value="" size="20" onFocus="(this.select())" class="LBlue BG_Black1 borddorange1px" accesskey="e"/>
2582
+ <input type="image" name="btnG" src="../IMG/STD/GOOGLE.png" alt="Google" accesskey="R" class="bordblack1px VAM"/>
2583
+ <input type="hidden" name="ie" value="UTF-8"/>
2584
+ <input type="hidden" name="oe" value="UTF-8"/>
2585
+ <input type="hidden" name="hl" value="de"/>
2586
+ </p>
2587
+ </form>'
2588
+ end
2589
+
2590
+ # ========================================================================= #
2591
+ # === return_program_name
2592
+ #
2593
+ # This method will return the filename. So if you have an URL such as
2594
+ # bla/webforum.cgi then this method will simply return webforum.cgi.
2595
+ # ========================================================================= #
2596
+ def return_program_name(
2597
+ i = $PROGRAM_NAME
2598
+ )
2599
+ return ensure_main_encoding(
2600
+ File.basename(i)
2601
+ )
2602
+ end; alias filename? return_program_name # === filename?
2603
+
2604
+ # ========================================================================= #
2605
+ # === filename_without_extension?
2606
+ #
2607
+ # This will return the raw filename, without extension. For example,
2608
+ # if the file is "index.cgi", then this method will return the string
2609
+ # "index".
2610
+ # ========================================================================= #
2611
+ def filename_without_extension?
2612
+ _ = filename?
2613
+ return _.delete_suffix(File.extname(_))
2614
+ end
2615
+
2616
+ # ========================================================================= #
2617
+ # === doc (doc tag)
2618
+ # ========================================================================= #
2619
+ def doc(
2620
+ optional_css_class = 'pad5px',
2621
+ optional_the_id = '',
2622
+ optional_css_style = '',
2623
+ &block
2624
+ )
2625
+ consider_autoclosing_the_head_tag
2626
+ # ======================================================================= #
2627
+ # Append the <body> tag if is not yet part of the String.
2628
+ # ======================================================================= #
2629
+ splitted = result?.split("\n")
2630
+ unless splitted.any? {|line| line.start_with? '<body' }
2631
+ addnl(:body, @internal_hash[:body_css_class])
2632
+ end
2633
+ # ======================================================================= #
2634
+ # === Simply pass onto div() next
2635
+ # ======================================================================= #
2636
+ div(
2637
+ optional_css_class,
2638
+ optional_the_id,
2639
+ optional_css_style,
2640
+ &block
2641
+ )
2642
+ end; alias document doc # === document
2643
+
2644
+ # ========================================================================= #
2645
+ # === circle
2646
+ # ========================================================================= #
2647
+ def circle(
2648
+ hash = {
2649
+ height: 150,
2650
+ colour: :yellow,
2651
+ radius: :quarter_default_width,
2652
+ stroke_width: 10
2653
+ }
2654
+ )
2655
+ _ = ::Cyberweb.circle(hash)
2656
+ addnl(_)
2657
+ end
2658
+
2659
+ require 'cyberweb/toplevel_methods/audio.rb'
2660
+ # ========================================================================= #
2661
+ # === audio
2662
+ #
2663
+ # This method essentially creates an "audio" tag, for playing an
2664
+ # audio file.
2665
+ # ========================================================================= #
2666
+ def audio(
2667
+ url = '',
2668
+ optional_autoplay = false
2669
+ )
2670
+ addnl(
2671
+ ::Cyberweb.audio(url, optional_autoplay)
2672
+ )
2673
+ end
2674
+
2675
+ # ========================================================================= #
2676
+ # === frame_right
2677
+ #
2678
+ # Simply append to :frame_string, by calling the method in the
2679
+ # Cyberweb module.
2680
+ # ========================================================================= #
2681
+ def frame_right(i)
2682
+ @internal_hash[:frame_string] << ::Cyberweb.frame_right(i)
2683
+ end
2684
+
2685
+ # ========================================================================= #
2686
+ # === frame_left
2687
+ #
2688
+ # Simply append to :frame_string.
2689
+ # ========================================================================= #
2690
+ def frame_left(i)
2691
+ @internal_hash[:frame_string] << ::Cyberweb.frame_left(i)
2692
+ end
2693
+
2694
+ # ========================================================================= #
2695
+ # === earrow
2696
+ # ========================================================================= #
2697
+ def earrow(i = '')
2698
+ e "→ #{i}"
2699
+ end
2700
+
2701
+ # ========================================================================= #
2702
+ # === header_id
2703
+ # ========================================================================= #
2704
+ def header_id(
2705
+ i, optional_css_class = ''
2706
+ )
2707
+ use_this_id = i.dup.tr(' ','_').downcase
2708
+ h2(i, optional_css_class, use_this_id)
2709
+ end
2710
+
2711
+ # ========================================================================= #
2712
+ # === on_click_change_opacity
2713
+ # ========================================================================= #
2714
+ def on_click_change_opacity(
2715
+ use_this_id = 'pic',
2716
+ which_opacity_value_to_use = '0.92'
2717
+ )
2718
+ addnl(
2719
+ ::Cyberweb.return_on_click_change_opacity(
2720
+ use_this_id, which_opacity_value_to_use
2721
+ )
2722
+ )
2723
+ end; alias on_click_highlight on_click_change_opacity # === on_click_highlight
2724
+ alias highlight_tag on_click_change_opacity # === highlight_tag
2725
+ alias highlight on_click_change_opacity # === highlight
2726
+
2727
+ # ========================================================================= #
2728
+ # === base64_image
2729
+ #
2730
+ # This is distinct to other base64-related images within the Cyberweb
2731
+ # project. It will simply, and directly, add the given data.
2732
+ # ========================================================================= #
2733
+ def base64_image(
2734
+ i, image_type_to_use = :infer
2735
+ )
2736
+ addnl(
2737
+ return_base64_image(i, image_type_to_use)
2738
+ )
2739
+ end
2740
+
2741
+ # ========================================================================= #
2742
+ # === return_base64_image
2743
+ # ========================================================================= #
2744
+ def return_base64_image(
2745
+ i,
2746
+ image_type_to_use = :infer,
2747
+ optional_css_class = '',
2748
+ optional_the_id = '',
2749
+ optional_css_style = ''
2750
+ )
2751
+ case image_type_to_use
2752
+ # ======================================================================= #
2753
+ # === :infer
2754
+ # ======================================================================= #
2755
+ when :infer
2756
+ image_type_to_use = File.extname(i)
2757
+ if image_type_to_use.empty?
2758
+ image_type_to_use = 'png' # Rescue in this case.
2759
+ end
2760
+ end
2761
+ _ = '<img src="data:image/'+
2762
+ image_type_to_use.to_s.delete('.')+
2763
+ ';base64,'+i+'"'.dup
2764
+ if optional_css_class
2765
+ _ << css_class_or_no_class(optional_css_class)
2766
+ end
2767
+ if optional_the_id
2768
+ _ << id_or_no_id(optional_the_id)
2769
+ end
2770
+ if optional_css_style
2771
+ _ << css_style_or_no_style(optional_css_style)
2772
+ end
2773
+ _ << '>'
2774
+ return _
2775
+ end
2776
+
2777
+ # ========================================================================= #
2778
+ # === pfeil_rechts
2779
+ # ========================================================================= #
2780
+ def pfeil_rechts(
2781
+ use_this_css_class = 'marr4px'
2782
+ )
2783
+ sg(:pfeil_rechts, use_this_css_class)
2784
+ end
2785
+
2786
+ # ========================================================================= #
2787
+ # === return_wikipedia_search_field
2788
+ # ========================================================================= #
2789
+ def return_wikipedia_search_field
2790
+ ee '<form name="searchform" action="https://en.wikipedia.org/wiki/Special:Search" id="searchform" class="disin pads5px">
2791
+ <p class="">
2792
+ <input type="text" id="searchinput" name="search" class="LBlue BG_Black1 borddorange1px" accesskey=""/>
2793
+ <input type="submit" value="Go" name="go" class="LBlue BG_Black1 borddorange1px" accesskey=""/>
2794
+ <input type="submit" value="Search" name="fulltext" class="LBlue BG_Black1 borddorange1px" accesskey=""/>
2795
+ </p>
2796
+ </form>'
2797
+ end
2798
+
2799
+ # ========================================================================= #
2800
+ # === cform
2801
+ # ========================================================================= #
2802
+ def cform
2803
+ close(:form)
2804
+ end
2805
+
2806
+ # ========================================================================= #
2807
+ # === cfieldset
2808
+ # ========================================================================= #
2809
+ def cfieldset
2810
+ close(:fieldset)
2811
+ end
2812
+
2813
+ # ========================================================================= #
2814
+ # === sclose
2815
+ # ========================================================================= #
2816
+ def sclose(i)
2817
+ "</#{i}>"
2818
+ end
2819
+
2820
+ # ========================================================================= #
2821
+ # === cdl
2822
+ # ========================================================================= #
2823
+ def cdl
2824
+ close(:dl)
2825
+ end
2826
+
2827
+ # ========================================================================= #
2828
+ # === ctd
2829
+ # ========================================================================= #
2830
+ def ctd
2831
+ close(:td)
2832
+ end
2833
+
2834
+ # ========================================================================= #
2835
+ # === ctbody
2836
+ # ========================================================================= #
2837
+ def ctbody
2838
+ close(:tbody)
2839
+ end
2840
+
2841
+ # ========================================================================= #
2842
+ # === ctr
2843
+ # ========================================================================= #
2844
+ def ctr
2845
+ close(:tr)
2846
+ end
2847
+
2848
+ # ========================================================================= #
2849
+ # === ctdctr
2850
+ # ========================================================================= #
2851
+ def ctdctr
2852
+ addn(
2853
+ '</td></tr>'
2854
+ )
2855
+ end
2856
+
2857
+ # ========================================================================= #
2858
+ # === ctdtd
2859
+ # ========================================================================= #
2860
+ def ctdtd
2861
+ addn(
2862
+ '</td><td>'
2863
+ )
2864
+ end
2865
+
2866
+ # ========================================================================= #
2867
+ # === test_the_html_colours
2868
+ # ========================================================================= #
2869
+ def test_the_html_colours
2870
+ all_html_colours.each {|this_html_colour|
2871
+ e 'Hello world!', this_html_colour
2872
+ }
2873
+ end
2874
+
2875
+ # ========================================================================= #
2876
+ # === return_this_base64_image
2877
+ # ========================================================================= #
2878
+ def return_this_base64_image(
2879
+ i,
2880
+ optional_css_class = '',
2881
+ optional_css_id = ''
2882
+ )
2883
+ return ::Cyberweb.return_this_base64_image(
2884
+ i,
2885
+ optional_css_class,
2886
+ optional_css_id
2887
+ )
2888
+ end
2889
+
2890
+ # ========================================================================= #
2891
+ # === use_the_internal_CSS_files?
2892
+ # ========================================================================= #
2893
+ def use_the_internal_CSS_files?
2894
+ @internal_hash[:use_the_internal_CSS_files]
2895
+ end; alias use_internal_css_files? use_the_internal_CSS_files? # === use_internal_css_files?
2896
+
2897
+ # ========================================================================= #
2898
+ # === do_not_use_the_internal_CSS_files
2899
+ # ========================================================================= #
2900
+ def do_not_use_the_internal_CSS_files
2901
+ @internal_hash[:use_the_internal_CSS_files] = false
2902
+ end
2903
+
2904
+ # ========================================================================= #
2905
+ # === colour_chart
2906
+ # ========================================================================= #
2907
+ def colour_chart
2908
+ addnl(
2909
+ Cyberweb.colour_chart
2910
+ )
2911
+ end
2912
+
2913
+ # ========================================================================= #
2914
+ # === save_into_the_default_html_page
2915
+ # ========================================================================= #
2916
+ def save_into_the_default_html_page(
2917
+ into = @internal_hash[:save_into_this_html_page]
2918
+ )
2919
+ puts 'Storing into `'+into+'`.'
2920
+ append_body_string
2921
+ append_cbody_and_chtml_tags
2922
+ what = string?
2923
+ SaveFile.write_what_into(what, into)
2924
+ end
2925
+
2926
+ # ========================================================================= #
2927
+ # === append_body_string
2928
+ # ========================================================================= #
2929
+ def append_body_string
2930
+ addnl(body_string?)
2931
+ end
2932
+
2933
+ # ========================================================================= #
2934
+ # === add_string_lateron
2935
+ #
2936
+ # We can append a string to the main string lateron.
2937
+ # ========================================================================= #
2938
+ def add_string_lateron
2939
+ if string_lateron? and !string_lateron?.empty?
2940
+ @internal_hash[:html_string] << string_lateron?.to_s
2941
+ end
2942
+ end
2943
+
2944
+ # ========================================================================= #
2945
+ # === print_the_result (display tag, report tag)
2946
+ #
2947
+ # This method can be used to report (output) the content of the
2948
+ # main string.
2949
+ #
2950
+ # You may have to properly build up the main string before invoking
2951
+ # this method.
2952
+ # ========================================================================= #
2953
+ def print_the_result
2954
+ print result?
2955
+ end; alias display print_the_result # === display
2956
+ alias report print_the_result # === report
2957
+
2958
+ # ========================================================================= #
2959
+ # === consider_compressing_main_string
2960
+ #
2961
+ # Right now this just removes all newlines, if the configuration
2962
+ # option was set.
2963
+ # ========================================================================= #
2964
+ def consider_compressing_main_string
2965
+ if compress_main_string?
2966
+ @internal_hash[:html_string].delete! N
2967
+ end
2968
+ end
2969
+
2970
+ # ========================================================================= #
2971
+ # === check_syntax_then_compress_the_main_string_then_remove_newlines
2972
+ # ========================================================================= #
2973
+ def check_syntax_then_compress_the_main_string_then_remove_newlines
2974
+ consider_checking_for_new_syntax
2975
+ consider_compressing_main_string
2976
+ consider_removing_newlines
2977
+ end
2978
+
2979
+ # ========================================================================= #
2980
+ # === close_html
2981
+ # ========================================================================= #
2982
+ def close_html
2983
+ addn('</body>')
2984
+ addn('</html>')
2985
+ add_string_lateron
2986
+ end
2987
+
2988
+ # ========================================================================= #
2989
+ # === add_to_main_string_lateron
2990
+ # ========================================================================= #
2991
+ def add_to_main_string_lateron(i)
2992
+ @internal_hash[:string_lateron] << i
2993
+ end
2994
+
2995
+ # ========================================================================= #
2996
+ # === title?
2997
+ #
2998
+ # Query method for the title of our webpage.
2999
+ #
3000
+ # Note that the method .title() is an alias for .title?(); in the past,
3001
+ # before April 2022, it was an alias for .set_title() instead.
3002
+ # ========================================================================= #
3003
+ def title?
3004
+ ::Cyberweb.title?
3005
+ end; alias use_this_title? title? # === use_this_title?
3006
+ alias title title? # === use_this_title?
3007
+
3008
+ # ========================================================================= #
3009
+ # === add_html_comment
3010
+ #
3011
+ # This method will add the given input as HTML comment into the
3012
+ # web-object at hand.
3013
+ # ========================================================================= #
3014
+ def add_html_comment(i = '')
3015
+ addnl(
3016
+ ::Cyberweb.html_comment(i)
3017
+ )
3018
+ end; alias ehtml_comment add_html_comment # === ehtml_comment
3019
+ alias html_comment add_html_comment # === html_comment
3020
+
3021
+ # ========================================================================= #
3022
+ # === handle_these_calls
3023
+ # ========================================================================= #
3024
+ def handle_these_calls(&block)
3025
+ # ======================================================================= #
3026
+ # Delegate the block given to this class here, so that we can handle
3027
+ # method calls properly.
3028
+ # ======================================================================= #
3029
+ if block_given?
3030
+ instance_exec(&block)
3031
+ end
3032
+ end
3033
+
3034
+ # ========================================================================= #
3035
+ # === draw_circle
3036
+ # ========================================================================= #
3037
+ def draw_circle(
3038
+ hash = {
3039
+ width: 200, # in px
3040
+ height: 200, # in px
3041
+ background_color: :crimson,
3042
+ border_radius: '50%'
3043
+ }
3044
+ )
3045
+ addnl(
3046
+ ::Cyberweb.draw_circle(hash)
3047
+ )
3048
+ end
3049
+
3050
+ # ========================================================================= #
3051
+ # === generate_cap_box
3052
+ #
3053
+ # Usage example:
3054
+ #
3055
+ # generate_cap_box(
3056
+ # string_h1(
3057
+ # sg(:package,'marr8px','drag_job_listing')+
3058
+ # 'Job Listing',
3059
+ # 'job_listing'
3060
+ # )
3061
+ # ) {{ width: '95%' }}
3062
+ #
3063
+ # ========================================================================= #
3064
+ def generate_cap_box(
3065
+ use_this_title_for_the_upper_box = 'Hello world!',
3066
+ # ===================================================================== #
3067
+ # The next variable is the inner content - by default it will
3068
+ # be empty.
3069
+ # ===================================================================== #
3070
+ title_for_the_content_header = '',
3071
+ inner_content = '', # This is the inner content.<br>Looks fancy!<br>',
3072
+ border_to_use = '3px solid #2a2a2a',
3073
+ box_width = '700px'
3074
+ )
3075
+ ::Cyberweb.generate_cap_box(
3076
+ use_this_title_for_the_upper_box,
3077
+ title_for_the_content_header,
3078
+ inner_content,
3079
+ border_to_use,
3080
+ box_width
3081
+ )
3082
+ end
3083
+
3084
+ # ========================================================================= #
3085
+ # === javascript?
3086
+ # ========================================================================= #
3087
+ def javascript?
3088
+ @internal_hash[:javascript]
3089
+ end
3090
+
3091
+ require 'cyberweb/javascript/on_click_change_opacity.rb'
3092
+ # ========================================================================= #
3093
+ # === on_click_make_darker
3094
+ # ========================================================================= #
3095
+ def on_click_make_darker(this_id, opacity = '0.90')
3096
+ addn(
3097
+ ::Cyberweb.on_click_make_darker(this_id, opacity)
3098
+ )
3099
+ end
3100
+
3101
+ # ========================================================================= #
3102
+ # === datume
3103
+ #
3104
+ # Like datum() but for english.
3105
+ # ========================================================================= #
3106
+ def datume(
3107
+ welches_datum = '',
3108
+ css_class = 'martb4px s2px yel',
3109
+ optional_id = nil,
3110
+ optional_css_style = ''
3111
+ )
3112
+ if optional_id.is_a? Hash
3113
+ optional_id = optional_id.delete(:id)
3114
+ end
3115
+ optional_id = optional_id.to_s
3116
+ welches_datum = date_today if welches_datum.empty? # Ask the method above.
3117
+ p(css_class, optional_id, optional_css_style) {
3118
+ espan "<ud class=\"BOLD\">Date</ud>: "\
3119
+ "<b>#{welches_datum}</b>"
3120
+ }
3121
+ end
3122
+
3123
+ # ========================================================================= #
3124
+ # === close_html_then_serve_the_webpage
3125
+ # ========================================================================= #
3126
+ def close_html_then_serve_the_webpage
3127
+ close_html
3128
+ serve_webpage
3129
+ end
3130
+
3131
+ # ========================================================================= #
3132
+ # === datum
3133
+ #
3134
+ # Display datum. The argument `welches_datum` will be empty by default
3135
+ # and will in this case call the method date_today().
3136
+ #
3137
+ # Usage examples:
3138
+ #
3139
+ # datum '06.08.2008','BG_Black yel wid20 pad4px', id: 'datum'
3140
+ #
3141
+ # ========================================================================= #
3142
+ def datum(
3143
+ welches_datum = '',
3144
+ css_class = 'martb4px s2px yel',
3145
+ optional_id = nil,
3146
+ optional_css_style = ''
3147
+ )
3148
+ if optional_id.is_a? Hash
3149
+ optional_id = optional_id.delete(:id)
3150
+ end
3151
+ optional_id = optional_id.to_s
3152
+ welches_datum = date_today if welches_datum.empty? # Ask the method above.
3153
+ p(css_class, optional_id, optional_css_style) {
3154
+ espan "<ud class=\"BOLD\">Datum</ud>: "\
3155
+ "<b>#{welches_datum}</b>"
3156
+ }
3157
+ end; alias show_datum datum # === show_datum
3158
+ alias datumg datum # === datumg
3159
+
3160
+ # ========================================================================= #
3161
+ # === marl1em
3162
+ # ========================================================================= #
3163
+ def marl1em(
3164
+ i = '',
3165
+ optional_css_class = '',
3166
+ optional_the_id = ''
3167
+ )
3168
+ optional_css_class = optional_css_class.dup
3169
+ optional_css_class << ' marl1em'
3170
+ s2(i, optional_css_class.strip)
3171
+ end
3172
+
3173
+ # ========================================================================= #
3174
+ # === marl2em
3175
+ # ========================================================================= #
3176
+ def marl2em(
3177
+ i = '',
3178
+ optional_css_class = '',
3179
+ optional_the_id = ''
3180
+ )
3181
+ optional_css_class = optional_css_class.dup
3182
+ optional_css_class << ' marl2em'
3183
+ s2(i, optional_css_class.strip)
3184
+ end
3185
+
3186
+ # ========================================================================= #
3187
+ # === marl3em
3188
+ # ========================================================================= #
3189
+ def marl3em(
3190
+ i = '',
3191
+ optional_css_class = '',
3192
+ optional_the_id = ''
3193
+ )
3194
+ optional_css_class = optional_css_class.dup
3195
+ optional_css_class << ' marl3em'
3196
+ s2(i, optional_css_class.strip, optional_the_id)
3197
+ end
3198
+
3199
+ # ========================================================================= #
3200
+ # === default_doc_type?
3201
+ # ========================================================================= #
3202
+ def default_doc_type?
3203
+ DOCTYPE_HTML5
3204
+ end
3205
+
3206
+ # ========================================================================= #
3207
+ # === german_unicode
3208
+ # ========================================================================= #
3209
+ def german_unicode
3210
+ use_german
3211
+ use_unicode
3212
+ end
3213
+
3214
+ # ========================================================================= #
3215
+ # === german_trinity
3216
+ #
3217
+ # This variant specifically does NOT force the use of jquery since as
3218
+ # of May 2021. If you want to force jquery, use the method
3219
+ # called german_unicode_and_jquery() instead.
3220
+ #
3221
+ # Strictly speaking the word "trinity" is thus no longer correct, but
3222
+ # for the time being it will be retained.
3223
+ # ========================================================================= #
3224
+ def german_trinity
3225
+ german_unicode # This bundles "use_german" and "use_unicode".
3226
+ add_html_comment("\nThis website is making use of german.\n")
3227
+ add_relevant_meta_entries(:ignore_checks)
3228
+ end; alias use_unicode_german_and_jquery german_trinity # === use_unicode_german_and_jquery
3229
+ alias trinity_german german_trinity # === trinity_german
3230
+ alias trinity german_trinity # === trinity
3231
+
3232
+ # ========================================================================= #
3233
+ # === language
3234
+ #
3235
+ # You can use this method to specify a certain language in order to
3236
+ # use for the given web page. I tend to use this to remind myself
3237
+ # in which language I shall write a web-page in, e. g. usually
3238
+ # either in german, or more commonly these days, in english.
3239
+ #
3240
+ # Invocation example:
3241
+ #
3242
+ # language :english
3243
+ #
3244
+ # ========================================================================= #
3245
+ def language(
3246
+ which_language = nil
3247
+ )
3248
+ case which_language
3249
+ # ======================================================================= #
3250
+ # === eng
3251
+ # ======================================================================= #
3252
+ when 'eng',
3253
+ 'e',
3254
+ 'en',
3255
+ 'default'
3256
+ which_language = 'english'
3257
+ # ======================================================================= #
3258
+ # === ger
3259
+ # ======================================================================= #
3260
+ when 'ger',
3261
+ 'g',
3262
+ 'ge',
3263
+ 'german',
3264
+ 'deutsch'
3265
+ which_language = 'german'
3266
+ end
3267
+ @internal_hash[:language] = which_language.to_s # Will be kept as a String.
3268
+ end
3269
+
3270
+ # ========================================================================= #
3271
+ # === german_unicode_and_jquery
3272
+ #
3273
+ # This convenience method will enable german language layout for a
3274
+ # webpage, jquery-drag-and-drop support, as well as declare that
3275
+ # the page at hand uses unicode characters (and thus needs support
3276
+ # for unicode).
3277
+ # ========================================================================= #
3278
+ def german_unicode_and_jquery
3279
+ do_use_jquery
3280
+ german_trinity
3281
+ end; alias german_unicode_jquery german_unicode_and_jquery # === german_unicode_jquery
3282
+ alias use_jquery_german_and_unicode german_unicode_and_jquery # === german_unicode_and_jquery
3283
+
3284
+ # ========================================================================= #
3285
+ # === use_german
3286
+ #
3287
+ # This is an easier shortcut to designate that the current webpage
3288
+ # makes use of the german language as part of its content primarily.
3289
+ # ========================================================================= #
3290
+ def use_german # An easier shortcut.
3291
+ language :german
3292
+ end
3293
+
3294
+ # ========================================================================= #
3295
+ # === logical_build_up
3296
+ #
3297
+ # This method can be used to "build up" a webpage from scratch.
3298
+ #
3299
+ # Furthermore it can be used to also "build from the middle", that is
3300
+ # start at a later point in time if necessary.
3301
+ #
3302
+ # This is experimental right now in October 2021 - perhaps one day we
3303
+ # will make it to handle all logical "small steps".
3304
+ # ========================================================================= #
3305
+ def logical_build_up(
3306
+ array =
3307
+ [
3308
+ :html_start_tag,
3309
+ :head_start_tag,
3310
+ :add_the_meta_tags,
3311
+ :close_body_head_and_html_tag
3312
+ ]
3313
+ )
3314
+ array.each {|entry|
3315
+ send(entry)
3316
+ }
3317
+ end
3318
+
3319
+ # ========================================================================= #
3320
+ # === marl4em
3321
+ # ========================================================================= #
3322
+ def marl4em(
3323
+ i = '',
3324
+ optional_css_class = '',
3325
+ optional_the_id = ''
3326
+ )
3327
+ optional_css_class = optional_css_class.dup
3328
+ optional_css_class << ' marl4em'
3329
+ s2(i, optional_css_class.strip)
3330
+ end
3331
+
3332
+ # ========================================================================= #
3333
+ # === marl5em
3334
+ # ========================================================================= #
3335
+ def marl5em(
3336
+ i = '',
3337
+ optional_css_class = '',
3338
+ optional_the_id = ''
3339
+ )
3340
+ optional_css_class = optional_css_class.dup
3341
+ optional_css_class << ' marl5em'
3342
+ s2(i, optional_css_class.strip)
3343
+ end
3344
+
3345
+ # ========================================================================= #
3346
+ # === view_source
3347
+ # ========================================================================= #
3348
+ def view_source(
3349
+ css_class = 'wid25',
3350
+ optional_id = 'view_source',
3351
+ optional_css_style = ''
3352
+ )
3353
+ button_css = 'view_source BG_White Black pad2px'
3354
+ if css_class.is_a? Hash
3355
+ css_class = css_class.delete :css_class
3356
+ end
3357
+ form '', '', '', optional_id, optional_css_style
3358
+ ee '<input class="'+button_css+' '+css_class+'" type="button" value="View Source" '
3359
+ # ee 'onClick=\'window.location = "view-source:"+window.location.href\'
3360
+ ee "onClick='window.location=\"view-source:\"+window.location.href'"
3361
+ ee '>'+"\n"
3362
+ cform
3363
+ end
3364
+
3365
+ # ========================================================================= #
3366
+ # === ordered_list
3367
+ #
3368
+ # This method can be used to show an ordered list.
3369
+ # ========================================================================= #
3370
+ def ordered_list(
3371
+ array = %w( cat dog parrot deer horse )
3372
+ )
3373
+ _ = "<ol>\n".dup
3374
+ array.each {|this_entry|
3375
+ _ << "<li>#{this_entry}</li>\n"
3376
+ }
3377
+ _ << "</ol>\n\n"
3378
+ addnl(_)
3379
+ end
3380
+
3381
+ # ========================================================================= #
3382
+ # === make_this_id_draggable
3383
+ #
3384
+ # Note that this will be guaranteed to always add the corresponding
3385
+ # javascript code, which is different to javascript_drag_and_drop().
3386
+ #
3387
+ # This is why you should not use it directly - instead, use
3388
+ # javascript_drag_and_drop().
3389
+ # ========================================================================= #
3390
+ def make_this_id_draggable(this_id)
3391
+ addnl(
3392
+ ::Cyberweb.return_javascript_drag_and_drop(this_id)
3393
+ )
3394
+ end; private :make_this_id_draggable
3395
+
3396
+ # ========================================================================= #
3397
+ # === prepend_doc_type
3398
+ # ========================================================================= #
3399
+ def prepend_doc_type
3400
+ @internal_hash[:html_string].prepend(
3401
+ "#{default_doc_type?}\n"
3402
+ )
3403
+ end
3404
+
3405
+ # ========================================================================= #
3406
+ # === return_jquery_string
3407
+ #
3408
+ # Since as of 21.09.2014 this method will return two .js files here.
3409
+ #
3410
+ # The version of jquery-ui is currently hardcoded.
3411
+ #
3412
+ # The latest version of jquery-ui can be viewed here:
3413
+ #
3414
+ # https://code.jquery.com/ui/
3415
+ #
3416
+ # ========================================================================= #
3417
+ def return_jquery_string(
3418
+ jquery_ui_version = Cyberweb.jquery_ui_version?
3419
+ )
3420
+ return ::Cyberweb.return_jquery_string(jquery_ui_version)
3421
+ end; alias build_jquery_string return_jquery_string # === build_jquery_string
3422
+
99
3423
  require 'cyberweb/javascript/drag_and_drop.rb'
3424
+ # ========================================================================= #
3425
+ # === drag_and_drop
3426
+ # ========================================================================= #
3427
+ def drag_and_drop(
3428
+ this_id = 'drag_test'
3429
+ )
3430
+ if use_jquery?
3431
+ addnl(
3432
+ ::Cyberweb.return_javascript_drag_and_drop(this_id)
3433
+ )
3434
+ end
3435
+ end; alias drag drag_and_drop # === drag
3436
+ alias enable_drag_for drag_and_drop # === enable_drag_for
3437
+ alias drag_n_drop drag_and_drop # === drag_n_drop
3438
+ alias drag_drop drag_and_drop # === drag_drop
3439
+ alias add_javascript_drag drag_and_drop # === add_javascript_drag
3440
+
3441
+ # ========================================================================= #
3442
+ # === update_the_body
3443
+ #
3444
+ # This method will update the content of the <body> tag, via javascript.
3445
+ # ========================================================================= #
3446
+ def update_the_body(with_this_content)
3447
+ ejavascript'
3448
+ document.body.innerHTML = "'+with_this_content+'"
3449
+ '
3450
+ end
3451
+
3452
+
3453
+ # ========================================================================= #
3454
+ # === show_cheerleader
3455
+ #
3456
+ # Shows an ASCII cheerleader.
3457
+ # ========================================================================= #
3458
+ def show_cheerleader(
3459
+ path_to_cheerleader_file = Cyberweb.path_to_data?+'CODE/javascript/cheerleader.js'
3460
+ )
3461
+ filename = 'cheerleader.js'
3462
+ _ = path_to_cheerleader_file
3463
+ _ << filename unless _[-filename.size, filename.size] == filename
3464
+ load_javascript(_)
3465
+ end
3466
+
3467
+ # ========================================================================= #
3468
+ # === chmod_displayer
3469
+ # ========================================================================= #
3470
+ def chmod_displayer(i = :default)
3471
+ addnl(
3472
+ ::Cyberweb.chmod_displayer(i)
3473
+ )
3474
+ end
3475
+
3476
+ require 'cyberweb/javascript/javascript.rb'
3477
+ # ========================================================================= #
3478
+ # === sanitize_javascript
3479
+ # ========================================================================= #
3480
+ def sanitize_javascript(i)
3481
+ ::Cyberweb.sanitize_javascript(i)
3482
+ end
3483
+
3484
+ # ========================================================================= #
3485
+ # === javascript_script=
3486
+ #
3487
+ # This method assigns to the @javascript variable. We expect it to
3488
+ # hold strings related to javascript-code.
3489
+ # ========================================================================= #
3490
+ def javascript_script=(i)
3491
+ if @internal_hash[:javascript].frozen?
3492
+ @internal_hash[:javascript] = @internal_hash[:javascript].dup
3493
+ end
3494
+ @internal_hash[:javascript] << return_javascript(i) # Tap into javascript/ subdirectory.
3495
+ end; alias javascript_in_head_tag javascript_script= # === javascript_in_head_tag
3496
+
3497
+ # ========================================================================= #
3498
+ # === return_default_javascript
3499
+ # ========================================================================= #
3500
+ def return_default_javascript(
3501
+ i = ::Cyberweb.converted_path_to_data
3502
+ )
3503
+ ::Cyberweb.return_default_javascript(i)
3504
+ end
3505
+
3506
+ # ========================================================================= #
3507
+ # === save_as_webobject
3508
+ #
3509
+ # This method will save as a WebObject variant, as a .cgi file.
3510
+ # ========================================================================= #
3511
+ def save_as_webobject(
3512
+ into = @internal_hash[:save_into_this_html_page].
3513
+ delete_suffix('.html')+
3514
+ '.cgi'
3515
+ )
3516
+ puts 'Storing into `'+into+'`.'
3517
+ what = ''.dup # string?
3518
+ what.prepend(ruby_header?+"\n")
3519
+ append_this = <<-EOF
3520
+ # =========================================================================== #
3521
+ #
3522
+ # =========================================================================== #
3523
+ require 'cyberweb/autoinclude'
3524
+
3525
+ english('#{use_this_title?}') {
3526
+ created_on '#{dd_mm_yyyy}' # Wednesday.
3527
+ body_css_class ''
3528
+ body_css_style ''
3529
+ font_size ''
3530
+
3531
+ doc {
3532
+ ee '#{body_string?.tr("'","\'")}'
3533
+ }}
3534
+ EOF
3535
+ what << append_this
3536
+ SaveFile.write_what_into(what, into)
3537
+ end
3538
+
3539
+ # ========================================================================= #
3540
+ # === addnl (addnl tag)
3541
+ #
3542
+ # This will call add(), and decree that a newline is used. It will NOT
3543
+ # modify the given input at hand - only add() may modify the given
3544
+ # input at hand.
3545
+ # ========================================================================= #
3546
+ def addnl(
3547
+ i = "\n",
3548
+ optional_css_class = nil
3549
+ )
3550
+ # ======================================================================= #
3551
+ # We can not call .to_s in the next line because we may pass a Symbol
3552
+ # such as :br too.
3553
+ # ======================================================================= #
3554
+ add(i, optional_css_class, :use_a_newline) # Delegate towards add() here.
3555
+ end; alias add_with_newline addnl # === add_with_newline
3556
+ alias add_newline addnl # === add_newline
3557
+ alias addn addnl # === addn
3558
+ alias adnl addnl # === adnl
3559
+
3560
+ # ========================================================================= #
3561
+ # === add (add tag)
3562
+ #
3563
+ # This is the general append-method for whenever we seek to append
3564
+ # onto the main String (stored in @_) of this class.
3565
+ # ========================================================================= #
3566
+ def add(
3567
+ i, # The input here can be a Symbol as well.
3568
+ optional_css_class = nil,
3569
+ optional_entry_for_newline = nil
3570
+ )
3571
+ case i
3572
+ # ======================================================================= #
3573
+ # === :newline
3574
+ # ======================================================================= #
3575
+ when :newline,
3576
+ :use_a_newline
3577
+ i = NL
3578
+ # ======================================================================= #
3579
+ # === :body
3580
+ # ======================================================================= #
3581
+ when :body
3582
+ consider_autoclosing_the_head_tag
3583
+ i = return_body_tag(optional_css_class).dup
3584
+ # ======================================================================= #
3585
+ # === :content_type_plain
3586
+ # ======================================================================= #
3587
+ when :content_type_plain
3588
+ i = Cyberweb::CONTENT_TYPE_PLAIN
3589
+ end
3590
+ if i
3591
+ # ===================================================================== #
3592
+ # === Handle symbols next
3593
+ # ===================================================================== #
3594
+ if i.is_a? Symbol
3595
+ i = "<#{i}>".dup # Such as for :br aka <br>.
3596
+ elsif i.is_a? Numeric
3597
+ i = i.to_s.dup
3598
+ elsif i.respond_to?(:is_an_objectified_html_tag?) and
3599
+ i.is_an_objectified_html_tag?
3600
+ # =================================================================== #
3601
+ # This entry clause adds support for directly adding
3602
+ # Objectified::HtmlTags.
3603
+ # =================================================================== #
3604
+ i = i.string?
3605
+ end
3606
+ if i.is_a?(String) and i.frozen?
3607
+ i = i.dup
3608
+ end
3609
+ end
3610
+ if i.nil?
3611
+ i = ''.dup
3612
+ end
3613
+ case optional_entry_for_newline
3614
+ # ======================================================================= #
3615
+ # === :newline
3616
+ # ======================================================================= #
3617
+ when :newline,
3618
+ :use_a_newline
3619
+ i << "\n"
3620
+ end
3621
+ # ======================================================================= #
3622
+ # Avoid a frozen main string:
3623
+ # ======================================================================= #
3624
+ if @internal_hash[:html_string].frozen?
3625
+ @internal_hash[:html_string] = @internal_hash[:html_string].dup
3626
+ end
3627
+ @internal_hash[:html_string] << i
3628
+ end; alias append add # === append
3629
+ alias add_to_main_string add # === add_to_main_string
3630
+
3631
+ # ========================================================================= #
3632
+ # === german
3633
+ # ========================================================================= #
3634
+ def german(
3635
+ use_this_as_title = nil,
3636
+ &block
3637
+ )
3638
+ add_doctype_then_html_start_tag_then_head_tag_then_charset
3639
+ german_trinity
3640
+ if use_this_as_title
3641
+ set_title(use_this_as_title)
3642
+ end
3643
+ handle_these_calls(&block)
3644
+ close_html_after_making_sure_that_the_body_tag_exists
3645
+ end
3646
+
3647
+ # ========================================================================= #
3648
+ # === create_standalone_html_page
3649
+ #
3650
+ # This method can be used to create a standalone .html page, representing
3651
+ # the WebObject content.
3652
+ # ========================================================================= #
3653
+ def create_standalone_html_page(
3654
+ use_this_filename = filename?
3655
+ )
3656
+ Cyberweb.set_log_directory(:classic_FHS_structure)
3657
+ what = to_html
3658
+ # ======================================================================= #
3659
+ # We will store into the log-directory of the Cyberweb project.
3660
+ # ======================================================================= #
3661
+ into = Cyberweb.log_directory?+
3662
+ use_this_filename.delete_suffix(
3663
+ File.extname(use_this_filename)
3664
+ )+'.html' # This must be accessible.
3665
+ message = 'Storing into the local file '+sfile(into)+'.'
3666
+ e message
3667
+ puts message
3668
+ write_what_into(what, into)
3669
+ end; alias dump_the_html create_standalone_html_page # === dump_the_html
3670
+
3671
+ # ========================================================================= #
3672
+ # === enable_namespace
3673
+ #
3674
+ # This simply includes the main Cyberweb "namespace".
3675
+ # ========================================================================= #
3676
+ def enable_namespace
3677
+ Object.send(
3678
+ :include, ::Cyberweb
3679
+ )
3680
+ require 'cyberweb/predefined_and_freeform_methods/predefined_methods.rb'
3681
+ Object.send(
3682
+ :include, ::Cyberweb::PredefinedMethods
3683
+ )
3684
+ # ======================================================================= #
3685
+ # The next line was added in March 2022.
3686
+ # ======================================================================= #
3687
+ Object.send(
3688
+ :include, ::Cyberweb::Objectified::Mask
3689
+ )
3690
+ end; alias autoextend enable_namespace # === autoextend
3691
+
3692
+ # ========================================================================= #
3693
+ # === img_dir?
3694
+ # ========================================================================= #
3695
+ def img_dir?
3696
+ "#{server_base_directory?}"\
3697
+ "data/"\
3698
+ "#{return_name_of_the_images_directory}/"
3699
+ end
3700
+
3701
+ # ========================================================================= #
3702
+ # === server_base_directory?
3703
+ # ========================================================================= #
3704
+ def server_base_directory?
3705
+ Cyberweb.server_base_directory?
3706
+ end
3707
+
3708
+ # ========================================================================= #
3709
+ # === template1
3710
+ # ========================================================================= #
3711
+ def template1(i = '')
3712
+ main_css "#{i}\n#{TEMPLATE1}"
3713
+ end
3714
+
3715
+ # ========================================================================= #
3716
+ # === add_unicode_charset
3717
+ # ========================================================================= #
3718
+ def add_unicode_charset
3719
+ append_this_to_the_meta_collection('<meta charset="UTF-8">')
3720
+ end
3721
+
3722
+ # ========================================================================= #
3723
+ # === use_unicode
3724
+ # ========================================================================= #
3725
+ def do_use_unicode
3726
+ @internal_hash[:use_unicode] = true
3727
+ end; alias use_unicode do_use_unicode # === use_unicode
100
3728
 
101
3729
  end
102
3730
 
103
3731
  # =========================================================================== #
104
3732
  # === Cyberweb.new
105
3733
  #
106
- # The toplevel method new, as in Cyberweb.new, will instantiate a
107
- # new WebObject-instance.
3734
+ # The toplevel method new, as in Cyberweb.new, will instantiate a new
3735
+ # WebObject-instance.
108
3736
  # =========================================================================== #
109
3737
  def self.new(
110
3738
  i = nil, &block
@@ -122,5 +3750,18 @@ end; self.instance_eval { alias initialize_web_object new } # === Cyberweb.initi
122
3750
  end
123
3751
 
124
3752
  if __FILE__ == $PROGRAM_NAME
125
- Cyberweb::WebObject.new(ARGV)
126
- end # web_object.rb
3753
+ require 'colours/autoinclude'
3754
+ web_object = Cyberweb::WebObject.new(ARGV)
3755
+ # ========================================================================= #
3756
+ # Next we test the code that can be used to read in an existing
3757
+ # .html file:
3758
+ # _.parse_from_this_html_file
3759
+ # _.save_into_the_default_html_page
3760
+ # _.save_as_webobject
3761
+ # ========================================================================= #
3762
+ web_object.append_to_body_css_style 'marl1em'
3763
+ web_object.set_title 'Hey there'
3764
+ web_object.rebuild_the_HTML_string
3765
+ # web_object.ejavascript(:tetris)
3766
+ e tomato(web_object.string?) # Debugging output.
3767
+ end # testwebobject