cyberweb 0.7.9 → 0.8.17

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

Potentially problematic release.


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

Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +242 -141
  3. data/cyberweb.gemspec +6 -6
  4. data/doc/README.gen +242 -142
  5. data/doc/todo/todo_for_the_cyberweb_project.md +13 -0
  6. data/examples/advanced/animated_colourful_border/animated_colourful_border.cgi +149 -0
  7. data/examples/advanced/no_right_click.cgi +1 -2
  8. data/examples/css/changing_border_colours_animation/changing_border_colours_animation.html +134 -0
  9. data/examples/css/editable_boxes_example/editable_boxes_example.html +75 -0
  10. data/examples/css/flexbox_example/flexbox_example.html +39 -0
  11. data/examples/css/keyboard_example/keyboard_example.html +238 -0
  12. data/examples/css/magic_card/magic_card.html +110 -0
  13. data/examples/css/overflow_example/overflow_example.html +125 -0
  14. data/examples/css/planet_example/planet_example.html +34 -0
  15. data/examples/css/progress_bar_examples/progress_bar_examples.html +316 -0
  16. data/examples/css/single_row_glow/single_row_glow.html +91 -0
  17. data/examples/css/slinky_animation/slinky_animation.html +292 -0
  18. data/examples/html/hbox_and_vbox_example.html +5 -5
  19. data/examples/javascript_and_jquery/all_in_one_example/all_in_one_example.cgi +38 -0
  20. data/lib/cyberweb/base/misc.rb +63 -25
  21. data/lib/cyberweb/cascading_style_sheets/border.css +61 -24
  22. data/lib/cyberweb/cascading_style_sheets/colours.css +2 -0
  23. data/lib/cyberweb/cascading_style_sheets/default.css +102 -89
  24. data/lib/cyberweb/cascading_style_sheets/glow_effects.css +36 -0
  25. data/lib/cyberweb/cascading_style_sheets/margin.css +11 -7
  26. data/lib/cyberweb/cascading_style_sheets/misc.css +7 -0
  27. data/lib/cyberweb/cascading_style_sheets/text_shadow.css +6 -1
  28. data/lib/cyberweb/generator/cgi.rb +9 -1
  29. data/lib/cyberweb/html_template/html_template.rb +7 -2
  30. data/lib/cyberweb/javascript_code/custom_functions.js +33 -2
  31. data/lib/cyberweb/javascript_code/math.js +0 -0
  32. data/lib/cyberweb/objectified/html_tags/progress.rb +8 -8
  33. data/lib/cyberweb/skeleton/README.md +2 -0
  34. data/lib/cyberweb/skeleton/html_keyboard.md +140 -0
  35. data/lib/cyberweb/toplevel_methods/is_an_image.rb +18 -0
  36. data/lib/cyberweb/toplevel_methods/listing.rb +2 -3
  37. data/lib/cyberweb/toplevel_methods/misc.rb +1 -57
  38. data/lib/cyberweb/toplevel_methods/registered_ids.rb +53 -37
  39. data/lib/cyberweb/toplevel_methods/sort_this_array_by_time.rb +65 -0
  40. data/lib/cyberweb/toplevel_methods/video.rb +32 -19
  41. data/lib/cyberweb/utility_scripts/images_to_html/images_to_html.rb +78 -49
  42. data/lib/cyberweb/utility_scripts/remove_this_image_from_that_webpage.rb +125 -0
  43. data/lib/cyberweb/version/version.rb +2 -2
  44. data/lib/cyberweb/web_images/map_symbol_to_image_location.rb +28 -8
  45. data/lib/cyberweb/web_object/effects.rb +19 -0
  46. data/lib/cyberweb/web_object/html_tags.rb +199 -196
  47. data/lib/cyberweb/web_object/images.rb +83 -26
  48. data/lib/cyberweb/web_object/misc.rb +1048 -529
  49. data/lib/cyberweb/web_object/reset.rb +47 -29
  50. data/lib/cyberweb/yaml/custom_tags.yml +2 -0
  51. metadata +52 -52
