cyberweb 0.5.225 → 0.6.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cyberweb might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +438 -238
- data/doc/README.gen +437 -237
- data/doc/todo/todo_for_the_cyberweb_project.md +6 -0
- data/examples/advanced/cursor_example/cursor_example.cgi +29 -0
- data/examples/advanced/draw_circle/draw_circle.cgi +13 -4
- data/examples/css/css_bubbles.html +8 -2
- data/examples/css/examples_with_borders/examples_with_borders.html +33 -0
- data/examples/javascript_and_jquery/copy_to_the_clipboard_example/copy_to_the_clipboard_example.html +80 -0
- data/images/cyberweb_theme.png +0 -0
- data/lib/cyberweb/base/misc.rb +67 -18
- data/lib/cyberweb/base_module/base_module.rb +66 -8
- data/lib/cyberweb/cascading_style_sheets/cursors.css +12 -5
- data/lib/cyberweb/cascading_style_sheets/default.css +20 -18
- data/lib/cyberweb/cascading_style_sheets/glow_effects.css +12 -6
- data/lib/cyberweb/cascading_style_sheets/misc.css +12 -1
- data/lib/cyberweb/generator/cgi.rb +3 -3
- data/lib/cyberweb/html_template/html_template.rb +172 -114
- data/lib/cyberweb/javascript/javascript.rb +34 -31
- data/lib/cyberweb/javascript_code/copy_to_the_clipboard.js +12 -0
- data/lib/cyberweb/jquery_module/jquery_module.rb +51 -0
- data/lib/cyberweb/modules/css_style.rb +27 -0
- data/lib/cyberweb/{favicon → modules}/favicon.rb +162 -33
- data/lib/cyberweb/requires/require_the_cyberweb_project.rb +6 -2
- data/lib/cyberweb/toplevel_methods/download_webpage.rb +16 -2
- data/lib/cyberweb/toplevel_methods/html_tables.rb +42 -30
- data/lib/cyberweb/toplevel_methods/log_directory.rb +11 -8
- data/lib/cyberweb/toplevel_methods/misc.rb +84 -47
- data/lib/cyberweb/toplevel_methods/path.rb +29 -8
- data/lib/cyberweb/toplevel_methods/temp_directory.rb +3 -1
- data/lib/cyberweb/version/version.rb +2 -2
- data/lib/cyberweb/web_images/map_symbol_to_image_location.rb +43 -7
- data/lib/cyberweb/web_object/favicon.rb +4 -106
- data/lib/cyberweb/web_object/html_tags.rb +133 -65
- data/lib/cyberweb/web_object/images.rb +20 -20
- data/lib/cyberweb/web_object/javascript_and_jquery.rb +39 -16
- data/lib/cyberweb/web_object/link.rb +18 -15
- data/lib/cyberweb/web_object/misc.rb +4158 -327
- data/lib/cyberweb/web_object/reset.rb +19 -15
- data/lib/cyberweb/web_object/run.rb +2 -0
- data/lib/cyberweb/web_object/web_object.rb +1 -3584
- data/lib/cyberweb/webmin/simple_forum/index.cgi +30 -0
- data/lib/cyberweb/webmin/simple_forum/simple_forum.rb +134 -0
- data/lib/cyberweb/yaml/http_status_codes.yml +3 -0
- data/lib/cyberweb/yaml/js_files_to_load.yml +6 -1
- data/test/html_template/html_template.rb +22 -3
- data/test/simple_tests/testing_the_javascript_component.cgi +32 -0
- data/test/simple_tests/testing_the_select_tag.cgi +7 -1
- metadata +13 -4
@@ -11,80 +11,4190 @@ module Cyberweb
|
|
11
11
|
class WebObject < ::Cyberweb::Base # === Cyberweb::WebObject
|
12
12
|
|
13
13
|
require 'cyberweb/javascript/javascript_helper/javascript_helper.rb'
|
14
|
+
require 'cyberweb/modules/css_style.rb'
|
15
|
+
|
16
|
+
# ========================================================================= #
|
17
|
+
# === string_link
|
18
|
+
#
|
19
|
+
# This method essentially creates a String representation of the HTML
|
20
|
+
# <a> tag.
|
21
|
+
#
|
22
|
+
# Since as of April 2022 the method "slink" is now an alias to string_link;
|
23
|
+
# it used to be an alias towards "def a()", but this was changed - the
|
24
|
+
# word string_link more logically may refer to slink as its intrinsic
|
25
|
+
# abbreviation.
|
26
|
+
# ========================================================================= #
|
27
|
+
def string_link(
|
28
|
+
i = '',
|
29
|
+
option_hash = {},
|
30
|
+
&block
|
31
|
+
)
|
32
|
+
# ======================================================================= #
|
33
|
+
# === Handle blocks given to this method next
|
34
|
+
# ======================================================================= #
|
35
|
+
if block_given?
|
36
|
+
yielded = yield
|
37
|
+
case yielded
|
38
|
+
# ===================================================================== #
|
39
|
+
# === :pretty
|
40
|
+
# ===================================================================== #
|
41
|
+
when :pretty
|
42
|
+
i = beautiful_url(i)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
if i.is_a?(Symbol)
|
46
|
+
if i.start_with?('local_')
|
47
|
+
i = BeautifulUrl.local_menu(i)
|
48
|
+
else
|
49
|
+
i = beautiful_url(i)
|
50
|
+
# =================================================================== #
|
51
|
+
# Also check if the second argument is a String. In this case we
|
52
|
+
# must modify it. Example for input that fulfils this criterium:
|
53
|
+
#
|
54
|
+
# remote_link(:hydrogenase, 'Hydrogenase')+
|
55
|
+
#
|
56
|
+
# =================================================================== #
|
57
|
+
if option_hash.is_a? String
|
58
|
+
option_hash = { content: option_hash }
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
# ======================================================================= #
|
63
|
+
# === Handle local entries for the "/home/x" directory layout.
|
64
|
+
# ======================================================================= #
|
65
|
+
if i.start_with? '/home/x'
|
66
|
+
i = i.dup
|
67
|
+
i.sub!(/\/home\/x\//, relative_path?)
|
68
|
+
end
|
69
|
+
i = rds(i.to_s.dup)
|
70
|
+
# ======================================================================= #
|
71
|
+
# Delegate onto HtmlTags.a().
|
72
|
+
# ======================================================================= #
|
73
|
+
return HtmlTags.a(
|
74
|
+
i, option_hash
|
75
|
+
)
|
76
|
+
end; alias string_a string_link # === string_a
|
77
|
+
alias string_href string_link # === string_href
|
78
|
+
alias string_remote_link string_link # === string_remote_link
|
79
|
+
alias slink string_link # === slink
|
80
|
+
|
81
|
+
# ========================================================================= #
|
82
|
+
# === default_hyperlinks_template1
|
83
|
+
# ========================================================================= #
|
84
|
+
def default_hyperlinks_template1(i = '')
|
85
|
+
default_hyperlink_behaviour
|
86
|
+
template1(i)
|
87
|
+
end; alias default_hyperlinks_template default_hyperlinks_template1 # === default_hyperlinks_template
|
88
|
+
alias hyperlinks_template1 default_hyperlinks_template1 # === hyperlinks_template1
|
89
|
+
alias hyperlinks_template default_hyperlinks_template1 # === hyperlinks_template
|
90
|
+
|
91
|
+
# ========================================================================= #
|
92
|
+
# === draw_triangle
|
93
|
+
# ========================================================================= #
|
94
|
+
def draw_triangle(
|
95
|
+
hash = {
|
96
|
+
width: 200, # in px
|
97
|
+
height: 200, # in px
|
98
|
+
background_color: :crimson,
|
99
|
+
border_radius: '50%'
|
100
|
+
}
|
101
|
+
)
|
102
|
+
addnl(
|
103
|
+
::Cyberweb.draw_triangle(hash)
|
104
|
+
)
|
105
|
+
end
|
106
|
+
|
107
|
+
# ========================================================================= #
|
108
|
+
# === draw_circle
|
109
|
+
# ========================================================================= #
|
110
|
+
def draw_circle(
|
111
|
+
hash = {
|
112
|
+
width: 200, # in px
|
113
|
+
height: 200, # in px
|
114
|
+
background_color: :crimson,
|
115
|
+
border_radius: '50%'
|
116
|
+
}
|
117
|
+
)
|
118
|
+
addnl(
|
119
|
+
::Cyberweb.draw_circle(hash)
|
120
|
+
)
|
121
|
+
end
|
122
|
+
|
123
|
+
# ========================================================================= #
|
124
|
+
# === circle
|
125
|
+
# ========================================================================= #
|
126
|
+
def circle(
|
127
|
+
hash = {
|
128
|
+
height: 150,
|
129
|
+
colour: :yellow,
|
130
|
+
radius: :quarter_default_width,
|
131
|
+
stroke_width: 10
|
132
|
+
}
|
133
|
+
)
|
134
|
+
_ = ::Cyberweb.circle(hash)
|
135
|
+
addnl(_)
|
136
|
+
end
|
137
|
+
|
138
|
+
# ========================================================================= #
|
139
|
+
# === div_default_english
|
140
|
+
# ========================================================================= #
|
141
|
+
def div_default_english(
|
142
|
+
optional_css_class = '',
|
143
|
+
the_id = '',
|
144
|
+
optional_css_style = '',
|
145
|
+
&block
|
146
|
+
)
|
147
|
+
add_this_div(
|
148
|
+
optional_css_class,
|
149
|
+
the_id,
|
150
|
+
optional_css_style
|
151
|
+
)
|
152
|
+
ee sg(:english_flag, 'mar8px')
|
153
|
+
yield if block_given?
|
154
|
+
cdiv
|
155
|
+
end
|
156
|
+
|
157
|
+
# ========================================================================= #
|
158
|
+
# === div_default
|
159
|
+
# ========================================================================= #
|
160
|
+
def div_default(
|
161
|
+
optional_css_class = '',
|
162
|
+
the_id = '',
|
163
|
+
optional_css_style = '',
|
164
|
+
&block
|
165
|
+
)
|
166
|
+
if optional_css_class.is_a? Hash
|
167
|
+
# ===================================================================== #
|
168
|
+
# === id
|
169
|
+
# ===================================================================== #
|
170
|
+
if optional_css_class.has_key? :id
|
171
|
+
the_id = optional_css_class.delete(:id)
|
172
|
+
end
|
173
|
+
# ===================================================================== #
|
174
|
+
# === css_class
|
175
|
+
#
|
176
|
+
# This entry must come last.
|
177
|
+
# ===================================================================== #
|
178
|
+
if optional_css_class.has_key? :css_class
|
179
|
+
optional_css_class = optional_css_class.delete(:css_class)
|
180
|
+
end
|
181
|
+
end
|
182
|
+
optional_css_class = optional_css_class.to_s.dup
|
183
|
+
optional_css_class.prepend('default ') # Make it the first argument, always.
|
184
|
+
div(
|
185
|
+
optional_css_class.strip,
|
186
|
+
the_id,
|
187
|
+
optional_css_style,
|
188
|
+
&block
|
189
|
+
)
|
190
|
+
end
|
191
|
+
|
192
|
+
# ========================================================================= #
|
193
|
+
# === cursor
|
194
|
+
# ========================================================================= #
|
195
|
+
def cursor(
|
196
|
+
i = :wait
|
197
|
+
)
|
198
|
+
append_onto_the_body_css_class "cursor_#{i}"
|
199
|
+
end
|
200
|
+
|
201
|
+
# ========================================================================= #
|
202
|
+
# === append_onto_the_body_css_class
|
203
|
+
# ========================================================================= #
|
204
|
+
def append_onto_the_body_css_class(i)
|
205
|
+
if @internal_hash[:body_css_class].frozen?
|
206
|
+
@internal_hash[:body_css_class] = @internal_hash[:body_css_class].dup
|
207
|
+
end
|
208
|
+
@internal_hash[:body_css_class] << " #{i}"
|
209
|
+
@internal_hash[:body_css_class].strip!
|
210
|
+
end
|
211
|
+
|
212
|
+
# ========================================================================= #
|
213
|
+
# === close_html_after_making_sure_that_the_body_tag_exists
|
214
|
+
# ========================================================================= #
|
215
|
+
def close_html_after_making_sure_that_the_body_tag_exists
|
216
|
+
splitted = result?.split("\n")
|
217
|
+
unless splitted.any? {|line| line.start_with? '<body' }
|
218
|
+
addnl(:body, @internal_hash[:body_css_class])
|
219
|
+
end
|
220
|
+
close_html
|
221
|
+
end
|
222
|
+
|
223
|
+
# ========================================================================= #
|
224
|
+
# === set_body_css_class
|
225
|
+
#
|
226
|
+
# This method can be used to designate a (or several) css_class(es)
|
227
|
+
# in the <body> tag of a webpage.
|
228
|
+
# ========================================================================= #
|
229
|
+
def set_body_css_class(
|
230
|
+
i = ''
|
231
|
+
)
|
232
|
+
@internal_hash[:body_css_class] = i.to_s
|
233
|
+
end; alias body_css_class set_body_css_class # === body_css_class
|
234
|
+
alias body_css_class= set_body_css_class # === body_css_class=
|
235
|
+
alias body_css_classes set_body_css_class # === body_css_classes
|
236
|
+
alias body_css_class set_body_css_class # === body_css_class
|
237
|
+
alias body_css= set_body_css_class # === body_css=
|
238
|
+
alias body_css set_body_css_class # === body_css
|
239
|
+
alias bcc= set_body_css_class # === bcc=
|
240
|
+
alias bcc set_body_css_class # === bcc
|
241
|
+
alias main_body= set_body_css_class # === main_body?
|
242
|
+
alias main_body set_body_css_class # === main_body
|
243
|
+
alias body= set_body_css_class # === body?
|
244
|
+
alias body set_body_css_class # === body
|
245
|
+
alias css_class set_body_css_class # === css_class
|
246
|
+
alias b1= set_body_css_class # === b1=
|
247
|
+
alias b1 set_body_css_class # === b1
|
248
|
+
|
249
|
+
# ========================================================================= #
|
250
|
+
# === table3
|
251
|
+
# ========================================================================= #
|
252
|
+
def table3(
|
253
|
+
css_class = '',
|
254
|
+
id = '',
|
255
|
+
css_style = '',
|
256
|
+
*content,
|
257
|
+
&block
|
258
|
+
)
|
259
|
+
addn(
|
260
|
+
string_table3(
|
261
|
+
css_class,
|
262
|
+
id,
|
263
|
+
css_style,
|
264
|
+
content,
|
265
|
+
&block
|
266
|
+
)
|
267
|
+
)
|
268
|
+
end
|
269
|
+
|
270
|
+
# ========================================================================= #
|
271
|
+
# === string_table3
|
272
|
+
#
|
273
|
+
# We will delegate towards Cyberweb.string_table3 for the
|
274
|
+
# functionality here.
|
275
|
+
# ========================================================================= #
|
276
|
+
def string_table3(
|
277
|
+
css_class = '',
|
278
|
+
id = '',
|
279
|
+
css_style = '',
|
280
|
+
*content,
|
281
|
+
&block
|
282
|
+
)
|
283
|
+
::Cyberweb.string_table3(
|
284
|
+
css_class,
|
285
|
+
id,
|
286
|
+
css_style,
|
287
|
+
content,
|
288
|
+
&block
|
289
|
+
)
|
290
|
+
end
|
291
|
+
|
292
|
+
# ========================================================================= #
|
293
|
+
# === table7
|
294
|
+
# ========================================================================= #
|
295
|
+
def table7(
|
296
|
+
css_class = '', id = '', css_style = '', *content
|
297
|
+
)
|
298
|
+
addn(
|
299
|
+
string_table7(
|
300
|
+
css_class, id, css_style, content
|
301
|
+
)
|
302
|
+
)
|
303
|
+
end
|
304
|
+
|
305
|
+
# ========================================================================= #
|
306
|
+
# === string_table5_with_heading
|
307
|
+
# ========================================================================= #
|
308
|
+
def string_table5_with_heading(css_class = '', id = '', css_style = '', *content)
|
309
|
+
::Cyberweb.string_table5_with_heading(
|
310
|
+
css_class, id, css_style,
|
311
|
+
content
|
312
|
+
)
|
313
|
+
end
|
314
|
+
|
315
|
+
require 'cyberweb/javascript/on_click_change_opacity.rb'
|
316
|
+
# ========================================================================= #
|
317
|
+
# === on_click_make_darker
|
318
|
+
# ========================================================================= #
|
319
|
+
def on_click_make_darker(this_id, opacity = '0.90')
|
320
|
+
addn(
|
321
|
+
::Cyberweb.on_click_make_darker(this_id, opacity)
|
322
|
+
)
|
323
|
+
end
|
324
|
+
|
325
|
+
# ========================================================================= #
|
326
|
+
# === datume
|
327
|
+
#
|
328
|
+
# Like datum() but for english.
|
329
|
+
# ========================================================================= #
|
330
|
+
def datume(
|
331
|
+
welches_datum = '',
|
332
|
+
css_class = 'martb4px s2px yel',
|
333
|
+
optional_id = nil,
|
334
|
+
optional_css_style = ''
|
335
|
+
)
|
336
|
+
if optional_id.is_a? Hash
|
337
|
+
optional_id = optional_id.delete(:id)
|
338
|
+
end
|
339
|
+
optional_id = optional_id.to_s
|
340
|
+
welches_datum = date_today if welches_datum.empty? # Ask the method above.
|
341
|
+
p(css_class, optional_id, optional_css_style) {
|
342
|
+
espan "<ud class=\"BOLD\">Date</ud>: "\
|
343
|
+
"<b>#{welches_datum}</b>"
|
344
|
+
}
|
345
|
+
end
|
346
|
+
|
347
|
+
# ========================================================================= #
|
348
|
+
# === close_html_then_serve_the_webpage
|
349
|
+
# ========================================================================= #
|
350
|
+
def close_html_then_serve_the_webpage
|
351
|
+
close_html
|
352
|
+
serve_webpage
|
353
|
+
end
|
354
|
+
|
355
|
+
# ========================================================================= #
|
356
|
+
# === datum
|
357
|
+
#
|
358
|
+
# Display datum. The argument `welches_datum` will be empty by default
|
359
|
+
# and will in this case call the method date_today().
|
360
|
+
#
|
361
|
+
# Usage examples:
|
362
|
+
#
|
363
|
+
# datum '06.08.2008','BG_Black yel wid20 pad4px', id: 'datum'
|
364
|
+
#
|
365
|
+
# ========================================================================= #
|
366
|
+
def datum(
|
367
|
+
welches_datum = '',
|
368
|
+
css_class = 'martb4px s2px yel',
|
369
|
+
optional_id = nil,
|
370
|
+
optional_css_style = ''
|
371
|
+
)
|
372
|
+
if optional_id.is_a? Hash
|
373
|
+
optional_id = optional_id.delete(:id)
|
374
|
+
end
|
375
|
+
optional_id = optional_id.to_s
|
376
|
+
welches_datum = date_today if welches_datum.empty? # Ask the method above.
|
377
|
+
p(css_class, optional_id, optional_css_style) {
|
378
|
+
espan "<ud class=\"BOLD\">Datum</ud>: "\
|
379
|
+
"<b>#{welches_datum}</b>"
|
380
|
+
}
|
381
|
+
end; alias show_datum datum # === show_datum
|
382
|
+
alias datumg datum # === datumg
|
383
|
+
|
384
|
+
# ========================================================================= #
|
385
|
+
# === marl1em
|
386
|
+
# ========================================================================= #
|
387
|
+
def marl1em(
|
388
|
+
i = '',
|
389
|
+
optional_css_class = '',
|
390
|
+
optional_the_id = ''
|
391
|
+
)
|
392
|
+
optional_css_class = optional_css_class.dup
|
393
|
+
optional_css_class << ' marl1em'
|
394
|
+
s2(i, optional_css_class.strip)
|
395
|
+
end
|
396
|
+
|
397
|
+
# ========================================================================= #
|
398
|
+
# === marl2em
|
399
|
+
# ========================================================================= #
|
400
|
+
def marl2em(
|
401
|
+
i = '',
|
402
|
+
optional_css_class = '',
|
403
|
+
optional_the_id = ''
|
404
|
+
)
|
405
|
+
optional_css_class = optional_css_class.dup
|
406
|
+
optional_css_class << ' marl2em'
|
407
|
+
s2(i, optional_css_class.strip)
|
408
|
+
end
|
409
|
+
|
410
|
+
# ========================================================================= #
|
411
|
+
# === marl3em
|
412
|
+
# ========================================================================= #
|
413
|
+
def marl3em(
|
414
|
+
i = '',
|
415
|
+
optional_css_class = '',
|
416
|
+
optional_the_id = ''
|
417
|
+
)
|
418
|
+
optional_css_class = optional_css_class.dup
|
419
|
+
optional_css_class << ' marl3em'
|
420
|
+
s2(i, optional_css_class.strip, optional_the_id)
|
421
|
+
end
|
422
|
+
|
423
|
+
# ========================================================================= #
|
424
|
+
# === default_doc_type?
|
425
|
+
# ========================================================================= #
|
426
|
+
def default_doc_type?
|
427
|
+
DOCTYPE_HTML5
|
428
|
+
end
|
429
|
+
|
430
|
+
# ========================================================================= #
|
431
|
+
# === german_unicode
|
432
|
+
# ========================================================================= #
|
433
|
+
def german_unicode
|
434
|
+
use_german
|
435
|
+
use_unicode
|
436
|
+
end
|
437
|
+
|
438
|
+
# ========================================================================= #
|
439
|
+
# === string_table2
|
440
|
+
# ========================================================================= #
|
441
|
+
def string_table2(
|
442
|
+
css_class = '',
|
443
|
+
the_id = '',
|
444
|
+
css_style = '',
|
445
|
+
*content,
|
446
|
+
&block
|
447
|
+
)
|
448
|
+
::Cyberweb.string_table2(
|
449
|
+
css_class,
|
450
|
+
the_id,
|
451
|
+
css_style,
|
452
|
+
content,
|
453
|
+
&block
|
454
|
+
)
|
455
|
+
end
|
456
|
+
|
457
|
+
# ========================================================================= #
|
458
|
+
# === table2
|
459
|
+
#
|
460
|
+
# This variant maks a two-elements-per-row HTML table.
|
461
|
+
#
|
462
|
+
# The last variable is the content; keep it even, if possible, e. g
|
463
|
+
# 2 elements or 4 or 6 and so forth.
|
464
|
+
# ========================================================================= #
|
465
|
+
def table2(
|
466
|
+
css_class = '',
|
467
|
+
id = '',
|
468
|
+
css_style = '',
|
469
|
+
*content,
|
470
|
+
&block
|
471
|
+
)
|
472
|
+
addn(
|
473
|
+
string_table2(
|
474
|
+
css_class,
|
475
|
+
id,
|
476
|
+
css_style,
|
477
|
+
content.flatten,
|
478
|
+
&block
|
479
|
+
)
|
480
|
+
)
|
481
|
+
end
|
482
|
+
|
483
|
+
# ========================================================================= #
|
484
|
+
# === glossar_table
|
485
|
+
# ========================================================================= #
|
486
|
+
def glossar_table(
|
487
|
+
*use_this_dataset
|
488
|
+
)
|
489
|
+
use_this_dataset.flatten!
|
490
|
+
use_this_dataset.compact!
|
491
|
+
table2('pad0_5em','glossar') {{
|
492
|
+
with_this_data: use_this_dataset
|
493
|
+
}}
|
494
|
+
end; alias glossar glossar_table # === glossar
|
495
|
+
|
496
|
+
# ========================================================================= #
|
497
|
+
# === table5_with_heading
|
498
|
+
# ========================================================================= #
|
499
|
+
def table5_with_heading(
|
500
|
+
css_class = '',
|
501
|
+
id = '',
|
502
|
+
css_style = '',
|
503
|
+
*content
|
504
|
+
)
|
505
|
+
addn(
|
506
|
+
string_table5_with_heading(
|
507
|
+
css_class, id, css_style, content
|
508
|
+
)
|
509
|
+
)
|
510
|
+
end
|
511
|
+
|
512
|
+
# ========================================================================= #
|
513
|
+
# === table_set_css_class
|
514
|
+
# ========================================================================= #
|
515
|
+
def table_set_css_class(
|
516
|
+
i = 'marl2em'
|
517
|
+
)
|
518
|
+
::Cyberweb::Table.set_css_class(i)
|
519
|
+
end
|
520
|
+
|
521
|
+
# ========================================================================= #
|
522
|
+
# === add_to_main_string_lateron
|
523
|
+
# ========================================================================= #
|
524
|
+
def add_to_main_string_lateron(i)
|
525
|
+
@internal_hash[:string_lateron] << i
|
526
|
+
end
|
527
|
+
|
528
|
+
# ========================================================================= #
|
529
|
+
# === title?
|
530
|
+
#
|
531
|
+
# Query method for the title of our webpage.
|
532
|
+
#
|
533
|
+
# Note that the method .title() is an alias for .title?(); in the past,
|
534
|
+
# before April 2022, it was an alias for .set_title() instead.
|
535
|
+
# ========================================================================= #
|
536
|
+
def title?
|
537
|
+
::Cyberweb.title?
|
538
|
+
end; alias use_this_title? title? # === use_this_title?
|
539
|
+
alias title title? # === use_this_title?
|
540
|
+
|
541
|
+
# ========================================================================= #
|
542
|
+
# === add_html_comment
|
543
|
+
#
|
544
|
+
# This method will add the given input as HTML comment into the
|
545
|
+
# web-object at hand.
|
546
|
+
# ========================================================================= #
|
547
|
+
def add_html_comment(i = '')
|
548
|
+
addnl(
|
549
|
+
::Cyberweb.html_comment(i)
|
550
|
+
)
|
551
|
+
end; alias ehtml_comment add_html_comment # === ehtml_comment
|
552
|
+
alias html_comment add_html_comment # === html_comment
|
553
|
+
|
554
|
+
# ========================================================================= #
|
555
|
+
# === generate_cap_box
|
556
|
+
#
|
557
|
+
# Usage example:
|
558
|
+
#
|
559
|
+
# generate_cap_box(
|
560
|
+
# string_h1(
|
561
|
+
# sg(:package,'marr8px','drag_job_listing')+
|
562
|
+
# 'Job Listing',
|
563
|
+
# 'job_listing'
|
564
|
+
# )
|
565
|
+
# ) {{ width: '95%' }}
|
566
|
+
#
|
567
|
+
# ========================================================================= #
|
568
|
+
def generate_cap_box(
|
569
|
+
use_this_title_for_the_upper_box = 'Hello world!',
|
570
|
+
# ===================================================================== #
|
571
|
+
# The next variable is the inner content - by default it will
|
572
|
+
# be empty.
|
573
|
+
# ===================================================================== #
|
574
|
+
title_for_the_content_header = '',
|
575
|
+
inner_content = '', # This is the inner content.<br>Looks fancy!<br>',
|
576
|
+
border_to_use = '3px solid #2a2a2a',
|
577
|
+
box_width = '700px'
|
578
|
+
)
|
579
|
+
::Cyberweb.generate_cap_box(
|
580
|
+
use_this_title_for_the_upper_box,
|
581
|
+
title_for_the_content_header,
|
582
|
+
inner_content,
|
583
|
+
border_to_use,
|
584
|
+
box_width
|
585
|
+
)
|
586
|
+
end
|
587
|
+
|
588
|
+
# ========================================================================= #
|
589
|
+
# === javascript?
|
590
|
+
# ========================================================================= #
|
591
|
+
def javascript?
|
592
|
+
@internal_hash[:javascript]
|
593
|
+
end
|
594
|
+
|
595
|
+
# ========================================================================= #
|
596
|
+
# === logical_build_up
|
597
|
+
#
|
598
|
+
# This method can be used to "build up" a webpage from scratch.
|
599
|
+
#
|
600
|
+
# Furthermore it can be used to also "build from the middle", that is
|
601
|
+
# start at a later point in time if necessary.
|
602
|
+
#
|
603
|
+
# This is experimental right now in October 2021 - perhaps one day we
|
604
|
+
# will make it to handle all logical "small steps".
|
605
|
+
# ========================================================================= #
|
606
|
+
def logical_build_up(
|
607
|
+
array =
|
608
|
+
[
|
609
|
+
:html_start_tag,
|
610
|
+
:head_start_tag,
|
611
|
+
:add_the_meta_tags,
|
612
|
+
:close_body_head_and_html_tag
|
613
|
+
]
|
614
|
+
)
|
615
|
+
array.each {|entry|
|
616
|
+
send(entry)
|
617
|
+
}
|
618
|
+
end
|
619
|
+
|
620
|
+
# ========================================================================= #
|
621
|
+
# === marl4em
|
622
|
+
# ========================================================================= #
|
623
|
+
def marl4em(
|
624
|
+
i = '',
|
625
|
+
optional_css_class = '',
|
626
|
+
optional_the_id = ''
|
627
|
+
)
|
628
|
+
optional_css_class = optional_css_class.dup
|
629
|
+
optional_css_class << ' marl4em'
|
630
|
+
s2(i, optional_css_class.strip)
|
631
|
+
end
|
632
|
+
|
633
|
+
# ========================================================================= #
|
634
|
+
# === marl5em
|
635
|
+
# ========================================================================= #
|
636
|
+
def marl5em(
|
637
|
+
i = '',
|
638
|
+
optional_css_class = '',
|
639
|
+
optional_the_id = ''
|
640
|
+
)
|
641
|
+
optional_css_class = optional_css_class.dup
|
642
|
+
optional_css_class << ' marl5em'
|
643
|
+
s2(i, optional_css_class.strip)
|
644
|
+
end
|
645
|
+
|
646
|
+
# ========================================================================= #
|
647
|
+
# === view_source
|
648
|
+
# ========================================================================= #
|
649
|
+
def view_source(
|
650
|
+
css_class = 'wid25',
|
651
|
+
optional_id = 'view_source',
|
652
|
+
optional_css_style = ''
|
653
|
+
)
|
654
|
+
button_css = 'view_source BG_White Black pad2px'
|
655
|
+
if css_class.is_a? Hash
|
656
|
+
css_class = css_class.delete :css_class
|
657
|
+
end
|
658
|
+
form '', '', '', optional_id, optional_css_style
|
659
|
+
ee '<input class="'+button_css+' '+css_class+'" type="button" value="View Source" '
|
660
|
+
# ee 'onClick=\'window.location = "view-source:"+window.location.href\'
|
661
|
+
ee "onClick='window.location=\"view-source:\"+window.location.href'"
|
662
|
+
ee '>'+"\n"
|
663
|
+
cform
|
664
|
+
end
|
665
|
+
|
666
|
+
# ========================================================================= #
|
667
|
+
# === ordered_list
|
668
|
+
#
|
669
|
+
# This method can be used to show an ordered list.
|
670
|
+
# ========================================================================= #
|
671
|
+
def ordered_list(
|
672
|
+
array = %w( cat dog parrot deer horse )
|
673
|
+
)
|
674
|
+
_ = "<ol>\n".dup
|
675
|
+
array.each {|this_entry|
|
676
|
+
_ << "<li>#{this_entry}</li>\n"
|
677
|
+
}
|
678
|
+
_ << "</ol>\n\n"
|
679
|
+
addnl(_)
|
680
|
+
end
|
681
|
+
|
682
|
+
# ========================================================================= #
|
683
|
+
# === make_this_id_draggable
|
684
|
+
#
|
685
|
+
# Note that this will be guaranteed to always add the corresponding
|
686
|
+
# javascript code, which is different to javascript_drag_and_drop().
|
687
|
+
#
|
688
|
+
# This is why you should not use it directly - instead, use
|
689
|
+
# javascript_drag_and_drop().
|
690
|
+
# ========================================================================= #
|
691
|
+
def make_this_id_draggable(this_id)
|
692
|
+
addnl(
|
693
|
+
::Cyberweb.return_javascript_drag_and_drop(this_id)
|
694
|
+
)
|
695
|
+
end; private :make_this_id_draggable
|
696
|
+
|
697
|
+
# ========================================================================= #
|
698
|
+
# === prepend_doc_type
|
699
|
+
# ========================================================================= #
|
700
|
+
def prepend_doc_type
|
701
|
+
@internal_hash[:html_string].prepend(
|
702
|
+
"#{default_doc_type?}\n"
|
703
|
+
)
|
704
|
+
end
|
705
|
+
|
706
|
+
# ========================================================================= #
|
707
|
+
# === return_jquery_string
|
708
|
+
#
|
709
|
+
# Since as of 21.09.2014 this method will return two .js files here.
|
710
|
+
#
|
711
|
+
# The version of jquery-ui is currently hardcoded.
|
712
|
+
#
|
713
|
+
# The latest version of jquery-ui can be viewed here:
|
714
|
+
#
|
715
|
+
# https://code.jquery.com/ui/
|
716
|
+
#
|
717
|
+
# ========================================================================= #
|
718
|
+
def return_jquery_string(
|
719
|
+
jquery_ui_version = Cyberweb.jquery_ui_version?
|
720
|
+
)
|
721
|
+
return ::Cyberweb.return_jquery_string(jquery_ui_version)
|
722
|
+
end; alias build_jquery_string return_jquery_string # === build_jquery_string
|
723
|
+
|
724
|
+
require 'cyberweb/javascript/drag_and_drop.rb'
|
725
|
+
# ========================================================================= #
|
726
|
+
# === drag_and_drop
|
727
|
+
# ========================================================================= #
|
728
|
+
def drag_and_drop(
|
729
|
+
this_id = 'drag_test'
|
730
|
+
)
|
731
|
+
if use_jquery?
|
732
|
+
addnl(
|
733
|
+
::Cyberweb.return_javascript_drag_and_drop(this_id)
|
734
|
+
)
|
735
|
+
end
|
736
|
+
end; alias drag drag_and_drop # === drag
|
737
|
+
alias enable_drag_for drag_and_drop # === enable_drag_for
|
738
|
+
alias drag_n_drop drag_and_drop # === drag_n_drop
|
739
|
+
alias drag_drop drag_and_drop # === drag_drop
|
740
|
+
alias add_javascript_drag drag_and_drop # === add_javascript_drag
|
741
|
+
|
742
|
+
# ========================================================================= #
|
743
|
+
# === update_the_body
|
744
|
+
#
|
745
|
+
# This method will update the content of the <body> tag, via javascript.
|
746
|
+
# ========================================================================= #
|
747
|
+
def update_the_body(with_this_content)
|
748
|
+
ejavascript'
|
749
|
+
document.body.innerHTML = "'+with_this_content+'"
|
750
|
+
'
|
751
|
+
end
|
752
|
+
|
753
|
+
# ========================================================================= #
|
754
|
+
# === string_table2_with_heading
|
755
|
+
# ========================================================================= #
|
756
|
+
def string_table2_with_heading(
|
757
|
+
css_class = '',
|
758
|
+
id = '',
|
759
|
+
css_style = '',
|
760
|
+
*content
|
761
|
+
)
|
762
|
+
::Cyberweb.string_table2_with_heading(
|
763
|
+
css_class, id, css_style,
|
764
|
+
content
|
765
|
+
)
|
766
|
+
end
|
767
|
+
|
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
|
+
# ========================================================================= #
|
806
|
+
# === string_table7
|
807
|
+
# ========================================================================= #
|
808
|
+
def string_table7(
|
809
|
+
css_class = '',
|
810
|
+
id = '',
|
811
|
+
css_style = '',
|
812
|
+
*content
|
813
|
+
)
|
814
|
+
# ======================================================================= #
|
815
|
+
# To test, try:
|
816
|
+
#
|
817
|
+
# puts ::Cyberweb.string_table5('','','',%w( ah asjhk avshvasjkh vajhksavjhk avsjhvashkjavs ))
|
818
|
+
#
|
819
|
+
# ======================================================================= #
|
820
|
+
::Cyberweb.string_table7(
|
821
|
+
css_class, id, css_style, content
|
822
|
+
)
|
823
|
+
end
|
824
|
+
|
825
|
+
# ========================================================================= #
|
826
|
+
# === string_table5
|
827
|
+
# ========================================================================= #
|
828
|
+
def string_table5(
|
829
|
+
css_class = '',
|
830
|
+
id = '',
|
831
|
+
css_style = '',
|
832
|
+
*content
|
833
|
+
)
|
834
|
+
# ======================================================================= #
|
835
|
+
# To test, try:
|
836
|
+
#
|
837
|
+
# puts ::Cyberweb.string_table5('','','',%w( ah asjhk avshvasjkh vajhksavjhk avsjhvashkjavs ))
|
838
|
+
#
|
839
|
+
# ======================================================================= #
|
840
|
+
::Cyberweb.string_table5(
|
841
|
+
css_class, id, css_style, content
|
842
|
+
)
|
843
|
+
end
|
844
|
+
|
845
|
+
# ========================================================================= #
|
846
|
+
# === parse_table
|
847
|
+
# ========================================================================= #
|
848
|
+
def parse_table(*args)
|
849
|
+
addnl(
|
850
|
+
::Cyberweb.parse_table(args)
|
851
|
+
)
|
852
|
+
end
|
853
|
+
|
854
|
+
# ========================================================================= #
|
855
|
+
# === n_steps_to_the_base_directory?
|
856
|
+
# ========================================================================= #
|
857
|
+
def n_steps_to_the_base_directory?
|
858
|
+
Cyberweb.n_slashes_towards_the_server_base_directory
|
859
|
+
end
|
860
|
+
|
861
|
+
# ========================================================================= #
|
862
|
+
# === string_table11_with_heading
|
863
|
+
# ========================================================================= #
|
864
|
+
def string_table11_with_heading(
|
865
|
+
css_class = '', id = '', css_style = '', *content
|
866
|
+
)
|
867
|
+
::Cyberweb.string_table11_with_heading(
|
868
|
+
css_class, id, css_style,
|
869
|
+
content
|
870
|
+
)
|
871
|
+
end
|
872
|
+
|
873
|
+
# ========================================================================= #
|
874
|
+
# === string_table12_with_heading
|
875
|
+
# ========================================================================= #
|
876
|
+
def string_table12_with_heading(
|
877
|
+
css_class = '',
|
878
|
+
id = '',
|
879
|
+
css_style = '',
|
880
|
+
*content
|
881
|
+
)
|
882
|
+
::Cyberweb.string_table12_with_heading(
|
883
|
+
css_class, id, css_style,
|
884
|
+
content
|
885
|
+
)
|
886
|
+
end
|
887
|
+
|
888
|
+
# ========================================================================= #
|
889
|
+
# === show_cheerleader
|
890
|
+
#
|
891
|
+
# Shows an ASCII cheerleader.
|
892
|
+
# ========================================================================= #
|
893
|
+
def show_cheerleader(
|
894
|
+
path_to_cheerleader_file = Cyberweb.path_to_data?+'CODE/javascript/cheerleader.js'
|
895
|
+
)
|
896
|
+
filename = 'cheerleader.js'
|
897
|
+
_ = path_to_cheerleader_file
|
898
|
+
_ << filename unless _[-filename.size, filename.size] == filename
|
899
|
+
load_javascript(_)
|
900
|
+
end
|
901
|
+
|
902
|
+
# ========================================================================= #
|
903
|
+
# === chmod_displayer
|
904
|
+
# ========================================================================= #
|
905
|
+
def chmod_displayer(i = :default)
|
906
|
+
addnl(
|
907
|
+
::Cyberweb.chmod_displayer(i)
|
908
|
+
)
|
909
|
+
end
|
910
|
+
|
911
|
+
require 'cyberweb/javascript/javascript.rb'
|
912
|
+
# ========================================================================= #
|
913
|
+
# === sanitize_javascript
|
914
|
+
# ========================================================================= #
|
915
|
+
def sanitize_javascript(i)
|
916
|
+
::Cyberweb.sanitize_javascript(i)
|
917
|
+
end
|
918
|
+
|
919
|
+
# ========================================================================= #
|
920
|
+
# === javascript_script=
|
921
|
+
#
|
922
|
+
# This method assigns to the @javascript variable. We expect it to
|
923
|
+
# hold strings related to javascript-code.
|
924
|
+
# ========================================================================= #
|
925
|
+
def javascript_script=(i)
|
926
|
+
if @internal_hash[:javascript].frozen?
|
927
|
+
@internal_hash[:javascript] = @internal_hash[:javascript].dup
|
928
|
+
end
|
929
|
+
@internal_hash[:javascript] << return_javascript(i) # Tap into javascript/ subdirectory.
|
930
|
+
end; alias javascript_in_head_tag javascript_script= # === javascript_in_head_tag
|
931
|
+
|
932
|
+
# ========================================================================= #
|
933
|
+
# === save_as_webobject
|
934
|
+
#
|
935
|
+
# This method will save as a WebObject variant, as a .cgi file.
|
936
|
+
# ========================================================================= #
|
937
|
+
def save_as_webobject(
|
938
|
+
into = @internal_hash[:save_into_this_html_page].
|
939
|
+
delete_suffix('.html')+
|
940
|
+
'.cgi'
|
941
|
+
)
|
942
|
+
puts 'Storing into `'+into+'`.'
|
943
|
+
what = ''.dup # string?
|
944
|
+
what.prepend(ruby_header?+"\n")
|
945
|
+
append_this = <<-EOF
|
946
|
+
# =========================================================================== #
|
947
|
+
#
|
948
|
+
# =========================================================================== #
|
949
|
+
require 'cyberweb/autoinclude'
|
950
|
+
|
951
|
+
english('#{use_this_title?}') {
|
952
|
+
created_on '#{dd_mm_yyyy}' # Wednesday.
|
953
|
+
body_css_class ''
|
954
|
+
body_css_style ''
|
955
|
+
font_size ''
|
956
|
+
|
957
|
+
doc {
|
958
|
+
ee '#{body_string?.tr("'","\'")}'
|
959
|
+
}}
|
960
|
+
EOF
|
961
|
+
what << append_this
|
962
|
+
SaveFile.write_what_into(what, into)
|
963
|
+
end
|
964
|
+
|
965
|
+
# ========================================================================= #
|
966
|
+
# === addnl (addnl tag)
|
967
|
+
#
|
968
|
+
# This will call add(), and decree that a newline is used. It will NOT
|
969
|
+
# modify the given input at hand - only add() may modify the given
|
970
|
+
# input at hand.
|
971
|
+
# ========================================================================= #
|
972
|
+
def addnl(
|
973
|
+
i = "\n",
|
974
|
+
optional_css_class = nil
|
975
|
+
)
|
976
|
+
# ======================================================================= #
|
977
|
+
# We can not call .to_s in the next line because we may pass a Symbol
|
978
|
+
# such as :br too.
|
979
|
+
# ======================================================================= #
|
980
|
+
add(i, optional_css_class, :use_a_newline) # Delegate towards add() here.
|
981
|
+
end; alias add_with_newline addnl # === add_with_newline
|
982
|
+
alias add_newline addnl # === add_newline
|
983
|
+
alias addn addnl # === addn
|
984
|
+
alias adnl addnl # === adnl
|
985
|
+
|
986
|
+
# ========================================================================= #
|
987
|
+
# === add (add tag)
|
988
|
+
#
|
989
|
+
# This is the general append-method for whenever we seek to append
|
990
|
+
# onto the main String (stored in @_) of this class.
|
991
|
+
# ========================================================================= #
|
992
|
+
def add(
|
993
|
+
i, # The input here can be a Symbol as well.
|
994
|
+
optional_css_class = nil,
|
995
|
+
optional_entry_for_newline = nil
|
996
|
+
)
|
997
|
+
case i
|
998
|
+
# ======================================================================= #
|
999
|
+
# === :newline
|
1000
|
+
# ======================================================================= #
|
1001
|
+
when :newline,
|
1002
|
+
:use_a_newline
|
1003
|
+
i = NL
|
1004
|
+
# ======================================================================= #
|
1005
|
+
# === :body
|
1006
|
+
# ======================================================================= #
|
1007
|
+
when :body
|
1008
|
+
consider_autoclosing_the_head_tag
|
1009
|
+
i = return_body_tag(optional_css_class).dup
|
1010
|
+
# ======================================================================= #
|
1011
|
+
# === :content_type_plain
|
1012
|
+
# ======================================================================= #
|
1013
|
+
when :content_type_plain
|
1014
|
+
i = Cyberweb::CONTENT_TYPE_PLAIN
|
1015
|
+
end
|
1016
|
+
if i
|
1017
|
+
# ===================================================================== #
|
1018
|
+
# === Handle symbols next
|
1019
|
+
# ===================================================================== #
|
1020
|
+
if i.is_a? Symbol
|
1021
|
+
i = "<#{i}>".dup # Such as for :br aka <br>.
|
1022
|
+
elsif i.is_a? Numeric
|
1023
|
+
i = i.to_s.dup
|
1024
|
+
elsif i.respond_to?(:is_an_objectified_html_tag?) and
|
1025
|
+
i.is_an_objectified_html_tag?
|
1026
|
+
# =================================================================== #
|
1027
|
+
# This entry clause adds support for directly adding
|
1028
|
+
# Objectified::HtmlTags.
|
1029
|
+
# =================================================================== #
|
1030
|
+
i = i.string?
|
1031
|
+
end
|
1032
|
+
if i.is_a?(String) and i.frozen?
|
1033
|
+
i = i.dup
|
1034
|
+
end
|
1035
|
+
end
|
1036
|
+
if i.nil?
|
1037
|
+
i = ''.dup
|
1038
|
+
end
|
1039
|
+
case optional_entry_for_newline
|
1040
|
+
# ======================================================================= #
|
1041
|
+
# === :newline
|
1042
|
+
# ======================================================================= #
|
1043
|
+
when :newline,
|
1044
|
+
:use_a_newline
|
1045
|
+
i << "\n"
|
1046
|
+
end
|
1047
|
+
# ======================================================================= #
|
1048
|
+
# Avoid a frozen main string:
|
1049
|
+
# ======================================================================= #
|
1050
|
+
if @internal_hash[:html_string].frozen?
|
1051
|
+
@internal_hash[:html_string] = @internal_hash[:html_string].dup
|
1052
|
+
end
|
1053
|
+
@internal_hash[:html_string] << i
|
1054
|
+
end; alias append add # === append
|
1055
|
+
alias add_to_main_string add # === add_to_main_string
|
1056
|
+
|
1057
|
+
# ========================================================================= #
|
1058
|
+
# === german
|
1059
|
+
# ========================================================================= #
|
1060
|
+
def german(
|
1061
|
+
use_this_as_title = nil,
|
1062
|
+
&block
|
1063
|
+
)
|
1064
|
+
add_doctype_then_html_start_tag_then_head_tag_then_charset
|
1065
|
+
german_trinity
|
1066
|
+
if use_this_as_title
|
1067
|
+
set_title(use_this_as_title)
|
1068
|
+
end
|
1069
|
+
handle_these_calls(&block)
|
1070
|
+
close_html_after_making_sure_that_the_body_tag_exists
|
1071
|
+
end
|
1072
|
+
|
1073
|
+
# ========================================================================= #
|
1074
|
+
# === create_standalone_html_page
|
1075
|
+
#
|
1076
|
+
# This method can be used to create a standalone .html page, representing
|
1077
|
+
# the WebObject content.
|
1078
|
+
# ========================================================================= #
|
1079
|
+
def create_standalone_html_page(
|
1080
|
+
use_this_filename = filename?
|
1081
|
+
)
|
1082
|
+
Cyberweb.set_log_directory(:classic_FHS_structure)
|
1083
|
+
what = to_html
|
1084
|
+
# ======================================================================= #
|
1085
|
+
# We will store into the log-directory of the Cyberweb project.
|
1086
|
+
# ======================================================================= #
|
1087
|
+
into = Cyberweb.log_directory?+
|
1088
|
+
use_this_filename.delete_suffix(
|
1089
|
+
File.extname(use_this_filename)
|
1090
|
+
)+'.html' # This must be accessible.
|
1091
|
+
message = 'Storing into the local file '+sfile(into)+'.'
|
1092
|
+
e message
|
1093
|
+
puts message
|
1094
|
+
write_what_into(what, into)
|
1095
|
+
end; alias dump_the_html create_standalone_html_page # === dump_the_html
|
1096
|
+
|
1097
|
+
# ========================================================================= #
|
1098
|
+
# === enable_namespace
|
1099
|
+
#
|
1100
|
+
# This simply includes the main Cyberweb "namespace".
|
1101
|
+
# ========================================================================= #
|
1102
|
+
def enable_namespace
|
1103
|
+
Object.send(
|
1104
|
+
:include, ::Cyberweb
|
1105
|
+
)
|
1106
|
+
require 'cyberweb/predefined_and_freeform_methods/predefined_methods.rb'
|
1107
|
+
Object.send(
|
1108
|
+
:include, ::Cyberweb::PredefinedMethods
|
1109
|
+
)
|
1110
|
+
# ======================================================================= #
|
1111
|
+
# The next line was added in March 2022.
|
1112
|
+
# ======================================================================= #
|
1113
|
+
Object.send(
|
1114
|
+
:include, ::Cyberweb::Objectified::Mask
|
1115
|
+
)
|
1116
|
+
end; alias autoextend enable_namespace # === autoextend
|
1117
|
+
|
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
|
+
# ========================================================================= #
|
1128
|
+
# === append_onto_the_main_CSS_rules
|
1129
|
+
# ========================================================================= #
|
1130
|
+
def append_onto_the_main_CSS_rules(i)
|
1131
|
+
@internal_hash[:main_CSS_rules] << i
|
1132
|
+
end
|
1133
|
+
|
1134
|
+
# ========================================================================= #
|
1135
|
+
# === default_hyperlink_behaviour
|
1136
|
+
# ========================================================================= #
|
1137
|
+
def default_hyperlink_behaviour
|
1138
|
+
append_onto_the_main_CSS_rules '
|
1139
|
+
a,
|
1140
|
+
a:link {
|
1141
|
+
text-decoration: none;
|
1142
|
+
}
|
1143
|
+
a:hover {
|
1144
|
+
text-decoration: underline;
|
1145
|
+
}
|
1146
|
+
'
|
1147
|
+
end; alias default_hyperlinks default_hyperlink_behaviour # === default_hyperlinks
|
1148
|
+
|
1149
|
+
# ========================================================================= #
|
1150
|
+
# === alt_text_or_no_alt_text
|
1151
|
+
# ========================================================================= #
|
1152
|
+
def alt_text_or_no_alt_text(i)
|
1153
|
+
unless i.to_s.empty?
|
1154
|
+
i = " alt=\"#{i}\""
|
1155
|
+
end
|
1156
|
+
return i
|
1157
|
+
end
|
1158
|
+
|
1159
|
+
# ========================================================================= #
|
1160
|
+
# === ctbody
|
1161
|
+
# ========================================================================= #
|
1162
|
+
def ctbody
|
1163
|
+
close(:tbody)
|
1164
|
+
end
|
1165
|
+
|
1166
|
+
# ========================================================================= #
|
1167
|
+
# === ctr
|
1168
|
+
# ========================================================================= #
|
1169
|
+
def ctr
|
1170
|
+
close(:tr)
|
1171
|
+
end
|
1172
|
+
|
1173
|
+
# ========================================================================= #
|
1174
|
+
# === ctdctr
|
1175
|
+
# ========================================================================= #
|
1176
|
+
def ctdctr
|
1177
|
+
addn(
|
1178
|
+
'</td></tr>'
|
1179
|
+
)
|
1180
|
+
end
|
1181
|
+
|
1182
|
+
# ========================================================================= #
|
1183
|
+
# === ctdtd
|
1184
|
+
# ========================================================================= #
|
1185
|
+
def ctdtd
|
1186
|
+
addn(
|
1187
|
+
'</td><td>'
|
1188
|
+
)
|
1189
|
+
end
|
1190
|
+
|
1191
|
+
# ========================================================================= #
|
1192
|
+
# === test_the_html_colours
|
1193
|
+
# ========================================================================= #
|
1194
|
+
def test_the_html_colours
|
1195
|
+
all_html_colours.each {|this_html_colour|
|
1196
|
+
e 'Hello world!', this_html_colour
|
1197
|
+
}
|
1198
|
+
end
|
1199
|
+
|
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
|
+
# ========================================================================= #
|
1216
|
+
# === use_the_internal_CSS_files?
|
1217
|
+
# ========================================================================= #
|
1218
|
+
def use_the_internal_CSS_files?
|
1219
|
+
@internal_hash[:use_the_internal_CSS_files]
|
1220
|
+
end; alias use_internal_css_files? use_the_internal_CSS_files? # === use_internal_css_files?
|
1221
|
+
|
1222
|
+
# ========================================================================= #
|
1223
|
+
# === do_not_use_the_internal_CSS_files
|
1224
|
+
# ========================================================================= #
|
1225
|
+
def do_not_use_the_internal_CSS_files
|
1226
|
+
@internal_hash[:use_the_internal_CSS_files] = false
|
1227
|
+
end
|
1228
|
+
|
1229
|
+
# ========================================================================= #
|
1230
|
+
# === add_simple_javascript_calculator
|
1231
|
+
# ========================================================================= #
|
1232
|
+
def add_simple_javascript_calculator
|
1233
|
+
add_javascript_file :simple_calculator
|
1234
|
+
addnl(
|
1235
|
+
::Cyberweb.return_html_code_for_the_javascript_calculator
|
1236
|
+
)
|
1237
|
+
end
|
1238
|
+
|
1239
|
+
# ========================================================================= #
|
1240
|
+
# === attach_these_constants
|
1241
|
+
#
|
1242
|
+
# This is an "alternative" to "include Foobar" code.
|
1243
|
+
# ========================================================================= #
|
1244
|
+
def attach_these_constants(i)
|
1245
|
+
Object.send(:include, i)
|
1246
|
+
end; alias fancy_extend attach_these_constants # === fancy_extend
|
1247
|
+
alias make_available attach_these_constants # === make_available
|
1248
|
+
alias smart_include attach_these_constants # === smart_include
|
1249
|
+
alias adhoc_include attach_these_constants # === adhoc_include
|
1250
|
+
|
1251
|
+
# ========================================================================= #
|
1252
|
+
# === cmd1
|
1253
|
+
# ========================================================================= #
|
1254
|
+
def cmd1(
|
1255
|
+
i = '',
|
1256
|
+
optional_css_class = ::Cyberweb.command1?,
|
1257
|
+
&block
|
1258
|
+
)
|
1259
|
+
if block_given? and (yield == :no_break)
|
1260
|
+
ee(
|
1261
|
+
string_span(i, optional_css_class)
|
1262
|
+
)
|
1263
|
+
else
|
1264
|
+
e(i, optional_css_class)
|
1265
|
+
end
|
1266
|
+
end; alias cmd cmd1 # === cmd
|
1267
|
+
|
1268
|
+
# ========================================================================= #
|
1269
|
+
# === return_css_for_tetris
|
1270
|
+
#
|
1271
|
+
# This is the CSS that will be returned when we want to enable the small
|
1272
|
+
# tetris-game that is distributed with the cyberweb project.
|
1273
|
+
# ========================================================================= #
|
1274
|
+
def return_css_for_tetris
|
1275
|
+
return ::Cyberweb.return_css_for_tetris
|
1276
|
+
end
|
1277
|
+
|
1278
|
+
# ========================================================================= #
|
1279
|
+
# === oop_div
|
1280
|
+
# ========================================================================= #
|
1281
|
+
def oop_div(
|
1282
|
+
a, b = nil, &block
|
1283
|
+
)
|
1284
|
+
addnl(
|
1285
|
+
::Cyberweb::Objectified::HtmlTags::Div.new(a, b, &block).to_s
|
1286
|
+
)
|
1287
|
+
end
|
1288
|
+
|
1289
|
+
# ========================================================================= #
|
1290
|
+
# === serve_webpage (serve tag, main serve)
|
1291
|
+
#
|
1292
|
+
# This will do the actual serving the webpage part.
|
1293
|
+
#
|
1294
|
+
# It can only serve @result, so you should have built up your web_object
|
1295
|
+
# already before calling this method here.
|
1296
|
+
# ========================================================================= #
|
1297
|
+
def serve_webpage(
|
1298
|
+
also_display = true
|
1299
|
+
)
|
1300
|
+
case also_display
|
1301
|
+
# ======================================================================= #
|
1302
|
+
# === :default
|
1303
|
+
# ======================================================================= #
|
1304
|
+
when :default
|
1305
|
+
also_display = true
|
1306
|
+
# ======================================================================= #
|
1307
|
+
# === :do_not_display_anything
|
1308
|
+
# ======================================================================= #
|
1309
|
+
when :do_not_display_anything
|
1310
|
+
also_display = false
|
1311
|
+
end
|
1312
|
+
@internal_hash[:already_served] = true
|
1313
|
+
check_syntax_then_compress_the_main_string_then_remove_newlines
|
1314
|
+
_ = main_string?
|
1315
|
+
display if also_display
|
1316
|
+
return _ # We always return the main string here.
|
1317
|
+
end; alias serve serve_webpage # === serve
|
1318
|
+
alias serv serve_webpage # === serv
|
1319
|
+
alias ser serve_webpage # === ser
|
1320
|
+
alias start serve_webpage # === start
|
1321
|
+
alias serve_again serve_webpage # === serve_again
|
1322
|
+
alias do_serve serve_webpage # === do_serve
|
1323
|
+
|
1324
|
+
# ========================================================================= #
|
1325
|
+
# === path?
|
1326
|
+
#
|
1327
|
+
# Reader method for the @fixed_path variable, which stores the relative
|
1328
|
+
# path to our LOCALHOST.
|
1329
|
+
# ========================================================================= #
|
1330
|
+
def path?
|
1331
|
+
::Cyberweb.converted_path
|
1332
|
+
end; alias fixed_path path? # === fixed_path
|
1333
|
+
|
1334
|
+
# ========================================================================= #
|
1335
|
+
# === meta_collection?
|
1336
|
+
# ========================================================================= #
|
1337
|
+
def meta_collection?
|
1338
|
+
@internal_hash[:meta_collection]
|
1339
|
+
end
|
1340
|
+
|
1341
|
+
# ======================================================================= #
|
1342
|
+
# === append_meta_collection
|
1343
|
+
# ======================================================================= #
|
1344
|
+
def append_meta_collection
|
1345
|
+
append(
|
1346
|
+
return_meta_collection
|
1347
|
+
)
|
1348
|
+
end; alias append_the_meta_collection append_meta_collection # === append_the_meta_collection
|
1349
|
+
|
1350
|
+
# ========================================================================= #
|
1351
|
+
# === meta_description
|
1352
|
+
#
|
1353
|
+
# Usage example for this method:
|
1354
|
+
#
|
1355
|
+
# meta_description 'This is a sitemap.'
|
1356
|
+
#
|
1357
|
+
# ========================================================================= #
|
1358
|
+
def meta_description(
|
1359
|
+
i = '20.08.2021'
|
1360
|
+
)
|
1361
|
+
@internal_hash[:meta_collection] <<
|
1362
|
+
'<meta name="description" content="'+i.to_s+'"/>'+"\n"
|
1363
|
+
end
|
1364
|
+
|
1365
|
+
# ========================================================================= #
|
1366
|
+
# === log (log tag)
|
1367
|
+
#
|
1368
|
+
# This is the general log-related method. For now it simply saves into
|
1369
|
+
# a default file.
|
1370
|
+
# ========================================================================= #
|
1371
|
+
def log(what)
|
1372
|
+
into = log_dir?+'default.log'
|
1373
|
+
save(what, :default, into)
|
1374
|
+
end
|
1375
|
+
|
1376
|
+
# ========================================================================= #
|
1377
|
+
# === header_for_sitemap
|
1378
|
+
#
|
1379
|
+
# This is a header that can be used to generate a sitemap.
|
1380
|
+
#
|
1381
|
+
# Note that if it is used it will also automatically generate
|
1382
|
+
# a sitemap on the top right of the page. This was one major
|
1383
|
+
# reason why this method was created - I wanted to automatically
|
1384
|
+
# use a sitemap if I use such a header.
|
1385
|
+
# ========================================================================= #
|
1386
|
+
def header_for_sitemap(i)
|
1387
|
+
id = i.tr(' ','_').delete('⁺')
|
1388
|
+
register_sitemap(i, id)
|
1389
|
+
h2(i, '',id)
|
1390
|
+
end
|
1391
|
+
|
1392
|
+
# ========================================================================= #
|
1393
|
+
# === register_sitemap
|
1394
|
+
#
|
1395
|
+
# Use only this method to register an id to a sitemap. This is
|
1396
|
+
# done automatically when we invoke the method sitemap().
|
1397
|
+
#
|
1398
|
+
# This method will delegate towards the toplevel-method, on the Cyberweb
|
1399
|
+
# namespace.
|
1400
|
+
#
|
1401
|
+
# If the second argument called `modify_input` is set to true, we
|
1402
|
+
# will replace all occurrences of '_' with ' '. The reason for
|
1403
|
+
# this is that HTML ids should not contain ' ' characters.
|
1404
|
+
# ========================================================================= #
|
1405
|
+
def register_sitemap(
|
1406
|
+
i, modify_input = false
|
1407
|
+
)
|
1408
|
+
if i.is_a? Array
|
1409
|
+
i.each {|entry|
|
1410
|
+
register_sitemap(entry, modify_input)
|
1411
|
+
}
|
1412
|
+
else
|
1413
|
+
# ===================================================================== #
|
1414
|
+
# Next simply delegate onto the toplevel method called
|
1415
|
+
# Cyberweb.register_sitemap().
|
1416
|
+
# ===================================================================== #
|
1417
|
+
::Cyberweb.register_sitemap(i, modify_input)
|
1418
|
+
end
|
1419
|
+
end; alias add_to_sitemap register_sitemap # === register_sitemap
|
1420
|
+
alias sitemap register_sitemap # === sitemap
|
1421
|
+
|
1422
|
+
# ========================================================================= #
|
1423
|
+
# === array_for_sitemap?
|
1424
|
+
#
|
1425
|
+
# Accessor-method towards the array-constant.
|
1426
|
+
# ========================================================================= #
|
1427
|
+
def array_for_sitemap?
|
1428
|
+
::Cyberweb.array_for_sitemap?
|
1429
|
+
end; alias array_for_sitemap array_for_sitemap? # === array_for_sitemap
|
1430
|
+
|
1431
|
+
# ========================================================================= #
|
1432
|
+
# === sitemap_array
|
1433
|
+
# ========================================================================= #
|
1434
|
+
def sitemap_array(
|
1435
|
+
*array
|
1436
|
+
)
|
1437
|
+
array = [array].flatten.compact
|
1438
|
+
register_sitemap(array)
|
1439
|
+
div('mars1em') {
|
1440
|
+
h2 'Sitemap','gold BG_Black pad8px'
|
1441
|
+
registered_sitemap?.each {|entry|
|
1442
|
+
abr_self('#'+entry.downcase)
|
1443
|
+
}
|
1444
|
+
}
|
1445
|
+
# autogenerated_sitemap # And call the autogenerated sitemap method at once.
|
1446
|
+
end
|
1447
|
+
|
1448
|
+
# ========================================================================= #
|
1449
|
+
# === autogenerated_sitemap
|
1450
|
+
#
|
1451
|
+
# This method will autogenerate a default Sitemap (an intralink).
|
1452
|
+
#
|
1453
|
+
# If the second argument for `optional_id` is :sort, then this method will
|
1454
|
+
# sort the result first before displaying it.
|
1455
|
+
# ========================================================================= #
|
1456
|
+
def autogenerated_sitemap(
|
1457
|
+
css_class = '',
|
1458
|
+
optional_id = '', # This could be :sort.
|
1459
|
+
optional_css_style = 'top: 2px; right: 2px; background-color: #eee;',
|
1460
|
+
append_css = true, # By default we will append more CSS rules.
|
1461
|
+
&block
|
1462
|
+
)
|
1463
|
+
# ======================================================================= #
|
1464
|
+
# Obtain the dataset first.
|
1465
|
+
# ======================================================================= #
|
1466
|
+
registered_sitemaps = ::Cyberweb.array_registered_sitemaps?
|
1467
|
+
css_for_li_elements = 'marl1px darkblue'
|
1468
|
+
default_css_class_to_use = 'pad5px bblack1 black posab'
|
1469
|
+
if block_given?
|
1470
|
+
yielded = yield
|
1471
|
+
# ===================================================================== #
|
1472
|
+
# === Handle Blocks next
|
1473
|
+
# ===================================================================== #
|
1474
|
+
if yielded.is_a? Hash
|
1475
|
+
# =================================================================== #
|
1476
|
+
# === :css_style
|
1477
|
+
# =================================================================== #
|
1478
|
+
if yielded.has_key? :css_style
|
1479
|
+
_ = yielded.delete :css_style
|
1480
|
+
default_css_class_to_use = ''
|
1481
|
+
optional_css_style = _
|
1482
|
+
end
|
1483
|
+
end
|
1484
|
+
end
|
1485
|
+
case optional_id
|
1486
|
+
# ======================================================================= #
|
1487
|
+
# === :sort
|
1488
|
+
# ======================================================================= #
|
1489
|
+
when :sort
|
1490
|
+
registered_sitemaps.sort!
|
1491
|
+
optional_id = ''
|
1492
|
+
end
|
1493
|
+
if css_class.empty?
|
1494
|
+
if append_css # This is the default.
|
1495
|
+
css_class = css_class.dup if css_class.frozen?
|
1496
|
+
css_class << " #{default_css_class_to_use}"
|
1497
|
+
end
|
1498
|
+
else # Else, user passed arguments here.
|
1499
|
+
css_class = css_class.dup if css_class.frozen?
|
1500
|
+
css_class << " #{default_css_class_to_use}"
|
1501
|
+
end
|
1502
|
+
# ======================================================================= #
|
1503
|
+
# Next comes the <div> that will hold our sitemap. For now this
|
1504
|
+
# will always be a <div> element.
|
1505
|
+
# ======================================================================= #
|
1506
|
+
div(css_class, optional_id, optional_css_style) {
|
1507
|
+
ee html_comment('Sitemap tag')
|
1508
|
+
h2 'Sitemap','black whi martb2px pad2px s4px yel mar1px',
|
1509
|
+
'SitemapHeader',
|
1510
|
+
'background-color:darkblue;'
|
1511
|
+
# ===================================================================== #
|
1512
|
+
# Build up the proper <ul> tag next.
|
1513
|
+
# ===================================================================== #
|
1514
|
+
ul(id: 'SitemapNavigation') {
|
1515
|
+
registered_sitemaps.each { |sitemap_id|
|
1516
|
+
ee '<li class="'+css_for_li_elements+'">'
|
1517
|
+
a '#'+sanitize_id(sitemap_id),
|
1518
|
+
content: sitemap_id,
|
1519
|
+
css_class: 'darkblue'
|
1520
|
+
ee '</li>'
|
1521
|
+
}
|
1522
|
+
}
|
1523
|
+
}
|
1524
|
+
end; alias show_sitemap autogenerated_sitemap # === show_sitemap
|
1525
|
+
alias display_sitemap autogenerated_sitemap # === display_sitemap
|
1526
|
+
alias asitemap autogenerated_sitemap # === asitemap
|
1527
|
+
alias add_sitemap autogenerated_sitemap # === add_sitemap
|
1528
|
+
|
1529
|
+
# ========================================================================= #
|
1530
|
+
# === random_colour
|
1531
|
+
#
|
1532
|
+
# This method will return a random HTML colour, such as 'steelblue' or
|
1533
|
+
# 'darkgreen'.
|
1534
|
+
# ========================================================================= #
|
1535
|
+
def random_colour
|
1536
|
+
::Cyberweb.all_html_colours.sample
|
1537
|
+
end
|
1538
|
+
|
1539
|
+
# ========================================================================= #
|
1540
|
+
# === registered_sitemap?
|
1541
|
+
# ========================================================================= #
|
1542
|
+
def registered_sitemap?
|
1543
|
+
::Cyberweb.array_registered_sitemaps?
|
1544
|
+
end
|
1545
|
+
|
1546
|
+
# ========================================================================= #
|
1547
|
+
# === colourize_ruby_code
|
1548
|
+
# ========================================================================= #
|
1549
|
+
def colourize_ruby_code(i)
|
1550
|
+
::Cyberweb.colourize_ruby_code(i)
|
1551
|
+
end
|
1552
|
+
|
1553
|
+
# ========================================================================= #
|
1554
|
+
# === colour_chart
|
1555
|
+
# ========================================================================= #
|
1556
|
+
def colour_chart
|
1557
|
+
addnl(
|
1558
|
+
Cyberweb.colour_chart
|
1559
|
+
)
|
1560
|
+
end
|
1561
|
+
|
1562
|
+
# ========================================================================= #
|
1563
|
+
# === save_into_the_default_html_page
|
1564
|
+
# ========================================================================= #
|
1565
|
+
def save_into_the_default_html_page(
|
1566
|
+
into = @internal_hash[:save_into_this_html_page]
|
1567
|
+
)
|
1568
|
+
puts 'Storing into `'+into+'`.'
|
1569
|
+
append_body_string
|
1570
|
+
append_cbody_and_chtml_tags
|
1571
|
+
what = string?
|
1572
|
+
SaveFile.write_what_into(what, into)
|
1573
|
+
end
|
1574
|
+
|
1575
|
+
# ========================================================================= #
|
1576
|
+
# === append_body_string
|
1577
|
+
# ========================================================================= #
|
1578
|
+
def append_body_string
|
1579
|
+
addnl(body_string?)
|
1580
|
+
end
|
1581
|
+
|
1582
|
+
# ========================================================================= #
|
1583
|
+
# === add_string_lateron
|
1584
|
+
#
|
1585
|
+
# We can append a string to the main string lateron.
|
1586
|
+
# ========================================================================= #
|
1587
|
+
def add_string_lateron
|
1588
|
+
if string_lateron? and !string_lateron?.empty?
|
1589
|
+
@internal_hash[:html_string] << string_lateron?.to_s
|
1590
|
+
end
|
1591
|
+
end
|
1592
|
+
|
1593
|
+
# ========================================================================= #
|
1594
|
+
# === print_the_result (display tag, report tag)
|
1595
|
+
#
|
1596
|
+
# This method can be used to report (output) the content of the
|
1597
|
+
# main string.
|
1598
|
+
#
|
1599
|
+
# You may have to properly build up the main string before invoking
|
1600
|
+
# this method.
|
1601
|
+
# ========================================================================= #
|
1602
|
+
def print_the_result
|
1603
|
+
print result?
|
1604
|
+
end; alias display print_the_result # === display
|
1605
|
+
alias report print_the_result # === report
|
1606
|
+
|
1607
|
+
# ========================================================================= #
|
1608
|
+
# === consider_compressing_main_string
|
1609
|
+
#
|
1610
|
+
# Right now this just removes all newlines, if the configuration
|
1611
|
+
# option was set.
|
1612
|
+
# ========================================================================= #
|
1613
|
+
def consider_compressing_main_string
|
1614
|
+
if compress_main_string?
|
1615
|
+
@internal_hash[:html_string].delete! N
|
1616
|
+
end
|
1617
|
+
end
|
1618
|
+
|
1619
|
+
# ========================================================================= #
|
1620
|
+
# === check_syntax_then_compress_the_main_string_then_remove_newlines
|
1621
|
+
# ========================================================================= #
|
1622
|
+
def check_syntax_then_compress_the_main_string_then_remove_newlines
|
1623
|
+
consider_checking_for_new_syntax
|
1624
|
+
consider_compressing_main_string
|
1625
|
+
consider_removing_newlines
|
1626
|
+
end
|
1627
|
+
|
1628
|
+
# ========================================================================= #
|
1629
|
+
# === close_html
|
1630
|
+
# ========================================================================= #
|
1631
|
+
def close_html
|
1632
|
+
addn('</body>')
|
1633
|
+
addn('</html>')
|
1634
|
+
add_string_lateron
|
1635
|
+
end
|
1636
|
+
|
1637
|
+
# ========================================================================= #
|
1638
|
+
# === doc_skeleton (main tag)
|
1639
|
+
#
|
1640
|
+
# This method has been specifically created to allow support of
|
1641
|
+
# .md (markdown) files in different languages - either german
|
1642
|
+
# or english.
|
1643
|
+
#
|
1644
|
+
# This method may also be called via a Symbol, such as:
|
1645
|
+
#
|
1646
|
+
# doc_skeleton(:english_or_german)
|
1647
|
+
#
|
1648
|
+
# ========================================================================= #
|
1649
|
+
def doc_skeleton(this_file)
|
1650
|
+
if this_file.is_a? Symbol
|
1651
|
+
case this_file
|
1652
|
+
# ===================================================================== #
|
1653
|
+
# === :english_or_german
|
1654
|
+
#
|
1655
|
+
# This will default to german.
|
1656
|
+
# ===================================================================== #
|
1657
|
+
when :english_or_german
|
1658
|
+
this_file = filename_without_extension?+'_german.md' # 'luft_german.md'
|
1659
|
+
end
|
1660
|
+
end
|
1661
|
+
# ======================================================================= #
|
1662
|
+
# Next, check for arguments given to the .cgi file at hand.
|
1663
|
+
# ======================================================================= #
|
1664
|
+
parameters_as_string = parameters_as_string?
|
1665
|
+
case parameters_as_string
|
1666
|
+
# ======================================================================= #
|
1667
|
+
# === use_english
|
1668
|
+
#
|
1669
|
+
# This can be invoked via:
|
1670
|
+
#
|
1671
|
+
# http://localhost/programming/ruby/src/roebe/lib/roebe/www/luft/luft.cgi?english
|
1672
|
+
#
|
1673
|
+
# ======================================================================= #
|
1674
|
+
when /use_english/,
|
1675
|
+
/english$/
|
1676
|
+
this_file = filename_without_extension?+'_english.md'
|
1677
|
+
# ======================================================================= #
|
1678
|
+
# === use_german
|
1679
|
+
# ======================================================================= #
|
1680
|
+
when /use_german/,
|
1681
|
+
/german$/
|
1682
|
+
this_file = filename_without_extension?+'_german.md'
|
1683
|
+
end
|
1684
|
+
if this_file and File.exist?(this_file)
|
1685
|
+
file_content = File.read(this_file, encoding: 'utf-8')
|
1686
|
+
dataset = remove_comments_from_this_string(file_content)
|
1687
|
+
eval(dataset)
|
1688
|
+
# ===================================================================== #
|
1689
|
+
# Next simply evaluate it.
|
1690
|
+
# ===================================================================== #
|
1691
|
+
else
|
1692
|
+
no_file_exists_at(this_file)
|
1693
|
+
end
|
1694
|
+
end
|
1695
|
+
|
1696
|
+
# ========================================================================= #
|
1697
|
+
# === created_when
|
1698
|
+
#
|
1699
|
+
# This method can be used to add a meta-tag to the web-object (web-page)
|
1700
|
+
# at hand.
|
1701
|
+
#
|
1702
|
+
# To read more on that meta-tag, look here:
|
1703
|
+
#
|
1704
|
+
# https://dublincore.org/resources/userguide/publishing_metadata/#dcterms:created
|
1705
|
+
#
|
1706
|
+
# Usage example:
|
1707
|
+
#
|
1708
|
+
# created_when('22.10.2021')
|
1709
|
+
#
|
1710
|
+
# ========================================================================= #
|
1711
|
+
def created_when(
|
1712
|
+
i = '20.08.2021'
|
1713
|
+
)
|
1714
|
+
@internal_hash[:additional_meta_collection] =
|
1715
|
+
'<meta name="DCTERMS.created" content="'+i.to_s+'"/>'
|
1716
|
+
end; alias created_on created_when # === created_on
|
1717
|
+
|
1718
|
+
# ========================================================================= #
|
1719
|
+
# === start_the_body_tag
|
1720
|
+
# ========================================================================= #
|
1721
|
+
def start_the_body_tag
|
1722
|
+
addnl '<body>'
|
1723
|
+
end
|
1724
|
+
|
1725
|
+
# ========================================================================= #
|
1726
|
+
# === parse_from_this_html_file
|
1727
|
+
# ========================================================================= #
|
1728
|
+
def parse_from_this_html_file(
|
1729
|
+
i =
|
1730
|
+
'/home/x/programming/ruby/src/cyberweb/test/simple_tests/simple_html_test_page/simple_html_test_page.html',
|
1731
|
+
be_verbose = true
|
1732
|
+
)
|
1733
|
+
do_not_use_the_internal_CSS_files # The new .html file must be simple.
|
1734
|
+
if i.is_a? Array
|
1735
|
+
i = i.first
|
1736
|
+
end
|
1737
|
+
if File.exist? i
|
1738
|
+
if be_verbose
|
1739
|
+
puts 'Now parsing the file '+i+'.'
|
1740
|
+
end
|
1741
|
+
dataset = File.read(i)
|
1742
|
+
regex_for_the_title = /<title>([a-zA-Z0-9 \n]+)<\/title>/ # See: https://rubular.com/r/atTe48o6iPG1TU
|
1743
|
+
if dataset.include?('<title')
|
1744
|
+
dataset =~ regex_for_the_title
|
1745
|
+
set_title($1)
|
1746
|
+
end
|
1747
|
+
regex_for_the_body = /<body>([\s\S]+)<\/body>/ # See: https://rubular.com/r/MhMR6p3eylZVZo
|
1748
|
+
if dataset.include?('<body')
|
1749
|
+
dataset =~ regex_for_the_body
|
1750
|
+
set_body_content($1)
|
1751
|
+
end
|
1752
|
+
end
|
1753
|
+
@internal_hash[:save_into_this_html_page] = return_pwd+
|
1754
|
+
'new_file_'+
|
1755
|
+
File.basename(i).delete_suffix('.html')+
|
1756
|
+
'.html'
|
1757
|
+
build_up_the_html_string
|
1758
|
+
end; alias parse_from_this_html_file= parse_from_this_html_file # === parse_from_this_html_file=
|
1759
|
+
alias parse_html_file= parse_from_this_html_file # === parse_html_file=
|
1760
|
+
|
1761
|
+
# ========================================================================= #
|
1762
|
+
# === handle_these_calls
|
1763
|
+
# ========================================================================= #
|
1764
|
+
def handle_these_calls(&block)
|
1765
|
+
# ======================================================================= #
|
1766
|
+
# Delegate the block given to this class here, so that we can handle
|
1767
|
+
# method calls properly.
|
1768
|
+
# ======================================================================= #
|
1769
|
+
if block_given?
|
1770
|
+
instance_exec(&block)
|
1771
|
+
end
|
1772
|
+
end
|
1773
|
+
|
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
|
+
# ========================================================================= #
|
1808
|
+
# === advanced_handle_these_calls_for_german
|
1809
|
+
# ========================================================================= #
|
1810
|
+
def advanced_handle_these_calls_for_german(&block)
|
1811
|
+
german_trinity
|
1812
|
+
handle_these_calls(&block)
|
1813
|
+
close_html_then_serve_the_webpage
|
1814
|
+
end
|
1815
|
+
|
1816
|
+
# ========================================================================= #
|
1817
|
+
# === show_admin_icons
|
1818
|
+
# ========================================================================= #
|
1819
|
+
def show_admin_icons
|
1820
|
+
::Cyberweb.show_admin_icons
|
1821
|
+
end
|
1822
|
+
|
1823
|
+
# ========================================================================= #
|
1824
|
+
# === table4
|
1825
|
+
# ========================================================================= #
|
1826
|
+
def table4(
|
1827
|
+
css_class = '',
|
1828
|
+
the_id = '',
|
1829
|
+
css_style = '',
|
1830
|
+
*content,
|
1831
|
+
&block
|
1832
|
+
)
|
1833
|
+
addn(
|
1834
|
+
string_table4(
|
1835
|
+
css_class,
|
1836
|
+
the_id,
|
1837
|
+
css_style,
|
1838
|
+
content,
|
1839
|
+
&block
|
1840
|
+
)
|
1841
|
+
)
|
1842
|
+
end
|
1843
|
+
|
1844
|
+
# ========================================================================= #
|
1845
|
+
# === css_template1
|
1846
|
+
#
|
1847
|
+
# Before this method was added in April 2022 I used to invoke the
|
1848
|
+
# method css_style() via :template1 as the first argument. Using
|
1849
|
+
# a single method instead, aka css_template1(), made more sense
|
1850
|
+
# though.
|
1851
|
+
# ========================================================================= #
|
1852
|
+
def css_template1
|
1853
|
+
css_style :template1
|
1854
|
+
end
|
1855
|
+
|
1856
|
+
# ========================================================================= #
|
1857
|
+
# === css_style
|
1858
|
+
#
|
1859
|
+
# Use this method to define the css style for the given web object.
|
1860
|
+
#
|
1861
|
+
# If the last four characters of the argument provided to this method
|
1862
|
+
# end with ".css" then this method will try to read the file specified
|
1863
|
+
# therein. (In this case we assume that it must be a .css file that
|
1864
|
+
# was passed into this method.)
|
1865
|
+
#
|
1866
|
+
# In order to use templates, do something like the following:
|
1867
|
+
#
|
1868
|
+
# css_style = :template1
|
1869
|
+
#
|
1870
|
+
# :symbol names can be used, such as :template1, :template2
|
1871
|
+
# and so forth. Alternatively, you can pass a String, or embed
|
1872
|
+
# the template-variants via a format such as '#TEMPLATE1#', which
|
1873
|
+
# will be substituted with whatever :template1 would normally
|
1874
|
+
# return.
|
1875
|
+
# ========================================================================= #
|
1876
|
+
def css_style(
|
1877
|
+
i = :default
|
1878
|
+
)
|
1879
|
+
# ======================================================================= #
|
1880
|
+
# === Special handling of Symbols given here
|
1881
|
+
# ======================================================================= #
|
1882
|
+
if i.is_a? Symbol
|
1883
|
+
case i
|
1884
|
+
# ===================================================================== #
|
1885
|
+
# === :default
|
1886
|
+
#
|
1887
|
+
# This can be used like in this way:
|
1888
|
+
#
|
1889
|
+
# css_style :template1
|
1890
|
+
#
|
1891
|
+
# ===================================================================== #
|
1892
|
+
when :default,
|
1893
|
+
:template,
|
1894
|
+
:template1,
|
1895
|
+
:css_template1
|
1896
|
+
i = css_comment("Generated via `#{i}`")+
|
1897
|
+
TEMPLATE1 # <- This is CSS/default.css
|
1898
|
+
# ===================================================================== #
|
1899
|
+
# === :template2
|
1900
|
+
# ===================================================================== #
|
1901
|
+
when :template2
|
1902
|
+
i = css_comment("Generated via `#{i}`")+
|
1903
|
+
TEMPLATE2
|
1904
|
+
# ===================================================================== #
|
1905
|
+
# === :code
|
1906
|
+
# ===================================================================== #
|
1907
|
+
when :code
|
1908
|
+
i = css_comment("Generated via `#{i}`")+
|
1909
|
+
CODE_TEMPLATE
|
1910
|
+
# ===================================================================== #
|
1911
|
+
# === :template_ruby_regex
|
1912
|
+
# ===================================================================== #
|
1913
|
+
when :template_ruby_regex
|
1914
|
+
i = css_css_comment("Generated via `#{i}`")+
|
1915
|
+
TEMPLATE_RUBY_REGEX
|
1916
|
+
end
|
1917
|
+
i = i.join('') if i.is_a? Array # Join them all.
|
1918
|
+
end
|
1919
|
+
# ======================================================================= #
|
1920
|
+
# Next, substitute for #TEMPLATE1 macro.
|
1921
|
+
# ======================================================================= #
|
1922
|
+
if i.to_s.include? '#TEMPLATE1'
|
1923
|
+
i = i.dup if i.frozen?
|
1924
|
+
i.gsub!(/#TEMPLATE1/, TEMPLATE1)
|
1925
|
+
end
|
1926
|
+
# ======================================================================= #
|
1927
|
+
# Read in .css files here. This will only be done if a certain variable
|
1928
|
+
# was set to true (which it is by default).
|
1929
|
+
# ======================================================================= #
|
1930
|
+
if i and i.end_with?('.css') and use_the_internal_CSS_files? # assume we pass a .css file here.
|
1931
|
+
i = readlines(i).join('') if File.exist?(i)
|
1932
|
+
end
|
1933
|
+
# ======================================================================= #
|
1934
|
+
# Append the main CSS rules next:
|
1935
|
+
# ======================================================================= #
|
1936
|
+
if @internal_hash[:main_CSS_rules] and !@internal_hash[:main_CSS_rules].empty?
|
1937
|
+
i = i.dup
|
1938
|
+
i.prepend("#{@internal_hash[:main_CSS_rules]}\n")
|
1939
|
+
end
|
1940
|
+
# ======================================================================= #
|
1941
|
+
# Next, we will always append to the @css_style instance variable.
|
1942
|
+
# This allows os to build-up the CSS for a webpage.
|
1943
|
+
# ======================================================================= #
|
1944
|
+
add_with_newline(
|
1945
|
+
return_css_style(i)
|
1946
|
+
)
|
1947
|
+
end; alias main_css_style css_style # === main_css_style
|
1948
|
+
alias main_css css_style # === main_css
|
1949
|
+
alias main_style css_style # === main_style
|
1950
|
+
alias css_main_style css_style # === css_main_style
|
1951
|
+
alias css_class css_style # === css_class
|
1952
|
+
alias css_classes css_style # === css_classes
|
1953
|
+
alias c_style= css_style # === c_style=
|
1954
|
+
alias c_class= css_style # === c_class=
|
1955
|
+
alias css_style= css_style # === css_style=
|
1956
|
+
alias general_css= css_style # === general_css=
|
1957
|
+
alias css= css_style # === css=
|
1958
|
+
alias c1= css_style # === c1=
|
1959
|
+
alias c1 css_style # === c1
|
1960
|
+
alias css_template= css_style # === css_template=
|
1961
|
+
alias css_main css_style # === css_main
|
1962
|
+
alias css_main_class css_style # === css_main_class
|
1963
|
+
alias css_code css_style # === css_code
|
1964
|
+
alias main_css_class css_style # === main_css_class
|
1965
|
+
alias css_style css_style # === css_style
|
1966
|
+
alias inline_css css_style # === inline_css
|
1967
|
+
alias append_to_css_style css_style # === append_to_css_style
|
1968
|
+
alias append_this_css css_style # === append_this_css
|
1969
|
+
alias add_css_style css_style # === add_css_style
|
1970
|
+
|
1971
|
+
# ========================================================================= #
|
1972
|
+
# === server_base_directory?
|
1973
|
+
# ========================================================================= #
|
1974
|
+
def server_base_directory?
|
1975
|
+
Cyberweb.server_base_directory?
|
1976
|
+
end
|
1977
|
+
|
1978
|
+
# ========================================================================= #
|
1979
|
+
# === template1
|
1980
|
+
# ========================================================================= #
|
1981
|
+
def template1(i = '')
|
1982
|
+
main_css "#{i}\n#{TEMPLATE1}"
|
1983
|
+
end
|
1984
|
+
|
1985
|
+
# ========================================================================= #
|
1986
|
+
# === add_unicode_charset
|
1987
|
+
# ========================================================================= #
|
1988
|
+
def add_unicode_charset
|
1989
|
+
append_this_to_the_meta_collection('<meta charset="UTF-8">')
|
1990
|
+
end
|
1991
|
+
|
1992
|
+
# ========================================================================= #
|
1993
|
+
# === use_unicode
|
1994
|
+
# ========================================================================= #
|
1995
|
+
def do_use_unicode
|
1996
|
+
@internal_hash[:use_unicode] = true
|
1997
|
+
end; alias use_unicode do_use_unicode # === use_unicode
|
1998
|
+
|
1999
|
+
# ========================================================================= #
|
2000
|
+
# === id_or_no_id
|
2001
|
+
#
|
2002
|
+
# The second argument is in particular used for draggable images.
|
2003
|
+
# ========================================================================= #
|
2004
|
+
def id_or_no_id(
|
2005
|
+
i = '',
|
2006
|
+
optional_url = nil
|
2007
|
+
)
|
2008
|
+
if i.is_a?(Hash) and i.has_key?(:id)
|
2009
|
+
i = i.delete(:id)
|
2010
|
+
end
|
2011
|
+
unless i.to_s.empty?
|
2012
|
+
case i
|
2013
|
+
# =============================================================== #
|
2014
|
+
# === :guess_draggable_id
|
2015
|
+
# =============================================================== #
|
2016
|
+
when :guess_draggable_id
|
2017
|
+
i = 'drag_'+File.basename(optional_url).
|
2018
|
+
gsub(File.extname(optional_url),'')
|
2019
|
+
end
|
2020
|
+
i = i.to_s
|
2021
|
+
# ===================================================================== #
|
2022
|
+
# We enable drag-support next. Keep in mind that the input can be
|
2023
|
+
# a symbol such as :drag, so we must check for that leading
|
2024
|
+
# string.
|
2025
|
+
# ===================================================================== #
|
2026
|
+
if i.start_with?('drag')
|
2027
|
+
register_this_id(i)
|
2028
|
+
end
|
2029
|
+
i = " id=\"#{i}\""
|
2030
|
+
end
|
2031
|
+
i
|
2032
|
+
end
|
2033
|
+
|
2034
|
+
# ========================================================================= #
|
2035
|
+
# === embed_this_pdf
|
2036
|
+
#
|
2037
|
+
# This method can be used to embed a .pdf file into your page. Using
|
2038
|
+
# width and height values is recommended but not mandatory.
|
2039
|
+
#
|
2040
|
+
# For more documentation, see these resources:
|
2041
|
+
#
|
2042
|
+
# https://pdfobject.com/markup/
|
2043
|
+
#
|
2044
|
+
# ========================================================================= #
|
2045
|
+
def embed_this_pdf(
|
2046
|
+
i,
|
2047
|
+
also_enable_link = false
|
2048
|
+
)
|
2049
|
+
case also_enable_link
|
2050
|
+
# === :also_enable_link
|
2051
|
+
when :also_enable_link
|
2052
|
+
also_enable_link = true
|
2053
|
+
end
|
2054
|
+
if also_enable_link
|
2055
|
+
pdf_image = sg(:pdf,'marr6px','','width:28px') # The pdf image.
|
2056
|
+
abr(i, content: pdf_image+'SELF_BASENAME')
|
2057
|
+
end
|
2058
|
+
result = '<object data="'+i.to_s+'" type="application/pdf" width="100%" height="100%">'+"\n"+
|
2059
|
+
'</object>'
|
2060
|
+
addnl(
|
2061
|
+
result
|
2062
|
+
)
|
2063
|
+
end; alias embed_pdf embed_this_pdf # === embed_pdf
|
2064
|
+
alias add_pdf embed_this_pdf # === add_pdf
|
2065
|
+
alias embed_this_pdf_file embed_this_pdf # === embed_this_pdf_file
|
2066
|
+
|
2067
|
+
# ========================================================================= #
|
2068
|
+
# === show_pdf
|
2069
|
+
# ========================================================================= #
|
2070
|
+
def show_pdf(i)
|
2071
|
+
addnl(
|
2072
|
+
::Cyberweb.embed_this_pdf(i)
|
2073
|
+
)
|
2074
|
+
end
|
2075
|
+
|
2076
|
+
# ========================================================================= #
|
2077
|
+
# === ibr
|
2078
|
+
# ========================================================================= #
|
2079
|
+
def ibr(content, optional_css_class = '')
|
2080
|
+
i(content)
|
2081
|
+
br
|
2082
|
+
end
|
2083
|
+
|
2084
|
+
# ========================================================================= #
|
2085
|
+
# === string_bold
|
2086
|
+
# ========================================================================= #
|
2087
|
+
def string_bold(
|
2088
|
+
i = '', optional_css_class = '', optional_the_id = ''
|
2089
|
+
)
|
2090
|
+
optional_css_class = optional_css_class.to_s.dup
|
2091
|
+
optional_css_class << ' BOLD'
|
2092
|
+
string_s2(i, optional_css_class.strip, optional_the_id)
|
2093
|
+
end
|
2094
|
+
|
2095
|
+
# ========================================================================= #
|
2096
|
+
# === bold
|
2097
|
+
#
|
2098
|
+
# This method will "create" an equivalent to the bold-tag.
|
2099
|
+
#
|
2100
|
+
# It must also keep backwards compatibility to invocations such
|
2101
|
+
# as:
|
2102
|
+
#
|
2103
|
+
# b 'Foobar:','yel'
|
2104
|
+
#
|
2105
|
+
# ========================================================================= #
|
2106
|
+
def bold(
|
2107
|
+
i = '', optional_css_class = '', optional_the_id = ''
|
2108
|
+
)
|
2109
|
+
addnl(
|
2110
|
+
string_bold(i, optional_css_class, optional_the_id)
|
2111
|
+
)
|
2112
|
+
end; alias b bold # === bold
|
2113
|
+
|
2114
|
+
# ========================================================================= #
|
2115
|
+
# === ip_is_allowed?
|
2116
|
+
#
|
2117
|
+
# This will forbid serving the site to unallowed visitors.
|
2118
|
+
# ========================================================================= #
|
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
|
2133
|
+
|
2134
|
+
# ========================================================================= #
|
2135
|
+
# === return_only_duplicates
|
2136
|
+
#
|
2137
|
+
# This method will return only duplicates. The input should be an
|
2138
|
+
# array.
|
2139
|
+
# ========================================================================= #
|
2140
|
+
def return_only_duplicates(array)
|
2141
|
+
duplicates = []
|
2142
|
+
array.each {|member| duplicates << member if array.count(member) > 1}
|
2143
|
+
duplicates.reject! {|entry| entry.empty? }
|
2144
|
+
duplicates.uniq
|
2145
|
+
end
|
2146
|
+
|
2147
|
+
# ========================================================================= #
|
2148
|
+
# === append_frame_string
|
2149
|
+
# ========================================================================= #
|
2150
|
+
def append_frame_string
|
2151
|
+
append @internal_hash[:frame_string]
|
2152
|
+
end
|
2153
|
+
|
2154
|
+
# ========================================================================= #
|
2155
|
+
# === append_chtml_tag
|
2156
|
+
# ========================================================================= #
|
2157
|
+
def append_chtml_tag
|
2158
|
+
append '</html>'+N
|
2159
|
+
end
|
2160
|
+
|
2161
|
+
# ========================================================================= #
|
2162
|
+
# === append_cbody_tag
|
2163
|
+
# ========================================================================= #
|
2164
|
+
def append_cbody_tag
|
2165
|
+
append '</body>'+N
|
2166
|
+
end
|
2167
|
+
|
2168
|
+
# ========================================================================= #
|
2169
|
+
# === append_cbody_and_chtml_tags
|
2170
|
+
#
|
2171
|
+
# This method will combine </body> and </html>.
|
2172
|
+
# ========================================================================= #
|
2173
|
+
def append_cbody_and_chtml_tags
|
2174
|
+
append_cbody_tag
|
2175
|
+
append_chtml_tag
|
2176
|
+
end; alias finish append_cbody_and_chtml_tags # === finish
|
2177
|
+
alias finalize append_cbody_and_chtml_tags # === finalize
|
2178
|
+
|
2179
|
+
# ========================================================================= #
|
2180
|
+
# === try_to_generate_pdf_file
|
2181
|
+
#
|
2182
|
+
# Use this method to generate a dump from a .cgi page.
|
2183
|
+
#
|
2184
|
+
# Invocation example from the commandline:
|
2185
|
+
#
|
2186
|
+
# rf biotut ?pdf
|
2187
|
+
#
|
2188
|
+
# ========================================================================= #
|
2189
|
+
def try_to_generate_pdf_file
|
2190
|
+
# ======================================================================= #
|
2191
|
+
# The directory where to generate our .pdf file into.
|
2192
|
+
# ======================================================================= #
|
2193
|
+
base_dir = '/home/Temp/lighty/'
|
2194
|
+
h2 'We will next generate a .pdf document of this webpage.'
|
2195
|
+
which_file = base_dir+'hello_world.pdf'
|
2196
|
+
which_file = base_dir+::Cyberweb.name_of_served_page?
|
2197
|
+
this_pdf_file = which_file.gsub(/\.cgi/,'')+'.pdf'
|
2198
|
+
target = ::Cyberweb.localhost?.to_s+ENV['SCRIPT_NAME']
|
2199
|
+
begin
|
2200
|
+
require 'serve_local_page'
|
2201
|
+
rescue LoadError; end
|
2202
|
+
if Object.const_defined? :ServeLocalPage
|
2203
|
+
# ===================================================================== #
|
2204
|
+
# Next, we will delegate towards class ServeLocalPage.
|
2205
|
+
# ===================================================================== #
|
2206
|
+
dataset = ServeLocalPage.new(target, :dont_save).dataset?
|
2207
|
+
# ===================================================================== #
|
2208
|
+
# This dataset contains all the HTML tags, which is not nice.
|
2209
|
+
# So we will get rid of them. But this may be a problem
|
2210
|
+
# lateron, so for now we won't do so.
|
2211
|
+
# ===================================================================== #
|
2212
|
+
# dataset = ::Cyberweb.remove_html(dataset)
|
2213
|
+
delete_file(this_pdf_file) if File.exist? this_pdf_file
|
2214
|
+
what = dataset
|
2215
|
+
into = which_file.gsub(/\.pdf/,'').gsub(/\.cgi/,'')+'.html'
|
2216
|
+
h3 'Storing into the .html file, by using wkhtmltopdf:
|
2217
|
+
<b class="darkblue BG_White s5px">'+into+'</b>.'
|
2218
|
+
a into, 'SELF',1,'marl3em'
|
2219
|
+
# ===================================================================== #
|
2220
|
+
# Next, create /Depot/Temp/lighty unless it already exists.
|
2221
|
+
# ===================================================================== #
|
2222
|
+
unless File.directory? File.dirname(this_pdf_file)
|
2223
|
+
mkdir(File.dirname(this_pdf_file))
|
2224
|
+
end
|
2225
|
+
# ===================================================================== #
|
2226
|
+
# Store into the .html page next.
|
2227
|
+
# ===================================================================== #
|
2228
|
+
write_what_into(what, into)
|
2229
|
+
h3 'Storing into .pdf file: <b class="darkblue BG_White s5px">'+this_pdf_file+'</b>.'
|
2230
|
+
a(
|
2231
|
+
this_pdf_file, content: 'SELF', css_class: 'marl3em'
|
2232
|
+
)
|
2233
|
+
br
|
2234
|
+
# ===================================================================== #
|
2235
|
+
# We essentially have two ways to generate a .pdf file:
|
2236
|
+
#
|
2237
|
+
# (1) by using wkhtmltopdf
|
2238
|
+
# (2) by using prawn
|
2239
|
+
#
|
2240
|
+
# (1) is more robust.
|
2241
|
+
# ===================================================================== #
|
2242
|
+
use_wkhtmltopdf = true # Hack. :D
|
2243
|
+
if use_wkhtmltopdf
|
2244
|
+
_ = 'wkhtmltopdf '+into+' '+this_pdf_file
|
2245
|
+
system _ # We are silent here.
|
2246
|
+
# =================================================================== #
|
2247
|
+
# Next, keep a reference to the generated .pdf file.
|
2248
|
+
# =================================================================== #
|
2249
|
+
::Cyberweb.set_path_to_last_generated_pdf_document(
|
2250
|
+
this_pdf_file
|
2251
|
+
)
|
2252
|
+
else # else use prawn.
|
2253
|
+
Prawn::Document.generate(this_pdf_file, :page_size => 'A4') {
|
2254
|
+
font 'Times-Roman'
|
2255
|
+
text 'Hello Prawn!'
|
2256
|
+
text(dataset)
|
2257
|
+
}
|
2258
|
+
end
|
2259
|
+
spacer
|
2260
|
+
e 'It is now available at `<b>'+which_file.gsub(/\.cgi/,'.html')+'</b>`.'
|
2261
|
+
# spacer
|
2262
|
+
end
|
2263
|
+
spacer
|
2264
|
+
end
|
2265
|
+
|
2266
|
+
# ========================================================================= #
|
2267
|
+
# === show_all_registered_ids
|
2268
|
+
# ========================================================================= #
|
2269
|
+
def show_all_registered_ids
|
2270
|
+
h2 "Now showing all registered IDs of this page ("\
|
2271
|
+
"#{name_of_served_page?}):"
|
2272
|
+
all_ids?.each { |entry|
|
2273
|
+
marl2em sg(:pfeil_rechts,'marr4px')+'`'+entry+'`', 'red'
|
2274
|
+
if entry.include? ' '
|
2275
|
+
anm('^^^ Please note that the entry above '+
|
2276
|
+
'('+entry.to_s+') is invalid!','large red')
|
2277
|
+
end
|
2278
|
+
}
|
2279
|
+
end
|
2280
|
+
|
2281
|
+
# ========================================================================= #
|
2282
|
+
# === return_google_search_field
|
2283
|
+
# ========================================================================= #
|
2284
|
+
def return_google_search_field
|
2285
|
+
ee '<div id="PC_CENTER" class="s5px padtb3px wid44 martb2px posab bordorange1px" style="left:16em">
|
2286
|
+
<form name="dict" method="GET" action="https://www.google.com/search" class="spads5px">
|
2287
|
+
<p class="mar0">
|
2288
|
+
<input type="text" name="q" value="" size="20" onFocus="(this.select())" class="LBlue BG_Black1 borddorange1px" accesskey="e"/>
|
2289
|
+
<input type="image" name="btnG" src="../IMG/STD/GOOGLE.png" alt="Google" accesskey="R" class="bordblack1px VAM"/>
|
2290
|
+
<input type="hidden" name="ie" value="UTF-8"/>
|
2291
|
+
<input type="hidden" name="oe" value="UTF-8"/>
|
2292
|
+
<input type="hidden" name="hl" value="de"/>
|
2293
|
+
</p>
|
2294
|
+
</form>'
|
2295
|
+
end
|
2296
|
+
|
2297
|
+
# ========================================================================= #
|
2298
|
+
# === return_program_name
|
2299
|
+
#
|
2300
|
+
# This method will return the filename. So if you have an URL such as
|
2301
|
+
# bla/webforum.cgi then this method will simply return webforum.cgi.
|
2302
|
+
# ========================================================================= #
|
2303
|
+
def return_program_name(
|
2304
|
+
i = $PROGRAM_NAME
|
2305
|
+
)
|
2306
|
+
return ensure_main_encoding(
|
2307
|
+
File.basename(i)
|
2308
|
+
)
|
2309
|
+
end; alias filename? return_program_name # === filename?
|
2310
|
+
|
2311
|
+
# ========================================================================= #
|
2312
|
+
# === filename_without_extension?
|
2313
|
+
#
|
2314
|
+
# This will return the raw filename, without extension. For example,
|
2315
|
+
# if the file is "index.cgi", then this method will return the string
|
2316
|
+
# "index".
|
2317
|
+
# ========================================================================= #
|
2318
|
+
def filename_without_extension?
|
2319
|
+
_ = filename?
|
2320
|
+
return _.delete_suffix(File.extname(_))
|
2321
|
+
end
|
2322
|
+
|
2323
|
+
# ========================================================================= #
|
2324
|
+
# === doc (doc tag)
|
2325
|
+
# ========================================================================= #
|
2326
|
+
def doc(
|
2327
|
+
optional_css_class = 'pad5px',
|
2328
|
+
optional_the_id = '',
|
2329
|
+
optional_css_style = '',
|
2330
|
+
&block
|
2331
|
+
)
|
2332
|
+
consider_autoclosing_the_head_tag
|
2333
|
+
# ======================================================================= #
|
2334
|
+
# Append the <body> tag if is not yet part of the String.
|
2335
|
+
# ======================================================================= #
|
2336
|
+
splitted = result?.split("\n")
|
2337
|
+
unless splitted.any? {|line| line.start_with? '<body' }
|
2338
|
+
addnl(:body, @internal_hash[:body_css_class])
|
2339
|
+
end
|
2340
|
+
# ======================================================================= #
|
2341
|
+
# === Simply pass onto div() next
|
2342
|
+
# ======================================================================= #
|
2343
|
+
div(
|
2344
|
+
optional_css_class,
|
2345
|
+
optional_the_id,
|
2346
|
+
optional_css_style,
|
2347
|
+
&block
|
2348
|
+
)
|
2349
|
+
end; alias document doc # === document
|
2350
|
+
|
2351
|
+
require 'cyberweb/toplevel_methods/audio.rb'
|
2352
|
+
# ========================================================================= #
|
2353
|
+
# === audio
|
2354
|
+
#
|
2355
|
+
# This method essentially creates an "audio" tag, for playing an
|
2356
|
+
# audio file.
|
2357
|
+
# ========================================================================= #
|
2358
|
+
def audio(
|
2359
|
+
url = '',
|
2360
|
+
optional_autoplay = false
|
2361
|
+
)
|
2362
|
+
addnl(
|
2363
|
+
::Cyberweb.audio(url, optional_autoplay)
|
2364
|
+
)
|
2365
|
+
end
|
2366
|
+
|
2367
|
+
# ========================================================================= #
|
2368
|
+
# === frame_right
|
2369
|
+
#
|
2370
|
+
# Simply append to :frame_string, by calling the method in the
|
2371
|
+
# Cyberweb module.
|
2372
|
+
# ========================================================================= #
|
2373
|
+
def frame_right(i)
|
2374
|
+
@internal_hash[:frame_string] << ::Cyberweb.frame_right(i)
|
2375
|
+
end
|
2376
|
+
|
2377
|
+
# ========================================================================= #
|
2378
|
+
# === frame_left
|
2379
|
+
#
|
2380
|
+
# Simply append to :frame_string.
|
2381
|
+
# ========================================================================= #
|
2382
|
+
def frame_left(i)
|
2383
|
+
@internal_hash[:frame_string] << ::Cyberweb.frame_left(i)
|
2384
|
+
end
|
2385
|
+
|
2386
|
+
# ========================================================================= #
|
2387
|
+
# === earrow
|
2388
|
+
# ========================================================================= #
|
2389
|
+
def earrow(i = '')
|
2390
|
+
e "→ #{i}"
|
2391
|
+
end
|
2392
|
+
|
2393
|
+
# ========================================================================= #
|
2394
|
+
# === header_id
|
2395
|
+
# ========================================================================= #
|
2396
|
+
def header_id(
|
2397
|
+
i, optional_css_class = ''
|
2398
|
+
)
|
2399
|
+
use_this_id = i.dup.tr(' ','_').downcase
|
2400
|
+
h2(i, optional_css_class, use_this_id)
|
2401
|
+
end
|
2402
|
+
|
2403
|
+
# ========================================================================= #
|
2404
|
+
# === on_click_change_opacity
|
2405
|
+
# ========================================================================= #
|
2406
|
+
def on_click_change_opacity(
|
2407
|
+
use_this_id = 'pic',
|
2408
|
+
which_opacity_value_to_use = '0.92'
|
2409
|
+
)
|
2410
|
+
addnl(
|
2411
|
+
::Cyberweb.return_on_click_change_opacity(
|
2412
|
+
use_this_id, which_opacity_value_to_use
|
2413
|
+
)
|
2414
|
+
)
|
2415
|
+
end; alias on_click_highlight on_click_change_opacity # === on_click_highlight
|
2416
|
+
alias highlight_tag on_click_change_opacity # === highlight_tag
|
2417
|
+
alias highlight on_click_change_opacity # === highlight
|
2418
|
+
|
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
|
+
# ========================================================================= #
|
2470
|
+
# === pfeil_rechts
|
2471
|
+
# ========================================================================= #
|
2472
|
+
def pfeil_rechts(
|
2473
|
+
use_this_css_class = 'marr4px'
|
2474
|
+
)
|
2475
|
+
sg(:pfeil_rechts, use_this_css_class)
|
2476
|
+
end
|
2477
|
+
|
2478
|
+
# ========================================================================= #
|
2479
|
+
# === return_wikipedia_search_field
|
2480
|
+
# ========================================================================= #
|
2481
|
+
def return_wikipedia_search_field
|
2482
|
+
ee '<form name="searchform" action="https://en.wikipedia.org/wiki/Special:Search" id="searchform" class="disin pads5px">
|
2483
|
+
<p class="">
|
2484
|
+
<input type="text" id="searchinput" name="search" class="LBlue BG_Black1 borddorange1px" accesskey=""/>
|
2485
|
+
<input type="submit" value="Go" name="go" class="LBlue BG_Black1 borddorange1px" accesskey=""/>
|
2486
|
+
<input type="submit" value="Search" name="fulltext" class="LBlue BG_Black1 borddorange1px" accesskey=""/>
|
2487
|
+
</p>
|
2488
|
+
</form>'
|
2489
|
+
end
|
2490
|
+
|
2491
|
+
# ========================================================================= #
|
2492
|
+
# === cform
|
2493
|
+
# ========================================================================= #
|
2494
|
+
def cform
|
2495
|
+
close(:form)
|
2496
|
+
end
|
2497
|
+
|
2498
|
+
# ========================================================================= #
|
2499
|
+
# === cfieldset
|
2500
|
+
# ========================================================================= #
|
2501
|
+
def cfieldset
|
2502
|
+
close(:fieldset)
|
2503
|
+
end
|
2504
|
+
|
2505
|
+
# ========================================================================= #
|
2506
|
+
# === sclose
|
2507
|
+
# ========================================================================= #
|
2508
|
+
def sclose(i)
|
2509
|
+
"</#{i}>"
|
2510
|
+
end
|
2511
|
+
|
2512
|
+
# ========================================================================= #
|
2513
|
+
# === cdl
|
2514
|
+
# ========================================================================= #
|
2515
|
+
def cdl
|
2516
|
+
close(:dl)
|
2517
|
+
end
|
2518
|
+
|
2519
|
+
# ========================================================================= #
|
2520
|
+
# === ctd
|
2521
|
+
# ========================================================================= #
|
2522
|
+
def ctd
|
2523
|
+
close(:td)
|
2524
|
+
end
|
2525
|
+
|
2526
|
+
# ========================================================================= #
|
2527
|
+
# === htmlescape
|
2528
|
+
# ========================================================================= #
|
2529
|
+
def htmlescape(i)
|
2530
|
+
return ::Cyberweb.escape_html(i)
|
2531
|
+
end; alias htmlentities htmlescape # === htmlentities
|
2532
|
+
alias hescape htmlescape # === hescape
|
2533
|
+
alias htmltitties htmlescape # === htmltitties
|
2534
|
+
|
2535
|
+
# ========================================================================= #
|
2536
|
+
# === table12_with_heading
|
2537
|
+
# ========================================================================= #
|
2538
|
+
def table12_with_heading(css_class = '', id = '', css_style = '', *content)
|
2539
|
+
addn(
|
2540
|
+
string_table12_with_heading(
|
2541
|
+
css_class, id, css_style, content
|
2542
|
+
)
|
2543
|
+
)
|
2544
|
+
end
|
2545
|
+
|
2546
|
+
# ========================================================================= #
|
2547
|
+
# === table11_with_heading
|
2548
|
+
# ========================================================================= #
|
2549
|
+
def table11_with_heading(css_class = '', id = '', css_style = '', *content)
|
2550
|
+
addn(
|
2551
|
+
string_table11_with_heading(
|
2552
|
+
css_class, id, css_style, content
|
2553
|
+
)
|
2554
|
+
)
|
2555
|
+
end
|
2556
|
+
|
2557
|
+
# ========================================================================= #
|
2558
|
+
# === hr_stars
|
2559
|
+
#
|
2560
|
+
# This method call displays three stars in one row, if all goes well.
|
2561
|
+
#
|
2562
|
+
# See this image for how this may look on the website:
|
2563
|
+
#
|
2564
|
+
# https://i.imgur.com/moDx2f1.png
|
2565
|
+
#
|
2566
|
+
# ========================================================================= #
|
2567
|
+
def hr_stars
|
2568
|
+
addnl(
|
2569
|
+
Cyberweb.return_pretty_stars
|
2570
|
+
)
|
2571
|
+
end; alias star_spacer hr_stars # === star_spacer
|
2572
|
+
alias pretty_spacer hr_stars # === pretty_spacer
|
2573
|
+
alias pretty_stars hr_stars # === pretty_stars
|
2574
|
+
alias pretty_star hr_stars # === pretty_star
|
2575
|
+
alias pretty_hsep hr_stars # === pretty_hsep
|
2576
|
+
alias fancy_stars hr_stars # === fancy_stars
|
2577
|
+
alias pretty_separator hr_stars # === pretty_separator
|
2578
|
+
|
2579
|
+
# ========================================================================= #
|
2580
|
+
# === div_p_default
|
2581
|
+
# ========================================================================= #
|
2582
|
+
def div_p_default(
|
2583
|
+
optional_css_class = '',
|
2584
|
+
the_id = '',
|
2585
|
+
optional_css_style = '',
|
2586
|
+
&block
|
2587
|
+
)
|
2588
|
+
div_default(optional_css_class, the_id, optional_css_style) {
|
2589
|
+
p_default(optional_css_class, the_id, optional_css_style, &block)
|
2590
|
+
}
|
2591
|
+
end
|
2592
|
+
|
2593
|
+
# ========================================================================= #
|
2594
|
+
# === p_default
|
2595
|
+
#
|
2596
|
+
# This is similar to p(), but the implicit CSS class 'default' will
|
2597
|
+
# be used.
|
2598
|
+
# ========================================================================= #
|
2599
|
+
def p_default(
|
2600
|
+
optional_css_class = '',
|
2601
|
+
the_id = '',
|
2602
|
+
optional_css_style = '',
|
2603
|
+
&block
|
2604
|
+
)
|
2605
|
+
if optional_css_class.is_a? Hash
|
2606
|
+
if optional_css_class.has_key? :id
|
2607
|
+
the_id = optional_css_class.delete(:id)
|
2608
|
+
end
|
2609
|
+
if optional_css_class.is_a?(Hash) and optional_css_class.empty?
|
2610
|
+
optional_css_class = ''
|
2611
|
+
end
|
2612
|
+
end
|
2613
|
+
optional_css_class = optional_css_class.to_s.dup
|
2614
|
+
optional_css_class.prepend('default ') # Make it the first argument.
|
2615
|
+
p(
|
2616
|
+
optional_css_class.strip,
|
2617
|
+
the_id,
|
2618
|
+
optional_css_style,
|
2619
|
+
&block
|
2620
|
+
)
|
2621
|
+
end
|
14
2622
|
|
15
2623
|
# ========================================================================= #
|
16
2624
|
# === return_stars
|
17
2625
|
# ========================================================================= #
|
18
|
-
def return_stars(
|
19
|
-
n_stars = 1,
|
20
|
-
optional_css_class = ''
|
2626
|
+
def return_stars(
|
2627
|
+
n_stars = 1,
|
2628
|
+
optional_css_class = ''
|
2629
|
+
)
|
2630
|
+
case n_stars.to_s
|
2631
|
+
when '1'
|
2632
|
+
sg(:one_star, optional_css_class)
|
2633
|
+
when '2'
|
2634
|
+
sg(:two_stars, optional_css_class)
|
2635
|
+
when '3'
|
2636
|
+
sg(:three_stars, optional_css_class)
|
2637
|
+
when '4'
|
2638
|
+
sg(:four_stars, optional_css_class)
|
2639
|
+
when '5'
|
2640
|
+
sg(:five_stars, optional_css_class)
|
2641
|
+
when '1x'
|
2642
|
+
sg(:one_and_half_star, optional_css_class)
|
2643
|
+
when '2x'
|
2644
|
+
sg(:two_and_half_star, optional_css_class)
|
2645
|
+
when '3x'
|
2646
|
+
sg(:three_and_half_star, optional_css_class)
|
2647
|
+
when '4x'
|
2648
|
+
sg(:four_and_half_star, optional_css_class)
|
2649
|
+
when '5x'
|
2650
|
+
sg(:five_and_half_star, optional_css_class)
|
2651
|
+
end
|
2652
|
+
end
|
2653
|
+
|
2654
|
+
# ========================================================================= #
|
2655
|
+
# === five_stars
|
2656
|
+
# ========================================================================= #
|
2657
|
+
def five_stars(optional_css_class = '')
|
2658
|
+
return_stars(5, optional_css_class)
|
2659
|
+
end
|
2660
|
+
|
2661
|
+
# ========================================================================= #
|
2662
|
+
# === efive_stars
|
2663
|
+
# ========================================================================= #
|
2664
|
+
def efive_stars(optional_css_class = '')
|
2665
|
+
ee five_stars(optional_css_class)
|
2666
|
+
end
|
2667
|
+
|
2668
|
+
# ========================================================================= #
|
2669
|
+
# === four_stars
|
2670
|
+
# ========================================================================= #
|
2671
|
+
def four_stars(optional_css_class = '')
|
2672
|
+
return_stars(4, optional_css_class)
|
2673
|
+
end; alias string_four_stars four_stars # === string_four_stars
|
2674
|
+
|
2675
|
+
# ========================================================================= #
|
2676
|
+
# === try_to_populate_the_log_directory_with_javascript_files
|
2677
|
+
#
|
2678
|
+
# This method will try to populate the main log directory with
|
2679
|
+
# the default javascript files.
|
2680
|
+
# ========================================================================= #
|
2681
|
+
def try_to_populate_the_log_directory_with_javascript_files
|
2682
|
+
_ = ::Cyberweb.log_dir?
|
2683
|
+
if File.directory? _
|
2684
|
+
# ===================================================================== #
|
2685
|
+
# If the log-directory exists, try to create the javascript_code/
|
2686
|
+
# directory, then cd into it. Since as of 20.10.2022 we will return
|
2687
|
+
# to the original directory afterwards.
|
2688
|
+
# ===================================================================== #
|
2689
|
+
full_target = "#{_}javascript_code"
|
2690
|
+
unless File.directory? full_target
|
2691
|
+
mkdir(full_target)
|
2692
|
+
end
|
2693
|
+
original_directory = return_pwd
|
2694
|
+
if File.directory?(full_target)
|
2695
|
+
cd(full_target)
|
2696
|
+
do_copy_the_javascript_code_files_into_current_working_directory
|
2697
|
+
end
|
2698
|
+
cd original_directory # Return to the original directory again.
|
2699
|
+
end
|
2700
|
+
end
|
2701
|
+
|
2702
|
+
# ========================================================================= #
|
2703
|
+
# === do_copy_the_javascript_code_files_into_current_working_directory
|
2704
|
+
# ========================================================================= #
|
2705
|
+
def do_copy_the_javascript_code_files_into_current_working_directory
|
2706
|
+
use_this_path = Cyberweb.project_base_directory?+'javascript_code/'
|
2707
|
+
current_directory = return_pwd
|
2708
|
+
# ======================================================================= #
|
2709
|
+
# The next clause will only copy files - at a later time this may
|
2710
|
+
# have to be changed to also copy directories, but for now (Oct 2022)
|
2711
|
+
# this is the way to go.
|
2712
|
+
# ======================================================================= #
|
2713
|
+
Dir[use_this_path+'*'].select {|entry| File.file?(entry) }.each {|entry|
|
2714
|
+
unless File.exist?(current_directory+File.basename(entry))
|
2715
|
+
copy_this_file(entry)
|
2716
|
+
end
|
2717
|
+
}
|
2718
|
+
end
|
2719
|
+
|
2720
|
+
# ========================================================================= #
|
2721
|
+
# === return_css_style
|
2722
|
+
#
|
2723
|
+
# This method will simply return the <style>CONTENT_HERE</style> variant.
|
2724
|
+
# ========================================================================= #
|
2725
|
+
def return_css_style(i)
|
2726
|
+
if i.is_a? Hash
|
2727
|
+
_ = ''.dup
|
2728
|
+
i.each_pair {|key, value|
|
2729
|
+
_ << "#{key} = #{value};"
|
2730
|
+
}
|
2731
|
+
i = _
|
2732
|
+
end
|
2733
|
+
# return "<style>\n#{i}\n</style>\n" <--
|
2734
|
+
return Cyberweb::CssStyle.style(i)
|
2735
|
+
end; alias return_this_css_style return_css_style # === return_this_css_style
|
2736
|
+
alias page_css_classes return_css_style # === page_css_classes
|
2737
|
+
|
2738
|
+
# ========================================================================= #
|
2739
|
+
# === create_copy_to_clipboard_button
|
2740
|
+
#
|
2741
|
+
# The third argument determines whether the "associated" input
|
2742
|
+
# field will be hidden or not.
|
2743
|
+
#
|
2744
|
+
# This would then generate an input-field such as this:
|
2745
|
+
#
|
2746
|
+
# <input type="hidden">
|
2747
|
+
#
|
2748
|
+
# ========================================================================= #
|
2749
|
+
def create_copy_to_clipboard_button(
|
2750
|
+
use_this_value = 'XXX',
|
2751
|
+
use_this_id = 'clipboard_button',
|
2752
|
+
hide_the_input_field = false,
|
2753
|
+
text_shown_on_the_button = 'Copy text',
|
2754
|
+
css_rules_for_the_button = ''
|
2755
|
+
)
|
2756
|
+
ee return_copy_to_clipboard_button(
|
2757
|
+
use_this_value,
|
2758
|
+
use_this_id,
|
2759
|
+
hide_the_input_field,
|
2760
|
+
text_shown_on_the_button,
|
2761
|
+
css_rules_for_the_button
|
2762
|
+
)
|
2763
|
+
end
|
2764
|
+
|
2765
|
+
# ========================================================================= #
|
2766
|
+
# === return_copy_to_clipboard_button
|
2767
|
+
#
|
2768
|
+
# The signature for this method must be synced with the method
|
2769
|
+
# called .create_copy_to_clipboard_button().
|
2770
|
+
# ========================================================================= #
|
2771
|
+
def return_copy_to_clipboard_button(
|
2772
|
+
use_this_value = 'XXX',
|
2773
|
+
use_this_id = 'clipboard_button',
|
2774
|
+
hide_the_input_field = false,
|
2775
|
+
text_shown_on_the_button = 'Copy text',
|
2776
|
+
css_rules_for_the_button = ''
|
2777
|
+
)
|
2778
|
+
_ = ''.dup
|
2779
|
+
use_this_id = use_this_id.to_s
|
2780
|
+
if hide_the_input_field
|
2781
|
+
_ << '<input type="hidden" value="'+use_this_value.to_s+'" id="'+use_this_id+'">'
|
2782
|
+
else
|
2783
|
+
_ << '<input type="text" value="'+use_this_value.to_s+'" id="'+use_this_id+'">'
|
2784
|
+
end
|
2785
|
+
_ << '<button class="'+css_rules_for_the_button.to_s+'" onclick="copy_to_the_clipboard(\''+use_this_id+'\')">'+
|
2786
|
+
text_shown_on_the_button.to_s+
|
2787
|
+
'</button>'
|
2788
|
+
return _
|
2789
|
+
end
|
2790
|
+
|
2791
|
+
# ========================================================================= #
|
2792
|
+
# === return_default_javascript
|
2793
|
+
# ========================================================================= #
|
2794
|
+
def return_default_javascript#(
|
2795
|
+
# i = ::Cyberweb.converted_path_to_data # Disabled this line as of October 2022.
|
2796
|
+
#)
|
2797
|
+
#::Cyberweb.return_default_javascript(i)
|
2798
|
+
_ = ''.dup
|
2799
|
+
# path_to_use = ::Cyberweb.converted_path_to_project_base_dir
|
2800
|
+
# path_to_use = ::Cyberweb.log_dir?+'javascript_code/'
|
2801
|
+
path_to_use = ::Cyberweb.converted_path_to_the_directory_containing_the_copied_javascript_files
|
2802
|
+
array = ARRAY_DEFAULT_JAVASCRIPT_LIBRARIES
|
2803
|
+
_ = ''.dup # This String will be returned.
|
2804
|
+
array.each {|entry|
|
2805
|
+
full_path = "#{path_to_use}#{entry}".dup
|
2806
|
+
_ << '<script src="'+full_path+'"'
|
2807
|
+
_ = _.ljust(48)
|
2808
|
+
_ << ' type="text/javascript"></script>'
|
2809
|
+
_ << NL
|
2810
|
+
}
|
2811
|
+
return _
|
2812
|
+
end
|
2813
|
+
|
2814
|
+
# ========================================================================= #
|
2815
|
+
# === table_padding=
|
2816
|
+
# ========================================================================= #
|
2817
|
+
def table_padding=(i = 10)
|
2818
|
+
::Cyberweb::Table.padding = i
|
2819
|
+
end
|
2820
|
+
|
2821
|
+
# ========================================================================= #
|
2822
|
+
# === table_clear
|
2823
|
+
# ========================================================================= #
|
2824
|
+
def table_clear
|
2825
|
+
::Cyberweb::Table.clear
|
2826
|
+
end
|
2827
|
+
|
2828
|
+
# ========================================================================= #
|
2829
|
+
# === table_parse
|
2830
|
+
# ========================================================================= #
|
2831
|
+
def table_parse(*i)
|
2832
|
+
addnl(
|
2833
|
+
::Cyberweb::Table.parse(i)
|
2834
|
+
)
|
2835
|
+
end
|
2836
|
+
|
2837
|
+
# ========================================================================= #
|
2838
|
+
# === table2_from_this_file
|
2839
|
+
#
|
2840
|
+
# This variant will read from an existing file, ideally a markdown file
|
2841
|
+
# .md. One row in the HTML table corresponds to one line in the original
|
2842
|
+
# markdown file.
|
2843
|
+
#
|
2844
|
+
# Note that currently we will split on ':' which is hardcoded; not
|
2845
|
+
# sure whether this will change in the future or not.
|
2846
|
+
# ========================================================================= #
|
2847
|
+
def table2_from_this_file(
|
2848
|
+
optional_css_class = '',
|
2849
|
+
optional_the_id = '',
|
2850
|
+
optional_css_style = '',
|
2851
|
+
this_file = 'games_timeline.md'
|
2852
|
+
)
|
2853
|
+
if File.exist? this_file
|
2854
|
+
dataset = File.readlines(this_file, encoding: 'UTF-8').reject {|line|
|
2855
|
+
line.start_with?('#') or line.strip.empty? # Ignore comments and empty lines.
|
2856
|
+
}
|
2857
|
+
splitted_dataset = dataset.map {|entry|
|
2858
|
+
if entry.include? ':'
|
2859
|
+
splitted = entry.split(':')
|
2860
|
+
entry = [
|
2861
|
+
splitted[0 .. -2].join(':'),
|
2862
|
+
splitted[-1].strip
|
2863
|
+
]
|
2864
|
+
end
|
2865
|
+
entry
|
2866
|
+
}
|
2867
|
+
dataset = splitted_dataset
|
2868
|
+
table2(
|
2869
|
+
optional_css_class,
|
2870
|
+
optional_the_id,
|
2871
|
+
optional_css_style,
|
2872
|
+
*dataset
|
2873
|
+
)
|
2874
|
+
else
|
2875
|
+
e '(line 5806) No file exists at '+this_file
|
2876
|
+
end
|
2877
|
+
end
|
2878
|
+
|
2879
|
+
# ========================================================================= #
|
2880
|
+
# === table2_with_heading
|
2881
|
+
# ========================================================================= #
|
2882
|
+
def table2_with_heading(
|
2883
|
+
css_class = '',
|
2884
|
+
id = '',
|
2885
|
+
css_style = '',
|
2886
|
+
*content
|
2887
|
+
)
|
2888
|
+
addn(
|
2889
|
+
string_table2_with_heading(
|
2890
|
+
css_class,
|
2891
|
+
id,
|
2892
|
+
css_style,
|
2893
|
+
content
|
2894
|
+
)
|
2895
|
+
)
|
2896
|
+
end
|
2897
|
+
|
2898
|
+
# ========================================================================= #
|
2899
|
+
# === string_table4
|
2900
|
+
# ========================================================================= #
|
2901
|
+
def string_table4(
|
2902
|
+
css_class = '',
|
2903
|
+
the_id = '',
|
2904
|
+
css_style = '',
|
2905
|
+
*content,
|
2906
|
+
&block
|
2907
|
+
)
|
2908
|
+
# ======================================================================= #
|
2909
|
+
# To test, try:
|
2910
|
+
#
|
2911
|
+
# puts ::Cyberweb.string_table4('','','',%w( ah asjhk avshvasjkh vajhksavjhk avsjhvashkjavs ))
|
2912
|
+
#
|
2913
|
+
# ======================================================================= #
|
2914
|
+
::Cyberweb.string_table4(
|
2915
|
+
css_class,
|
2916
|
+
the_id,
|
2917
|
+
css_style,
|
2918
|
+
content,
|
2919
|
+
&block
|
2920
|
+
)
|
2921
|
+
end
|
2922
|
+
|
2923
|
+
# ========================================================================= #
|
2924
|
+
# === draggable_img_base64
|
2925
|
+
#
|
2926
|
+
# This method has to respond to css_class and css_style as well. This
|
2927
|
+
# may also be provided via a Hash.
|
2928
|
+
# ========================================================================= #
|
2929
|
+
def draggable_img_base64(
|
2930
|
+
i,
|
2931
|
+
css_class = '',
|
2932
|
+
css_style = ''
|
2933
|
+
)
|
2934
|
+
if css_class.is_a? Hash
|
2935
|
+
# ===================================================================== #
|
2936
|
+
# === :css_style
|
2937
|
+
# ===================================================================== #
|
2938
|
+
if css_class.has_key? :css_style
|
2939
|
+
css_style = css_class.delete(:css_style)
|
2940
|
+
end
|
2941
|
+
# ===================================================================== #
|
2942
|
+
# === :css_class
|
2943
|
+
#
|
2944
|
+
# This variant must come last.
|
2945
|
+
# ===================================================================== #
|
2946
|
+
if css_class.has_key? :css_class
|
2947
|
+
css_class = css_class.delete(:css_class)
|
2948
|
+
end
|
2949
|
+
end
|
2950
|
+
absolute_path_to_the_image = File.absolute_path(
|
2951
|
+
path_to_the_main_image_directory?.to_s+
|
2952
|
+
i.to_s
|
2953
|
+
)
|
2954
|
+
use_this_id = 'drag_'+File.basename(
|
2955
|
+
absolute_path_to_the_image
|
2956
|
+
).delete_suffix(
|
2957
|
+
File.extname(absolute_path_to_the_image)
|
2958
|
+
).downcase
|
2959
|
+
dataset = convert_image_to_base64(absolute_path_to_the_image)
|
2960
|
+
|
2961
|
+
addnl(
|
2962
|
+
return_base64_image(
|
2963
|
+
dataset, :infer, css_class, use_this_id, css_style
|
2964
|
+
)
|
2965
|
+
)
|
2966
|
+
end; alias draggable_base64img draggable_img_base64 # === draggable_base64img
|
2967
|
+
|
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
|
+
# ========================================================================= #
|
3021
|
+
# === save_into_this_html_page?
|
3022
|
+
# ========================================================================= #
|
3023
|
+
def save_into_this_html_page?
|
3024
|
+
@internal_hash[:save_into_this_html_page]
|
3025
|
+
end
|
3026
|
+
|
3027
|
+
# ========================================================================= #
|
3028
|
+
# === string_lateron?
|
3029
|
+
# ========================================================================= #
|
3030
|
+
def string_lateron?
|
3031
|
+
@internal_hash[:string_lateron]
|
3032
|
+
end
|
3033
|
+
|
3034
|
+
# ========================================================================= #
|
3035
|
+
# === add_javascript_file
|
3036
|
+
#
|
3037
|
+
# This will show the javascript-file as-is. It can only be used for
|
3038
|
+
# javascript code that is bundled within the cyberweb project, as-is.
|
3039
|
+
# ========================================================================= #
|
3040
|
+
def add_javascript_file(i)
|
3041
|
+
if i.is_a? Symbol
|
3042
|
+
case i
|
3043
|
+
# ===================================================================== #
|
3044
|
+
# === :simple_calculator
|
3045
|
+
# ===================================================================== #
|
3046
|
+
when :simple_calculator
|
3047
|
+
i = File.absolute_path(
|
3048
|
+
project_base_dir?+'javascript_code/simple_calculator.js'
|
3049
|
+
)
|
3050
|
+
end
|
3051
|
+
if i and File.exist?(i)
|
3052
|
+
i = File.read(i)
|
3053
|
+
end
|
3054
|
+
end
|
3055
|
+
addnl(
|
3056
|
+
"<script>\n"+
|
3057
|
+
i.to_s+
|
3058
|
+
"</script>\n"
|
3059
|
+
)
|
3060
|
+
end
|
3061
|
+
|
3062
|
+
# ========================================================================= #
|
3063
|
+
# === set_body_content
|
3064
|
+
# ========================================================================= #
|
3065
|
+
def set_body_content(i)
|
3066
|
+
@internal_hash[:body_content] = i.to_s.dup
|
3067
|
+
end
|
3068
|
+
|
3069
|
+
# ========================================================================= #
|
3070
|
+
# === body_content?
|
3071
|
+
# ========================================================================= #
|
3072
|
+
def body_content?
|
3073
|
+
@internal_hash[:body_content]
|
3074
|
+
end; alias body_string? body_content? # === body_string?
|
3075
|
+
|
3076
|
+
# ========================================================================= #
|
3077
|
+
# === cmd2
|
3078
|
+
# ========================================================================= #
|
3079
|
+
def cmd2(
|
3080
|
+
i = '',
|
3081
|
+
optional_css_class = ::Cyberweb.command2?
|
3082
|
+
)
|
3083
|
+
e(i, optional_css_class)
|
3084
|
+
end
|
3085
|
+
|
3086
|
+
# ========================================================================= #
|
3087
|
+
# === cmd3
|
3088
|
+
# ========================================================================= #
|
3089
|
+
def cmd3(
|
3090
|
+
i = '',
|
3091
|
+
optional_css_class = ::Cyberweb.command3?
|
3092
|
+
)
|
3093
|
+
e(i, optional_css_class)
|
3094
|
+
end
|
3095
|
+
|
3096
|
+
# ========================================================================= #
|
3097
|
+
# === cmd1_is
|
3098
|
+
# ========================================================================= #
|
3099
|
+
def cmd1_is(i)
|
3100
|
+
Cyberweb.internal_hash?[:cmd1] = i
|
3101
|
+
end; alias cmd_is cmd1_is # === cmd_is
|
3102
|
+
|
3103
|
+
# ========================================================================= #
|
3104
|
+
# === cmd2_is
|
3105
|
+
# ========================================================================= #
|
3106
|
+
def cmd2_is(i)
|
3107
|
+
Cyberweb.internal_hash?[:cmd2] = i
|
3108
|
+
end
|
3109
|
+
|
3110
|
+
# ========================================================================= #
|
3111
|
+
# === cmd3_is
|
3112
|
+
# ========================================================================= #
|
3113
|
+
def cmd3_is(i)
|
3114
|
+
Cyberweb.internal_hash?[:cmd3] = i
|
3115
|
+
end
|
3116
|
+
|
3117
|
+
# ========================================================================= #
|
3118
|
+
# === cmd_pre
|
3119
|
+
# ========================================================================= #
|
3120
|
+
def cmd_pre(i)
|
3121
|
+
splitted = i.split(N)
|
3122
|
+
splitted.each {|entry| cmd(entry) }
|
3123
|
+
end; alias pre_cmd cmd_pre # === pre_cmd
|
3124
|
+
|
3125
|
+
# ========================================================================= #
|
3126
|
+
# === col_cmd
|
3127
|
+
# ========================================================================= #
|
3128
|
+
def col_cmd(
|
3129
|
+
i = '',
|
3130
|
+
optional_id = ''
|
3131
|
+
)
|
3132
|
+
ee(
|
3133
|
+
i, ::Cyberweb.internal_hash?[:col_cmd], optional_id
|
3134
|
+
)
|
3135
|
+
end; alias col col_cmd # === col
|
3136
|
+
|
3137
|
+
# ========================================================================= #
|
3138
|
+
# === append_to_cmd1
|
3139
|
+
# ========================================================================= #
|
3140
|
+
def append_to_cmd1(i = '')
|
3141
|
+
::Cyberweb.append_to_cmd1(i)
|
3142
|
+
end; alias append_cmd1 append_to_cmd1 # === append_cmd1
|
3143
|
+
|
3144
|
+
# ========================================================================= #
|
3145
|
+
# === append_to_cmd2
|
3146
|
+
# ========================================================================= #
|
3147
|
+
def append_to_cmd2(i = '')
|
3148
|
+
::Cyberweb.append_to_cmd2(i)
|
3149
|
+
end
|
3150
|
+
|
3151
|
+
# ========================================================================= #
|
3152
|
+
# === append_to_cmd3
|
3153
|
+
# ========================================================================= #
|
3154
|
+
def append_to_cmd3(i = '')
|
3155
|
+
::Cyberweb.append_to_cmd3(i)
|
3156
|
+
end
|
3157
|
+
|
3158
|
+
# ========================================================================= #
|
3159
|
+
# === random_linear_gradient_background
|
3160
|
+
#
|
3161
|
+
# This method generates gradients via linear-gradient().
|
3162
|
+
#
|
3163
|
+
# The first argument to linear-gradient() is the "degree".
|
3164
|
+
# ========================================================================= #
|
3165
|
+
def random_linear_gradient_background
|
3166
|
+
degree = (0..180).to_a.sample.to_s+'deg'
|
3167
|
+
return 'background: linear-gradient('+degree+', '+random_colour+', '+random_colour+', '+random_colour+');'
|
3168
|
+
end
|
3169
|
+
|
3170
|
+
# ========================================================================= #
|
3171
|
+
# === linear_gradient_background
|
3172
|
+
#
|
3173
|
+
# Usage examples:
|
3174
|
+
#
|
3175
|
+
# linear_gradient_background(90, :steelblue, :darkgreen, :tomato)
|
3176
|
+
# linear_gradient_background(90, :steelblue, :darkgreen, :royalblue)
|
3177
|
+
#
|
3178
|
+
# ========================================================================= #
|
3179
|
+
def linear_gradient_background(
|
3180
|
+
degree_to_use = (0..180).to_a.sample.to_s+'deg',
|
3181
|
+
colour1 = random_colour,
|
3182
|
+
colour2 = random_colour,
|
3183
|
+
colour3 = random_colour
|
3184
|
+
)
|
3185
|
+
degree_to_use = degree_to_use.to_s.dup
|
3186
|
+
unless degree_to_use.end_with? 'deg'
|
3187
|
+
degree_to_use << 'deg'
|
3188
|
+
end
|
3189
|
+
return 'background: linear-gradient('+
|
3190
|
+
degree_to_use+', '+
|
3191
|
+
colour1.to_s+', '+
|
3192
|
+
colour2.to_s+', '+
|
3193
|
+
colour3.to_s+
|
3194
|
+
');'
|
3195
|
+
end
|
3196
|
+
|
3197
|
+
# ========================================================================= #
|
3198
|
+
# === autotitle
|
3199
|
+
#
|
3200
|
+
# This will simply capitalize the title in use.
|
3201
|
+
# ========================================================================= #
|
3202
|
+
def autotitle
|
3203
|
+
set_title :capitalized
|
3204
|
+
end
|
3205
|
+
|
3206
|
+
# ========================================================================= #
|
3207
|
+
# === black_background
|
3208
|
+
# ========================================================================= #
|
3209
|
+
def black_background
|
3210
|
+
set_background(:black)
|
3211
|
+
end
|
3212
|
+
|
3213
|
+
# ========================================================================= #
|
3214
|
+
# === append_newline
|
3215
|
+
# ========================================================================= #
|
3216
|
+
def append_newline
|
3217
|
+
append :newline
|
3218
|
+
end
|
3219
|
+
|
3220
|
+
# ========================================================================= #
|
3221
|
+
# === append_path_to_dragula_js_file
|
3222
|
+
# ========================================================================= #
|
3223
|
+
def append_path_to_dragula_js_file
|
3224
|
+
append(
|
3225
|
+
'<script src="'+path_to_data?+
|
3226
|
+
'CODE/javascript/dragula.js" type="text/javascript"></script>'+N
|
3227
|
+
)
|
3228
|
+
end
|
3229
|
+
|
3230
|
+
# ========================================================================= #
|
3231
|
+
# === append_chead_tag
|
3232
|
+
#
|
3233
|
+
# Close the html <head> tag here. We also append a newline.
|
3234
|
+
# ========================================================================= #
|
3235
|
+
def append_chead_tag
|
3236
|
+
append "</head>\n"
|
3237
|
+
end
|
3238
|
+
|
3239
|
+
# ========================================================================= #
|
3240
|
+
# === german_trinity
|
3241
|
+
#
|
3242
|
+
# This variant specifically does NOT force the use of jquery since as
|
3243
|
+
# of May 2021. If you want to force jquery, use the method
|
3244
|
+
# called german_unicode_and_jquery() instead.
|
3245
|
+
#
|
3246
|
+
# Strictly speaking the word "trinity" is thus no longer correct, but
|
3247
|
+
# for the time being it will be retained.
|
3248
|
+
# ========================================================================= #
|
3249
|
+
def german_trinity
|
3250
|
+
german_unicode # This bundles "use_german" and "use_unicode".
|
3251
|
+
add_html_comment("\nThis website is making use of german.\n")
|
3252
|
+
add_relevant_meta_entries(:ignore_checks)
|
3253
|
+
end; alias use_unicode_german_and_jquery german_trinity # === use_unicode_german_and_jquery
|
3254
|
+
alias trinity_german german_trinity # === trinity_german
|
3255
|
+
alias trinity german_trinity # === trinity
|
3256
|
+
|
3257
|
+
# ========================================================================= #
|
3258
|
+
# === language
|
3259
|
+
#
|
3260
|
+
# You can use this method to specify a certain language in order to
|
3261
|
+
# use for the given web page. I tend to use this to remind myself
|
3262
|
+
# in which language I shall write a web-page in, e. g. usually
|
3263
|
+
# either in german, or more commonly these days, in english.
|
3264
|
+
#
|
3265
|
+
# Invocation example:
|
3266
|
+
#
|
3267
|
+
# language :english
|
3268
|
+
#
|
3269
|
+
# ========================================================================= #
|
3270
|
+
def language(
|
3271
|
+
which_language = nil
|
3272
|
+
)
|
3273
|
+
case which_language
|
3274
|
+
# ======================================================================= #
|
3275
|
+
# === eng
|
3276
|
+
# ======================================================================= #
|
3277
|
+
when 'eng',
|
3278
|
+
'e',
|
3279
|
+
'en',
|
3280
|
+
'default'
|
3281
|
+
which_language = 'english'
|
3282
|
+
# ======================================================================= #
|
3283
|
+
# === ger
|
3284
|
+
# ======================================================================= #
|
3285
|
+
when 'ger',
|
3286
|
+
'g',
|
3287
|
+
'ge',
|
3288
|
+
'german',
|
3289
|
+
'deutsch'
|
3290
|
+
which_language = 'german'
|
3291
|
+
end
|
3292
|
+
@internal_hash[:language] = which_language.to_s # Will be kept as a String.
|
3293
|
+
end
|
3294
|
+
|
3295
|
+
# ========================================================================= #
|
3296
|
+
# === german_unicode_and_jquery
|
3297
|
+
#
|
3298
|
+
# This convenience method will enable german language layout for a
|
3299
|
+
# webpage, jquery-drag-and-drop support, as well as declare that
|
3300
|
+
# the page at hand uses unicode characters (and thus needs support
|
3301
|
+
# for unicode).
|
3302
|
+
# ========================================================================= #
|
3303
|
+
def german_unicode_and_jquery
|
3304
|
+
do_use_jquery
|
3305
|
+
german_trinity
|
3306
|
+
end; alias german_unicode_jquery german_unicode_and_jquery # === german_unicode_jquery
|
3307
|
+
alias use_jquery_german_and_unicode german_unicode_and_jquery # === german_unicode_and_jquery
|
3308
|
+
|
3309
|
+
# ========================================================================= #
|
3310
|
+
# === use_german
|
3311
|
+
#
|
3312
|
+
# This is an easier shortcut to designate that the current webpage
|
3313
|
+
# makes use of the german language as part of its content primarily.
|
3314
|
+
# ========================================================================= #
|
3315
|
+
def use_german # An easier shortcut.
|
3316
|
+
language :german
|
3317
|
+
end
|
3318
|
+
|
3319
|
+
# ========================================================================= #
|
3320
|
+
# === tag
|
3321
|
+
# ========================================================================= #
|
3322
|
+
def tag(
|
3323
|
+
this_tag,
|
3324
|
+
optional_css_class = '',
|
3325
|
+
optional_the_id = '',
|
3326
|
+
optional_css_style = '',
|
3327
|
+
optional_javascript = ''
|
3328
|
+
)
|
3329
|
+
_ = '<'+this_tag.to_s+
|
3330
|
+
css_class_or_no_class(optional_css_class)+
|
3331
|
+
id_or_no_id(optional_the_id)+
|
3332
|
+
css_style_or_no_style(optional_css_style).dup
|
3333
|
+
if optional_javascript and !optional_javascript.empty?
|
3334
|
+
_ << ' javascript="'+javascript+'"'
|
3335
|
+
end
|
3336
|
+
_ << '>'
|
3337
|
+
addnl(_)
|
3338
|
+
end
|
3339
|
+
|
3340
|
+
|
3341
|
+
# ========================================================================= #
|
3342
|
+
# === escape_html
|
3343
|
+
#
|
3344
|
+
# Simply delegate towards the class-method here.
|
3345
|
+
# ========================================================================= #
|
3346
|
+
def escape_html(i)
|
3347
|
+
addnl(
|
3348
|
+
htmlescape(i)
|
3349
|
+
)
|
3350
|
+
end; alias htmlsanitize escape_html # === htmlsanitize
|
3351
|
+
alias return_htmlentities escape_html # === return_htmlentities
|
3352
|
+
alias return_htmlsanitized escape_html # === return_htmlsanitized
|
3353
|
+
alias html_ready escape_html # === html_ready
|
3354
|
+
alias html_escape escape_html # === html_escape
|
3355
|
+
alias htitties escape_html # === htitties
|
3356
|
+
|
3357
|
+
# ========================================================================= #
|
3358
|
+
# === inject_this_onto_that
|
3359
|
+
#
|
3360
|
+
# This has been added specifically for SimpleWidgets support. Highly
|
3361
|
+
# experimental as of September 2021.
|
3362
|
+
# ========================================================================= #
|
3363
|
+
def inject_this_onto_that(
|
3364
|
+
this,
|
3365
|
+
that
|
3366
|
+
)
|
3367
|
+
position = that.to_s.index('</div>')
|
3368
|
+
that[position,0] = this
|
3369
|
+
return that
|
3370
|
+
end
|
3371
|
+
|
3372
|
+
# ========================================================================= #
|
3373
|
+
# === add_relevant_meta_entries
|
3374
|
+
#
|
3375
|
+
# This will instantly append onto @_.
|
3376
|
+
# ========================================================================= #
|
3377
|
+
def add_relevant_meta_entries(
|
3378
|
+
honour_checks = true
|
3379
|
+
)
|
3380
|
+
case honour_checks
|
3381
|
+
# ======================================================================= #
|
3382
|
+
# === :ignore_checks
|
3383
|
+
# ======================================================================= #
|
3384
|
+
when :ignore_checks
|
3385
|
+
honour_checks = false
|
3386
|
+
end
|
3387
|
+
if honour_checks and use_unicode?
|
3388
|
+
add_unicode_charset
|
3389
|
+
else
|
3390
|
+
add_unicode_charset
|
3391
|
+
end
|
3392
|
+
end
|
3393
|
+
|
3394
|
+
# ======================================================================= #
|
3395
|
+
# === return_html_to_head_start
|
3396
|
+
#
|
3397
|
+
# This method will delegate to a toplevel method and ultimately
|
3398
|
+
# return a String such as:
|
3399
|
+
#
|
3400
|
+
# "Content-type: text/html\n\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n"
|
3401
|
+
#
|
3402
|
+
# ======================================================================= #
|
3403
|
+
def return_html_to_head_start
|
3404
|
+
::Cyberweb.return_html_to_head_start
|
3405
|
+
end
|
3406
|
+
|
3407
|
+
# ========================================================================= #
|
3408
|
+
# === create_database
|
3409
|
+
# ========================================================================= #
|
3410
|
+
def create_database
|
3411
|
+
case database?
|
3412
|
+
when :sqlite
|
3413
|
+
require 'sqlite3'
|
3414
|
+
db = SQLite3::Database.new '/Depot/j/test.db' # Open a database
|
3415
|
+
# ===================================================================== #
|
3416
|
+
# Create a database
|
3417
|
+
# ===================================================================== #
|
3418
|
+
# rows = db.execute <<-SQL
|
3419
|
+
db.execute <<-SQL
|
3420
|
+
create table numbers (
|
3421
|
+
name varchar(30),
|
3422
|
+
val int
|
3423
|
+
);
|
3424
|
+
SQL
|
3425
|
+
{
|
3426
|
+
'one' => 1,
|
3427
|
+
'two' => 2,
|
3428
|
+
}.each { |pair|
|
3429
|
+
db.execute 'insert into numbers values ( ?, ? )', pair
|
3430
|
+
}
|
3431
|
+
# Execute inserts with parameter markers
|
3432
|
+
db.execute("INSERT INTO students (name, email, grade, blog)
|
3433
|
+
VALUES (?, ?, ?, ?)", ['joe', 'hoe@hotmail.com', '5', 'yo'])
|
3434
|
+
# Find a few rows
|
3435
|
+
db.execute( "select * from numbers" ) do |row|
|
3436
|
+
p row
|
3437
|
+
end
|
3438
|
+
end
|
3439
|
+
end
|
3440
|
+
|
3441
|
+
# ========================================================================= #
|
3442
|
+
# === slight_indent
|
3443
|
+
# ========================================================================= #
|
3444
|
+
def slight_indent(i = '', optional_css_class = '')
|
3445
|
+
e i, "padl0_5em #{optional_css_class}"
|
3446
|
+
end; alias slight_ind slight_indent # === slight_ind
|
3447
|
+
alias sind slight_indent # === sind
|
3448
|
+
|
3449
|
+
# ========================================================================= #
|
3450
|
+
# === frage
|
3451
|
+
# ========================================================================= #
|
3452
|
+
def frage(
|
3453
|
+
i = '',
|
3454
|
+
optional_css_class = ''
|
3455
|
+
)
|
3456
|
+
h2 i, optional_css_class
|
3457
|
+
end
|
3458
|
+
|
3459
|
+
# ========================================================================= #
|
3460
|
+
# === fragebr
|
3461
|
+
# ========================================================================= #
|
3462
|
+
def fragebr(
|
3463
|
+
i = '',
|
3464
|
+
optional_css_class = ''
|
3465
|
+
)
|
3466
|
+
frage(i, optional_css_class)
|
3467
|
+
br
|
3468
|
+
end
|
3469
|
+
|
3470
|
+
# ========================================================================= #
|
3471
|
+
# === do_show_sys_info
|
3472
|
+
#
|
3473
|
+
# This method will show some system-related information about the
|
3474
|
+
# environment.
|
3475
|
+
# ========================================================================= #
|
3476
|
+
def do_show_sys_info(
|
3477
|
+
css_class = 'FS1_1em bblack1 pad1empx BG_Black White'
|
3478
|
+
)
|
3479
|
+
div(css_class,'','margin:0.25em'){
|
3480
|
+
h2 sg(:wings,'marr8px')+'Displaying some Sys Info stuff:',
|
3481
|
+
'lightblue'
|
3482
|
+
p('pad4px'){
|
3483
|
+
uptime = `uptime`
|
3484
|
+
e 'Uptime since:','lgreen BOLD'
|
3485
|
+
br
|
3486
|
+
e uptime,'yel padl1em'
|
3487
|
+
}
|
3488
|
+
p('pad4px'){
|
3489
|
+
ruby_version = `ruby --version`
|
3490
|
+
e 'Ruby version:','lgreen BOLD'
|
3491
|
+
br
|
3492
|
+
e ruby_version,'yel padl1em BOLD'
|
3493
|
+
br
|
3494
|
+
ruby_gem_version = `gem --version`
|
3495
|
+
e 'Ruby gem version:','lgreen BOLD'
|
3496
|
+
br
|
3497
|
+
e ruby_gem_version,'yel padl1em BOLD'
|
3498
|
+
br
|
3499
|
+
path_to_the_rubygem_installation_directory = Gem.vendor_dir
|
3500
|
+
e 'Ruby installation directory:','lgreen BOLD'
|
3501
|
+
br
|
3502
|
+
e path_to_the_rubygem_installation_directory,'yel padl1em'
|
3503
|
+
ruby_user_home = Gem.user_home
|
3504
|
+
br
|
3505
|
+
e 'Ruby user home:','lgreen BOLD'
|
3506
|
+
br
|
3507
|
+
e ruby_user_home.to_s,'yel padl1em'
|
3508
|
+
}
|
3509
|
+
p('pad4px mart0_2em') {
|
3510
|
+
e 'Free Memory:','lgreen BOLD'
|
3511
|
+
free = `free -l`
|
3512
|
+
pre free
|
3513
|
+
}
|
3514
|
+
begin
|
3515
|
+
p('pad4px mart0_2em'){
|
3516
|
+
e 'Hdparm Settings:','lgreen BOLD'
|
3517
|
+
# bl $LINUX_YAML/*roeb*
|
3518
|
+
festplatte = '/dev/sda1'
|
3519
|
+
hdparm = `hdparm -Tt #{festplatte}`
|
3520
|
+
e hdparm,'yel padl1em'
|
3521
|
+
br
|
3522
|
+
e 'CPU-Info:','lgreen BOLD'
|
3523
|
+
if File.exist? '/proc/cpuinfo' # We can run this only when that file exists.
|
3524
|
+
begin
|
3525
|
+
cpuinfo = `cat /proc/cpuinfo`
|
3526
|
+
pre cpuinfo,'default'
|
3527
|
+
rescue; end
|
3528
|
+
end
|
3529
|
+
}
|
3530
|
+
rescue; end
|
3531
|
+
h4 sg(:black_dot, 'marr10px')+
|
3532
|
+
'LSPCI','yellow'
|
3533
|
+
p('pad4px mart0_2em'){
|
3534
|
+
lspci = `lspci -v 2>&1`
|
3535
|
+
pre lspci if lspci
|
3536
|
+
}
|
3537
|
+
p('pad4px mart0_2em'){
|
3538
|
+
e 'Vmstat Settings:','lgreen'
|
3539
|
+
vmstat=`vmstat`
|
3540
|
+
pre vmstat
|
3541
|
+
e 'Disk Free:','lgreen'
|
3542
|
+
df=`df -ha`
|
3543
|
+
df.gsub!(/\/dev\/hda1/,'<b class="lightblue">
|
3544
|
+
<a href="file:///dev/">/dev/hda1</a></b>')
|
3545
|
+
pre df
|
3546
|
+
}
|
3547
|
+
}
|
3548
|
+
end
|
3549
|
+
|
3550
|
+
# ========================================================================= #
|
3551
|
+
# === enable (enable tag)
|
3552
|
+
# ========================================================================= #
|
3553
|
+
def enable(
|
3554
|
+
what = 'scroll'
|
3555
|
+
)
|
3556
|
+
case what.to_s
|
3557
|
+
# ======================================================================= #
|
3558
|
+
# === predefine_squares
|
3559
|
+
# ======================================================================= #
|
3560
|
+
when 'predefine_squares','predefinesquares','squares'
|
3561
|
+
predefine_squares
|
3562
|
+
# ======================================================================= #
|
3563
|
+
# === drag_all_images
|
3564
|
+
# ======================================================================= #
|
3565
|
+
when /drag(_|-)?all(_|-)?images$/,
|
3566
|
+
'all_images',
|
3567
|
+
'+images',
|
3568
|
+
'images+'
|
3569
|
+
enable_drag_all_images
|
3570
|
+
# ======================================================================= #
|
3571
|
+
# === scroll
|
3572
|
+
# ======================================================================= #
|
3573
|
+
when 'scroll','default'
|
3574
|
+
enable_scrolling
|
3575
|
+
end
|
3576
|
+
end
|
3577
|
+
|
3578
|
+
# ========================================================================= #
|
3579
|
+
# === listing_css
|
3580
|
+
# ========================================================================= #
|
3581
|
+
def listing_css(i)
|
3582
|
+
::Cyberweb.listing_css_object = i
|
3583
|
+
end
|
3584
|
+
|
3585
|
+
# ========================================================================= #
|
3586
|
+
# === spacer (spacer tag)
|
3587
|
+
# ========================================================================= #
|
3588
|
+
def spacer(
|
3589
|
+
i = :middle,
|
3590
|
+
optional_css_class = ''
|
3591
|
+
)
|
3592
|
+
case i
|
3593
|
+
# ======================================================================= #
|
3594
|
+
# === :middle
|
3595
|
+
# ======================================================================= #
|
3596
|
+
when :middle,
|
3597
|
+
:center,
|
3598
|
+
:default
|
3599
|
+
result = sg(
|
3600
|
+
:spacer,
|
3601
|
+
optional_css_class,
|
3602
|
+
'',
|
3603
|
+
'text-align: center;
|
3604
|
+
display: block;
|
3605
|
+
margin-left: auto;
|
3606
|
+
margin-right: auto;'.delete("\n").squeeze(' ')
|
3607
|
+
)
|
3608
|
+
end
|
3609
|
+
addnl(
|
3610
|
+
result
|
3611
|
+
)
|
3612
|
+
end; alias trenner spacer # === trenner
|
3613
|
+
alias spalter spacer # === spalter
|
3614
|
+
alias space spacer # === space
|
3615
|
+
alias spacer_center spacer # === spacer_center
|
3616
|
+
alias beautiful_spacer spacer # === beautiful_spacer
|
3617
|
+
alias fancy_spacer spacer # === fancy_spacer
|
3618
|
+
alias fancy_separator spacer # === fancy_separator
|
3619
|
+
|
3620
|
+
# ========================================================================= #
|
3621
|
+
# === hspacer
|
3622
|
+
# ========================================================================= #
|
3623
|
+
def hspacer
|
3624
|
+
spacer(:center)
|
3625
|
+
end
|
3626
|
+
|
3627
|
+
# ========================================================================= #
|
3628
|
+
# === register_the_constants?
|
3629
|
+
# ========================================================================= #
|
3630
|
+
def register_the_constants?
|
3631
|
+
@internal_hash[:register_the_constants]
|
3632
|
+
end
|
3633
|
+
|
3634
|
+
# ========================================================================= #
|
3635
|
+
# === consider_loading_addons_based_on_the_config_file
|
3636
|
+
#
|
3637
|
+
# This presently only attempts to load prawn.
|
3638
|
+
# ========================================================================= #
|
3639
|
+
def consider_loading_addons_based_on_the_config_file
|
3640
|
+
if use_prawn?
|
3641
|
+
# ===================================================================== #
|
3642
|
+
# Then we try to load prawn. We are silent about this.
|
3643
|
+
# ===================================================================== #
|
3644
|
+
begin
|
3645
|
+
require 'prawn'
|
3646
|
+
rescue LoadError; end
|
3647
|
+
end
|
3648
|
+
end
|
3649
|
+
|
3650
|
+
# ========================================================================= #
|
3651
|
+
# === do_show_source
|
3652
|
+
# ========================================================================= #
|
3653
|
+
def do_show_source
|
3654
|
+
@internal_hash[:show_source] = true
|
3655
|
+
end
|
3656
|
+
|
3657
|
+
# ========================================================================= #
|
3658
|
+
# === show_source?
|
3659
|
+
# ========================================================================= #
|
3660
|
+
def show_source?
|
3661
|
+
@internal_hash[:show_source]
|
3662
|
+
end
|
3663
|
+
|
3664
|
+
# ========================================================================= #
|
3665
|
+
# === is_a_sinatra_application?
|
3666
|
+
# ========================================================================= #
|
3667
|
+
def is_a_sinatra_application?
|
3668
|
+
@internal_hash[:is_a_sinatra_application]
|
3669
|
+
end; alias uses_sinatra? is_a_sinatra_application? # === uses_sinatra?
|
3670
|
+
alias are_we_using_sinatra? is_a_sinatra_application? # === are_we_using_sinatra?
|
3671
|
+
|
3672
|
+
# ========================================================================= #
|
3673
|
+
# === is_a_sinatra_application
|
3674
|
+
#
|
3675
|
+
# Setter method to designate a given application as a sinatra-application.
|
3676
|
+
# ========================================================================= #
|
3677
|
+
def is_a_sinatra_application
|
3678
|
+
@internal_hash[:is_a_sinatra_application] = true
|
3679
|
+
end; alias enable_sinatra_application is_a_sinatra_application # === enable_sinatra_application
|
3680
|
+
|
3681
|
+
# ========================================================================= #
|
3682
|
+
# === set_web_const
|
3683
|
+
#
|
3684
|
+
# Easier, internal wrapper towards setting a constant.
|
3685
|
+
#
|
3686
|
+
# All constants will be registered inside the variable
|
3687
|
+
# @array_predefined_constants, and the method here will ensure that.
|
3688
|
+
#
|
3689
|
+
# Currently the css class which we will use is hardset. I am not sure
|
3690
|
+
# if we should be able to change this, and if so, how to alter it.
|
3691
|
+
# For now it will stay as it is.
|
3692
|
+
#
|
3693
|
+
# Notice that this method requires the string_img() method to exist,
|
3694
|
+
# aliased to sg(), which is defined as part of the module Cyberweb.
|
3695
|
+
#
|
3696
|
+
# The constant ARRAY_PREDEFINED_CONSTANTS is defined in the file
|
3697
|
+
# bl $CYBER/constants/constants.rb
|
3698
|
+
# ========================================================================= #
|
3699
|
+
def set_web_const(
|
3700
|
+
name_of_the_constant,
|
3701
|
+
symbol,
|
3702
|
+
css_class_to_use = 'marr4px'
|
21
3703
|
)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
sg(
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
3704
|
+
array_predefined_constants = ::Cyberweb.array_predefined_constants?
|
3705
|
+
unless array_predefined_constants.include? name_of_the_constant
|
3706
|
+
# ===================================================================== #
|
3707
|
+
# The next line will store the constant in a top-level variable, the
|
3708
|
+
# one referenced by Cyberweb.array_predefined_constants?
|
3709
|
+
# We will set on the Cyberweb namespace.
|
3710
|
+
# ===================================================================== #
|
3711
|
+
array_predefined_constants << name_of_the_constant
|
3712
|
+
# ===================================================================== #
|
3713
|
+
# The following code was disabled as of 07.08.2018. We do not want to
|
3714
|
+
# pollute the main Object namespace, so the constants now reside
|
3715
|
+
# within the Cyberweb "namespace" instead.
|
3716
|
+
# ===================================================================== #
|
3717
|
+
# Object.const_set(
|
3718
|
+
# name_of_the_constant, ::Cyberweb.sg(symbol, css_class_to_use)
|
3719
|
+
# )
|
3720
|
+
# ===================================================================== #
|
3721
|
+
# The constants will typically be like:
|
3722
|
+
# Cyberweb::PFEIL_RECHTS
|
3723
|
+
# ===================================================================== #
|
3724
|
+
# In October 2021 the following "if use_jquery?" line was removed.
|
3725
|
+
# You now have to specifically enable 'drag_' for the image ID
|
3726
|
+
# if you need draggable images here.
|
3727
|
+
# ===================================================================== #
|
3728
|
+
# if use_jquery?
|
3729
|
+
# use_this_as_the_image = sg(symbol, css_class_to_use) { :drag }
|
3730
|
+
# else
|
3731
|
+
use_this_as_the_image = sg(symbol, css_class_to_use)
|
3732
|
+
# end
|
3733
|
+
::Cyberweb.const_set(
|
3734
|
+
name_of_the_constant,
|
3735
|
+
use_this_as_the_image
|
3736
|
+
)
|
43
3737
|
end
|
44
3738
|
end
|
45
3739
|
|
46
3740
|
# ========================================================================= #
|
47
|
-
# ===
|
3741
|
+
# === register_constants (constants tag, const tag)
|
3742
|
+
#
|
3743
|
+
# This is a convenience method. It will register some constants
|
3744
|
+
# which can then be used in your web-app.
|
3745
|
+
#
|
3746
|
+
# This will set constants such as Cyberweb::ALERT or Cyberweb::HANGMAN.
|
3747
|
+
# ========================================================================= #
|
3748
|
+
def register_constants
|
3749
|
+
set_web_const 'ALERT', :ausrufungszeichen
|
3750
|
+
set_web_const 'AUSRUFUNG', :ausrufungszeichen
|
3751
|
+
set_web_const 'ANMERKUNG', :ausrufungszeichen
|
3752
|
+
set_web_const 'ANM', :ausrufungszeichen
|
3753
|
+
set_web_const 'WICHTIG', :ausrufungszeichen
|
3754
|
+
set_web_const 'HANGMAN', :hangman
|
3755
|
+
set_web_const 'HALLOWEEN', :halloween
|
3756
|
+
set_web_const 'EXTERNAL', :external
|
3757
|
+
set_web_const 'EXTERN', :external
|
3758
|
+
set_web_const 'DONE_IMAGE', :checkbox_on
|
3759
|
+
set_web_const 'DONE', :checkbox_on
|
3760
|
+
set_web_const 'DOT1', :dot1
|
3761
|
+
set_web_const 'DOT2', :dot2
|
3762
|
+
set_web_const 'DOT3', :dot3
|
3763
|
+
set_web_const 'DOT4', :dot4
|
3764
|
+
set_web_const 'DOT5', :dot5
|
3765
|
+
set_web_const 'DOT6', :dot6
|
3766
|
+
set_web_const 'DOT7', :dot7
|
3767
|
+
set_web_const 'DOT8', :dot8
|
3768
|
+
set_web_const 'DOT9', :dot9
|
3769
|
+
set_web_const 'DOT10', :dot10
|
3770
|
+
set_web_const 'DOT11', :dot11
|
3771
|
+
set_web_const 'DOT12', :dot12
|
3772
|
+
set_web_const 'LENS', :lens
|
3773
|
+
set_web_const 'LEAF', :leaf
|
3774
|
+
set_web_const 'LEAF2', :leaf2
|
3775
|
+
set_web_const 'MONEY', :money
|
3776
|
+
set_web_const 'NEW', :new
|
3777
|
+
set_web_const 'NEWS', :new
|
3778
|
+
set_web_const 'RUBY', :ruby
|
3779
|
+
set_web_const 'PFEIL1', :pfeil1
|
3780
|
+
set_web_const 'PFEIL2', :pfeil2
|
3781
|
+
set_web_const 'PFEIL3', :pfeil3
|
3782
|
+
set_web_const 'HTML_LINK_IMG', :pfeil3
|
3783
|
+
set_web_const 'PFEIL4', :pfeil4
|
3784
|
+
set_web_const 'PFEIL5', :pfeil5
|
3785
|
+
set_web_const 'PFEIL6', :pfeil6
|
3786
|
+
set_web_const 'PFEIL7', :pfeil7
|
3787
|
+
set_web_const 'PFEIL8', :pfeil8
|
3788
|
+
set_web_const 'PFEIL9', :pfeil9
|
3789
|
+
set_web_const 'PFEIL10', :pfeil10
|
3790
|
+
set_web_const 'PFEIL11', :pfeil11
|
3791
|
+
set_web_const 'PFEIL12', :pfeil12
|
3792
|
+
set_web_const 'PFEIL_RECHTS', :pfeil_rechts
|
3793
|
+
end; alias do_define_convenience_constants register_constants # === do_define_convenience_constants
|
3794
|
+
|
3795
|
+
# ========================================================================= #
|
3796
|
+
# === append_body_tag
|
3797
|
+
#
|
3798
|
+
# Open up the body-tag.
|
3799
|
+
# ========================================================================= #
|
3800
|
+
def append_body_tag
|
3801
|
+
addnl(
|
3802
|
+
return_body_tag
|
3803
|
+
)
|
3804
|
+
end
|
3805
|
+
|
48
3806
|
# ========================================================================= #
|
49
|
-
|
50
|
-
|
3807
|
+
# === use_utf
|
3808
|
+
# ========================================================================= #
|
3809
|
+
def use_utf
|
3810
|
+
set_encoding_to_use :utf # ← Better to pass it through a method.
|
3811
|
+
end; alias use_utf8 use_utf # === use_utf8
|
3812
|
+
alias use_unicode use_utf # === use_unicode
|
3813
|
+
alias use_utf_encoding use_utf # === use_utf_encoding
|
3814
|
+
|
3815
|
+
# ========================================================================= #
|
3816
|
+
# === save (save tag)
|
3817
|
+
#
|
3818
|
+
# This method will store the "HTML" stored inside the main string at
|
3819
|
+
# the variable :html_string into a local file.
|
3820
|
+
#
|
3821
|
+
# The first argument denotes the name of the file at hand, stored as
|
3822
|
+
# a .html file always.
|
3823
|
+
# ========================================================================= #
|
3824
|
+
def save(
|
3825
|
+
what = html_string?,
|
3826
|
+
use_this_as_filename = title?.to_s,
|
3827
|
+
into = :default
|
3828
|
+
)
|
3829
|
+
log_dir = log_dir?
|
3830
|
+
case use_this_as_filename
|
3831
|
+
# ======================================================================= #
|
3832
|
+
# === :default
|
3833
|
+
# ======================================================================= #
|
3834
|
+
when :default
|
3835
|
+
use_this_as_filename = title?.to_s.tr(' ','_')
|
3836
|
+
end
|
3837
|
+
case into
|
3838
|
+
# ======================================================================= #
|
3839
|
+
# === :save_into_this_html_page
|
3840
|
+
# ======================================================================= #
|
3841
|
+
when :save_into_this_html_page
|
3842
|
+
into = save_into_this_html_page?
|
3843
|
+
# ======================================================================= #
|
3844
|
+
# === :default
|
3845
|
+
#
|
3846
|
+
# Build the filename here.
|
3847
|
+
# ======================================================================= #
|
3848
|
+
when :default
|
3849
|
+
into = log_dir+
|
3850
|
+
use_this_as_filename.to_s+'.html'
|
3851
|
+
end
|
3852
|
+
mkdir(log_dir) unless File.directory? log_dir
|
3853
|
+
message = "Storing into the file #{into}."
|
3854
|
+
puts message
|
3855
|
+
e message
|
3856
|
+
write_what_into(what, into)
|
51
3857
|
end
|
52
3858
|
|
53
3859
|
# ========================================================================= #
|
54
|
-
# ===
|
3860
|
+
# === espan_no_newline
|
55
3861
|
# ========================================================================= #
|
56
|
-
def
|
57
|
-
|
3862
|
+
def espan_no_newline(
|
3863
|
+
i = '',
|
3864
|
+
optional_css_class = '',
|
3865
|
+
optional_the_id = '',
|
3866
|
+
optional_css_style = ''
|
3867
|
+
)
|
3868
|
+
add(
|
3869
|
+
string_s2(
|
3870
|
+
i.to_s,
|
3871
|
+
optional_css_class,
|
3872
|
+
optional_the_id,
|
3873
|
+
optional_css_style
|
3874
|
+
)
|
3875
|
+
)
|
3876
|
+
end; alias eee espan_no_newline # === eee
|
3877
|
+
|
3878
|
+
# ========================================================================= #
|
3879
|
+
# === anm
|
3880
|
+
# ========================================================================= #
|
3881
|
+
def anm(
|
3882
|
+
i = '', # Should be an empty String.
|
3883
|
+
optional_css_class = '',
|
3884
|
+
optional_the_id = '',
|
3885
|
+
optional_css_style = ''
|
3886
|
+
)
|
3887
|
+
addn(
|
3888
|
+
sg(:anmerkung, 'marr5px')+
|
3889
|
+
string_span(
|
3890
|
+
i, optional_css_class, optional_the_id, optional_css_style
|
3891
|
+
)
|
3892
|
+
)
|
3893
|
+
end; alias anmerkung anm # === anmerkung
|
3894
|
+
|
3895
|
+
require 'cyberweb/toplevel_methods/markdown.rb'
|
3896
|
+
# ========================================================================= #
|
3897
|
+
# === markdown
|
3898
|
+
# ========================================================================= #
|
3899
|
+
def markdown(i = '')
|
3900
|
+
addnl(
|
3901
|
+
::Cyberweb.markdown(i)
|
3902
|
+
)
|
3903
|
+
end; alias markdown_display_this_file markdown # === markdown_display_this_file
|
3904
|
+
alias read_and_display_markdown markdown # === read_and_display_markdown
|
3905
|
+
alias show_md markdown # === show_md
|
3906
|
+
alias display_markdown markdown # === display_markdown
|
3907
|
+
|
3908
|
+
# ========================================================================= #
|
3909
|
+
# === add_svg_table
|
3910
|
+
# ========================================================================= #
|
3911
|
+
def add_svg_table(
|
3912
|
+
i = 'fancy_table'
|
3913
|
+
)
|
3914
|
+
addnl(
|
3915
|
+
Cyberweb.return_svg_table(i)
|
3916
|
+
)
|
58
3917
|
end
|
59
3918
|
|
60
3919
|
# ========================================================================= #
|
61
|
-
# ===
|
3920
|
+
# === try_to_create_the_log_directory_unless_it_already_exists
|
62
3921
|
# ========================================================================= #
|
63
|
-
def
|
64
|
-
|
3922
|
+
def try_to_create_the_log_directory_unless_it_already_exists
|
3923
|
+
_ = ::Cyberweb.log_dir?
|
3924
|
+
unless File.directory?(_)
|
3925
|
+
mkdir(_)
|
3926
|
+
end
|
65
3927
|
end
|
66
3928
|
|
67
3929
|
# ========================================================================= #
|
68
|
-
# ===
|
3930
|
+
# === oop_progress
|
69
3931
|
#
|
70
|
-
#
|
3932
|
+
# The progress element represents the completion progress of a task. The
|
3933
|
+
# method here will simply delegate towards the corresponding objectified
|
3934
|
+
# HTML tag.
|
3935
|
+
# ========================================================================= #
|
3936
|
+
def oop_progress(
|
3937
|
+
n_percent,
|
3938
|
+
&block
|
3939
|
+
)
|
3940
|
+
addnl(
|
3941
|
+
::Cyberweb::Objectified::HtmlTags::Progress.new(n_percent, &block).to_s
|
3942
|
+
)
|
3943
|
+
end; alias progress oop_progress # === progress
|
3944
|
+
|
3945
|
+
# ========================================================================= #
|
3946
|
+
# === text
|
3947
|
+
# ========================================================================= #
|
3948
|
+
def text(i)
|
3949
|
+
Cyberweb::Objectified::HtmlTags::Span.new(i)
|
3950
|
+
end; alias label_text text # === label_text
|
3951
|
+
|
3952
|
+
# ========================================================================= #
|
3953
|
+
# === label
|
71
3954
|
#
|
72
|
-
#
|
3955
|
+
# This may look like so:
|
73
3956
|
#
|
74
|
-
#
|
3957
|
+
# <label for="male">Male</label><br>
|
3958
|
+
#
|
3959
|
+
# ========================================================================= #
|
3960
|
+
def label(i)
|
3961
|
+
addnl(
|
3962
|
+
"<label>#{i}</label>"
|
3963
|
+
)
|
3964
|
+
end
|
3965
|
+
|
3966
|
+
# ========================================================================= #
|
3967
|
+
# === oop_abbr
|
3968
|
+
#
|
3969
|
+
# This method makes use of the OOP variant for the abbr-html-tag.
|
3970
|
+
# ========================================================================= #
|
3971
|
+
def oop_abbr(a, b = nil)
|
3972
|
+
addnl(
|
3973
|
+
::Cyberweb::Objectified::HtmlTags::Abbr.new(a, b).to_s
|
3974
|
+
)
|
3975
|
+
end
|
3976
|
+
|
3977
|
+
# ========================================================================= #
|
3978
|
+
# === return_css_style_for_the_triangle_isosceles_bubble
|
3979
|
+
#
|
3980
|
+
# This method will return two CSS classes, which can be used if you
|
3981
|
+
# want to make use of CSS bubbles. Currently only the downwards-facing
|
3982
|
+
# triangle is available.
|
3983
|
+
#
|
3984
|
+
# The original source has been adapted from here:
|
3985
|
+
#
|
3986
|
+
# http://nicolasgallagher.com/pure-css-speech-bubbles/demo/
|
3987
|
+
#
|
3988
|
+
# ========================================================================= #
|
3989
|
+
def return_css_style_for_the_triangle_isosceles_bubble(
|
3990
|
+
additional_css_rules = ''
|
3991
|
+
)
|
3992
|
+
if additional_css_rules and additional_css_rules.empty?
|
3993
|
+
additional_css_rules = 'margin: 1em 0 3em;'
|
3994
|
+
end
|
3995
|
+
return '.triangle_isosceles_bubble {
|
3996
|
+
position:relative;
|
3997
|
+
padding:15px;
|
3998
|
+
'+additional_css_rules.to_s+';
|
3999
|
+
width:500px;
|
4000
|
+
color:#000;
|
4001
|
+
background:#f3961c; /* default background for browsers without gradient support */
|
4002
|
+
/* css3 */
|
4003
|
+
background:linear-gradient(#f9d835, #f3961c);
|
4004
|
+
border-radius:10px;
|
4005
|
+
border: 1px solid black;
|
4006
|
+
}
|
4007
|
+
|
4008
|
+
/* This class creates the triangle that faces downwards */
|
4009
|
+
.triangle_isosceles_bubble:after {
|
4010
|
+
content:"";
|
4011
|
+
position:absolute;
|
4012
|
+
bottom:-13px; /* value = - border-top-width - border-bottom-width */
|
4013
|
+
left:30px; /* controls the horizontal position */
|
4014
|
+
border-width: 15px 15px 0; /* vary these values to change the angle of the vertex */
|
4015
|
+
border-style: solid;
|
4016
|
+
border-color: #f3961c transparent;
|
4017
|
+
display:block;
|
4018
|
+
width:0;
|
4019
|
+
}'
|
4020
|
+
end
|
4021
|
+
|
4022
|
+
# ========================================================================= #
|
4023
|
+
# === colour_gradient_left_to_right
|
4024
|
+
#
|
4025
|
+
# This method will "return" a CSS class, for a colour-gradient left to
|
4026
|
+
# right.
|
4027
|
+
# ========================================================================= #
|
4028
|
+
def colour_gradient_left_to_right(
|
4029
|
+
colour1 = :steelblue,
|
4030
|
+
colour2 = :darkgreen,
|
4031
|
+
css_name_that_will_be_returned = '.gradient1'
|
4032
|
+
)
|
4033
|
+
return "#{css_name_that_will_be_returned} {
|
4034
|
+
background: linear-gradient(to right, #{colour1}, #{colour2});
|
4035
|
+
}"
|
4036
|
+
end; alias colour_gradient colour_gradient_left_to_right # === colour_gradient
|
4037
|
+
|
4038
|
+
# ========================================================================= #
|
4039
|
+
# === colour_gradient_right_to_left
|
4040
|
+
#
|
4041
|
+
# This method will "return" a CSS class, for a colour-gradient left to
|
4042
|
+
# right.
|
4043
|
+
# ========================================================================= #
|
4044
|
+
def colour_gradient_right_to_left(
|
4045
|
+
colour1 = :steelblue,
|
4046
|
+
colour2 = :darkgreen,
|
4047
|
+
css_name_that_will_be_returned = '.gradient1'
|
4048
|
+
)
|
4049
|
+
return "#{css_name_that_will_be_returned} {
|
4050
|
+
background: linear-gradient(to left, #{colour1}, #{colour2});
|
4051
|
+
}"
|
4052
|
+
end
|
4053
|
+
|
4054
|
+
# ========================================================================= #
|
4055
|
+
# === css_class_or_no_class
|
4056
|
+
# ========================================================================= #
|
4057
|
+
def css_class_or_no_class(i = '')
|
4058
|
+
unless i.to_s.empty?
|
4059
|
+
i = " class=\"#{i}\""
|
4060
|
+
end
|
4061
|
+
return i
|
4062
|
+
end
|
4063
|
+
|
4064
|
+
# ========================================================================= #
|
4065
|
+
# === use_monospace_font
|
4066
|
+
#
|
4067
|
+
# By default this will use the "Lucida Console" font.
|
4068
|
+
# ========================================================================= #
|
4069
|
+
def use_monospace_font(
|
4070
|
+
use_this_font = '"Lucida Console", Monaco, monospace'
|
4071
|
+
)
|
4072
|
+
use_this_font = use_this_font.dup if use_this_font.frozen?
|
4073
|
+
use_this_font << ';' unless use_this_font.end_with? ';'
|
4074
|
+
append_to_css_style '
|
4075
|
+
body {
|
4076
|
+
font-family: '+use_this_font+'
|
4077
|
+
}
|
4078
|
+
'
|
4079
|
+
end; alias monospace_font use_monospace_font # === monospace_font
|
4080
|
+
|
4081
|
+
# ========================================================================= #
|
4082
|
+
# === add_this_remote_css_page
|
4083
|
+
#
|
4084
|
+
# Use this method in order to include a remote css file.
|
4085
|
+
#
|
4086
|
+
# The argument to this method should be the remote URL that
|
4087
|
+
# you want to access.
|
4088
|
+
#
|
4089
|
+
# Please use use this method solely for remote URLs.
|
4090
|
+
#
|
4091
|
+
# Specific Usage Example:
|
4092
|
+
#
|
4093
|
+
# css_remote_url 'http://www.playgroundblues.com/media/stylesheets/screen.css'
|
4094
|
+
#
|
4095
|
+
# ========================================================================= #
|
4096
|
+
def add_this_remote_css_page(i)
|
4097
|
+
addnl(
|
4098
|
+
'<link rel="stylesheet" href="'+i+'" type="text/css" media="screen">'
|
4099
|
+
)
|
4100
|
+
end; alias css_remote_url add_this_remote_css_page # === css_remote_url
|
4101
|
+
alias external_stylesheet add_this_remote_css_page # === external_stylesheet
|
4102
|
+
alias remote_css add_this_remote_css_page # === remote_css
|
4103
|
+
alias add_remote_css_page add_this_remote_css_page # === add_remote_css_page
|
4104
|
+
alias css_file= add_this_remote_css_page # === css_file=
|
4105
|
+
alias add_css_file add_this_remote_css_page # === add_css_file
|
4106
|
+
alias css_file add_this_remote_css_page # === css_file
|
4107
|
+
alias external_style_sheet add_this_remote_css_page # === external_style_sheet
|
4108
|
+
|
4109
|
+
# ========================================================================= #
|
4110
|
+
# === check_whether_to_show_the_source_code
|
75
4111
|
#
|
4112
|
+
# This is the method that can display the source code of a given .cgi
|
4113
|
+
# page.
|
4114
|
+
# ========================================================================= #
|
4115
|
+
def check_whether_to_show_the_source_code
|
4116
|
+
# ======================================================================= #
|
4117
|
+
# We must also check whether the configuration file allows us to
|
4118
|
+
# show the source code.
|
4119
|
+
# ======================================================================= #
|
4120
|
+
if show_source? and ::Cyberweb.config['may_show_source']
|
4121
|
+
_ = this_file?(:full_path)
|
4122
|
+
ee '<html>'
|
4123
|
+
ee '<head>'
|
4124
|
+
# ===================================================================== #
|
4125
|
+
# Add the following in order to enable on-click highlight at a later time.
|
4126
|
+
# ===================================================================== #
|
4127
|
+
ee HtmlTags.style('.highlight {
|
4128
|
+
background:yellow;
|
4129
|
+
}')
|
4130
|
+
ee '</head>'
|
4131
|
+
ee '<body>'
|
4132
|
+
ee 'Next displaying the source code of the file <b>'+_+'</b>'
|
4133
|
+
# ===================================================================== #
|
4134
|
+
# The following has not yet been enabled. It shall follow this
|
4135
|
+
# here:
|
4136
|
+
#
|
4137
|
+
# http://jsfiddle.net/kB7u2/1/
|
4138
|
+
#
|
4139
|
+
# ===================================================================== #
|
4140
|
+
if false
|
4141
|
+
output_this_javascript "
|
4142
|
+
$('.stripe_table').hover(
|
4143
|
+
function() {
|
4144
|
+
$(this).addClass('highlight');
|
4145
|
+
}, function() {
|
4146
|
+
$(this).removeClass('highlight');
|
4147
|
+
}
|
4148
|
+
)"
|
4149
|
+
end
|
4150
|
+
dataset = File.readlines(_)
|
4151
|
+
n_lines = dataset.size
|
4152
|
+
ee '<h4>'+n_lines.to_s+' lines</h4>'
|
4153
|
+
ee '<pre>'
|
4154
|
+
# ===================================================================== #
|
4155
|
+
# Presently, we will always display the index-number.
|
4156
|
+
# ===================================================================== #
|
4157
|
+
dataset.each_with_index {|content, index|
|
4158
|
+
index += 1
|
4159
|
+
ee '<span class="line_'+index.to_s+'"><b>'+index.to_s.ljust(5)+'</b>'+content+'</span>'
|
4160
|
+
}
|
4161
|
+
ee '</pre>'
|
4162
|
+
ee '</body></html>'
|
4163
|
+
exit
|
4164
|
+
end
|
4165
|
+
end
|
4166
|
+
|
4167
|
+
# ========================================================================= #
|
4168
|
+
# === display_this_file_without_comments
|
4169
|
+
#
|
4170
|
+
# This method is similar to the method defined above; it will
|
4171
|
+
# read in the dataset, before it will then remove all parts
|
4172
|
+
# after ' #' in a given line. Furthermore, any lines starting
|
4173
|
+
# with '#' will also be removed entirely.
|
4174
|
+
# ========================================================================= #
|
4175
|
+
def display_this_file_without_comments(
|
4176
|
+
this_file,
|
4177
|
+
optional_css_class = '',
|
4178
|
+
optional_the_id = '',
|
4179
|
+
optional_css_style = '',
|
4180
|
+
&block
|
4181
|
+
)
|
4182
|
+
display_this_file(
|
4183
|
+
this_file,
|
4184
|
+
optional_css_class = '',
|
4185
|
+
optional_the_id = '',
|
4186
|
+
optional_css_style
|
4187
|
+
) { :strip_the_parts_after_a_comment }
|
4188
|
+
end
|
4189
|
+
|
76
4190
|
# ========================================================================= #
|
77
|
-
|
78
|
-
|
79
|
-
|
4191
|
+
# === white_font
|
4192
|
+
# ========================================================================= #
|
4193
|
+
def white_font
|
4194
|
+
add_this_css_style(
|
4195
|
+
'body { color: white; }'
|
80
4196
|
)
|
81
|
-
end
|
82
|
-
alias pretty_spacer hr_stars # === pretty_spacer
|
83
|
-
alias pretty_stars hr_stars # === pretty_stars
|
84
|
-
alias pretty_star hr_stars # === pretty_star
|
85
|
-
alias pretty_hsep hr_stars # === pretty_hsep
|
86
|
-
alias fancy_stars hr_stars # === fancy_stars
|
87
|
-
alias pretty_separator hr_stars # === pretty_separator
|
4197
|
+
end
|
88
4198
|
|
89
4199
|
# ========================================================================= #
|
90
4200
|
# === sentence
|
@@ -869,15 +4979,6 @@ class WebObject < ::Cyberweb::Base # === Cyberweb::WebObject
|
|
869
4979
|
@internal_hash[:head_string] << "#{i}\n"
|
870
4980
|
end
|
871
4981
|
|
872
|
-
# ========================================================================= #
|
873
|
-
# === advanced_handle_these_calls_for_german
|
874
|
-
# ========================================================================= #
|
875
|
-
def advanced_handle_these_calls_for_german(&block)
|
876
|
-
german_trinity
|
877
|
-
handle_these_calls(&block)
|
878
|
-
close_html_then_serve_the_webpage
|
879
|
-
end
|
880
|
-
|
881
4982
|
# ========================================================================= #
|
882
4983
|
# === head_string?
|
883
4984
|
# ========================================================================= #
|
@@ -1251,7 +5352,6 @@ class WebObject < ::Cyberweb::Base # === Cyberweb::WebObject
|
|
1251
5352
|
::Cyberweb.frameset(i, &block) # Call the other method. Where is this?
|
1252
5353
|
end
|
1253
5354
|
|
1254
|
-
|
1255
5355
|
# ========================================================================= #
|
1256
5356
|
# === return_body_tag
|
1257
5357
|
# ========================================================================= #
|
@@ -1350,23 +5450,6 @@ class WebObject < ::Cyberweb::Base # === Cyberweb::WebObject
|
|
1350
5450
|
alias background_colour= set_background # === background_colour=
|
1351
5451
|
alias background set_background # === background
|
1352
5452
|
|
1353
|
-
# ========================================================================= #
|
1354
|
-
# === return_css_style
|
1355
|
-
#
|
1356
|
-
# This method will simply return the <style>CONTENT_HERE</style> variant.
|
1357
|
-
# ========================================================================= #
|
1358
|
-
def return_css_style(i)
|
1359
|
-
if i.is_a? Hash
|
1360
|
-
_ = ''.dup
|
1361
|
-
i.each_pair {|key, value|
|
1362
|
-
_ << "#{key} = #{value};"
|
1363
|
-
}
|
1364
|
-
i = _
|
1365
|
-
end
|
1366
|
-
return "<style>\n#{i}\n</style>\n"
|
1367
|
-
end; alias return_this_css_style return_css_style # === return_this_css_style
|
1368
|
-
alias page_css_classes return_css_style # === page_css_classes
|
1369
|
-
|
1370
5453
|
# ========================================================================= #
|
1371
5454
|
# === pull_in_these_css_classes
|
1372
5455
|
#
|
@@ -1454,32 +5537,6 @@ class WebObject < ::Cyberweb::Base # === Cyberweb::WebObject
|
|
1454
5537
|
'
|
1455
5538
|
end; alias disable_scrollbars hide_scrollbars # === disable_scrollbars
|
1456
5539
|
|
1457
|
-
# ========================================================================= #
|
1458
|
-
# === set_body_css_class
|
1459
|
-
#
|
1460
|
-
# This method can be used to designate a (or several) css_class(es)
|
1461
|
-
# in the <body> tag of a webpage.
|
1462
|
-
# ========================================================================= #
|
1463
|
-
def set_body_css_class(
|
1464
|
-
i = ''
|
1465
|
-
)
|
1466
|
-
@internal_hash[:body_css_class] = i.to_s
|
1467
|
-
end; alias body_css_class set_body_css_class # === body_css_class
|
1468
|
-
alias body_css_class= set_body_css_class # === body_css_class=
|
1469
|
-
alias body_css_classes set_body_css_class # === body_css_classes
|
1470
|
-
alias body_css_class set_body_css_class # === body_css_class
|
1471
|
-
alias body_css= set_body_css_class # === body_css=
|
1472
|
-
alias body_css set_body_css_class # === body_css
|
1473
|
-
alias bcc= set_body_css_class # === bcc=
|
1474
|
-
alias bcc set_body_css_class # === bcc
|
1475
|
-
alias main_body= set_body_css_class # === main_body?
|
1476
|
-
alias main_body set_body_css_class # === main_body
|
1477
|
-
alias body= set_body_css_class # === body?
|
1478
|
-
alias body set_body_css_class # === body
|
1479
|
-
alias css_class set_body_css_class # === css_class
|
1480
|
-
alias b1= set_body_css_class # === b1=
|
1481
|
-
alias b1 set_body_css_class # === b1
|
1482
|
-
|
1483
5540
|
# ========================================================================= #
|
1484
5541
|
# === show_debug_information (debug tag)
|
1485
5542
|
#
|
@@ -1678,47 +5735,6 @@ class WebObject < ::Cyberweb::Base # === Cyberweb::WebObject
|
|
1678
5735
|
h2 i, 'lightblue'
|
1679
5736
|
end
|
1680
5737
|
|
1681
|
-
# ========================================================================= #
|
1682
|
-
# === pre (pre tag)
|
1683
|
-
# ========================================================================= #
|
1684
|
-
def pre(
|
1685
|
-
i = '',
|
1686
|
-
optional_css_class = 'FS1_5em',
|
1687
|
-
optional_the_id = '',
|
1688
|
-
optional_css_style = '',
|
1689
|
-
optional_commands = nil,
|
1690
|
-
&block
|
1691
|
-
)
|
1692
|
-
if optional_commands
|
1693
|
-
case optional_commands
|
1694
|
-
# ===================================================================== #
|
1695
|
-
# === :remove_html
|
1696
|
-
# ===================================================================== #
|
1697
|
-
when :remove_html
|
1698
|
-
i = Cyberweb.remove_html(i)
|
1699
|
-
end
|
1700
|
-
end
|
1701
|
-
# ======================================================================= #
|
1702
|
-
# === Handle blocks next
|
1703
|
-
# ======================================================================= #
|
1704
|
-
if block_given?
|
1705
|
-
yielded = yield.to_s
|
1706
|
-
if yielded and !yielded.empty?
|
1707
|
-
i = i.to_s.dup
|
1708
|
-
i << yielded
|
1709
|
-
end
|
1710
|
-
end
|
1711
|
-
addn(
|
1712
|
-
'<pre'+
|
1713
|
-
css_class_or_no_class(optional_css_class)+
|
1714
|
-
id_or_no_id(optional_the_id)+
|
1715
|
-
css_style_or_no_style(optional_css_style)+
|
1716
|
-
'>'+
|
1717
|
-
i.to_s+
|
1718
|
-
'</pre>'
|
1719
|
-
)
|
1720
|
-
end
|
1721
|
-
|
1722
5738
|
# ========================================================================= #
|
1723
5739
|
# === load_this_external_javascript_file
|
1724
5740
|
# ========================================================================= #
|
@@ -2438,17 +6454,6 @@ class WebObject < ::Cyberweb::Base # === Cyberweb::WebObject
|
|
2438
6454
|
add :content_type_plain
|
2439
6455
|
end
|
2440
6456
|
|
2441
|
-
# ========================================================================= #
|
2442
|
-
# === close_html_after_making_sure_that_the_body_tag_exists
|
2443
|
-
# ========================================================================= #
|
2444
|
-
def close_html_after_making_sure_that_the_body_tag_exists
|
2445
|
-
splitted = result?.split("\n")
|
2446
|
-
unless splitted.any? {|line| line.start_with? '<body' }
|
2447
|
-
addnl(:body, @internal_hash[:body_css_class])
|
2448
|
-
end
|
2449
|
-
close_html
|
2450
|
-
end
|
2451
|
-
|
2452
6457
|
# ========================================================================= #
|
2453
6458
|
# === doc_write
|
2454
6459
|
# ========================================================================= #
|
@@ -3237,41 +7242,6 @@ function '+name_of_the_function_to_use+'{
|
|
3237
7242
|
end; alias get_images_from get_images # === get_images_from
|
3238
7243
|
alias return_all_images_from get_images # === return_all_images_from
|
3239
7244
|
|
3240
|
-
# ========================================================================= #
|
3241
|
-
# === div_default
|
3242
|
-
# ========================================================================= #
|
3243
|
-
def div_default(
|
3244
|
-
optional_css_class = '',
|
3245
|
-
the_id = '',
|
3246
|
-
optional_css_style = '',
|
3247
|
-
&block
|
3248
|
-
)
|
3249
|
-
if optional_css_class.is_a? Hash
|
3250
|
-
# ===================================================================== #
|
3251
|
-
# === id
|
3252
|
-
# ===================================================================== #
|
3253
|
-
if optional_css_class.has_key? :id
|
3254
|
-
the_id = optional_css_class.delete(:id)
|
3255
|
-
end
|
3256
|
-
# ===================================================================== #
|
3257
|
-
# === css_class
|
3258
|
-
#
|
3259
|
-
# This entry must come last.
|
3260
|
-
# ===================================================================== #
|
3261
|
-
if optional_css_class.has_key? :css_class
|
3262
|
-
optional_css_class = optional_css_class.delete(:css_class)
|
3263
|
-
end
|
3264
|
-
end
|
3265
|
-
optional_css_class = optional_css_class.to_s.dup
|
3266
|
-
optional_css_class.prepend('default ') # Make it the first argument, always.
|
3267
|
-
div(
|
3268
|
-
optional_css_class.strip,
|
3269
|
-
the_id,
|
3270
|
-
optional_css_style,
|
3271
|
-
&block
|
3272
|
-
)
|
3273
|
-
end
|
3274
|
-
|
3275
7245
|
# ========================================================================= #
|
3276
7246
|
# === display_simple_clock
|
3277
7247
|
#
|
@@ -3629,13 +7599,6 @@ function simple_clock_timer() {
|
|
3629
7599
|
addnl '</head>'
|
3630
7600
|
end
|
3631
7601
|
|
3632
|
-
# ========================================================================= #
|
3633
|
-
# === start_the_body_tag
|
3634
|
-
# ========================================================================= #
|
3635
|
-
def start_the_body_tag
|
3636
|
-
addnl '<body>'
|
3637
|
-
end
|
3638
|
-
|
3639
7602
|
# ========================================================================= #
|
3640
7603
|
# === close_body_head_and_html_tag
|
3641
7604
|
# ========================================================================= #
|
@@ -3730,65 +7693,6 @@ function simple_clock_timer() {
|
|
3730
7693
|
@internal_hash[:database]
|
3731
7694
|
end
|
3732
7695
|
|
3733
|
-
# ========================================================================= #
|
3734
|
-
# === doc_skeleton
|
3735
|
-
#
|
3736
|
-
# This method has been specifically created to allow support of
|
3737
|
-
# .md (markdown) files in different languages - either german
|
3738
|
-
# or english.
|
3739
|
-
#
|
3740
|
-
# This method may also be called via a Symbol, such as:
|
3741
|
-
#
|
3742
|
-
# doc_skeleton(:english_or_german)
|
3743
|
-
#
|
3744
|
-
# ========================================================================= #
|
3745
|
-
def doc_skeleton(this_file)
|
3746
|
-
if this_file.is_a? Symbol
|
3747
|
-
case this_file
|
3748
|
-
# ===================================================================== #
|
3749
|
-
# === :english_or_german
|
3750
|
-
#
|
3751
|
-
# This will default to german.
|
3752
|
-
# ===================================================================== #
|
3753
|
-
when :english_or_german
|
3754
|
-
this_file = filename_without_extension?+'_german.md' # 'luft_german.md'
|
3755
|
-
end
|
3756
|
-
end
|
3757
|
-
# ======================================================================= #
|
3758
|
-
# Next, check for arguments given to the .cgi file at hand.
|
3759
|
-
# ======================================================================= #
|
3760
|
-
parameters_as_string = parameters_as_string?
|
3761
|
-
case parameters_as_string
|
3762
|
-
# ======================================================================= #
|
3763
|
-
# === use_english
|
3764
|
-
#
|
3765
|
-
# This can be invoked via:
|
3766
|
-
#
|
3767
|
-
# http://localhost/programming/ruby/src/roebe/lib/roebe/www/luft/luft.cgi?english
|
3768
|
-
#
|
3769
|
-
# ======================================================================= #
|
3770
|
-
when /use_english/,
|
3771
|
-
/english$/
|
3772
|
-
this_file = filename_without_extension?+'_english.md'
|
3773
|
-
# ======================================================================= #
|
3774
|
-
# === use_german
|
3775
|
-
# ======================================================================= #
|
3776
|
-
when /use_german/,
|
3777
|
-
/german$/
|
3778
|
-
this_file = filename_without_extension?+'_german.md'
|
3779
|
-
end
|
3780
|
-
if this_file and File.exist?(this_file)
|
3781
|
-
file_content = File.read(this_file, encoding: 'utf-8')
|
3782
|
-
dataset = remove_comments_from_this_string(file_content)
|
3783
|
-
eval(dataset)
|
3784
|
-
# ===================================================================== #
|
3785
|
-
# Next simply evaluate it.
|
3786
|
-
# ===================================================================== #
|
3787
|
-
else
|
3788
|
-
no_file_exists_at(this_file)
|
3789
|
-
end
|
3790
|
-
end
|
3791
|
-
|
3792
7696
|
# ========================================================================= #
|
3793
7697
|
# === window
|
3794
7698
|
#
|
@@ -3971,29 +7875,6 @@ function simple_clock_timer() {
|
|
3971
7875
|
string_img(url, css_class, the_id, css_style, alt_text) { :draggable_attribute }
|
3972
7876
|
end
|
3973
7877
|
|
3974
|
-
# ========================================================================= #
|
3975
|
-
# === enable_drag_all_images
|
3976
|
-
#
|
3977
|
-
# We enable a configuration option through this method call here.
|
3978
|
-
#
|
3979
|
-
# Note that we will also automatically enable jquery in this case,
|
3980
|
-
# as otherwise we could not drag the image in question around,
|
3981
|
-
# which would sort of defeat the points of having this method
|
3982
|
-
# in the first place - or it would require of you to manually
|
3983
|
-
# enable jquery, which seems superfluous.
|
3984
|
-
# ========================================================================= #
|
3985
|
-
def enable_drag_all_images
|
3986
|
-
do_use_jquery unless use_jquery?
|
3987
|
-
@config['drag_all_images'] = true
|
3988
|
-
end; alias drag_all_images enable_drag_all_images # === drag_all_images
|
3989
|
-
alias drag_everything enable_drag_all_images # === drag_everything
|
3990
|
-
alias do_drag_all_images enable_drag_all_images # === do_drag_all_image
|
3991
|
-
alias do_enable_drag_all_images enable_drag_all_images # === do_enable_drag_all_image
|
3992
|
-
alias drag_everything enable_drag_all_images # === drag_everything
|
3993
|
-
alias all_images_will_be_draggable enable_drag_all_images # === all_images_will_be_draggable
|
3994
|
-
alias enable_dragging enable_drag_all_images # === enable_dragging
|
3995
|
-
alias enable_drag_and_drop enable_drag_all_images # === enable_drag_and_drop
|
3996
|
-
|
3997
7878
|
# ========================================================================= #
|
3998
7879
|
# === add_dragula_drag_for
|
3999
7880
|
#
|
@@ -4170,56 +8051,6 @@ function simple_clock_timer() {
|
|
4170
8051
|
alias alink a # === alink
|
4171
8052
|
alias remote_link a # === remote_link
|
4172
8053
|
|
4173
|
-
# ========================================================================= #
|
4174
|
-
# === string_link
|
4175
|
-
#
|
4176
|
-
# This method essentially creates a String representation of the HTML
|
4177
|
-
# <a> tag.
|
4178
|
-
#
|
4179
|
-
# Since as of April 2022 the method "slink" is now an alias to string_link;
|
4180
|
-
# it used to be an alias towards "def a()", but this was changed - the
|
4181
|
-
# word string_link more logically may refer to slink as its intrinsic
|
4182
|
-
# abbreviation.
|
4183
|
-
# ========================================================================= #
|
4184
|
-
def string_link(
|
4185
|
-
i = '',
|
4186
|
-
option_hash = {}
|
4187
|
-
)
|
4188
|
-
if i.is_a?(Symbol)
|
4189
|
-
if i.start_with?('local_')
|
4190
|
-
i = BeautifulUrl.local_menu(i)
|
4191
|
-
else
|
4192
|
-
i = beautiful_url(i)
|
4193
|
-
# =================================================================== #
|
4194
|
-
# Also check if the second argument is a String. In this case we
|
4195
|
-
# must modify it. Example for input that fulfils this criterium:
|
4196
|
-
#
|
4197
|
-
# remote_link(:hydrogenase, 'Hydrogenase')+
|
4198
|
-
#
|
4199
|
-
# =================================================================== #
|
4200
|
-
if option_hash.is_a? String
|
4201
|
-
option_hash = { content: option_hash }
|
4202
|
-
end
|
4203
|
-
end
|
4204
|
-
end
|
4205
|
-
# ======================================================================= #
|
4206
|
-
# === Handle local entries for the "/home/x" directory layout.
|
4207
|
-
# ======================================================================= #
|
4208
|
-
if i.start_with? '/home/x'
|
4209
|
-
i = i.dup
|
4210
|
-
i.sub!(/\/home\/x\//, relative_path?)
|
4211
|
-
end
|
4212
|
-
i = rds(i.to_s.dup)
|
4213
|
-
# ======================================================================= #
|
4214
|
-
# Delegate onto HtmlTags.a().
|
4215
|
-
# ======================================================================= #
|
4216
|
-
return HtmlTags.a(
|
4217
|
-
i, option_hash
|
4218
|
-
)
|
4219
|
-
end; alias string_a string_link # === string_a
|
4220
|
-
alias string_remote_link string_link # === string_remote_link
|
4221
|
-
alias slink string_link # === slink
|
4222
|
-
|
4223
8054
|
# ========================================================================= #
|
4224
8055
|
# === set_font_size
|
4225
8056
|
#
|
@@ -4678,7 +8509,7 @@ function simple_clock_timer() {
|
|
4678
8509
|
# The following is experimental as of April 2011.
|
4679
8510
|
# In June 2014 it was moved into the <head> tag.
|
4680
8511
|
# ===================================================================== #
|
4681
|
-
append
|
8512
|
+
append(return_default_javascript)
|
4682
8513
|
# ===================================================================== #
|
4683
8514
|
# === Use Jquery
|
4684
8515
|
#
|