Class: Cyberweb::ObtainFilesAndDirectoriesFromThisPath

Inherits:
Base
  • Object
show all
Includes:
HtmlTags
Defined in:
lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb

Overview

Cyberweb::ObtainFilesAndDirectoriesFromThisPath

Direct Known Subclasses

HtmlToHtml, ImagesToHtml, PdfToHtml, VideoToHtml

Constant Summary collapse

FONT_SIZE_TO_USE =
#

FONT_SIZE_TO_USE

#
'1.3em'
SHALL_WE_DEBUG =
#

SHALL_WE_DEBUG

Whether we debug this class or not.

#
false
ARRAY_IMAGES =
#

ARRAY_IMAGES

All valid image-formats should be denoted into this Array.

#
::Cyberweb::ARRAY_IMAGES
INFO_DIRECTORY =
#

INFO_DIRECTORY

This is the base directory where to store, unless we use Dir.pwd.

#
'/Depot/Information/'
HTML =
#

HTML

#
'.html'
BE_VERBOSE =
#

BE_VERBOSE

#
true
THESE_CSS_CLASSES_ARE_KNOWN_TO_THE_RENDERED_TEMPLATE =
#

THESE_CSS_CLASSES_ARE_KNOWN_TO_THE_RENDERED_TEMPLATE

#
'pad6px BOLD marl2em pad12px BG_Black '\
'rounded_border rounded_corner marr10px '\
'round_black1 round_black2 round_black3 '+
Cyberweb.array_all_html_colours?.join(' ').rstrip
CSS_STYLE_TO_USE_FOR_THE_TOP_HEADER =
#

CSS_STYLE_TO_USE_FOR_THE_TOP_HEADER

The top-header used to be called rounded_corners in the past.

#
"
#top_header {
  border:         2px solid #73AD21;
  border-radius: 22px;
  padding:       18px; 
  width:        500px;
  height:       140px;
  margin-bottom: 1.5em;
  margin-left:    8%;
  width:         60%;
}

.common_border {
  border:         2px solid #73AD21;
  border-radius: 22px;
}
  
a:hover {
  color: lightgreen;
}
"
'
    a:link,
    a:visited { text-decoration: none; color: gold; }
    a:hover   { text-decoration: none; color: lightblue; }

'
IMG_CSS_STYLE =
#

IMG_CSS_STYLE

Determine the default css-rules for each <img> tag to be used.

#
'border:             1px solid black;
border-radius:      8px;
margin-left:      4.5em;
background-color: black;
padding-left:     6px;'.
delete("\n").squeeze(' ')

Constants inherited from Base

Base::HOME_DIRECTORY_OF_THE_USER_X, Base::NAMESPACE

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#be_verbose, #cascading_style_sheets_directory?, #cd, #commandline_mode?, #copyright?, #css_comment, #delete_directory, #do_toggle, #e, #echo_raw, #filename?, #full_path_to_image_directory?, #html_colours?, #html_image, #htmlentities, #img_dir?, #infer_the_namespace, #initialize_the_configuration, #is_a_file?, #is_a_video_file?, #is_an_image_file?, #is_on_roebe?, #last_tag_used?, #last_tag_used_first_element?, #last_tag_used_id?, #mkdir, #mode?, #namespace?, #open_in_browser, #opne, #opnn, #remove_comments_from_this_string_but_preserve_CSS_rules, #remove_html, #return_all_directories, #return_date, #return_program_name, #return_pwd, #ruby_header?, #server_base_directory?, #set_commandline_mode, #set_last_tag_used, #update_the_image_directory, #use_this_relative_directory_for_custom_images?, #www_mode?

Methods included from BaseModule::FileRelatedFunctionality

#copy_this_file, #cpr, #delete_file, #filename_without_extension?, #read_file_via_utf8_encoding

Methods included from BaseModule

#attach_these_constants, #base_dir?, #beautiful_url, #cd, #create_the_internal_hash, #doctype?, #ee, #ensure_main_encoding, #esystem, #html_templates, #initialize_the_config_if_the_config_hash_is_empty, #internal_hash?, #log_dir?, #no_http, #random_alphabet_characters, #rarrow?, #rds, #remove_comments_from_this_string, #remove_numbers, #require_the_html_templates, #require_these, #return_file_size_in_kb_of, #return_html_comment, #ruby_sitelib_dir?, #sanitize_this_id, #server_base_directory?, #string_remote_image, #today?, #try_to_require_rack, #try_to_require_the_open_gem, #write_what_into

Methods included from BaseModule::ContentType

#content_type_is_html, #content_type_is_jpeg, #content_type_is_json, #content_type_is_plain_text

Methods included from BaseModule::CommandlineArguments

#append_to_the_commandline_arguments, #commandline_arguments?, #first_argument?, #parse_these_commandline_arguments, #second_argument?, #set_commandline_arguments

Methods included from BaseModule::Colours

#all_html_colours, #lightgreen, #rev, #sdir, #sfancy, #sfile, #simp, #steelblue, #tomato

Constructor Details

#initialize(commandline_arguments = ARGV, run_already = true, &block) ⇒ ObtainFilesAndDirectoriesFromThisPath

#

initialize

#


136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 136

def initialize(
    commandline_arguments = ARGV,
    run_already           = true,
    &block
  )
  reset
  # ======================================================================= #
  # The next clause must come before set_commandline_arguments().
  #
  # A usage example for this follows:
  #
  #   Cyberweb::ObtainFilesAndDirectoriesFromThisPath.new(:do_not_run_yet)
  #
  # ======================================================================= #
  case commandline_arguments
  # ======================================================================= #
  # === :do_not_run_yet
  # ======================================================================= #
  when :do_not_run_yet,
       :dont_run_yet
    commandline_arguments = []
    run_already = false
  end
  set_commandline_arguments(
    commandline_arguments
  )
  # ======================================================================= #
  # === Handle blocks next, after having called reset() and determined
  #     the commandline arguments
  # ======================================================================= #
  if block_given?
    case yield
    # ===================================================================== #
    # === :use_jquery
    # ===================================================================== #
    when :use_jquery,
         :jquery
      @internal_hash[:use_jquery] = true
    # ===================================================================== #
    # === :do_not_run_yet
    # ===================================================================== #
    when :do_not_run_yet
      run_already = false
    end
  end
  case run_already
  # ======================================================================= #
  # === :do_not_run_yet
  # ======================================================================= #
  when :do_not_run_yet,
       :dont_run_yet
    run_already = false
  end
  run if run_already