@@ -61,6 +61,7 @@ module Cyberweb
61
61
  require 'cyberweb/toplevel_methods/s2.rb'
62
62
  require 'cyberweb/toplevel_methods/write_what_into.rb'
63
63
  require 'cyberweb/html_tags/option.rb'
64
+ require 'cyberweb/toplevel_methods/is_an_image.rb'
64
65
 
65
66
  # ========================================================================= #
66
67
  # === Cyberweb.return_all_images_from_this_webpage
@@ -334,56 +335,6 @@ module Cyberweb
334
335
  return `magick #{this_image} #{file_type}:- | base64`
335
336
  end
336
337
 
337
- # ========================================================================= #
338
- # === Cyberweb.sort_this_array_by_time
339
- #
340
- # This method can be used to sort an array by time. In particular it
341
- # was designed to sort an array of image-files that include their
342
- # "timestamp" as part of the filename.
343
- # ========================================================================= #
344
- def self.sort_this_array_by_time(array)
345
- array.sort_by {|filename|
346
- filename = File.basename(filename)
347
- if filename =~ /\d{4}/ # Assume a year such as "1984" here.
348
- # ================================================================= #
349
- # Extract from the start to the year-part next.
350
- #
351
- # An example for a filename will be:
352
- #
353
- # "2013_Marchettigasse_6_Garten_am_Abend.jpg".
354
- #
355
- # ================================================================= #
356
- filename = filename.scan(/^.*\d{4}/).flatten.first
357
- filename.tr!('_','.')
358
- filename = filename.delete('^0-9.')
359
- filename.squeeze!('.') # Some entries may now be "...1986".
360
- filename.chop! if filename.end_with? '.'
361
- if filename.start_with?('.')
362
- if filename.count('.') > 1 # Assume here: ".2.1981"
363
- filename.prepend('01') if filename.count('.') == 2
364
- else
365
- filename.prepend('01.01')
366
- end
367
- end
368
- unless filename.include? '.'
369
- unless filename.start_with?('.')
370
- filename.prepend('.')
371
- end
372
- filename.prepend('01.01')
373
- end
374
- if filename.split('.')[1].to_i > 12
375
- splitted = filename.split('.')
376
- splitted[1] = '12'
377
- filename = splitted.join('.')
378
- end
379
- sort_on_this = ::Time.parse(filename)
380
- else
381
- sort_on_this = ::Time.parse('01.01.1970') # Simply assume this here.
382
- end
383
- sort_on_this
384
- }
385
- end; self.instance_eval { alias sort_based_on_time sort_this_array_by_time } # === Cyberweb.sort_based_on_time
386
-
387
338
  # ========================================================================= #
388
339
  # === Cyberweb.return_all_html_tags_in_this_line
389
340
  # ========================================================================= #
@@ -1852,13 +1803,6 @@ and <b>newlines</b>.</p>
1852
1803
  return result
1853
1804
  end
1854
1805
 
1855
- # ========================================================================= #
1856
- # === Cyberweb.is_an_image_file?
1857
- # ========================================================================= #
1858
- def self.is_an_image_file?(i)
1859
- ARRAY_IMAGES.include?(File.extname(i).delete('.'))
1860
- end; self.instance_eval { alias is_an_image? is_an_image_file? } # === Cyberweb.is_an_image?
1861
-
1862
1806
  # ========================================================================= #
1863
1807
  # === Cyberweb.sanitize_this_string_by_adding_a_newline_after_every_closing_HTML_tag
1864
1808
  #
@@ -24,6 +24,59 @@ module Cyberweb
24
24
  end; self.instance_eval { alias array_registered_ids all_ids? } # === Cyberweb.array_registered_ids
25
25
  self.instance_eval { alias array_registered_ids? all_ids? } # === Cyberweb.array_registered_ids?
26
26
 
