cyberweb 0.6.17 → 0.7.9

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 (42) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +299 -134
  3. data/bin/images_from_this_webpage +11 -0
  4. data/doc/README.gen +276 -107
  5. data/doc/todo/todo_for_the_cyberweb_project.md +90 -90
  6. data/examples/css/day_night_toggle/day_night_toggle.html +202 -0
  7. data/examples/css/fleeing_dinosaur_animation/fleeing_dinosaur_animation.html +420 -0
  8. data/examples/css/important_style/important_style.html +35 -0
  9. data/examples/html/custom_cursor.html +1 -1
  10. data/examples/javascript_and_jquery/misc/miscallenous_javascript_examples.html +25 -0
  11. data/examples/javascript_and_jquery/roll_a_die/roll_a_die.html +48 -0
  12. data/lib/cyberweb/base/misc.rb +7 -0
  13. data/lib/cyberweb/cascading_style_sheets/div.css +2 -2
  14. data/lib/cyberweb/cascading_style_sheets/drop_shadow.css +4 -0
  15. data/lib/cyberweb/cascading_style_sheets/fonts.css +42 -30
  16. data/lib/cyberweb/cascading_style_sheets/glow_effects.css +58 -0
  17. data/lib/cyberweb/cascading_style_sheets/margin.css +254 -248
  18. data/lib/cyberweb/cascading_style_sheets/tooltip.css +73 -0
  19. data/lib/cyberweb/generator/cgi.rb +2 -1
  20. data/lib/cyberweb/javascript_code/custom_functions.js +16 -16
  21. data/lib/cyberweb/javascript_code/math.js +18 -0
  22. data/lib/cyberweb/javascript_code/simulate_a_dice.js +13 -5
  23. data/lib/cyberweb/sinatra/custom_extensions.rb +2 -2
  24. data/lib/cyberweb/toplevel_methods/misc.rb +44 -0
  25. data/lib/cyberweb/utility_scripts/create_coloured_tags.rb +1 -5
  26. data/lib/cyberweb/utility_scripts/download_balloon_css.rb +1 -5
  27. data/lib/cyberweb/utility_scripts/fix_incorrect_links_to_locally_existing_images_in_this_file.rb +5 -33
  28. data/lib/cyberweb/utility_scripts/hyperlink_all_images_from.rb +1 -5
  29. data/lib/cyberweb/utility_scripts/obtain_css_rules.rb +169 -0
  30. data/lib/cyberweb/version/version.rb +2 -2
  31. data/lib/cyberweb/web_object/html_tags.rb +12 -1
  32. data/lib/cyberweb/web_object/images.rb +534 -178
  33. data/lib/cyberweb/web_object/javascript_and_jquery.rb +9 -9
  34. data/lib/cyberweb/web_object/link.rb +102 -67
  35. data/lib/cyberweb/web_object/misc.rb +320 -518
  36. data/lib/cyberweb/yaml/js_files_to_load.yml +3 -2
  37. data/lib/cyberweb/yaml/load_these_yaml_files_by_default.yml +1 -0
  38. data/test/complex_tests/testing_style_variants/show_coloured_boxes.cgi +2 -2
  39. data/test/javascript/testing_various_javascript_related_APIs.html +17 -0
  40. data/test/simple_tests/testing_dragging_an_image.cgi +2 -0
  41. data/test/simple_tests/testing_uniform_css_rules_for_all_images.cgi +25 -0
  42. metadata +15 -5
@@ -12,6 +12,297 @@ class WebObject < ::Cyberweb::Base # === Cyberweb::WebObject
12
12
 
13
13
  require 'cyberweb/javascript/javascript_helper/javascript_helper.rb'
14
14
  require 'cyberweb/modules/css_style.rb'