end

Class Method Details

.[](i = ARGV) ⇒ Object

#

Cyberweb::ObtainFilesAndDirectoriesFromThisPath[]

#


1426
1427
1428
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 1426

def self.[](i = ARGV)
  new(i)
end

Instance Method Details

#add(i) ⇒ Object Also known as: _

#

add (add tag)

This method can be used to add (append) onto the main String that stores the content of the webpage as such.

Use this (and only this) method to append onto the main string - or addnl(), which in turn calls add() anyway

Using the alias _ is also permissive, but I recommend using only add() - it makes the code more explicit without it becoming too long, in my opinion.

#


948
949
950
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 948

def add(i)
  @internal_hash[:content_of_the_HTML_page] << i
end

#add_date_in_the_lower_part_of_the_webpage?Boolean

#

add_date_in_the_lower_part_of_the_webpage?

#

Returns:

  • (Boolean)


451
452
453
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 451

def add_date_in_the_lower_part_of_the_webpage?
  @internal_hash[:add_date_in_the_lower_part_of_the_webpage]
end
#
#

Returns:

  • (Boolean)


521
522
523
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 521

def add_hyperlinks_to_subdirectories?
  @internal_hash[:add_hyperlinks_to_subdirectories]
end
#

This method will add the footer, which by default is not used - the user has to provide a commandline argument such as –footer to make use of this feature.

What does the footer contain?

Basically it contains a <div> element, which in turn has various hyperlinks to all subdirectories in the current working directory. It will scan for a random .html page in these subdirectories and return the first match found. (This latter behaviour may be subject to change in the future, pehraps, so do not rely too much on it - we may decide to prioritize some .html pages over others, such as index.html or similar names. But for now, the behaviour is as stated before this addendum.)

Since as of December 2023, no <div> will be appended if it were empty.

#


1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 1278

def add_the_footer_with_hyperlinks(
    filter_for                                       = '.html',
    all_subdirectories                               = :default,
    show_how_many_pdf_files_are_in_that_subdirectory = false
  )
  add_date_in_the_lower_part_of_the_webpage = add_date_in_the_lower_part_of_the_webpage?
  case show_how_many_pdf_files_are_in_that_subdirectory
  # ======================================================================= #
  # === :count_the_pdf_files
  # ======================================================================= #
  when :count_the_pdf_files
    show_how_many_pdf_files_are_in_that_subdirectory = true
  end
  case all_subdirectories
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default
    all_subdirectories = return_all_directories
  end
  all_subdirectories.reject! {|entry|
    File.symlink?(entry) # We don't need symlinks past this point.
  }
  all_files = []
  # ======================================================================= #
  # Work through that Array next, which could look like this:
  #
  #   ["ausland", "baustellen", "sonstige_baustellen", "wien"]
  #
  # We must reject symlinks, though.
  # ======================================================================= #
  all_subdirectories.each {|this_subdirectory|
    this_target = Dir[
      rds(
        this_subdirectory+'/*'+'.'+filter_for.to_s.delete('.')
      )
    ]
    if this_target and this_target.is_a?(Array)
      first = this_target.first
      all_files << first
    end
  }
  if all_files and !all_files.empty?
    _ = ''.dup
    all_files.each {|this_html_file|
      unless this_html_file.nil? or this_html_file.empty?
        # ================================================================= #
        # Delegate towards HtmlTags.a() to add the correct <a> tags next:
        # ================================================================= #
        use_this_description = "#{rarrow} #{this_html_file}"
        if show_how_many_pdf_files_are_in_that_subdirectory
          # =============================================================== #
          # In this event we must obtain how many .pdf files are
          # in that subdirectory.
          # =============================================================== #
          use_this_description = use_this_description.dup if use_this_description.frozen?
          # ================================================================= #
          # Shorten the content if it exceeds a certain threshold:
          # ================================================================= #
          use_this_threshold_value = 80
          if use_this_description.size > use_this_threshold_value
            use_this_description = use_this_description[0 .. use_this_threshold_value]+' [...]'
          end
          n_pdf_files = Dir["#{File.dirname(this_html_file)}/*.pdf"]
          if use_german? # Currently we only do this if this class uses german.
            case n_pdf_files.size # Query how many .pdf files we have.
            when 1
              use_this_description << colour_for_pdf_files(
                ' ('+n_pdf_files.size.to_s+' .pdf Datei)' # Nur eine Datei.
              )
            else
              use_this_description << colour_for_pdf_files(
                ' ('+n_pdf_files.size.to_s+' .pdf Dateien)' # Mehrere Dateien.
              )
            end
          end
          # =============================================================== #
          # Next, add the date-range, if this is enabled through the commandline.
          # =============================================================== #
          if add_date_in_the_lower_part_of_the_webpage
            # ============================================================= #
            # Next we must get the starting_year and the ending_year. We
            # can do so by first getting an Array of all files in the
            # subdirectory first.
            # ============================================================= #
            dirname_is = File.dirname(this_html_file)
            files_in_that_directory = Dir["#{dirname_is}/*"].select {|entry|
              is_a_file?(entry)
            }
            array = Cyberweb.return_time_range_based_on_this_array(files_in_that_directory)
            starting_year = array.first.to_s
            ending_year   = array.last.to_s
            years_description = ''.dup
            if (ending_year.to_i > starting_year.to_i) or # Then we have two entries.
               (starting_year.to_i > ending_year.to_i) 
              years_description = ' (years: '+starting_year+' - '+ending_year+')'
              years_description = ' (Jahre: '+starting_year+' - '+ending_year+')' if use_german?
            else # else we have only one year.
              years_description = ' (year: '+starting_year+')'
              years_description = ' (Jahr: '+starting_year+')' if use_german?
            end
            use_this_description << olivedrab(
              years_description
            )
          end
        end
        # ================================================================= #
        # Next add the href tag:
        # ================================================================= #
        _ << HtmlTags.a(
               this_html_file,
               css_class:   'marl1_5em BOLD',
               description: use_this_description
             )
        _ << "<br>\n"
      end
    }
  end
  unless _.nil? or _.empty?
    # ===================================================================== #
    # Build the <div> tag next:
    # ===================================================================== #
    div_tag_to_use = HtmlTags.div(
        _, 'common_border',
           'div_footer_id', # The id.
           'border:        4px dotted lightgreen;
            border-radius: 18px;
            margin:        1.6em;
            padding:       15px;
            font-size:     1.1em;
           '
      )
    addnl(div_tag_to_use)
  end