27
+ # ========================================================================= #
28
+ # === Cyberweb.sanitize_this_id
29
+ # ========================================================================= #
30
+ def self.sanitize_this_id(i)
31
+ return i.to_s.dup.downcase.
32
+ delete(':(),'). # We reject these characters.
33
+ tr(' ','_').
34
+ tr('-','_').
35
+ tr('.','_'). # This line was inherited from the old code in class Cyberweb::ImagesToHtml.
36
+ squeeze('_') # Multiple '_' are not so pretty.
37
+ end
38
+
39
+ require 'cyberweb/toplevel_methods/umlaute.rb'
40
+ # ========================================================================= #
41
+ # === Cyberweb.sanitize_id
42
+ #
43
+ # Use this method when you want to sanitize the given id.
44
+ #
45
+ # We will generate a valid HTML id through this method.
46
+ #
47
+ # Note that this is different to the method Cyberweb.sanitize_this_id().
48
+ # In the long run we may unify these two methods, but for now (2023)
49
+ # they are separate.
50
+ #
51
+ # Usage example:
52
+ #
53
+ # Cyberweb.sanitize_id(' hey there')
54
+ #
55
+ # ========================================================================= #
56
+ def self.sanitize_id(i)
57
+ i = convert_back_german_umlauts(i)
58
+ # ======================================================================= #
59
+ # If we have two '#' tokens, check here:
60
+ # ======================================================================= #
61
+ if i.count('#') > 1 # Example: 'drag_#NAME#'
62
+ if i.include? '#NAME#'
63
+ filename = ::Cyberweb.filename?
64
+ new_name = File.basename(filename, File.extname(filename)).downcase
65
+ i = i.gsub(/#NAME#/, new_name)
66
+ end
67
+ end
68
+ i.strip! # Get rid of leading and trailing ' ' tokens.
69
+ i.gsub!(/ /,'_') if i.include? ' '
70
+ case i
71
+ when 'DEF' # Overrule.
72
+ filename = $0
73
+ filename = ensure_main_encoding(filename)
74
+ i = File.basename(filename).downcase.gsub(/\..*$/,'')
75
+ end
76
+ i = no_html(i) if i.include? '>' # We assume a HTML tag here.
77
+ return i
78
+ end
79
+
27
80
  # ========================================================================= #
28
81
  # === return_the_id
29
82
  # ========================================================================= #
@@ -131,43 +184,6 @@ module Cyberweb
131
184
  ee return_the_id(the_id)
132
185
  end
133
186
 
134
- require 'cyberweb/toplevel_methods/umlaute.rb'
135
- # ========================================================================= #
136
- # === Cyberweb.sanitize_id
137
- #
138
- # Use this method when you want to sanitize the given id.
139
- #
140
- # We will generate a valid HTML id through this method.
141
- #
142
- # Usage example:
143
- #
144
- # Cyberweb.sanitize_id(' hey there')
145
- #
146
- # ========================================================================= #
147
- def self.sanitize_id(i)
148
- i = convert_back_german_umlauts(i)
149
- # ======================================================================= #
150
- # If we have two '#' tokens, check here:
151
- # ======================================================================= #
152
- if i.count('#') > 1 # Example: 'drag_#NAME#'
153
- if i.include? '#NAME#'
154
- filename = ::Cyberweb.filename?
155
- new_name = File.basename(filename, File.extname(filename)).downcase
156
- i = i.gsub(/#NAME#/, new_name)
157
- end
158
- end
159
- i.strip! # Get rid of leading and trailing ' ' tokens.
160
- i.gsub!(/ /,'_') if i.include? ' '
161
- case i
162
- when 'DEF' # Overrule.
163
- filename = $0
164
- filename = ensure_main_encoding(filename)
165
- i = File.basename(filename).downcase.gsub(/\..*$/,'')
166
- end
167
- i = no_html(i) if i.include? '>' # We assume a HTML tag here.
168
- return i
169
- end
170
-
171
187
  # ========================================================================= #
172
188
  # === sanitize_id
173
189
  # ========================================================================= #
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'cyberweb/toplevel_methods/sort_this_array_by_time.rb'
6
+ # =========================================================================== #
7
+ module Cyberweb
8
+
9
+ # ========================================================================= #
10
+ # === Cyberweb.sort_this_array_by_time
11
+ #
12
+ # This method can be used to sort an array by time. In particular it
13
+ # was designed to sort an array of image-files that include their
14
+ # "timestamp" as part of the filename.
15
+ # ========================================================================= #
16
+ def self.sort_this_array_by_time(array)
17
+ require 'time'
18
+ array.sort_by {|filename|
19
+ filename = File.basename(filename)
20
+ if filename =~ /\d{4}/ # Assume a year such as "1984" here.
21
+ # ================================================================= #
22
+ # Extract from the start to the year-part next.
23
+ #
24
+ # Examples for a filename may be:
25
+ #
26
+ # "2013_Marchettigasse_6_Garten_am_Abend.jpg".
27
+ # "41586_2012_BFnature10999_MOESM258_ESM-9391"
28
+ #
29
+ # ================================================================= #
30
+ filename = filename.scan(/^.*\d{4}/).flatten.first
31
+ filename.tr!('_','.')
32
+ filename = filename.delete('^0-9.')
33
+ filename.squeeze!('.') # Some entries may now be "...1986".
34
+ filename.chop! if filename.end_with? '.'
35
+ if filename.start_with?('.')
36
+ if filename.count('.') > 1 # Assume here: ".2.1981"
37
+ filename.prepend('01') if filename.count('.') == 2
38
+ else
39
+ filename.prepend('01.01')
40
+ end
41
+ end
42
+ unless filename.include? '.'
43
+ unless filename.start_with?('.')
44
+ filename.prepend('.')
45
+ end
46
+ filename.prepend('01.01')
47
+ end
48
+ if filename.split('.')[1].to_i > 12
49
+ splitted = filename.split('.')
50
+ splitted[1] = '12'
51
+ filename = splitted.join('.')
52
+ end
53
+ begin
54
+ sort_on_this = ::Time.parse(filename)
55
+ rescue
56
+ sort_on_this = ::Time.parse('01.01.1970')
57
+ end
58
+ else
59
+ sort_on_this = ::Time.parse('01.01.1970') # Simply assume this here.
60
+ end
61
+ sort_on_this
62
+ }
63
+ end; self.instance_eval { alias sort_based_on_time sort_this_array_by_time } # === Cyberweb.sort_based_on_time
64
+
65
+ end
@@ -15,21 +15,6 @@ module Cyberweb
15
15
  DEFAULT_VIDEO_WIDTH = '380'
16
16
  DEFAULT_VIDEO_HEIGHT = '260'
17
17
 
18
- # ========================================================================= #
19
- # === imdb (imdb tag)
20
- #
21
- # Makes a link towards the "Internet Movie Database".
22
- # ========================================================================= #
23
- def imdb(
24
- title, where_precisely
25
- )
26
- base_url = 'http://www.imdb.com/title/'
27
- string_link(
28
- base_url+where_precisely,
29
- title
30
- )
31
- end
32
-
33
18
  # ========================================================================= #
34
19
  # === Cyberweb.embed_youtube_video (youtube tag)
35
20
  #
@@ -54,12 +39,25 @@ module Cyberweb
54
39
  begin
55
40
  require 'multimedia_paradise/videos/youtube_embedder.rb'
56
41
  rescue LoadError; end
57
- _ = ''.dup
42
+ _ = ''.dup # Our String that will be returned.
43
+ use_this_css_class = ''.dup
58
44
  src = src.strip if src.is_a? String # We have no use for leading and trailing ' '.
45
+ # ======================================================================= #
46
+ # === Handle the case where width is a Hash next:
47
+ # ======================================================================= #
48
+ if width.is_a? Hash
49
+ # ===================================================================== #
50
+ # === :css_class
51
+ # ===================================================================== #
52
+ if width.has_key? :css_class
53
+ use_this_css_class << " #{width[:css_class]}"
54
+ end
55
+ end
56
+ # embed_youtube_video 'https://www.youtube.com/watch?v=sAeMTsvGmoQ',
59
57
  if src.is_a? Array
60
- src.each {|s| div { embed_youtube_video(s, width, height) } }
58
+ src.each {|entry| div { embed_youtube_video(entry, width, height) } }
61
59
  elsif src.include? ' '
62
- src.split(' ').each {|s| div { embed_youtube_video(s) } }
60
+ src.split(' ').each {|entry| div { embed_youtube_video(entry) } }
63
61
  else
64
62
  # ===================================================================== #
65
63
  # Prepend proper youtube link:
@@ -70,7 +68,7 @@ module Cyberweb
70
68
  if src.include? 'watch'
71
69
  src.gsub!(/watch\?v\=/, 'v/')
72
70
  end
73
- _ << '<object class="pad1em mar2em">'+N
71
+ _ << '<object class="'+use_this_css_class+'">'+N
74
72
  _ << '<param name="movie" value="'+src+'" />'+N
75
73
  _ << '<param name="wmode" value="transparent" />'+N
76
74
  _ << '<param name="allowFullScreen" value="true" />'+N # Allow fullscreen.
@@ -348,4 +346,19 @@ module Cyberweb
348
346
  ee _
349
347
  end
350
348
 
349
+ # ========================================================================= #
350
+ # === imdb (imdb tag)
351
+ #
352
+ # Makes a link towards the "Internet Movie Database".
353
+ # ========================================================================= #
354
+ def imdb(
355
+ title, where_precisely
356
+ )
357
+ base_url = 'http://www.imdb.com/title/'
358
+ string_link(
359
+ base_url+where_precisely,
360
+ title
361
+ )
362
+ end
363
+
351
364
  end
@@ -96,6 +96,11 @@ class ImagesToHtml < ::Cyberweb::Base # === Cyberweb::ImagesToHtml
96
96
  padding-left: 5px;'.
97
97
  delete("\n").squeeze(' ')
98
98
 
99
+ # ========================================================================= #
100
+ # === FONT_SIZE_TO_USE
101
+ # ========================================================================= #
102
+ FONT_SIZE_TO_USE = '1.3em'
103
+
99
104
  # ========================================================================= #
100
105
  # === initialize
101
106
  #
@@ -185,7 +190,7 @@ class ImagesToHtml < ::Cyberweb::Base # === Cyberweb::ImagesToHtml
185
190
  # === @body_css_style
186
191
  # ======================================================================= #
187
192
  @body_css_style = '
188
- background-color: black; color: white; font-size: 1.2em;'
193
+ background-color: black; color: white; font-size: '+FONT_SIZE_TO_USE+';'
189
194
  # ======================================================================= #
190
195
  # === @debug
191
196
  # ======================================================================= #
@@ -255,39 +260,6 @@ class ImagesToHtml < ::Cyberweb::Base # === Cyberweb::ImagesToHtml
255
260
  @show_the_name_of_the_image_file
256
261
  end
257
262
 
258
- # ========================================================================= #
259
- # === return_image
260
- #
261
- # Use this when you wish to append an image.
262
- # ========================================================================= #
263
- def return_image(i)
264
- result = ''.dup
265
- i = rds(i)
266
- if show_the_name_of_the_image_file? and !use_html_table?
267
- result <<
268
- '<h2 style="color:orange; font-style: italic; padding: 5px">'+i+'</h2>'+NBR
269
- end
270
- new_filename = File.basename(i).gsub(/#{File.extname(i)}/, '')
271
- id = 'drag_'+new_filename.downcase.tr(' ','').tr('.','_')
272
- # ======================================================================= #
273
- # Store these IDs in the global Array as well:
274
- # ======================================================================= #
275
- @internal_hash[:registered_ids] << id
276
- result << '<img id="'+id+'" style="'+IMG_CSS_STYLE+'" src="'+i+'"'.dup
277
- if use_HTML_table?
278
- result << ' width="440"'
279
- end
280
- result << '>'+NBR
281
- if use_jquery?
282
- result << '<script>
283
- $(function() {
284
- $( "#'+id+'" ).draggable();
285
- });
286
- </script>'
287
- end
288
- return result
289
- end
290
-
291
263
  # ========================================================================= #
292
264
  # === clear_images
293
265
  # ========================================================================= #
@@ -744,15 +716,6 @@ class ImagesToHtml < ::Cyberweb::Base # === Cyberweb::ImagesToHtml
744
716
  end
745
717
  end
746
718
 
747
- # ========================================================================= #
748
- # === run
749
- # ========================================================================= #
750
- def run
751
- menu
752
- debug if @debug
753
- the_three_main_actions
754
- end
755
-
756
719
  # ========================================================================= #
757
720
  # === show_help (help tag)
758
721
  #
@@ -771,6 +734,45 @@ class ImagesToHtml < ::Cyberweb::Base # === Cyberweb::ImagesToHtml
771
734
  e
772
735
  end
773
736
 
737
+ # ========================================================================= #
738
+ # === return_image
739
+ #
740
+ # Use this when you wish to append an image.
741
+ #
742
+ # This method will also have to create a proper ID for the image at
743
+ # hand, one that makes sense. On 25.01.2023 this was changed with
744
+ # a generic method first defined originally in Cyberweb::WebObject
745
+ # some time before that day.
746
+ # ========================================================================= #
747
+ def return_image(i)
748
+ result = ''.dup
749
+ i = rds(i)
750
+ if show_the_name_of_the_image_file? and !use_html_table?
751
+ result <<
752
+ '<h2 style="color:orange; font-style: italic; padding: 5px">'+i+'</h2>'+NBR
753
+ end
754
+ new_filename = File.basename(i).gsub(/#{File.extname(i)}/, '')
755
+ id = 'drag_'+
756
+ Cyberweb.sanitize_this_id(new_filename)
757
+ # ======================================================================= #
758
+ # Store these IDs in the global Array as well:
759
+ # ======================================================================= #
760
+ @internal_hash[:registered_ids] << id
761
+ result << '<img id="'+id+'" style="'+IMG_CSS_STYLE+'" src="'+i+'"'.dup
762
+ if use_HTML_table?
763
+ result << ' width="440"'
764
+ end
765
+ result << '>'+NBR
766
+ if use_jquery?
767
+ result << '<script>
768
+ $(function() {
769
+ $( "#'+id+'" ).draggable();
770
+ });
771
+ </script>'
772
+ end
773
+ return result
774
+ end
775
+
774
776
  # ========================================================================= #
775
777
  # === build_up_the_HTML_string
776
778
  #
@@ -794,7 +796,18 @@ class ImagesToHtml < ::Cyberweb::Base # === Cyberweb::ImagesToHtml
794
796
  # this situation for us.
795
797
  # ======================================================================= #
796
798
  unless array.empty?
799
+ working_directory = return_pwd
797
800
  array.each_with_index {|this_entry, index|
801
+ original_this_entry = this_entry.dup
802
+ # =================================================================== #
803
+ # entry will refer to a String such as:
804
+ #
805
+ # "/home/x/data/images/fotos/cats_and_dogs/aisha/01.01.2013_Aisha_schläft_im_Bett.jpg"
806
+ #
807
+ # =================================================================== #
808
+ # =================================================================== #
809
+ # This clause is only valid if we work on video-related multimedia.
810
+ # =================================================================== #
798
811
  if work_on_video_files_only?
799
812
  _ << '<div style="color: lightgreen">'
800
813
  _ << HtmlTags.h2(this_entry, 'lightgreen')
@@ -802,13 +815,19 @@ class ImagesToHtml < ::Cyberweb::Base # === Cyberweb::ImagesToHtml
802
815
  _ << "<br>\n"
803
816
  _ << "</div>\n"
804
817
  else
818
+ # ================================================================= #
819
+ # This clause will be entered if we use a HTML table layout.
820
+ # ================================================================= #
805
821
  if use_HTML_table_layout?
806
822
  filesize_string = ' <span style="color: lightblue">'+
807
823
  '(<b>filesize</b>: <b>'+
808
824
  (File.size(this_entry).to_f / 1000.0).floor(0).to_s+
809
825
  '</b> <b>kb</b>)'+
810
826
  '</span>'
811
-
827
+ # =============================================================== #
828
+ # Determine the raw description for the image, based on the
829
+ # filename itself.
830
+ # =============================================================== #
812
831
  raw_description_of_the_image = File.basename(this_entry).
813
832
  delete_suffix(File.extname(this_entry)).
814
833
  tr('_',' ')
@@ -821,19 +840,20 @@ class ImagesToHtml < ::Cyberweb::Base # === Cyberweb::ImagesToHtml
821
840
  '(<b>\1</b>)'
822
841
  )+'</span>'
823
842
  this_entry = File.basename(this_entry) # We try this line as of October 2022.
843
+ use_this_for_the_href_entry = original_this_entry.sub(/#{working_directory}/,'')
824
844
  case index % n_rows?
825
845
  when 0 # This would mean we should do a new row.
826
846
  _ << "<tr style=\"width:25%;\"><td style=\"width:28%\">"
827
- _ << "<a target=\"_blank\" href=\"#{this_entry}\">#{return_image(this_entry)}#{description_of_the_image}"
847
+ _ << "<a target=\"_blank\" href=\"#{use_this_for_the_href_entry}\">#{return_image(use_this_for_the_href_entry)}#{description_of_the_image}"
828
848
  _ << "</a>#{filesize_string}</td>\n"
829
849
  when (n_rows? - 3),
830
850
  (n_rows? - 2)
831
- _ << "<td style=\"width:28%\">"
832
- _ << "<a target=\"_blank\" href=\"#{this_entry}\">#{return_image(this_entry)}#{description_of_the_image}"
851
+ _ << "<td style=\"width: 28%\">"
852
+ _ << "<a target=\"_blank\" href=\"#{use_this_for_the_href_entry}\">#{return_image(use_this_for_the_href_entry)}#{description_of_the_image}"
833
853
  _ << "</a>#{filesize_string}</td>\n"
834
854
  when (n_rows? - 1)
835
- _ << "<td style=\"width:28%\">"
836
- _ << "<a target=\"_blank\" href=\"#{this_entry}\">#{return_image(this_entry)}#{description_of_the_image}"
855
+ _ << "<td style=\"width: 28%\">"
856
+ _ << "<a target=\"_blank\" href=\"#{use_this_for_the_href_entry}\">#{return_image(use_this_for_the_href_entry)}#{description_of_the_image}"
837
857
  _ << "</a>#{filesize_string}</td></tr>\n"
838
858
  end
839
859
  else
@@ -845,6 +865,15 @@ class ImagesToHtml < ::Cyberweb::Base # === Cyberweb::ImagesToHtml
845
865
  set_content_of_the_html_page(_)
846
866
  end
847
867
 
868
+ # ========================================================================= #
869
+ # === run
870
+ # ========================================================================= #
871
+ def run
872
+ menu
873
+ debug if @debug
874
+ the_three_main_actions
875
+ end
876
+
848
877
  end
849
878
 
850
879
  # =========================================================================== #
@@ -0,0 +1,125 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === Cyberweb::RemoveThisImageFromThatWebpage
6
+ #
7
+ # This class will remove a specific image from a webpage, typically a
8
+ # target .html file.
9
+ #
10
+ # So if you have something like "foobar.png", all <img> tags that have
11
+ # this image will be removed. A backup will be created of that .html
12
+ # file before modifications are made.
13
+ #
14
+ # Usage example:
15
+ #
16
+ # RemoveThisImageFromThatWebpage.new(ARGV)
17
+ #
18
+ # =========================================================================== #
19
+ # require 'remove_this_image_from_that_webpage.rb'
20
+ # =========================================================================== #
21
+ require 'cyberweb/base/base.rb'
22
+
23
+ module Cyberweb
24
+
25
+ class RemoveThisImageFromThatWebpage < Base # === Cyberweb::RemoveThisImageFromThatWebpage
26
+
27
+ # ========================================================================= #
28
+ # === initialize
29
+ # ========================================================================= #
30
+ def initialize(
31
+ this_image = nil,
32
+ that_webpage = nil,
33
+ run_already = true
34
+ )
35
+ reset
36
+ @this_image = this_image
37
+ pp that_webpage
38
+ @that_webpage = [that_webpage].flatten.compact
39
+ run if run_already
40
+ end
41
+
42
+ # ========================================================================= #
43
+ # === reset (reset tag)
44
+ # ========================================================================= #
45
+ def reset
46
+ super()
47
+ infer_the_namespace
48
+ # ======================================================================= #
49
+ # === @this_image
50
+ # ======================================================================= #
51
+ @this_image = nil
52
+ # ======================================================================= #
53
+ # === @that_webpage
54
+ # ======================================================================= #
55
+ @that_webpage = []
56
+ end
57
+
58
+ # ========================================================================= #
59
+ # === run (run tag)
60
+ # ========================================================================= #
61
+ def run
62
+ if @that_webpage.empty?
63
+ e 'Please supply two arguments to this class:'
64
+ e
65
+ e ' (1) the image that you wish to remove from the .html file'
66
+ e ' (2) the local file you want to work on'
67
+ e
68
+ exit
69
+ end
70
+ @that_webpage.each {|this_webpage|
71
+ if this_webpage and File.exist?(this_webpage)
72
+ puts ::Colours.rev+'Now working on the file '+
73
+ sfile(this_webpage)+':'
74
+ dataset = File.read(this_webpage)
75
+ if dataset.include?(@this_image) and dataset.include?('<img')
76
+ # Ok in this case we can modify the file as-is.
77
+ puts rev+'Yes, the dataset contains the image '+
78
+ ::Colours.steelblue(@this_image)+rev+'.'
79
+ dataset = dataset.dup if dataset.frozen?
80
+ new_dataset = ''.dup
81
+ # ================================================================= #
82
+ # See: https://rubular.com/r/VsIipzUOSCDhA7
83
+ # ================================================================= #
84
+ # regex = /(<img.+src=".+" \/>)/
85
+ regex = /(<img.+src="#{@this_image}" \/>)/
86
+ dataset.split("\n").each {|line|
87
+ if line.include?('<img') and line.include?(@this_image)
88
+ line.gsub!(regex, '')
89
+ end
90
+ new_dataset << "#{line}\n"
91
+ }
92
+ backup_this_file(this_webpage)
93
+ write_what_into(new_dataset, this_webpage)
94
+ else
95
+ puts "No entry called #{::Colours.steelblue(@this_image)} "\
96
+ "was found."
97
+ end
98
+ else
99
+ opnn; no_file_exists_at(this_webpage)
100
+ end
101
+ }
102
+ end
103
+
104
+ # ========================================================================= #
105
+ # === backup_this_file
106
+ # ========================================================================= #
107
+ def backup_this_file(i)
108
+ target = log_dir?+File.basename(i)
109
+ puts 'Making a backup of the file '+sfile(i)+'. It will be copied'
110
+ puts 'towards '+target+'.'
111
+ copy_file(i, target)
112
+ end
113
+
114
+ # ========================================================================= #
115
+ # === Cyberweb::RemoveThisImageFromThatWebpage[]
116
+ # ========================================================================= #
117
+ def self.[](i = ARGV)
118
+ new(i)
119
+ end
120
+
121
+ end; end
122
+
123
+ if __FILE__ == $PROGRAM_NAME
124
+ Cyberweb::RemoveThisImageFromThatWebpage.new(ARGV[0], ARGV[1 .. -1])
125
+ end # removethisimagefromthatwebpage brdrtpr.png *.htm
@@ -9,12 +9,12 @@ module Cyberweb
9
9
  # ========================================================================= #
10
10
  # === VERSION
11
11
  # ========================================================================= #
12
- VERSION = '0.7.9'
12
+ VERSION = '0.8.17'
13
13
 
14
14
  # ========================================================================= #
15
15
  # === LAST_UPDATE
16
16
  # ========================================================================= #
17
- LAST_UPDATE = '28.11.2022'
17
+ LAST_UPDATE = '26.01.2023'
18
18
 
19
19
  # ========================================================================= #
20
20
  # === URL_TO_THE_DOCUMENTATION