15
+ require 'cyberweb/utility_scripts/obtain_css_rules.rb'
16
+
17
+ begin
18
+ require 'roebe/classes/to_binary.rb'
19
+ rescue LoadError; end
20
+
21
+ # ========================================================================= #
22
+ # === Cyberweb::WebObject.evaluate_from_the_same_named_file_then_serve
23
+ #
24
+ # This is the simplified variant that can be used for .cgi files, if
25
+ # a nearby .rb file exists. In order for this to work, the file must
26
+ # have the same name, minus the extension (which can be different).
27
+ # ========================================================================= #
28
+ def self.evaluate_from_the_same_named_file_then_serve(
29
+ output_the_result = :default,
30
+ optional_use_this_name_instead = nil
31
+ )
32
+ _ = Cyberweb::WebObject.new
33
+ ::Cyberweb.set_web_object(_)
34
+ _.evaluate_from_the_same_named_file(optional_use_this_name_instead)
35
+ return _.do_serve(output_the_result)
36
+ end
37
+
38
+ # ========================================================================= #
39
+ # === science_hyperlinks
40
+ #
41
+ # This method will add some of my default hyperlinks for local files,
42
+ # in regards to science-related links/content.
43
+ #
44
+ # The first argument to this method can be additional entries that
45
+ # the user may want to display.
46
+ #
47
+ # Usage examples:
48
+ #
49
+ # science_hyperlinks
50
+ # science_hyperlinks { :use_unicode_right_arrows }
51
+ #
52
+ # ========================================================================= #
53
+ def science_hyperlinks(
54
+ additional_entries = nil,
55
+ &block
56
+ )
57
+ array_science_entries = %w(
58
+ local_cellbiology
59
+ local_biochemistry
60
+ local_chemistry
61
+ local_genetics
62
+ local_gene_expression
63
+ local_microbiology
64
+ local_biotechnology
65
+ local_evolution
66
+ )
67
+ if additional_entries
68
+ array_science_entries << [additional_entries]
69
+ array_science_entries.flatten!
70
+ array_science_entries.compact!
71
+ end
72
+ yielded = nil
73
+ yielded = yield if block_given?
74
+ array_science_entries.each {|this_local_link|
75
+ this_local_link = BeautifulUrl.local_menu(this_local_link)
76
+ short_name = File.basename(this_local_link).delete_suffix('.cgi').dup.
77
+ tr('_',' ').
78
+ sub(/local/,'')
79
+ if yielded == :use_unicode_right_arrows
80
+ short_name.prepend('→')
81
+ end
82
+ abr_self(
83
+ this_local_link,
84
+ content: short_name
85
+ )
86
+ }
87
+ end; alias add_science_links science_hyperlinks # === add_science_links
88
+ alias science_links science_hyperlinks # === science_links
89
+
90
+ # ========================================================================= #
91
+ # === register_ids?
92
+ # ========================================================================= #
93
+ def register_ids?
94
+ @internal_hash[:register_ids]
95
+ end; alias registered_ids? register_ids? # === registered_ids?
96
+
97
+ # ========================================================================= #
98
+ # === random_alphabet_characters
99
+ # ========================================================================= #
100
+ def random_alphabet_characters(
101
+ n_characters = 10
102
+ )
103
+ _ = ''.dup
104
+ n_characters.times {
105
+ _ << ('a' .. 'z').to_a.sample
106
+ }
107
+ return _
108
+ end
109
+
110
+ # ========================================================================= #
111
+ # === is_a_duplicate_id?
112
+ # ========================================================================= #
113
+ def is_a_duplicate_id?(i)
114
+ @internal_hash[:register_ids].include?(i)
115
+ end
116
+
117
+ # ========================================================================= #
118
+ # === register_this_id
119
+ #
120
+ # This method will register the ID that is used into the corresponding
121
+ # Array.
122
+ # ========================================================================= #
123
+ def register_this_id(the_id = '')
124
+ if the_id and the_id.to_s.start_with?('drag')
125
+ drag_and_drop(the_id)
126
+ end
127
+ @internal_hash[:register_ids] << the_id
128
+ return the_id # Always return it here.
129
+ end; alias register_id register_this_id # === register_id
130
+
131
+ # ========================================================================= #
132
+ # === header
133
+ #
134
+ # This is a variant for h1() essentially.
135
+ # ========================================================================= #
136
+ def header(
137
+ i = '',
138
+ optional_css_class = '',
139
+ optional_the_id = '',
140
+ optional_css_style = '',
141
+ optional_javascript = ''
142
+ )
143
+ if optional_the_id.empty?
144
+ # ===================================================================== #
145
+ # Determine the id next:
146
+ # ===================================================================== #
147
+ optional_the_id = ::Cyberweb.remove_html(i).tr(' ','_')
148
+ end
149
+ h1(
150
+ i,
151
+ optional_css_class,
152
+ optional_the_id,
153
+ optional_css_style,
154
+ optional_javascript
155
+ )
156
+ @internal_hash[:register_ids] << register_this_id(optional_the_id) # optional_the_id
157
+ end
158
+
159
+ # ========================================================================= #
160
+ # === internal_hash?
161
+ # ========================================================================= #
162
+ def internal_hash?
163
+ @internal_hash
164
+ end
165
+
166
+ # ========================================================================= #
167
+ # === dynamic_text_shadow
168
+ #
169
+ # This method can be used to generate a dynamic text shadow.
170
+ # ========================================================================= #
171
+ def dynamic_text_shadow(
172
+ optional_hash = {
173
+ padding_to_use: '5vmin',
174
+ background_hsl: 'hsl(200 50% 50%)'
175
+ }
176
+ )
177
+ _ = optional_hash
178
+ if _.has_key? :padding
179
+ padding_to_use = _[:padding].to_s
180
+ elsif _.has_key? :padding_to_use
181
+ padding_to_use = _[:padding_to_use].to_s
182
+ end
183
+ if _.has_key? :background_hsl
184
+ background_hsl = _[:background_hsl].to_s
185
+ else # else use a default
186
+ background_hsl = 'hsl(200 50% 50%)'
187
+ end
188
+ # ======================================================================= #
189
+ # Next add these to the main CSS rules:
190
+ # ======================================================================= #
191
+ return '
192
+ .dynamic_text_shadow {
193
+ /* larger font size, more shadow distance */
194
+ text-shadow: .1em .1em 0 hsl(200 50% 30%);
195
+ block-size: 100%;
196
+ background: '+background_hsl+';
197
+ color: hsl(200 50% 90%);
198
+ font-family: "Fugaz One", cursive;
199
+ min-block-size: 100%;
200
+ padding: '+padding_to_use+';
201
+ display: grid;
202
+ }'
203
+ end; alias return_dynamic_text_shadow dynamic_text_shadow # === return_dynamic_text_shadow
204
+ alias dynamic_header dynamic_text_shadow # === dynamic_header
205
+
206
+ # ========================================================================= #
207
+ # === caps
208
+ # ========================================================================= #
209
+ def caps(i = '')
210
+ return '<span class="pretty_caps">'+i.to_s+'</span>'
211
+ end; alias cap caps # === cap
212
+
213
+ # ========================================================================= #
214
+ # === string_tag
215
+ # ========================================================================= #
216
+ def string_tag(
217
+ which_tag = 'span',
218
+ css_class = '',
219
+ the_id = '',
220
+ css_style = '',
221
+ javascript_code = '',
222
+ &block
223
+ )
224
+ return ::Cyberweb.string_tag(
225
+ which_tag,
226
+ css_class,
227
+ the_id,
228
+ css_style,
229
+ javascript_code,
230
+ &block
231
+ )
232
+ end; alias stag string_tag # === stag
233
+ alias make_tag string_tag # === make_tag
234
+ alias string_stag string_tag # === string_stag
235
+
236
+ # ========================================================================= #
237
+ # === README
238
+ # ========================================================================= #
239
+ def README(
240
+ i = 'README.md'
241
+ )
242
+ # require 'kramdown'
243
+ # doc = Kramdown::Document.new(File.read(i))
244
+ # i = doc.to_html
245
+ display_this_file(i)
246
+ end
247
+
248
+ # ========================================================================= #
249
+ # === to_binary
250
+ # ========================================================================= #
251
+ def to_binary(i)
252
+ return Roebe::ToBinary.to(i)
253
+ end
254
+
255
+ # ========================================================================= #
256
+ # === readonly_input
257
+ #
258
+ # Usage example:
259
+ #
260
+ # readonly_input id: 'result_for_circle_calculations'
261
+ #
262
+ # ========================================================================= #
263
+ def readonly_input(
264
+ i = nil
265
+ )
266
+ _ = '<input type="text"'.dup
267
+ if i and i.is_a? Hash
268
+ if i.has_key?(:id)
269
+ _ << ' id="'+i[:id].to_s+'"'
270
+ end
271
+ end
272
+ _ << ' readonly>'
273
+ addnl(_)
274
+ end
275
+
276
+ # ========================================================================= #
277
+ # === template1
278
+ # ========================================================================= #
279
+ def template1(
280
+ i = ''
281
+ )
282
+ obtain_css_rules = Cyberweb::ObtainCssRules.new
283
+ if i and i.include?(' .')
284
+ # ===================================================================== #
285
+ # In this case we may assume that i contains a custom CSS rule.
286
+ # ===================================================================== #
287
+ splitted = i.split("\n")
288
+ splitted.map! {|this_line| # parse each line
289
+ if this_line.start_with?(' .')
290
+ _ = this_line.strip.split(' ').first # Mandate a ' ' here.
291
+ obtain_css_rules.set_seek_this(_)
292
+ obtain_css_rules.parse_string(this_line)
293
+ replace_it_with_this_string = obtain_css_rules.body?
294
+ # ================================================================= #
295
+ # Next we have to replace something like '.mars1em;' with
296
+ # 'margin-right: 1em; margin-left: 1em'.
297
+ # ================================================================= #
298
+ this_line = replace_it_with_this_string
299
+ end
300
+ this_line # return it here.
301
+ }
302
+ i = splitted.join("\n")
303
+ end
304
+ main_css "#{i}\n#{TEMPLATE1}"
305
+ end
15
306
 