end

#addnl(i) ⇒ Object

#

addnl

#


837
838
839
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 837

def addnl(i)
  add("#{i}\n")
end

#append(i) ⇒ Object

#

append (append tag)

#


991
992
993
994
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 991

def append(i)
  @internal_hash[:files] << i
  @internal_hash[:files].flatten!
end

#append_to_local_css_style(i) ⇒ Object

#

append_to_local_css_style

#


368
369
370
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 368

def append_to_local_css_style(i)
  @internal_hash[:use_this_local_css_style] << i
end

#be_verbose?Boolean

#

be_verbose?

#

Returns:

  • (Boolean)


999
1000
1001
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 999

def be_verbose?
  @internal_hash[:be_verbose]
end

#body_css_style?Boolean

#

body_css_style?

#

Returns:

  • (Boolean)


1185
1186
1187
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 1185

def body_css_style?
  @internal_hash[:body_css_style]
end

#check_whether_at_the_least_one_argument_was_given_and_then_act_accordinglyObject

#

check_whether_at_the_least_one_argument_was_given_and_then_act_accordingly

#


1220
1221
1222
1223
1224
1225
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 1220

def check_whether_at_the_least_one_argument_was_given_and_then_act_accordingly
  _ = first_argument?
  if _ and File.directory?(_)
    do_process_all_entries_from_this_directory(_)
  end
end

#clear_directoriesObject

#

clear_directories

#


753
754
755
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 753

def clear_directories
  @internal_hash[:directories].clear
end

#clear_filesObject Also known as: clear_array

#

clear_files

#


746
747
748
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 746

def clear_files
  @internal_hash[:files].clear
end

#colour_for_pdf_files(i) ⇒ Object

#

colour_for_pdf_files

#


1230
1231
1232
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 1230

def colour_for_pdf_files(i)
  mediumorchid(i)
end

#consider_appending_the_jquery_stringObject

#

consider_appending_the_jquery_string

#


375
376
377
378
379
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 375

def consider_appending_the_jquery_string
  if use_jquery?
    addnl(return_jquery)
  end
end

#content_of_the_HTML_page?Boolean Also known as: content_of_the_html_page?, html_content?, html_string?, main_string?

#

content_of_the_HTML_page?

#

Returns:

  • (Boolean)


955
956
957
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 955

def content_of_the_HTML_page?
  @internal_hash[:content_of_the_HTML_page]
end

#directory_containing_all_files?Boolean Also known as: input_directory?, work_on_which_directory?, work_on_this_directory?, which_dir?, main_directory?, dir?

#

directory_containing_all_files?

#

Returns:

  • (Boolean)


535
536
537
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 535

def directory_containing_all_files?
  @internal_hash[:directory_containing_all_files]
end

#display_the_top_header?Boolean

#

display_the_top_header?

#

Returns:

  • (Boolean)


830
831
832
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 830

def display_the_top_header?
  @internal_hash[:display_the_top_header]
end

#do_debugObject Also known as: debug

#

do_debug

#


811
812
813
814
815
816
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 811

def do_debug
  e '='*80
  pp input_directory?
  pp store_where?
  e '='*80
end

#do_include_subdirectoriesObject

#

do_include_subdirectories

#


528
529
530
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 528

def do_include_subdirectories
  @internal_hash[:include_subdirectories] = true
end
#
#


894
895
896
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 894

def do_make_use_of_a_go_down_one_level_link
  @internal_hash[:make_use_of_a_go_down_one_level_link] = true
end

#do_not_include_subdirectoriesObject

#

do_not_include_subdirectories

#


384
385
386
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 384

def do_not_include_subdirectories
  @internal_hash[:include_subdirectories] = false
end

#do_not_use_HTML_table_layoutObject

#

do_not_use_HTML_table_layout

#


1237
1238
1239
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 1237

def do_not_use_HTML_table_layout
  @internal_hash[:use_HTML_table_layout] = false
end

#do_open_the_webpage_if_we_are_on_a_roebe_system(i = save_into_this_local_file? ) ⇒ Object

#

do_open_the_webpage_if_we_are_on_a_roebe_system

#


786
787
788
789
790
791
792
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 786

def do_open_the_webpage_if_we_are_on_a_roebe_system(
    i = save_into_this_local_file?
  )
  if roebe_system?
    open_in_browser(i)
  end
end

#do_process_all_entries_from_this_directory(i = :pwd, &block) ⇒ Object Also known as: do_obtain_all_files

#

do_process_all_entries_from_this_directory

Only invoke this method if there is a file.

#


1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 1083

def do_process_all_entries_from_this_directory(
    i = :pwd,
    &block
  )
  # ======================================================================= #
  # === Handle blocks given to the method next
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :do_include_subdirectories
    # ===================================================================== #
    when :do_include_subdirectories
      do_include_subdirectories
    end
  end
  clear_files
  clear_directories
  set_directory_containing_all_files(i)
  _ = '*'.dup
  _ << '*/**' if include_subdirectories?
  entries = Dir[main_directory?+_]
  # ======================================================================= #
  # === :files
  # ======================================================================= #
  @internal_hash[:files] = entries.select {|entry|
    File.file?(entry)
  }
  # ======================================================================= #
  # === :directories
  # ======================================================================= #
  @internal_hash[:directories] = entries.select {|entry|
    File.directory?(entry)
  }
end

#do_store_the_content(what = content_of_the_HTML_page?, , into = save_into_this_local_file? ) ⇒ Object Also known as: do_create_the_html_page, do_create_the_HTML_page, save_what_to, save_file, append_everything

#

do_store_the_content (save tag)

#


391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 391

def do_store_the_content(
    what = content_of_the_HTML_page?,
    into = save_into_this_local_file?
  )
  # ======================================================================= #
  # Always use the absolute path of the file that keeps track of the
  # stored HTML string.
  # ======================================================================= #
  into = File.absolute_path(into)
  if be_verbose?
    opne "Now saving into the file `#{sfile(into)}#{rev}`."
  end
  if File.exist? into
    opne tomato('Warning: ')+
         sfile(into)+
         tomato(' already exists.')
    opne tomato('We will delete it first.')
    File.delete(into)
  end
  # ======================================================================= #
  # Make the title a bit cleaner next - as well as replace all '_':
  # ======================================================================= #
  raw_title_to_use = File.basename(title?).
                     tr('_',' ').
                     delete_suffix('.html')
  if raw_title_to_use.include?(' ')
    splitted = raw_title_to_use.split(' ')
    first_word = splitted[0]
    first_word[0, 1] = first_word[0, 1].capitalize
    if splitted[1]
      second_word = splitted[1]
      second_word[0, 1] = second_word[0, 1].capitalize
      splitted[1] = second_word
    end
    raw_title_to_use = splitted.join(' ')
  end
  use_this_title = raw_title_to_use
  # ======================================================================= #
  # === Pass information to the HtmlTemplate class next
  #
  # Build the .html file via the HtmlTemplate class next (render tag)
  # ======================================================================= #
  @rendered_template = Cyberweb.rendered_template(
    title:          use_this_title,
    css_style:      @internal_hash[:use_this_local_css_style],
    css_classes:    THESE_CSS_CLASSES_ARE_KNOWN_TO_THE_RENDERED_TEMPLATE,
    body_css_style: body_css_style?.strip, # This will honour the CSS rules.
    body:           what,
    font_size:      :use_the_default_font_size
  )
  write_what_into(@rendered_template.result?, into)
end

#do_traverse_into_subdirectories?Boolean

#

do_traverse_into_subdirectories?

#

Returns:

  • (Boolean)


1213
1214
1215
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 1213

def do_traverse_into_subdirectories?
  @internal_hash[:do_traverse_into_subdirectories]
end

#do_use_HTML_table_layoutObject

#

do_use_HTML_table_layout

#


1244
1245
1246
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 1244

def do_use_HTML_table_layout
  @internal_hash[:use_HTML_table_layout] = true
end

#files?Boolean Also known as: array_work_on_these_files?, array_work_on_these_files, work_on_which_files?, all_files?

#

files?

#

Returns:

  • (Boolean)


736
737
738
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 736

def files?
  @internal_hash[:files]
end

#filter_for_these_files(i, files = ) ⇒ Object Also known as: apply_filter, do_filter_for

#

filter_for_these_files (filter tag)

This method can be employed to filter for specific files, such as for all .pdf files or for only .gif files.

Typically a Symbol should be passed into this method, but the method will try to remain flexible, so other input arguments are also permissive. The code in the method body may be adjusted to additional use cases, if need be.

Usage examples:

filter_for_these_files(:pdf)
filter_for_these_files('only gif') # This is equivalent to :gif as argument.
#


485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 485

def filter_for_these_files( # Apply a filter here.
    i,
    files = @internal_hash[:files] # Work on all designated files here.
  )
  if i
    files.select! {|entry|
      case i # Check against the first argument to the method here.
      # =================================================================== #
      # === :multimedia_files
      #
      # This entry point depends on the external gem called
      # multimedia_paradise.
      # =================================================================== #
      when :multimedia_files
        begin
          require 'multimedia_paradise/toplevel_methods/is_a_multimedia_file.rb'
          ::MultimediaParadise.is_a_multimedia_file?(entry)
        rescue LoadError; end
      # =================================================================== #
      # === only gif
      #
      # This filter only allows for .gif files to remain in the main Array.
      # =================================================================== #
      when /^only gif/
        entry.end_with?('.gif')
      else # else the default
        entry.end_with?(i.to_s)
      end
    }
  end
end

#gold(i, optional_css_style = '') ⇒ Object

#

gold

#


1130
1131
1132
1133
1134
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 1130

def gold(
    i, optional_css_style = ''
  )
  '<span style="color: gold; '+optional_css_style+'">'+i.to_s+'</span>'
end

#include_subdirectories?Boolean

#

include_subdirectories?

#

Returns:

  • (Boolean)


1206
1207
1208
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 1206

def include_subdirectories?
  @internal_hash[:include_subdirectories]
end

#make_use_of_a_go_down_one_level_link?Boolean

#

This variable will determine whether we will display a “go down one level” entry on the top-header.

#

Returns:

  • (Boolean)


872
873
874
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 872

def make_use_of_a_go_down_one_level_link?
  @internal_hash[:make_use_of_a_go_down_one_level_link]
end

#mediumorchid(i, optional_css_style = '') ⇒ Object

#

mediumorchid