16
307
  # ========================================================================= #
17
308
  # === string_link
@@ -39,7 +330,7 @@ class WebObject < ::Cyberweb::Base # === Cyberweb::WebObject
39
330
  # === :pretty
40
331
  # ===================================================================== #
41
332
  when :pretty
42
- i = beautiful_url(i)
333
+ option_hash[:remote_URL] = beautiful_url(i)
43
334
  end
44
335
  end
45
336
  if i.is_a?(Symbol)
@@ -71,7 +362,8 @@ class WebObject < ::Cyberweb::Base # === Cyberweb::WebObject
71
362
  # Delegate onto HtmlTags.a().
72
363
  # ======================================================================= #
73
364
  return HtmlTags.a(
74
- i, option_hash
365
+ i,
366
+ option_hash
75
367
  )
76
368
  end; alias string_a string_link # === string_a
77
369
  alias string_href string_link # === string_href
@@ -87,6 +379,10 @@ class WebObject < ::Cyberweb::Base # === Cyberweb::WebObject
87
379
  end; alias default_hyperlinks_template default_hyperlinks_template1 # === default_hyperlinks_template
88
380
  alias hyperlinks_template1 default_hyperlinks_template1 # === hyperlinks_template1
89
381
  alias hyperlinks_template default_hyperlinks_template1 # === hyperlinks_template
382
+ alias hyperlink_template1 default_hyperlinks_template1 # === hyperlink_template1
383
+ alias default_template1 default_hyperlinks_template1 # === default_template1
384
+ alias default_template default_hyperlinks_template1 # === default_template
385
+ alias default_css_template default_hyperlinks_template1 # === default_css_template
90
386
 
91
387
  # ========================================================================= #
92
388
  # === draw_triangle
@@ -491,7 +787,8 @@ class WebObject < ::Cyberweb::Base # === Cyberweb::WebObject
491
787
  table2('pad0_5em','glossar') {{
492
788
  with_this_data: use_this_dataset
493
789
  }}