#


1148
1149
1150
1151
1152
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 1148

def mediumorchid(
    i, optional_css_style = ''
  )
  '<span style="color: mediumorchid; '+optional_css_style+'">'+i.to_s+'</span>'
end

#mediumseagreen(i, optional_css_style = '') ⇒ Object

#

mediumseagreen

#


1166
1167
1168
1169
1170
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 1166

def mediumseagreen(
    i, optional_css_style = ''
  )
  '<span style="color: mediumseagreen; '+optional_css_style+'">'+i.to_s+'</span>'
end
#

menu (menu tag)

#


567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 567

def menu(
    i = commandline_arguments?
  )
  if i.is_a? Array
    i.each {|entry| menu(entry) }
  else
    case i # case tag
    # ===================================================================== #
    # === cweb --add-date-in-the-lower-part
    #
    # This will also add additional information in the lower part of
    # the generated webpage, specifically showing the time range
    # if possible, the years. Example: (2021 to 2024)
    #
    # Usage example:
    #
    #   pdf1  --add-date-in-the-lower-part
    #
    # ===================================================================== #
    when /^-?-?add(-|_)?date(-|_)?in(-|_)?the(-|_)?lower(-|_)?part$/i,
         /^-?-?lower(-|_)?part$/i
      @internal_hash[:add_date_in_the_lower_part_of_the_webpage] = true
    # ===================================================================== #
    # === cweb --add-hyperlinks-to-subdirectories
    #
    # This entry point will add a footer-area containing links
    # to the corresponding subdirectories.
    # ===================================================================== #
    when /^-?-?add(-|_)?hyperlinks(-|_)?to(-|_)?subdirectories$/i,
         /^-?-?hyperlinks(-|_)?at(-|_)?the(-|_)?bottom$/i, # === --hyperlinks-at-the-bottom
         /^-?-?bottom$/i # === cweb --bottom
      @internal_hash[:add_hyperlinks_to_subdirectories] = true
    # ===================================================================== #
    # === cweb --tablelayout
    # ===================================================================== #
    when /^-?-?tablelayout$/i,
         /^-?-?table$/i,
         /^-?-?html(-|_)?tables?$/i,          # === cweb --html-table
         /^-?-?use(-|_)?HTML(-|_)?tables?$/i, # === cweb --use-HTML-table
         /^-?-?use(-|_)?HTML$/i
      do_use_HTML_table_layout
    # ===================================================================== #
    # === cweb --do-not-include-subdirectories
    # ===================================================================== #
    when /^-?-?do(-|_)?not(-|_)?include(-|_)?subdirectories$/i
      do_not_include_subdirectories
    # ===================================================================== #
    # === cweb --traverse
    # ===================================================================== #
    when /^-?-?traverse$/i
      @internal_hash[:do_traverse_into_subdirectories] = true
    # ===================================================================== #
    # === --do-include-subdirectories
    #
    # This option allows the use to include all files in all subdirectories
    # as well. Internally this is handled via a modified argument sent
    # towards Dir[].
    # ===================================================================== #
    when /^-?-?do(-|_)?include(-|_)?subdirectories$/i,
         /^-?-?include(-|_)?subdirectories$/i,
         /^-?-?subdirectories$/i, # === --subdirectories
         /^-?-?subdirs$/i
      do_include_subdirectories
    # ===================================================================== #
    # === cweb --do-not-traverse
    #
    # This will NOT check for any images in a subdirectory.
    # ===================================================================== #
    when /^-?-?do(-|_)?not(-|_)?traverse$/i,
         /^-?-?simple$/i, # cweb --simple
         /^-?-?ignore(-|_)?subdirectories$/i # cweb --ignore-subdirectories
      @internal_hash[:do_traverse_into_subdirectories] = false
    # ===================================================================== #
    # === --do_make_use_of_a_go_down_one_level_link
    # ===================================================================== #
    when /^-?-?do(-|_)?make(-|_)?use(-|_)?of(-|_)?a(-|_)?go(-|_)?down(-|_)?one(-|_)?level(-|_)?link$/,
         /^-?-?go(-|_)?down$/,
         /^-?-?do(-|_)?go(-|_)?down$/,
         /^-?-?down$/
      do_make_use_of_a_go_down_one_level_link
    # ===================================================================== #
    # === --pwd
    # ===================================================================== #
    when /^-?-?pwd$/i, # This means we store in the current directory.
         :return_pwd
      set_this_directory_contains_the_images(:pwd)
      set_store_where(:infer)
      clear_images
      scan_for_images_in_this_directory
      the_three_main_actions
      do_open_the_webpage_if_we_are_on_a_roebe_system # Open it in the browser.
      exit
    # ===================================================================== #
    # === cweb --use-no-size-value
    # ===================================================================== #
    when /^-?-?use(-|_)?no(-|_)?size(-|_)?value$/i,
         /^-?-?no(-|_)?special(-|_)?size$/i
      @internal_hash[:use_no_size_value] = true
    # ===================================================================== #
    # === cweb --videos
    #
    # This entry point allows us to work on video-files only. If that
    # is the case then the sorting-mode will be changed - aka to not
    # sort at all.
    # ===================================================================== #
    when /^-?-?videos$/i,
         /^-?-?videos(-|_)?only$/i
      @internal_hash[:work_on_video_files_only] = true
      @internal_hash[:sort_how] = :do_not_sort_at_all
    # ===================================================================== #
    # === --njoy
    # ===================================================================== #
    when /-?-?njoy$/i,
         :njoy
      e 'We will use the excellent images from a special directory.'
      scan_there :njoy
    # ===================================================================== #
    # === cweb --table=4 # 4 rows
    #
    # This entry point allows the user to set another number of rows
    # for the generated HTML table, such as four rows or two rows.
    # ===================================================================== #
    when /^-?-?table=(.+)$/i
      n_rows = $1.to_s.to_i
      @internal_hash[:use_n_rows_for_the_html_table] = n_rows
      do_use_HTML_table_layout
    # ===================================================================== #
    # === cweb ?
    # ===================================================================== #
    when '?'
      opne 'The file in question will be:'
      e
      e "  #{sfile(store_where?)}"
      e
      exit
    # ===================================================================== #
    # === cweb --display-top-header
    # ===================================================================== #
    when /^-?-?display(-|_| )?top(-|_| )?header$/i,
         /^-?-?do(-|_| )?display(-|_| )?top(-|_| )?header$/i
      @internal_hash[:display_the_top_header] = true
    # ===================================================================== #
    # === --help
    # ===================================================================== #
    when /^-?-?help$/i
      show_help
      exit
    else
      if i.is_a?(String) and File.directory?(i)
        # ================================================================= #
        # (1) Assign a new main directory in this case.
        # ================================================================= #
        set_work_on_this_directory(i)
        # ================================================================= #
        # (2) Infer a new name for the locally saved file.
        # ================================================================= #
        set_save_into_this_local_file(
          :use_the_directory_containing_all_images_as_base
        )
      elsif i.start_with?('--') # Report that this commandline argument is not registered.
        report_not_registered_commandline_argument(i)
      end
    end
  end