494
- end; alias glossar glossar_table # === glossar
790
+ end; alias glossar glossar_table # === glossar
791
+ alias table_for_glossar glossar_table # === table_for_glossar
495
792
 
496
793
  # ========================================================================= #
497
794
  # === table5_with_heading
@@ -765,43 +1062,6 @@ document.body.innerHTML = "'+with_this_content+'"
765
1062
  )
766
1063
  end
767
1064
 
768
- # ========================================================================= #
769
- # === science_hyperlinks
770
- #
771
- # This method will add some of my default hyperlinks for local files,
772
- # in regards to science-related links/content.
773
- #
774
- # Usage examples:
775
- #
776
- # science_hyperlinks
777
- # science_hyperlinks { :use_unicode_right_arrows }
778
- #
779
- # ========================================================================= #
780
- def science_hyperlinks(&block)
781
- array_science_entries = %w(
782
- local_cellbiology
783
- local_biochemistry
784
- local_chemistry
785
- local_genetics
786
- local_gene_expression
787
- local_microbiology
788
- local_biotechnology
789
- )
790
- yielded = nil
791
- yielded = yield if block_given?
792
- array_science_entries.each {|this_local_link|
793
- this_local_link = BeautifulUrl.local_menu(this_local_link)
794
- short_name = File.basename(this_local_link).delete_suffix('.cgi').dup
795
- if yielded == :use_unicode_right_arrows
796
- short_name.prepend('→')
797
- end
798
- abr_self(
799
- this_local_link,
800
- content: short_name
801
- )
802
- }
803
- end; alias add_science_links science_hyperlinks # === add_science_links
804
-
805
1065
  # ========================================================================= #
806
1066
  # === string_table7
807
1067
  # ========================================================================= #
@@ -1115,15 +1375,6 @@ EOF
1115
1375
  )
1116
1376
  end; alias autoextend enable_namespace # === autoextend
1117
1377
 
1118
- # ========================================================================= #
1119
- # === img_dir?
1120
- # ========================================================================= #
1121
- def img_dir?
1122
- "#{server_base_directory?}"\
1123
- "data/"\
1124
- "#{return_name_of_the_images_directory}/"
1125
- end
1126
-
1127
1378
  # ========================================================================= #
1128
1379
  # === append_onto_the_main_CSS_rules
1129
1380
  # ========================================================================= #
@@ -1197,21 +1448,6 @@ a:hover {
1197
1448
  }
1198
1449
  end
1199
1450
 
1200
- # ========================================================================= #
1201
- # === return_this_base64_image
1202
- # ========================================================================= #
1203
- def return_this_base64_image(
1204
- i,
1205
- optional_css_class = '',
1206
- optional_css_id = ''
1207
- )
1208
- return ::Cyberweb.return_this_base64_image(
1209
- i,
1210
- optional_css_class,
1211
- optional_css_id
1212
- )
1213
- end
1214
-
1215
1451
  # ========================================================================= #
1216
1452
  # === use_the_internal_CSS_files?
1217
1453
  # ========================================================================= #