end

#n_rows?Boolean

#

n_rows?

#

Returns:

  • (Boolean)


965
966
967
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 965

def n_rows?
  @internal_hash[:use_n_rows_for_the_html_table]
end

#olivedrab(i, optional_css_style = '') ⇒ Object

#

olivedrab

#


1139
1140
1141
1142
1143
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 1139

def olivedrab(
    i, optional_css_style = ''
  )
  '<span style="color: olivedrab; '+optional_css_style+'">'+i.to_s+'</span>'
end

#paleturquoise(i, optional_css_style = '') ⇒ Object

#

paleturquoise

#


1157
1158
1159
1160
1161
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 1157

def paleturquoise(
    i, optional_css_style = ''
  )
  '<span style="color: paleturquoise; '+optional_css_style+'">'+i.to_s+'</span>'
end

#registered_ids?Boolean

#

registered_ids?

#

Returns:

  • (Boolean)


855
856
857
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 855

def registered_ids?
  @internal_hash[:registered_ids]
end

#report_not_registered_commandline_argument(i) ⇒ Object

#

report_not_registered_commandline_argument

#


972
973
974
975
976
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 972

def report_not_registered_commandline_argument(i)
  opne tomato('The commandline argument `')+
       steelblue(i)+
       tomato('` is not registered.')
end

#report_scanning_directory(i = work_on_which_directory? ) ⇒ Object

#

report_scanning_directory

#


821
822
823
824
825
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 821

def report_scanning_directory(
    i = work_on_which_directory?
  )
  opne "Scanning from the directory `#{sdir(i)}`."
end

#resetObject

#

reset (reset tag)

#


195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 195

def reset
  super()
  infer_the_namespace
  initialize_the_config_if_the_config_hash_is_empty
  # ======================================================================= #
  # Keep track of a default work directory.
  # ======================================================================= #
  set_work_on_this_directory(return_pwd)
  # ======================================================================= #
  # === :show_year_in_the_header
  #
  # If the following variable is set to true then a year-range will
  # also be shown in the top-header of the .html file at hand. This
  # will only be honoured if the :display_the_top_header variable
  # is also set to true - otherwise this variable here will simply
  # be ignored.
  # ======================================================================= #
  @internal_hash[:show_year_in_the_header] = true
  # ======================================================================= #
  # === :sort_how
  #
  # The next variable determines if, and how, we should sort on the
  # Dir[] result. To disable sorting set this to nil or to
  # :do_not_sort_at_all. The value :sort_by_date will sort by date,
  # meaning older images are sorted before other images. This will be
  # based on the filename, so if the filename includes "1982" then
  # this means that it is the date 1982.
  # ======================================================================= # 
  @internal_hash[:sort_how] = :sort_by_date # :do_not_sort_at_all
  # ======================================================================= #
  # === :body_css_style
  #
  # This specifies the default CSS style to be used for the
  # <body> tag. The user (respectively subclasses of this class)
  # can modify this variable.
  # ======================================================================= #
  @internal_hash[:body_css_style] = '
    background-color: black; color: white; font-size: '+FONT_SIZE_TO_USE+';'
  # ======================================================================= #
  # === :directory_containing_all_files
  #
  # This variable defaults to the current working directory.
  # ======================================================================= #
  set_directory_containing_all_files(:pwd)
  # ======================================================================= #
  # === :content_of_the_HTML_page
  #
  # This variable will keep the content of the HTML page at hand.
  # ======================================================================= #
  @internal_hash[:content_of_the_HTML_page] = ''.dup
  # ======================================================================= #
  # === :add_date_in_the_lower_part_of_the_webpage
  #
  # Add dates in the lower part of the webpage, if the following
  # variable is set to true. It will be false initially.
  # ======================================================================= #
  @internal_hash[:add_date_in_the_lower_part_of_the_webpage] = false
  # ======================================================================= #
  # === :files
  #
  # This Array will contain all the different files that were found
  # in the given directory at hand.
  # ======================================================================= #
  @internal_hash[:files] = []
  # ======================================================================= #
  # === :directories
  # ======================================================================= #
  @internal_hash[:directories] = []
  # ======================================================================= #
  # === :shall_we_debug
  # ======================================================================= #
  @internal_hash[:shall_we_debug] = SHALL_WE_DEBUG
  # ======================================================================= #
  # === :registered_ids
  #
  # This array will keep track of each id assigned to the <img> tag.
  #
  # This is necessary for the jquery-drag operation.
  # ======================================================================= #
  @internal_hash[:registered_ids] = []
  # ======================================================================= #
  # === :make_use_of_a_go_down_one_level_link
  #
  # If the following variable is set to true then we will also use a
  # helpful href-hyperlink on top (the header bar), in order to allow
  # the user to quickly go one level down.
  # ======================================================================= #
  @internal_hash[:make_use_of_a_go_down_one_level_link] = true
  # ======================================================================= #
  # === :use_jquery
  #
  # This boolean variable will determine whether this class will use
  # jquery by default or whether it will not.
  #
  # I decided to set this to true in June 2021. While it creates a
  # definite overhead and an overall increase in file size of the
  # autogenerated .html file, I think jquery is very convenient to have
  # and use. This may, however had, be subject to change in the future,
  # hence why this comment has been added. The user can toggle this
  # variable via the commandline at any rate, such as via --disable-jquery.
  # ======================================================================= #
  @internal_hash[:use_jquery] = true
  # ======================================================================= #
  # === :display_the_top_header
  #
  # If the following variable is set to true then a top-header will
  # be shown on the webpage, early on, just showing how many images
  # are displayed, and how large these images are in total.
  #
  # Since as of June 2023 this now defaults to true.
  # ======================================================================= #
  @internal_hash[:display_the_top_header] = true
  # ======================================================================= #
  # === :use_no_size_value
  # ======================================================================= #
  @internal_hash[:use_no_size_value] = false
  # ======================================================================= #
  # === :work_on_video_files_only
  # ======================================================================= #
  @internal_hash[:work_on_video_files_only] = false
  # ======================================================================= #
  # === :include_subdirectories
  #
  # If the next variable is true then all subdirectories are included.
  # ======================================================================= #
  do_not_include_subdirectories
  # ======================================================================= #
  # === :add_hyperlinks_to_subdirectories
  #
  # This will determine the most bottom div - the one that may show
  # various hyperlinks to the subdirectories in the working directory.
  # ======================================================================= #
  @internal_hash[:add_hyperlinks_to_subdirectories] = false
  # ======================================================================= #
  # === :use_this_local_css_style
  # ======================================================================= #
  @internal_hash[:use_this_local_css_style] = DEFAULT_CSS_STYLE_FOR_HYPERLINKS.dup
  # ======================================================================= #
  # === :use_german
  # ======================================================================= #
  @internal_hash[:use_german] = true
  # ======================================================================= #
  # === :be_verbose
  # ======================================================================= #
  @internal_hash[:be_verbose] = BE_VERBOSE
  # ======================================================================= #
  # === :use_HTML_table_layout
  #
  # This variable will be true if we make use of a HTML table layout.
  #
  # This is currently used by pdf_to_html.rb, showing various .pdf files,
  # as well as by images_to_html.rb, so we have to keep that in mind -
  # it will do different things for each individual .rb file there.
  # ======================================================================= #
  @internal_hash[:use_HTML_table_layout] = false
  # ======================================================================= #
  # === :save_into_this_local_file
  # ======================================================================= #
  set_save_into_this_local_file(
    :pwd
  )
end

#return_early_and_late_year_from_this_array(i = array_work_on_these_files? ) ⇒ Object

#

return_early_and_late_year_from_this_array

This method must return an Array, with two elements.

#


762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 762

def return_early_and_late_year_from_this_array(
    i = array_work_on_these_files?
  )
  regex_to_use = /(\d{4})/ # Get the year here.
  result = []
  simplified_array = i.map {|entry|
    _ = File.basename(entry)
    _ =~ regex_to_use
    $1.to_s.dup.to_i # Return value here.
  }.sort.uniq
  # ======================================================================= #
  # Must reject erroneous entries next:
  # ======================================================================= #
  simplified_array.reject! {|entry|
    entry == 0
  }
  result << simplified_array.min
  result << simplified_array.max
  return result
end

#return_jqueryObject

#

return_jquery

This method will add the jquery version.

In order to do this, we have to tap into the Cyberweb project.

#


848
849
850
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 848

def return_jquery
  "\n#{::Cyberweb.return_jquery_string}"
end

#return_the_code_for_going_down_one_levelObject

#

return_the_code_for_going_down_one_level

This code basically inserts some HTML code, in particular a href link.

#


882
883
884
885
886
887
888
889
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 882

def return_the_code_for_going_down_one_level
  base_dir_below_the_current_level = File.basename(File.dirname(Dir.pwd))
  html_file_below = "#{base_dir_below_the_current_level}.html"
  add_this_line = "<br><br>\n<a href=\"../#{html_file_below}\" style=\"font-size: 1.1em; color: lightblue; margin: auto; "\
                  "margin-left: 6em; "\
                  "font-weight: bold\">\n→ Go down to the base directory here.</a><br><br><br>\n\n"
  return add_this_line
end

#return_the_pretty_name_of_the_webpageObject

#

return_the_pretty_name_of_the_webpage

This method will return the pretty name of the webpage.

#


460
461
462
463
464
465
466
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 460

def return_the_pretty_name_of_the_webpage
  _ = File.basename(save_into_this_local_file?).
           delete_suffix('.html').
           tr('_',' ')
  _ = _.split(' ').map(&:capitalize).join(' ').strip if _.include?(' ')
  return _
end

#royalblue(i) ⇒ Object

#

royalblue

#


1123
1124
1125
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 1123

def royalblue(i)
  '<span style="color: royalblue">'+i.to_s+'</span>'
end

#runObject

#

run (run tag)

#


1417
1418
1419
1420
1421
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 1417

def run
  menu
  do_debug if shall_we_debug?
  check_whether_at_the_least_one_argument_was_given_and_then_act_accordingly
end

#save_into_this_local_file?Boolean Also known as: title?, store_where?, stored_where?, output_file?, store_into?, save_into_which_file?, save?

#

save_into_this_local_file?

#

Returns:

  • (Boolean)


1068
1069
1070
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 1068

def save_into_this_local_file?
  @internal_hash[:save_into_this_local_file]
end

#set_background(i) ⇒ Object Also known as: background