@@ -1771,39 +2007,6 @@ a:hover {
1771
2007
  end
1772
2008
  end
1773
2009
 
1774
- # ========================================================================= #
1775
- # === display_all_images
1776
- #
1777
- # Use this when you just want to display all images.
1778
- #
1779
- # The first argument should be the location towards the
1780
- # directory that holds all images.
1781
- # ========================================================================= #
1782
- def display_all_images(
1783
- dir = ::Cyberweb.return_pwd,
1784
- optional_css = 'bblack1'
1785
- )
1786
- if dir.is_a? Hash
1787
- dir = dir.delete(:from) if dir.has_key? :from
1788
- end
1789
- if dir.include? '$'
1790
- dir = ConvertGlobalEnv[dir]
1791
- end
1792
- unless Dir.exist? dir
1793
- e 'It seems as if the directory at `'+dir+'` does not exist.'
1794
- end
1795
- all_the_images = get_images_from(dir)
1796
- all_the_images.each {|file|
1797
- file = rds(file)
1798
- h3 file, 'slateblue'
1799
- imgbr(
1800
- file,
1801
- optional_css
1802
- )
1803
- }
1804
- end; alias display_images_from display_all_images # === display_images_from
1805
- alias display_images display_all_images # === display_images
1806
-
1807
2010
  # ========================================================================= #
1808
2011
  # === advanced_handle_these_calls_for_german
1809
2012
  # ========================================================================= #
@@ -1975,13 +2178,6 @@ a:hover {
1975
2178
  Cyberweb.server_base_directory?
1976
2179
  end
1977
2180
 
1978
- # ========================================================================= #
1979
- # === template1
1980
- # ========================================================================= #
1981
- def template1(i = '')
1982
- main_css "#{i}\n#{TEMPLATE1}"
1983
- end
1984
-
1985
2181
  # ========================================================================= #
1986
2182
  # === add_unicode_charset
1987
2183
  # ========================================================================= #
@@ -2047,7 +2243,9 @@ a:hover {
2047
2243
  also_enable_link = false
2048
2244
  )
2049
2245
  case also_enable_link
2246
+ # ======================================================================= #
2050
2247
  # === :also_enable_link
2248
+ # ======================================================================= #
2051
2249
  when :also_enable_link
2052
2250
  also_enable_link = true
2053
2251
  end
@@ -2116,20 +2314,9 @@ a:hover {
2116
2314
  #
2117
2315
  # This will forbid serving the site to unallowed visitors.
2118
2316
  # ========================================================================= #
2119
- def ip_is_allowed?
2120
- exit unless ALLOWED_IPS.include? VISITOR_IP
2121
- end; alias forbidden ip_is_allowed? # === forbidden
2122
-
2123
- # ========================================================================= #
2124
- # === do_use_in_dir_images
2125
- # ========================================================================= #
2126
- def do_use_in_dir_images
2127
- @config['use_in_dir_images'] = true
2128
- # ======================================================================= #
2129
- # Also keep track of the new path.
2130
- # ======================================================================= #
2131
- ::Cyberweb.set_path_to_images('')
2132
- end; alias use_in_dir_images do_use_in_dir_images # === use_in_dir_images
2317
+ def ip_is_allowed?
2318
+ exit unless ALLOWED_IPS.include? VISITOR_IP
2319
+ end; alias forbidden ip_is_allowed? # === forbidden
2133
2320
 
2134
2321
  # ========================================================================= #
2135
2322
  # === return_only_duplicates
@@ -2416,56 +2603,6 @@ a:hover {
2416
2603
  alias highlight_tag on_click_change_opacity # === highlight_tag
2417
2604
  alias highlight on_click_change_opacity # === highlight
2418
2605
 
2419
- # ========================================================================= #
2420
- # === base64_image
2421
- #
2422
- # This is distinct to other base64-related images within the Cyberweb
2423
- # project. It will simply, and directly, add the given data.
2424
- # ========================================================================= #
2425
- def base64_image(
2426
- i, image_type_to_use = :infer
2427
- )
2428
- addnl(
2429
- return_base64_image(i, image_type_to_use)
2430
- )
2431
- end
2432
-
2433
- # ========================================================================= #
2434
- # === return_base64_image
2435
- # ========================================================================= #
2436
- def return_base64_image(
2437
- i,
2438
- image_type_to_use = :infer,
2439
- optional_css_class = '',
2440
- optional_the_id = '',
2441
- optional_css_style = ''
2442
- )
2443
- case image_type_to_use
2444
- # ======================================================================= #
2445
- # === :infer
2446
- # ======================================================================= #
2447
- when :infer
2448
- image_type_to_use = File.extname(i)
2449
- if image_type_to_use.empty?
2450
- image_type_to_use = 'png' # Rescue in this case.
2451
- end
2452
- end
2453
- _ = '<img src="data:image/'+
2454
- image_type_to_use.to_s.delete('.')+
2455
- ';base64,'+i+'"'.dup
2456
- if optional_css_class
2457
- _ << css_class_or_no_class(optional_css_class)
2458
- end
2459
- if optional_the_id
2460
- _ << id_or_no_id(optional_the_id)
2461
- end
2462
- if optional_css_style
2463
- _ << css_style_or_no_style(optional_css_style)
2464
- end
2465
- _ << '>'
2466
- return _
2467
- end
2468
-
2469
2606
  # ========================================================================= #
2470
2607
  # === pfeil_rechts
2471
2608
  # ========================================================================= #
@@ -2656,7 +2793,7 @@ a:hover {
2656
2793
  # ========================================================================= #
2657
2794
  def five_stars(optional_css_class = '')
2658
2795
  return_stars(5, optional_css_class)
2659
- end
2796
+ end; alias return_five_stars five_stars # === return_five_stars
2660
2797
 
2661
2798
  # ========================================================================= #
2662
2799
  # === efive_stars
@@ -2957,7 +3094,6 @@ a:hover {
2957
3094
  File.extname(absolute_path_to_the_image)
2958
3095
  ).downcase
2959
3096
  dataset = convert_image_to_base64(absolute_path_to_the_image)
2960
-
2961
3097
  addnl(
2962
3098
  return_base64_image(
2963
3099
  dataset, :infer, css_class, use_this_id, css_style
@@ -2965,58 +3101,6 @@ a:hover {
2965
3101
  )
2966
3102
  end; alias draggable_base64img draggable_img_base64 # === draggable_base64img
2967
3103
 
2968
- # ========================================================================= #
2969
- # === local_image_or_remote_image
2970
- #
2971
- # This method can be used to add a substitute image in the event that
2972
- # a local image could not be found. Otherwise it behaves exactly like
2973
- # image() does.
2974
- # ========================================================================= #
2975
- def local_image_or_remote_image(
2976
- local_image = '',
2977
- remote_image_substitute = '', # This one should be the remote URL.
2978
- optional_css_class = '',
2979
- optional_the_id = '',
2980
- optional_css_style = '',
2981
- alt_text = '',
2982
- &block
2983
- )
2984
- # ======================================================================= #
2985
- # We first have to decide whether the image exists or whether it does
2986
- # not exist, at the specified location. If it exists then we can use
2987
- # the regular img() call; otherwise we have to use the second argument
2988
- # to this method.
2989
- # ======================================================================= #
2990
- assumed_path = rds(
2991
- path_to_the_image_directory?+
2992
- local_image
2993
- )
2994
- if File.exist?(assumed_path) and !local_image.empty?
2995
- img(
2996
- local_image,
2997
- optional_css_class,
2998
- optional_the_id,
2999
- optional_css_style,
3000
- alt_text,
3001
- &block
3002
- )
3003
- else
3004
- # ===================================================================== #
3005
- # else we use a remote URL or a rescue URL anyway.
3006
- # ===================================================================== #
3007
- remote_img(
3008
- remote_image_substitute,
3009
- {
3010
- css_class: optional_css_class,
3011
- id: optional_the_id,
3012
- css_style: optional_css_style
3013
- },
3014
- &block
3015
- # alt_text is currently not handled here.
3016
- )
3017
- end
3018
- end
3019
-
3020
3104
  # ========================================================================= #
3021
3105
  # === save_into_this_html_page?
3022
3106
  # ========================================================================= #
@@ -4410,19 +4494,6 @@ end
4410
4494
  alias t= set_title # === t=
4411
4495
  alias title= set_title # === title= # <-- This alias here may be more popular than set_title().
4412
4496
 
4413
- # ========================================================================= #
4414
- # === embed_this_image
4415
- # ========================================================================= #
4416
- def embed_this_image(
4417
- i = 'lyxandras-das-Dorf-Nadorp.jpg',
4418
- optional_css_class = 'bblack1',
4419
- optional_the_id = ''
4420
- )
4421
- addnl(
4422
- ::Cyberweb.embed_this_image(i, optional_css_class, optional_the_id)
4423
- )
4424
- end
4425
-
4426
4497
  # ========================================================================= #
4427
4498
  # === check_for_links_markdown_file
4428
4499
  #
@@ -5024,32 +5095,6 @@ end
5024
5095
  }
5025
5096
  end
5026
5097
 
5027
- # ========================================================================= #
5028
- # === relative_background_image
5029
- #
5030
- # We have to build the proper path, e. g.:
5031
- #
5032
- # url(data/images/WALLPAPERS/TheCalling_AnimeWallpaper.jpg);
5033
- #
5034
- # ========================================================================= #
5035
- def relative_background_image(this_image)
5036
- _ = ('../' * n_steps_to_the_base_directory?) +
5037
- "#{name_of_img_dir?}".dup
5038
- _ << this_image
5039
- background_image = "background-image: url(#{_});" # The string to append.
5040
- # ======================================================================= #
5041
- # Next, add some default assumptions here. No repeat is ok to
5042
- # use, centered background position - not sure.
5043
- # background-position: center;
5044
- # ======================================================================= #
5045
- add_this_css_style(
5046
- 'body {
5047
- '+background_image+'
5048
- background-repeat: no-repeat;
5049
- }'
5050
- )
5051
- end
5052
-
5053
5098
  # ========================================================================= #
5054
5099
  # === br (br tag)
5055
5100
  # ========================================================================= #
@@ -5161,61 +5206,6 @@ end
5161
5206
  )
5162
5207
  end; alias mathml_start mathml # === mathml_start
5163
5208
 
5164
- # ========================================================================= #
5165
- # === background_image=
5166
- #
5167
- # Use this method to set the background image for a page.
5168
- #
5169
- # body {background-image: url("../IMG/");}'
5170
- #
5171
- # Since as of December 2011, if you pass an argument such as 'NJOY/#RAND'
5172
- # then we use this as instruction to fetch a random entry from this
5173
- # directory.
5174
- #
5175
- # Usage Example:
5176
- #
5177
- # w.background_image = 'NJOY/#RAND'
5178
- #
5179
- # ========================================================================= #
5180
- def background_image=(
5181
- i = '/blaaa/foo.png'
5182
- )
5183
- _ = "#{name_of_img_dir?}/".dup # Hardcoded for now. Yes, I am aware that this sucks.
5184
- if i.to_s.downcase.include? '#rand' # Then get path given. Example: w.background_image = 'NJOY/#RAND'
5185
- first_part = i.split('#').first
5186
- _ << first_part
5187
- _ << get_files_from(::Cyberweb.path_to_images?).sample.to_s
5188
- else
5189
- case i
5190
- when :random
5191
- _ << Dir[::Cyberweb.path_to_images?+'NJOY/*'].sample.
5192
- sub(/\/home\/x\/DATA\/IMG\//, '')
5193
- else
5194
- _ << i
5195
- end
5196
- end
5197
- background_img = "background-image: url(#{::Cyberweb.path_to_images?}#{_});" # The string to append.
5198
- # ======================================================================= #
5199
- # Next, add some default assumptions here. No repeat is ok to
5200
- # use, centered background position - not sure.
5201
- # background-position: center;
5202
- # ======================================================================= #
5203
- add_this_css_style(
5204
- 'body {
5205
- '+background_img+'
5206
- background-repeat: no-repeat;
5207
- }'
5208
- )
5209
- end; alias body_background_image background_image= # === body_background_image
5210
- alias background_image background_image= # === background_image
5211
-
5212
- # ========================================================================= #
5213
- # === return_the_registered_base64_images
5214
- # ========================================================================= #
5215
- def return_the_registered_base64_images
5216
- ::Cyberweb.base64_images
5217
- end
5218
-
5219
5209
  # ========================================================================= #
5220
5210
  # === obtain_the_parameters_passed
5221
5211
  #
@@ -5376,15 +5366,6 @@ end
5376
5366
  )
5377
5367
  end
5378
5368
 
5379
- # ========================================================================= #
5380
- # === disable_webimages
5381
- #
5382
- # We wont use the webimages if we use this method here.
5383
- # ========================================================================= #
5384
- def disable_webimages
5385
- ::Cyberweb.config?['use_webimages'] = false
5386
- end
5387
-
5388
5369
  # ========================================================================= #
5389
5370
  # === add_the_title_to_the_webobject
5390
5371
  # ========================================================================= #
@@ -6547,29 +6528,6 @@ end
6547
6528
  end; alias beautiful_legend field_with_legend # Alias beautiful_legend() towards field_with_legend().
6548
6529
  alias mini_header field_with_legend # Alias mini_header() towards field_with_legend().
6549
6530
 
6550
- # ========================================================================= #
6551
- # === string_tag
6552
- # ========================================================================= #
6553
- def string_tag(
6554
- which_tag = 'span',
6555
- css_class = '',
6556
- the_id = '',
6557
- css_style = '',
6558
- javascript_code = '',
6559
- &block
6560
- )
6561
- return ::Cyberweb.string_tag(
6562
- which_tag,
6563
- css_class,
6564
- the_id,
6565
- css_style,
6566
- javascript_code,
6567
- &block
6568
- )
6569
- end; alias stag string_tag # === stag
6570
- alias make_tag string_tag # === make_tag
6571
- alias string_stag string_tag # === string_stag
6572
-
6573
6531
  # ========================================================================= #
6574
6532
  # === external_javascript_file
6575
6533
  # ========================================================================= #
@@ -7227,21 +7185,6 @@ function '+name_of_the_function_to_use+'{
7227
7185
  end
7228
7186
  end
7229
7187
 
7230
- # ========================================================================= #
7231
- # === get_images
7232
- #
7233
- # This method will obtain all files from all subdirectories there as
7234
- # well.
7235
- # ========================================================================= #
7236
- def get_images(
7237
- from_this_dir = return_pwd
7238
- )
7239
- Dir["#{from_this_dir}/**/**"].select {|entry|
7240
- ::Cyberweb.is_an_image?(entry)
7241
- }
7242
- end; alias get_images_from get_images # === get_images_from
7243
- alias return_all_images_from get_images # === return_all_images_from
7244
-
7245
7188
  # ========================================================================= #
7246
7189
  # === display_simple_clock
7247
7190
  #
@@ -7335,46 +7278,6 @@ function simple_clock_timer() {
7335
7278
  alias drag_drop javascript_drag_and_drop # === drag_drop
7336
7279
  alias enable_drag_for javascript_drag_and_drop # === enable_drag_for
7337
7280
 
7338
- # ========================================================================= #
7339
- # === dynamic_text_shadow
7340
- #
7341
- # This method can be used to generate a dynamic text shadow.
7342
- # ========================================================================= #
7343
- def dynamic_text_shadow(
7344
- optional_hash = {
7345
- padding_to_use: '5vmin',
7346
- background_hsl: 'hsl(200 50% 50%)'
7347
- }
7348
- )
7349
- _ = optional_hash
7350
- if _.has_key? :padding
7351
- padding_to_use = _[:padding].to_s
7352
- elsif _.has_key? :padding_to_use
7353
- padding_to_use = _[:padding_to_use].to_s
7354
- end
7355
- if _.has_key? :background_hsl
7356
- background_hsl = _[:background_hsl].to_s
7357
- else # else use a default
7358
- background_hsl = 'hsl(200 50% 50%)'
7359
- end
7360
- # ======================================================================= #
7361
- # Next add these to the main CSS rules:
7362
- # ======================================================================= #
7363
- return '
7364
- .dynamic_text_shadow {
7365
- /* larger font size, more shadow distance */
7366
- text-shadow: .1em .1em 0 hsl(200 50% 30%);
7367
- block-size: 100%;
7368
- background: '+background_hsl+';
7369
- color: hsl(200 50% 90%);
7370
- font-family: "Fugaz One", cursive;
7371
- min-block-size: 100%;
7372
- padding: '+padding_to_use+';
7373
- display: grid;
7374
- }'
7375
- end; alias return_dynamic_text_shadow dynamic_text_shadow # === return_dynamic_text_shadow
7376
- alias dynamic_header dynamic_text_shadow # === dynamic_header
7377
-
7378
7281
  # ========================================================================= #
7379
7282
  # === add_dynamic_text_shadow
7380
7283
  # ========================================================================= #
@@ -7419,13 +7322,6 @@ function simple_clock_timer() {
7419
7322
  addnl(Cyberweb.container_for_the_CSS_coffee_animation)
7420
7323
  end
7421
7324
 
7422
- # ========================================================================= #
7423
- # === done_image
7424
- # ========================================================================= #
7425
- def done_image
7426
- sg(:done, 'marr10px')
7427
- end
7428
-
7429
7325
  # ========================================================================= #
7430
7326
  # === add_doctype_then_html_start_tag_then_head_tag_then_charset
7431
7327
  #
@@ -7818,63 +7714,6 @@ function simple_clock_timer() {
7818
7714
  enable_drag_for(_) if _
7819
7715
  end
7820
7716
 
7821
- # ========================================================================= #
7822
- # === register_this_id
7823
- # ========================================================================= #
7824
- def register_this_id(the_id = '')
7825
- if the_id and the_id.to_s.start_with?('drag')
7826
- drag_and_drop(the_id)
7827
- end
7828
- @internal_hash[:register_ids] << the_id
7829
- return the_id
7830
- end; alias register_id register_this_id # === register_id
7831
-
7832
- # ========================================================================= #
7833
- # === header
7834
- #
7835
- # This is a variant for h1() essentially.
7836
- # ========================================================================= #
7837
- def header(
7838
- i = '',
7839
- optional_css_class = '',
7840
- optional_the_id = '',
7841
- optional_css_style = '',
7842
- optional_javascript = ''
7843
- )
7844
- if optional_the_id.empty?
7845
- optional_the_id = i.tr(' ','_')
7846
- end
7847
- h1(
7848
- i,
7849
- optional_css_class,
7850
- optional_the_id,
7851
- optional_css_style,
7852
- optional_javascript
7853
- )
7854
- @internal_hash[:register_ids] << optional_the_id
7855
- end
7856
-
7857
- # ========================================================================= #
7858
- # === draggable_string_image
7859
- # ========================================================================= #
7860
- def draggable_string_image(
7861
- url = '',
7862
- css_class = '',
7863
- the_id = '',
7864
- css_style = '',
7865
- alt_text = '',
7866
- &block
7867
- )
7868
- if the_id and the_id.empty?
7869
- the_id = 'drag_'+File.basename(url).downcase.delete_suffix(File.extname(url))
7870
- end
7871
- if the_id and !the_id.empty? and !the_id.start_with?('drag_')
7872
- the_id = the_id.dup
7873
- the_id.prepend('drag_')
7874
- end
7875
- string_img(url, css_class, the_id, css_style, alt_text) { :draggable_attribute }
7876
- end
7877
-
7878
7717
  # ========================================================================= #
7879
7718
  # === add_dragula_drag_for
7880
7719
  #
@@ -8018,39 +7857,6 @@ function simple_clock_timer() {
8018
7857
  end
8019
7858
  end
8020
7859
 
8021
- # ========================================================================= #
8022
- # === a (a tag, link tag)
8023
- #
8024
- # This method essentially refers to the <a> tag.
8025
- #
8026
- # If the first input argument is a Symbol then we will tap into
8027
- # BeautifulUrl,via Cyberweb.beautiful_url().
8028
- # ========================================================================= #
8029
- def a(
8030
- i = '',
8031
- option_hash = {}
8032
- )
8033
- if i.is_a? Symbol
8034
- i = beautiful_url(i)
8035
- # ===================================================================== #
8036
- # Also check if the second argument is a String. In this case we
8037
- # must modify it. Example for input that fulfils this criterium:
8038
- #
8039
- # remote_link(:hydrogenase, 'Hydrogenase')+
8040
- #
8041
- # ===================================================================== #
8042
- if option_hash.is_a? String
8043
- option_hash = { content: option_hash }
8044
- end
8045
- end
8046
- addn(
8047
- string_link(i, option_hash)
8048
- )
8049
- end; alias link a # === a
8050
- alias link_to a # === link_to
8051
- alias alink a # === alink
8052
- alias remote_link a # === remote_link
8053
-
8054
7860
  # ========================================================================= #
8055
7861
  # === set_font_size
8056
7862
  #
@@ -8072,7 +7878,7 @@ function simple_clock_timer() {
8072
7878
  # Remove leading 'FS' strings - at the least this is the main rationale
8073
7879
  # for the following .sub!() method call.
8074
7880
  # ======================================================================= #
8075
- this_font_size.sub!(/FS/,'') if this_font_size.include? 'FS'
7881
+ this_font_size.sub!(/FS/,'') if this_font_size.include? 'FS'
8076
7882
  this_font_size.gsub!(/_/,'.') if this_font_size.include? '_'
8077
7883
  case this_font_size
8078
7884
  # ======================================================================= #
@@ -8672,23 +8478,6 @@ function simple_clock_timer() {
8672
8478
  return _.do_serve
8673
8479
  end
8674
8480
 
8675
- # ========================================================================= #
8676
- # === Cyberweb::WebObject.evaluate_from_the_same_named_file_then_serve
8677
- #
8678
- # This is the simplified variant that can be used for .cgi files, if
8679
- # a nearby .rb file exists. In order for this to work, the file must
8680
- # have the same name, minus the extension (which can be different).
8681
- # ========================================================================= #
8682
- def self.evaluate_from_the_same_named_file_then_serve(
8683
- output_the_result = :default,
8684
- optional_use_this_name_instead = nil
8685
- )
8686
- _ = Cyberweb::WebObject.new
8687
- ::Cyberweb.set_web_object(_)
8688
- _.evaluate_from_the_same_named_file(optional_use_this_name_instead)
8689
- return _.do_serve(output_the_result)
8690
- end
8691
-
8692
8481
  # ========================================================================= #
8693
8482
  # === Cyberweb::WebObject[]
8694
8483
  # ========================================================================= #
@@ -8993,4 +8782,17 @@ def self.css_rules_for_the_coffee_animation
8993
8782
  '
8994
8783
  end
8995
8784
 
8785
+ # =========================================================================== #
8786
+ # === Cyberweb.evaluate_from_the_same_named_file_then_serve
8787
+ # =========================================================================== #
8788
+ def self.evaluate_from_the_same_named_file_then_serve(
8789
+ output_the_result = :default,
8790
+ optional_use_this_name_instead = nil
8791
+ )
8792
+ return ::Cyberweb::WebObject.evaluate_from_the_same_named_file_then_serve(
8793
+ output_the_result,
8794
+ optional_use_this_name_instead
8795
+ )
8796
+ end
8797
+
8996
8798
  end