#

set_background

Pass the colour that you want to use for the background here, such as :orange or :tomato.

#


1178
1179
1180
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 1178

def set_background(i)
  @internal_hash[:body_css_style] = "background-color: #{i};"
end

#set_body_css_style(i) ⇒ Object

#

set_body_css_style

#


1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 1192

def set_body_css_style(i)
  case i
  # ======================================================================= #
  # === :default_for_white_background
  # ======================================================================= #
  when :default_for_white_background
    i = 'background-color: white; color: black; font-size: '+FONT_SIZE_TO_USE+';'
  end
  @internal_hash[:body_css_style] = i
end

#set_content_of_the_html_page(i) ⇒ Object

#

set_content_of_the_html_page

#


804
805
806
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 804

def set_content_of_the_html_page(i)
  @internal_hash[:content_of_the_HTML_page] = i
end

#set_directory_containing_all_files(i = :pwd) ⇒ Object Also known as: set_work_on_this_directory, set_this_dir, set_main_directory

#

set_directory_containing_all_files

#


547
548
549
550
551
552
553
554
555
556
557
558
559
560
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 547

def set_directory_containing_all_files(
    i = :pwd
  )
  case i
  # ======================================================================= #
  # === :pwd
  # ======================================================================= #
  when :pwd,
       :return_pwd
    i = "#{Dir.pwd}/"
  end
  i = rds(i)
  @internal_hash[:directory_containing_all_files] = i
end

#set_files(i) ⇒ Object Also known as: set_array_work_on_these_files, work_on_these_files=, files=

#

set_files

#


981
982
983
984
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 981

def set_files(i)
  i = [i].flatten.compact
  @internal_hash[:files] = i
end

#set_save_into_this_local_file(i = "#{INFO_DIRECTORY}/all_files_from_#{input_directory?}") ⇒ Object Also known as: set_store_where, store_where, store_where=, set_page_name, set_output_page_here

#

set_save_into_this_local_file

#


1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 1013

def set_save_into_this_local_file(
    i = "#{INFO_DIRECTORY}/all_files_from_#{input_directory?}"
  ) # contains the full path where to store things.
  case i
  # ======================================================================= #
  # === :infer_the_name_from_the_directory_containing_all_images
  #
  # This is actually the default.
  # ======================================================================= #
  when :infer_the_name_from_the_directory_containing_all_images,
       :infer,
       :use_the_directory_containing_all_images_as_base,
       :default
    _ = directory_containing_all_files?
    i = File.basename(_).downcase
  # ======================================================================= #
  # === :use_the_current_working_directory_base_name
  # ======================================================================= #
  when :use_the_current_working_directory_base_name,
       :pwd
    i = File.basename(return_pwd).downcase
  end
  if i
    i = i.dup if i.frozen?
    # ===================================================================== #
    # i = File.basename(i) # File.basename() is not good, it removes '/'
    # Append '.html' string, unless it already exists there.
    # ===================================================================== #
    i << HTML unless i.end_with? HTML
  end
  i = File.absolute_path(i)
  @internal_hash[:save_into_this_local_file] = i
end

#shall_we_debug?Boolean

#

shall_we_debug?

#

Returns:

  • (Boolean)


1061
1062
1063
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 1061

def shall_we_debug?
  @internal_hash[:shall_we_debug]
end

#show_helpObject

#

show_help (help tag)

This method will show usage-information, on the commandline, to the end user.

Invocation example:

images_to_html --help
#


916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 916

def show_help
  e "#{rev}This class currently allows for these special arguments:"
  e
  e steelblue('  NJOY')
  e steelblue('  PWD')
  e steelblue('  ?')
  e steelblue('  --videos-only        ')+
    lightgreen('# to work on video-files only')
  e steelblue('  --do-not-traverse    ')+
    lightgreen('# do not obtain images from any subdirectory')
  e steelblue('  --use-HTML-table     ')+
    lightgreen('# display via a HTML table; currently hardcoded to 3 images per row')
  e steelblue('  --table=2            ')+
    lightgreen('# use a HTML table, but 2 images per row, so you can change this setting actually')
  e steelblue('  --use-no-size-value  ')+
    lightgreen('# do not use explicit width and height setting; the images will appear as-is')
  e
end

#show_year_in_the_header?Boolean

#

show_year_in_the_header?

#

Returns:

  • (Boolean)


1006
1007
1008
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 1006

def show_year_in_the_header?
  @internal_hash[:show_year_in_the_header]
end

#sort_how?Boolean

#

sort_how?

#

Returns:

  • (Boolean)


901
902
903
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 901

def sort_how?
  @internal_hash[:sort_how]
end

#use_german?Boolean

#

use_german?

#

Returns:

  • (Boolean)


361
362
363
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 361

def use_german?
  @internal_hash[:use_german]
end

#use_HTML_table_layout?Boolean Also known as: use_html_table_layout?, use_html_table?, use_HTML_table?

#

use_HTML_table_layout?

#

Returns:

  • (Boolean)


1251
1252
1253
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 1251

def use_HTML_table_layout?
  @internal_hash[:use_HTML_table_layout]
end

#use_jquery?Boolean

#

use_jquery?

#

Returns:

  • (Boolean)


862
863
864
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 862

def use_jquery?
  @internal_hash[:use_jquery]
end

#use_no_size_value?Boolean

#

use_no_size_value?

#

Returns:

  • (Boolean)


1054
1055
1056
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 1054

def use_no_size_value?
  @internal_hash[:use_no_size_value]
end

#work_on_video_files_only?Boolean

#

work_on_video_files_only?

#

Returns:

  • (Boolean)


797
798
799
# File 'lib/cyberweb/utility_scripts/obtain_files_and_directories_from_this_path/obtain_files_and_directories_from_this_path.rb', line 797

def work_on_video_files_only?
  @internal_hash[:work_on_video_files_only]
end