Class: Cyberweb::HtmlTemplate

Inherits:
Base
  • Object
show all
Defined in:
lib/cyberweb/html_template/html_template.rb

Overview

Cyberweb::HtmlTemplate

Direct Known Subclasses

WebObject

Constant Summary

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, #be_verbose?, #cascading_style_sheets_directory?, #cd, #commandline_mode?, #copyright?, #css_comment, #delete_directory, #do_toggle, #echo_raw, #filename?, #full_path_to_image_directory?, #html_colours?, #html_image, #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?, #ensure_main_encoding, #esystem, #html_templates, #initialize_the_config_if_the_config_hash_is_empty, #internal_hash?, #log_dir?, #no_http, #random_alphabet_characters, #rds, #remove_comments_from_this_string, #remove_numbers, #require_the_html_templates, #require_these, #return_file_size_in_kb_of, #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) ⇒ HtmlTemplate

#

initialize

#


67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/cyberweb/html_template/html_template.rb', line 67

def initialize(
    commandline_arguments = ARGV,
    run_already           = true,
    &block
  )
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  # ======================================================================= #
  # === Handle Strings first
  # ======================================================================= #
  if commandline_arguments.is_a? String
    set_body_content(commandline_arguments)
  # ======================================================================= #
  # === Handle Arrays next
  # ======================================================================= #
  elsif commandline_arguments.is_a? Array
    set_body_content(commandline_arguments.join(' ').strip)
  # ======================================================================= #
  # === Next, handle Hashes given to this method
  # ======================================================================= #
  elsif commandline_arguments.is_a? Hash
    # ===================================================================== #
    # In this case the passed Hash will be parsed and evaluated.
    # ===================================================================== #
    parse_this_hash(commandline_arguments)
  end
  # ======================================================================= #
  # === Handle blocks passed to this class next, before invoking run()
  # ======================================================================= #
  if block_given?
    yielded = yield
    if yielded.is_a? Symbol
      send(yielded)
    else
      parse_this_hash(yielded)
    end
  end
  run if run_already
end

Class Method Details

.[](i = ARGV, &block) ⇒ Object

#

Cyberweb::HtmlTemplate[]

#


6998
6999
7000
7001
7002
7003
# File 'lib/cyberweb/html_template/html_template.rb', line 6998

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

Instance Method Details

#a(i = '', option_hash = {}) ⇒ Object Also known as: link, link_to, alink, remote_link

#

a (a tag, link tag)

This method essentially refers to the <a> tag.

If the first input argument is a Symbol then we will tap into BeautifulUrl,via Cyberweb.beautiful_url().

#


3281
3282
3283
3284
3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
3302
3303
3304
3305
3306
3307
3308
3309
3310
3311
3312
3313
# File 'lib/cyberweb/html_template/html_template.rb', line 3281

def a(
    i           = '',
    option_hash = {}
  )
  if i.is_a? Symbol
    i = beautiful_url(i)
    # ===================================================================== #
    # Also check if the second argument is a String. In this case we
    # must modify it. Example for input that fulfils this criterium:
    #
    #   remote_link(:hydrogenase, 'Hydrogenase')+
    #
    # ===================================================================== #
    if option_hash.is_a? String
      option_hash = { content: option_hash }
    end
  end
  if show_the_lines?
    @internal_hash[:counter_for_show_the_lines] += 1
    ee '<b class="darkblue">'+
       @internal_hash[:counter_for_show_the_lines].to_s+')</b> '
  end
  if i.start_with?(Cyberweb.base_directory?)
    i = i.dup if i.frozen?
    i.sub!(
      /^#{Cyberweb.base_directory?}/,
      Cyberweb.convert_n_relative_slashes_to_relative_directory
    )
  end
  add_to_body_tag_nl(
    string_link(i, option_hash)
  )
end

#add_content_type_htmlObject

#

add_content_type_html

#


1369
1370
1371
# File 'lib/cyberweb/html_template/html_template.rb', line 1369

def add_content_type_html
  add :content_type_plain
end

#add_html_comment(i = '') ⇒ Object Also known as: ehtml_comment, html_comment

#

add_html_comment

This method will add the given input as HTML comment into the web-object at hand.

For instance, this method will add something like “foobar” as “<!– foobar –>n” precisely.

For now this will only append a HTML comment onto the <body> tag. In the future we may want to change this to allow a HTML comment anywhere on a .html page, but I am not certain this is that important really.

#


428
429
430
431
432
433
434
# File 'lib/cyberweb/html_template/html_template.rb', line 428

def add_html_comment(
    i = ''
  )
  append_onto_the_body_content_nl(
    return_html_comment(i)
  )
end

#add_javascript_file(i, optional_use_this_onload_function = nil) ⇒ Object

#

add_javascript_file

This will show the javascript-file as-is. It can only be used for javascript code that is bundled within the cyberweb project, as-is.

In August 2023 the above restriction has been lessened. It is now also possible to pass a remote URL into this method.

#


1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
# File 'lib/cyberweb/html_template/html_template.rb', line 1228

def add_javascript_file(
    i,
    optional_use_this_onload_function = nil
  )
  if i.is_a? Symbol
    case i
    # ===================================================================== #
    # === :simple_calculator
    # ===================================================================== #
    when :simple_calculator
      i = File.absolute_path(
            project_base_dir?+'javascript_code/simple_calculator.js'
          )
    end
    if i and File.exist?(i)
      i = File.read(i)
    end
  end
  opening_tag = '<script'.dup
  if i and i.is_a?(String) and i.start_with?('http')
    opening_tag << ' src="'+i+'"'
    i = '' # And reset i here.
  end
  if optional_use_this_onload_function
    opening_tag << ' onload="'+optional_use_this_onload_function.to_s+'"'
  end
  opening_tag << ">\n"
  # ======================================================================= #
  # Append it onto the <body> tag next:
  # ======================================================================= #
  append_onto_the_body_tag_nl(
    opening_tag+
    i.to_s+
    "</script>\n"
  )
end

#add_omega_symbolObject

#

add_omega_symbol

#


2805
2806
2807
2808
2809
# File 'lib/cyberweb/html_template/html_template.rb', line 2805

def add_omega_symbol
  append_onto_the_body_tag_nl(
    return_omega_symbol
  )
end

#add_omega_symbol_semanticsObject

#

add_omega_symbol_semantics

#


3798
3799
3800
3801
3802
# File 'lib/cyberweb/html_template/html_template.rb', line 3798

def add_omega_symbol_semantics
  append_onto_the_body_tag_nl(
    return_omega_symbol_semantics
  )
end

#add_relevant_meta_entries(honour_checks = true) ⇒ Object Also known as: add_the_meta_tags, add_the_meta_collection

#

add_relevant_meta_entries

This will instantly append onto @_.

#


1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
# File 'lib/cyberweb/html_template/html_template.rb', line 1378

def add_relevant_meta_entries(
    honour_checks = true
  )
  case honour_checks
  # ======================================================================= #
  # === :ignore_checks
  # ======================================================================= #
  when :ignore_checks
    honour_checks = false
  end
  if honour_checks and use_unicode?
    add_unicode_charset
  else
    add_unicode_charset
  end
end

#add_svg_table(i = 'fancy_table') ⇒ Object

#

add_svg_table

#


4633
4634
4635
4636
4637
4638
4639
# File 'lib/cyberweb/html_template/html_template.rb', line 4633

def add_svg_table(
    i = 'fancy_table'
  )
  append_onto_the_body_tag_nl(
    Cyberweb.return_svg_table(i)
  )
end

#add_the_content_from_the_default_js_filesObject

#

add_the_content_from_the_default_js_files

This method will add the content of all local javascript files that we wish to add onto the HtmlTemplate at hand.

#


6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
# File 'lib/cyberweb/html_template/html_template.rb', line 6385

def add_the_content_from_the_default_js_files
  if @internal_hash[:javascript_code].nil? # Ensure we can work on a String.
    @internal_hash[:javascript_code] = ''.dup
  end
  @internal_hash[:js_files_to_load].each {|this_file|
    target_file = "#{Cyberweb.project_directory?}javascript_code/#{this_file}"
    if File.exist? target_file
      @internal_hash[:javascript_code] << "#{File.read(target_file, encoding: 'UTF-8')}#{N}"
    end
  }
end

#add_this_div(optional_css_class = '', optional_the_id = '', optional_css_style = '', optional_javascript = '') ⇒ Object

#

add_this_div

This method will call append_onto_the_body_nl(), so it is just syntactic sugar really.

#


810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
# File 'lib/cyberweb/html_template/html_template.rb', line 810

def add_this_div(
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = ''
  )
  if optional_css_class.include? '#'
    # ===================================================================== #
    # Handle entries such as:
    #
    #   #ON_TEXT_SELECT_COLOUR_GREEN_BACKGROUND_COLOUR_BLUE
    #
    # next.
    # ===================================================================== #
    optional_css_class = check_this_css_class_for_select_rules(optional_css_class)
  end
  append_onto_the_body_nl(
    Cyberweb.string_div(
      optional_css_class,
      optional_the_id,
      optional_css_style,
      optional_javascript
    )
  )
end

#add_this_remote_css_page(i) ⇒ Object Also known as: css_remote_url, external_stylesheet, remote_css, add_remote_css_page, css_file=, add_css_file, css_file, external_style_sheet

#

add_this_remote_css_page

Use this method in order to include a remote css file.

The argument to this method should be the remote URL for the .css file that you wish to access.

Please use use this method solely for remote URLs.

Specific Usage Example:

css_remote_url 'https://www.playgroundblues.com/media/stylesheets/screen.css'
#


6352
6353
6354
# File 'lib/cyberweb/html_template/html_template.rb', line 6352

def add_this_remote_css_page(i)
  @internal_hash[:link_in_these_remote_CSS_files] << i
end

#add_unicode_charsetObject

#

add_unicode_charset

#


3435
3436
3437
# File 'lib/cyberweb/html_template/html_template.rb', line 3435

def add_unicode_charset
  append_this_to_the_meta_collection('<meta charset="UTF-8">')
end

#additional_CSS_rules_to_use?Boolean Also known as: main_CSS_rules?

#

additional_CSS_rules_to_use?

#

Returns:

  • (Boolean)


1874
1875
1876
# File 'lib/cyberweb/html_template/html_template.rb', line 1874

def additional_CSS_rules_to_use?
  @internal_hash[:additional_CSS_rules_to_use]
end

#advanced_handle_these_calls_for_englishObject

#

advanced_handle_these_calls_for_english

Note that the alias english() does not work here.

#


1460
1461
1462
# File 'lib/cyberweb/html_template/html_template.rb', line 1460

def advanced_handle_these_calls_for_english
  complex_handle_this_language(:english)
end

#advanced_handle_these_calls_for_germanObject

#

advanced_handle_these_calls_for_german

#


1451
1452
1453
# File 'lib/cyberweb/html_template/html_template.rb', line 1451

def advanced_handle_these_calls_for_german
  complex_handle_this_language(:german)
end

#already_served?Boolean Also known as: already_served, served?

#

already_served?

Whether we already did serve the webpage or not.

#

Returns:

  • (Boolean)


2346
2347
2348
# File 'lib/cyberweb/html_template/html_template.rb', line 2346

def already_served?
  @internal_hash[:already_served]
end

#alt_text_or_no_alt_text(i) ⇒ Object

#

alt_text_or_no_alt_text

#


3683
3684
3685
3686
3687
3688
# File 'lib/cyberweb/html_template/html_template.rb', line 3683

def alt_text_or_no_alt_text(i)
  unless i.to_s.empty?
    i = " alt=\"#{i}\""
  end
  return i
end

#angstrom?Boolean Also known as: angstrom

#

angstrom?

#

Returns:

  • (Boolean)


3143
3144
3145
# File 'lib/cyberweb/html_template/html_template.rb', line 3143

def angstrom?
  'Å'
end

#append_after_the_closing_body_tag(i) ⇒ Object

#

append_after_the_closing_body_tag

This method can be used to append content after the closing </body> tag.

#


6803
6804
6805
# File 'lib/cyberweb/html_template/html_template.rb', line 6803

def append_after_the_closing_body_tag(i)
  @internal_hash[:append_after_the_closing_body_tag] << i
end

#append_newlineObject

#

append_newline

#


1501
1502
1503
# File 'lib/cyberweb/html_template/html_template.rb', line 1501

def append_newline
  body_addnl('') # ← This defaults to a newline.
end

#append_onto_the_body_content(i, append_a_newline = false) ⇒ Object Also known as: append_onto_the_body_tag, addl

#

append_onto_the_body_content

This method will append onto the variable @internal_hash.

The second argument determines whether a newline will be appended or not.

#


1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
# File 'lib/cyberweb/html_template/html_template.rb', line 1661

def append_onto_the_body_content(
    i,
    append_a_newline = false
  )
  case append_a_newline
  # ======================================================================= #
  # === :use_a_newline
  # ======================================================================= #
  when :use_a_newline
    append_a_newline = true
  end
  case i
  # ======================================================================= #
  # === :br
  # ======================================================================= #
  when :br
    i = '<br>'
  end
  if append_a_newline
    i = i.to_s unless i.is_a?(String)
    i = i.dup if i.frozen?
    i << "\n"
  end
  # ======================================================================= #
  # Append onto :body_content finally:
  # ======================================================================= #
  @internal_hash[:body_content] << "#{i}"
end

#append_onto_the_body_css_class(i) ⇒ Object Also known as: append_onto_the_default_body_CSS_class

#

append_onto_the_body_css_class

This helper-method can be used to append onto the <body> CSS class.

#


2188
2189
2190
2191
2192
2193
2194
# File 'lib/cyberweb/html_template/html_template.rb', line 2188

def append_onto_the_body_css_class(i)
  if @internal_hash[:body_css_class].frozen?
    @internal_hash[:body_css_class] = @internal_hash[:body_css_class].dup
  end
  @internal_hash[:body_css_class] << " #{i}"
  @internal_hash[:body_css_class].strip!
end

#append_onto_the_js_files_to_load(i) ⇒ Object Also known as: javascript_src, load_this_external_javascript_file

#

append_onto_the_js_files_to_load

This method accepts a path to a .js file and adds it onto the Cyberweb instance.

If it is a .js file that is distributed by the cyberweb gem then you only have to provide its name, not the full path. This is mostly a convenience feature.

#


1942
1943
1944
1945
# File 'lib/cyberweb/html_template/html_template.rb', line 1942

def append_onto_the_js_files_to_load(i)
  @internal_hash[:js_files_to_load] << i
  @internal_hash[:js_files_to_load].flatten!
end

#append_onto_the_main_CSS_rules(i) ⇒ Object Also known as: css_class, add_to_css, add_to_CSS, add_to_main_CSS, add_onto_the_CSS_rules, css_style, css_style=, append_CSS, append_CSS_style, main_css_class, main_css_style, main_css, main_style, css_main_style, css_classes, c_style=, c_class=, general_css=, css=, c1=, c1, css_template=, css_main, css_main_class, css_code, inline_css, append_to_css_style, add_css_style, append_onto_CSS, append_onto_the_CSS_rules, append_to_CSS, append_these_CSS_rules, append_onto_the_CSS_style, add_this_css_style, add_to_CSS_rules, estyle

#

append_onto_the_main_CSS_rules

This method can be used to add custom CSS rules for the given webpage at hand. In other words: it can be used to define a CSS style for the given web object.

If the last four characters of the provided argument to this method end with ‘.css’ then this method will try to read the file specified therein. (In this case we assume that it must be a .css file that was passed into this method.)

Symbols are treated in a special way, as far as this method here is concerned. For instance, :template1, :template2 and so forth are valid arguments to this method. Alternatively, you can pass in a String, or embed the template-variants via a format such as ‘#TEMPLATE1#’, which will be substituted with whatever :template1 would normally return normally.

This allows us to use APIs such as:

append_onto_the_main_CSS_rules(:template1)
.css_style = :template1 # Or this variant.
#


6887
6888
6889
6890
6891
6892
6893
6894
6895
6896
6897
6898
6899
6900
6901
6902
6903
6904
6905
6906
6907
6908
6909
6910
6911
6912
6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
6924
6925
6926
6927
6928
6929
6930
6931
6932
6933
6934
6935
6936
6937
6938
6939
6940
6941
6942
6943
6944
6945
6946
6947
6948
6949
6950
6951
6952
6953
6954
6955
6956
# File 'lib/cyberweb/html_template/html_template.rb', line 6887

def append_onto_the_main_CSS_rules(i)
  # ======================================================================= #
  # === Special handling of Symbols first
  # ======================================================================= #
  if i.is_a? Symbol
    case i
    # ===================================================================== #
    # === :default
    #
    # This can be used like in this way:
    #
    #   append_CSS :template1
    #
    # ===================================================================== #
    when :default,
         :template,
         :template1,
         :css_template1
      i = css_comment("Generated via `append_onto_the_main_CSS_rules(:#{i})` on #{today?}")+
          TEMPLATE1 # <- This is CSS/default.css
    # ===================================================================== #
    # === :template2
    # ===================================================================== #
    when :template2
      i = css_comment("Generated via `append_onto_the_main_CSS_rules(:#{i})` on #{today?}")+
          TEMPLATE2
    # ===================================================================== #
    # === :code
    # ===================================================================== #
    when :code
      i = css_comment("Generated via `append_onto_the_main_CSS_rules(:#{i})` on #{today?}")+
          CODE_TEMPLATE
    # ===================================================================== #
    # === :template_ruby_regex
    # ===================================================================== #
    when :template_ruby_regex
      i = css_css_comment("Generated via `append_onto_the_main_CSS_rules(:#{i})` on #{today?}")+
          TEMPLATE_RUBY_REGEX
    end
  end
  if @internal_hash[:additional_CSS_rules_to_use].frozen?
    @internal_hash[:additional_CSS_rules_to_use] = @internal_hash[:additional_CSS_rules_to_use].dup
  end
  # ======================================================================= #
  # Next, substitute for #TEMPLATE1 macro - and then other macros.
  # ======================================================================= #
  if i.include?('#TEMPLATE1') or i.include?('#READ_FILE')
    i = i.dup if i.frozen?
    i.gsub!(/#TEMPLATE1/, TEMPLATE1) if i.include?('#TEMPLATE1')
    if i.include?('#READ_FILE')
      target = i.strip.sub(/#READ_FILE /,'')
      target = File.absolute_path(target)
      file_content = File.read(target)
      i.prepend(file_content)
    end
  end
  # ======================================================================= #
  # Read in .css files here. This will only be done if a certain variable
  # was set to true (which it is by default).
  # ======================================================================= #
  if i and i.end_with?('.css') and use_the_internal_CSS_files? # assume we pass a .css file here.
    i = readlines(i).join('') if File.exist?(i)
  end
  # ======================================================================= #
  # Next, we will always append to the variable that keeps track of the
  # CSS rules to be used for this webpage. This allows for the proper
  # build-up of the webpage at hand, including all CSS rules.
  # ======================================================================= #
  @internal_hash[:additional_CSS_rules_to_use] << i
end

#append_onto_the_main_javascript_variable(i) ⇒ Object

#

append_onto_the_main_javascript_variable

#


1107
1108
1109
# File 'lib/cyberweb/html_template/html_template.rb', line 1107

def append_onto_the_main_javascript_variable(i)
  @internal_hash[:javascript_code] << i
end

#append_path_to_dragula_js_fileObject

#

append_path_to_dragula_js_file

#


1951
1952
1953
# File 'lib/cyberweb/html_template/html_template.rb', line 1951

def append_path_to_dragula_js_file
  append_onto_the_js_files_to_load('dragula.js')
end

#append_raw(i = "\n") ⇒ Object Also known as: _, add_to_main_string, append, add

#

append_raw (add tag)

This is the general append-method for whenever we seek to append onto the main String, stored under :result, of this class.

Since as of August 2023 this method is no longer that important; it is kept mostly for legacy reasons now.

#


4240
4241
4242
4243
4244
4245
4246
4247
4248
4249
4250
4251
4252
4253
4254
4255
4256
4257
4258
4259
4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276
4277
4278
4279
4280
4281
4282
4283
4284
# File 'lib/cyberweb/html_template/html_template.rb', line 4240

def append_raw(i = "\n")
  case i
  # ======================================================================= #
  # === :newline
  # ======================================================================= #
  when :newline,
       :use_a_newline
    i = NL
  # ======================================================================= #
  # === :body
  # ======================================================================= #
  when :body
    # consider_autoclosing_the_head_tag
    i = return_body_tag(optional_css_class).dup
  # ======================================================================= #
  # === :content_type_plain
  # ======================================================================= #
  when :content_type_plain
    i = Cyberweb::CONTENT_TYPE_PLAIN
  end
  if i
    # ===================================================================== #
    # === Handle symbols next
    # ===================================================================== #
    if i.is_a? Symbol
      i = "<#{i}>".dup # Such as for :br aka <br>.
    elsif i.is_a? Numeric
      i = i.to_s.dup
    elsif i.respond_to?(:is_an_objectified_html_tag?) and
          i.is_an_objectified_html_tag?
      # =================================================================== #
      # This entry clause adds support for directly adding
      # Objectified::HtmlTags.
      # =================================================================== #
      i = i.string?
    end
    if i.is_a?(String) and i.frozen?
      i = i.dup
    end
  end
  if i.nil?
    i = ''.dup
  end
  @internal_hash[:result] << i
end

#append_this_css(i) ⇒ Object

#

append_this_css

#


2382
2383
2384
# File 'lib/cyberweb/html_template/html_template.rb', line 2382

def append_this_css(i)
  Cyberweb::Cmd.append_this_css(i)
end

#append_this_to_the_body_css(i) ⇒ Object Also known as: append_to_body_css_style

#

append_this_to_the_body_css

#


5361
5362
5363
# File 'lib/cyberweb/html_template/html_template.rb', line 5361

def append_this_to_the_body_css(i)
  @internal_hash[:body_css_style] << i.to_s
end

#append_this_to_the_meta_collection(i) ⇒ Object

#

append_this_to_the_meta_collection

#


5233
5234
5235
# File 'lib/cyberweb/html_template/html_template.rb', line 5233

def append_this_to_the_meta_collection(i)
  @internal_hash[:meta_content] << "#{i}\n"
end

#append_to_cmd(i) ⇒ Object

#

append_to_cmd

#


3095
3096
3097
# File 'lib/cyberweb/html_template/html_template.rb', line 3095

def append_to_cmd(i)
  Cyberweb.append_to_all_cmd(i)
end

#append_to_cmd1(i = '') ⇒ Object Also known as: append_cmd1

#

append_to_cmd1

This method will append to cmd1, by wrapping over a toplevel-method.

#


2891
2892
2893
# File 'lib/cyberweb/html_template/html_template.rb', line 2891

def append_to_cmd1(i = '')
  Cyberweb.append_to_cmd1(i)
end

#append_to_cmd2(i = '') ⇒ Object

#

append_to_cmd2

#


2898
2899
2900
# File 'lib/cyberweb/html_template/html_template.rb', line 2898

def append_to_cmd2(i = '')
  Cyberweb.append_to_cmd2(i)
end

#append_to_cmd3(i = '') ⇒ Object

#

append_to_cmd3

#


2905
2906
2907
# File 'lib/cyberweb/html_template/html_template.rb', line 2905

def append_to_cmd3(i = '')
  Cyberweb.append_to_cmd3(i)
end

#append_to_cmd4(i = '') ⇒ Object

#

append_to_cmd4

#


2912
2913
2914
# File 'lib/cyberweb/html_template/html_template.rb', line 2912

def append_to_cmd4(i = '')
  Cyberweb.append_to_cmd4(i)
end

#append_to_cmd5(i = '') ⇒ Object

#

append_to_cmd5

#


2919
2920
2921
# File 'lib/cyberweb/html_template/html_template.rb', line 2919

def append_to_cmd5(i = '')
  Cyberweb.append_to_cmd5(i)
end

#area(shape = :rect, coords = '92,39,104,140', href_to_use = '') ⇒ Object

#

area

This does an area on an image. DO NOT FORGET TO USE usemap IN YOUR IMAGE!

The coords for rect are:

left, top, right, bottom

(Die Ecke oben links: x1, y1, und die Ecke unten rechts: x2, y2) for circ they are: centerx,centery,radius for poly they are: x1,y1,x2,y2,..,xn,yn

Usage Examples:

area :rect, '242'
#


3602
3603
3604
3605
3606
3607
3608
3609
3610
# File 'lib/cyberweb/html_template/html_template.rb', line 3602

def area(
    shape       = :rect,
    coords      = '92,39,104,140',
    href_to_use = ''
  )
  append_onto_the_body_tag_nl(
    '<area shape="'+shape.to_s+'" coords="'+coords+'" href="'+href_to_use+'"/>'
  )
end

#arrow_right?(i = '', optional_css_class = '') ⇒ Boolean Also known as: arrow_right, rarrow, rarrow?, string_rarrow?, string_rarrow

#

arrow_right?

This method basically returns a right arrow, that is, the Unicode String ‘→’.

Since as of April 2023, this method has two modus operandi:

(1) the default variant is to just return a right arrow. This
    will be the case when no argument is passed to the method.

(2) if an input argument was given, then right_arrow will be
    combined via the method e(), thus achieving output onto
    the webpage at hand.
#

Returns:

  • (Boolean)


4397
4398
4399
4400
4401
4402
4403
4404
4405
4406
4407
# File 'lib/cyberweb/html_template/html_template.rb', line 4397

def arrow_right?(
    i                  = '',
    optional_css_class = ''
  )
  _ = Cyberweb.right_arrow
  if i.empty?
    return _
  else
    e("#{_}#{i}", optional_css_class)
  end
end

#audio(url = '', optional_autoplay = false) ⇒ Object

#

audio

This method essentially creates an “audio” tag, for playing an audio file.

#


5880
5881
5882
5883
5884
5885
5886
5887
# File 'lib/cyberweb/html_template/html_template.rb', line 5880

def audio(
    url               = '',
    optional_autoplay = false
  )
  append_onto_the_body_nl(
    Cyberweb.audio(url, optional_autoplay)
  )
end

#background_image=(i = '/blaaa/foo.png', name_of_img_dir = name_of_img_dir?, , path_to_images = Cyberweb.path_to_images?) ⇒ Object Also known as: body_background_image, background_image

#

background_image=

Consistently use this method if you wish to set the background image for a webpage.

body {background-image: url("../IMG/");}'

Since as of December 2011, if you pass an argument such as ‘NJOY/#RAND’ then we use this as instruction to fetch a random entry from this directory.

Usage examples:

w.background_image = 'NJOY/#RAND'
w.background_image = 'https://www.w3schools.com/cssref/paper.gif'
#


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
# File 'lib/cyberweb/html_template/html_template.rb', line 571

def background_image=(
    i               = '/blaaa/foo.png',
    name_of_img_dir = name_of_img_dir?,
    path_to_images  = Cyberweb.path_to_images?
  )
  # ======================================================================= #
  # Since as of August 2023, the following clause will NOT be entered
  # if a direct "http" link is given. This allows us to use a remote
  # picture as background such as:
  #
  #   'https://www.w3schools.com/cssref/paper.gif'
  #
  # ======================================================================= #
  if i.start_with? 'http'
    _ = i.dup
  else
    _ = "#{name_of_img_dir}/".dup # Hardcoded for now. Yes, I am aware that this sucks.
    if i.to_s.downcase.include? '#rand' # Then get path given. Example: w.background_image = 'NJOY/#RAND'
      first_part = i.split('#').first
      _ << first_part
      _ << get_files_from(path_to_images).sample.to_s
    else
      case i
      # =================================================================== #
      # === :random
      # =================================================================== #
      when :random
        _ << Dir[path_to_images+'NJOY/*'].sample.
             sub(/\/home\/x\/data\/images\//, '')
      else
        _ << i
      end
    end
  end
  # ======================================================================= #
  # === Use a variable to make use of the CSS rule "background-image".
  #
  # This would yield a String such as:
  #
  #     background-image: url("paper.gif");
  #
  # ======================================================================= #
  if i.start_with? 'http'
    background_img = "background-image: url(#{_});" # The string to append.
  else
    background_img = "background-image: url(#{path_to_images}#{_});".dup # The string to append.
    background_img << "\nbackground-repeat: no-repeat;"
  end
  # ======================================================================= #
  # Next, add some default assumptions here. No repeat is ok to
  # use, centered background position - not sure.
  #   background-position: center;
  # ======================================================================= #
  result = <<-EOF
body {
#{background_img}
}

EOF
  add_this_css_style(result)
end

#background_scrollObject

#

background_scroll

#


4696
4697
4698
# File 'lib/cyberweb/html_template/html_template.rb', line 4696

def background_scroll
  set_background :scroll
end

#black_backgroundObject

#

black_background

#


3381
3382
3383
# File 'lib/cyberweb/html_template/html_template.rb', line 3381

def black_background
  set_background(:black)
end

#black_whiteObject

#

black_white

#


3373
3374
3375
3376
# File 'lib/cyberweb/html_template/html_template.rb', line 3373

def black_white
  black_background
  white_font
end

#blockquote(i = '', optional_css_class = '') ⇒ Object

#

blockquote

For documentation about this HTML tag, have a look at:

https://www.w3schools.com/tags/tag_blockquote.asp
#


3522
3523
3524
3525
3526
3527
3528
3529
# File 'lib/cyberweb/html_template/html_template.rb', line 3522

def blockquote(
    i                  = '',
    optional_css_class = ''
  )
  append_onto_the_body_nl(
    '<blockquote class="'+optional_css_class.to_s+'">'+i+'</blockquote>'
  )
end

#body_addnl(i = '', &block) ⇒ Object Also known as: append_to_body, append_onto_the_body_with_newline, append_onto_the_body_tag_nl, append_onto_the_body_content_nl, append_onto_the_body_nl, append_onto_the_body_content_newline, add_to_body_tag_nl, addlnl, addnl

#

body_addnl

This method will append onto the body-content, while also making sure that there is a trailing newline added to the given input at hand.

This method will ultimately append onto @internal_hash.

#


1346
1347
1348
# File 'lib/cyberweb/html_template/html_template.rb', line 1346

def body_addnl(i = '', &block)
  append_onto_the_body_content(i, :use_a_newline, &block)
end

#body_content?Boolean Also known as: body?, body_string?

#

body_content?

#

Returns:

  • (Boolean)


5650
5651
5652
# File 'lib/cyberweb/html_template/html_template.rb', line 5650

def body_content?
  @internal_hash[:body_content]
end

#body_css_class?Boolean

#

body_css_class?

#

Returns:

  • (Boolean)


2008
2009
2010
# File 'lib/cyberweb/html_template/html_template.rb', line 2008

def body_css_class?
  @internal_hash[:body_css_class]
end

#body_css_style?Boolean

#

body_css_style?

#

Returns:

  • (Boolean)


4292
4293
4294
# File 'lib/cyberweb/html_template/html_template.rb', line 4292

def body_css_style?
  @internal_hash[:body_css_style]
end

#body_javascript=(this_javascript = '') ⇒ Object Also known as: onload=, onload, body_onload=, body_javascript

#

body_javascript=

This method sets the @body_javascript ivar. This variable will be used for making the <body> of a HTML page, at the least to JavaScript that is associated with the <body> tag. Normally this is not in use for most webpages though.

As of September 2011 it is required that the last character is a ‘;’. If this is not the case it will be appended.

Usage example:

w.body_onload = 'draginit()' # This is an alias.
#


5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
# File 'lib/cyberweb/html_template/html_template.rb', line 5720

def body_javascript=(
    this_javascript = ''
  )
  @internal_hash[:body_javascript] << this_javascript
  if @internal_hash[:body_javascript] and @internal_hash[:body_javascript].end_with?(';')
  else
    if @internal_hash[:body_javascript].frozen?
      @internal_hash[:body_javascript] = @internal_hash[:body_javascript].dup
    end
    @internal_hash[:body_javascript] << ';'
  end
end

#body_javascript?Boolean

#

body_javascript?

#

Returns:

  • (Boolean)


5700
5701
5702
# File 'lib/cyberweb/html_template/html_template.rb', line 5700

def body_javascript?
  @internal_hash[:body_javascript]
end

#bold(i = '', optional_css_class = '', optional_the_id = '') ⇒ Object Also known as: b

#

bold

This method will “create” an equivalent to the bold-tag.

It must also keep backwards compatibility to invocations such as:

b 'Foobar:','yel'
#


3462
3463
3464
3465
3466
3467
3468
3469
3470
# File 'lib/cyberweb/html_template/html_template.rb', line 3462

def bold(
    i                  = '',
    optional_css_class = '',
    optional_the_id    = ''
  )
  append_onto_the_body_tag_nl(
    string_bold(i, optional_css_class, optional_the_id)
  )
end

#boldbr(i, optional_css_class = '', optional_the_id = '') ⇒ Object Also known as: bbr, ebold

#

boldbr

#


3495
3496
3497
3498
3499
3500
3501
3502
# File 'lib/cyberweb/html_template/html_template.rb', line 3495

def boldbr(
    i,
    optional_css_class = '',
    optional_the_id    = ''
  )
  bold(i, optional_css_class, optional_the_id)
  br
end

#brObject Also known as: nbr

#

br (br tag)

#


5575
5576
5577
# File 'lib/cyberweb/html_template/html_template.rb', line 5575

def br
  append_onto_the_body_tag_nl(:br)
end

#brbrObject

#

brbr

This simply combines two calls to br().

#


3770
3771
3772
# File 'lib/cyberweb/html_template/html_template.rb', line 3770

def brbr
  br; br
end

#build_up_the_resultObject Also known as: create_the_main_string

#

build_up_the_result (main tag)

This method, called from within render(), will build up the full HTML string. This is the String that can be returned/served to a visitor of a website, or stored into a local .html file.

Everything will be appended onto the result-variable, called @internal_hash. This is ensured via the method call set_result().

This method is just about the most important method for class Cyberweb::WebObject too.

#


6490
6491
6492
6493
6494
6495
6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
6510
6511
6512
6513
6514
6515
6516
6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
6528
6529
6530
6531
6532
6533
6534
6535
6536
6537
6538
6539
6540
6541
6542
6543
6544
6545
6546
6547
6548
6549
6550
6551
6552
6553
6554
6555
6556
6557
6558
6559
6560
6561
6562
6563
6564
6565
6566
6567
6568
6569
6570
6571
6572
6573
6574
6575
6576
6577
6578
6579
6580
6581
6582
6583
6584
6585
6586
6587
6588
6589
6590
6591
6592
6593
6594
6595
6596
6597
6598
6599
6600
6601
6602
6603
6604
6605
6606
6607
6608
6609
6610
6611
6612
6613
6614
6615
6616
6617
6618
6619
6620
6621
6622
6623
6624
6625
6626
6627
6628
# File 'lib/cyberweb/html_template/html_template.rb', line 6490

def build_up_the_result
  case @internal_hash[:special_actions]
  # ======================================================================= #
  # === :use_raw_body
  #
  # This entry point will simply allow us to use a passed <body> tag
  # as-is, without any special modification to that.
  #
  # Usage example:
  #
  #   dataset = Cyberweb.read_file(:tales)
  #
  #   Cyberweb.html_template(
  #     body:  dataset,
  #     special_actions: :use_raw_body # This will use the <body> tag directly.
  #   ).to_s
  #
  # ======================================================================= #
  when :use_raw_body
    set_result(body_content?.to_s)
  else
    # ===================================================================== #
    # This is the default. We will do more actions in this clause. (else tag)
    # ===================================================================== #
    _ = ''.dup
    # ===================================================================== #
    # Honour in which language we will have the content here.
    # ===================================================================== #
    _ << return_the_doctype(language?)
    _ << "<head>\n" # Start the <head> tag here.
    # ===================================================================== #
    # Next add the title of the webpage:
    # ===================================================================== #
    _ << "#{html_title?}\n" if web_title?
    if shall_we_add_the_meta_content?
      _ << meta_content?
    end
    # ===================================================================== #
    # Next we will add add jquery support. This should be added before
    # the content following the <body> tag is appended.
    # ===================================================================== #
    if shall_we_use_jquery?
      _ << return_the_jquery_string
    end
    # ===================================================================== #
    # === Add favicons next:
    # ===================================================================== #
    if use_favicon?
      _ << '<link rel="icon" type="image/png" href="'+use_favicon?.to_s+'"/>'+"\n"
    end
    # ===================================================================== #
    # === Consider appending the assumed JavaScript code next
    #
    # This should come before we close the <head> tag and before we
    # add any possible <frame> tag.
    # ===================================================================== #
    assumed_javascript = return_assumed_javascript
    _ << "#{assumed_javascript}\n" unless assumed_javascript.empty?
    @internal_hash[:link_in_these_remote_CSS_files].each {|this_remote_CSS_file|
      # =================================================================== #
      # We will use rel="stylesheet" to tell the browser that we are 
      # importing a stylesheet here. The type is always type="text/css"
      # for a .css file. We could omit the type-statement too, though,
      # as it is the default anyway.
      #
      # This all has to be within the <head> tag.
      # =================================================================== #
      _ << '<link rel="stylesheet" href="'+this_remote_CSS_file.to_s+'" type="text/css" media="screen">'+"\n"
    }
    # ===================================================================== #
    # === Append any custom CSS style next
    #
    # The next line should come AFTER the default CSS rules have been
    # appended, which in turn should come AFTER the title was set
    # and copied onto the main result string.
    # ===================================================================== #
    _ << consider_returning_the_css_style # Pull in the CSS rules here.
    # ===================================================================== #
    # === Closing the <head> tag next:
    # ===================================================================== #
    _ << "</head>\n" # The <head> tag is now closed. \o/
    # ===================================================================== #
    # Add a semi-useful HTML comment next:
    # ===================================================================== #
    _ << return_html_comment(
      'The font size in use is: '+current_font_size?.to_s.rstrip
    )
    # ===================================================================== #
    # === Add the proper <body> tag next
    #
    # Append the body-tag next. This must come before we append the
    # body-content.
    # ===================================================================== #
    if use_body_tag?
      _ << return_the_body_tag # Add the body-string. This is just "<body>" for the most part.
    end
    # ===================================================================== #
    # === Consider appending the <iframe> tag, but this is rare
    #
    # The frame-string is usually empty, so it will not be appended.
    #
    # In the past, before August 2023, this was done via a method called
    # append_frame_string().
    #
    # Note that the frame tag comes AFTER the <body> tag.
    # ===================================================================== #
    frame_string = @internal_hash[:frame_string]
    _ << frame_string if frame_string and !frame_string.empty?
    # ===================================================================== #
    # Next we will append the content of the body of the webpage - this
    # will usually be the biggest, ad-hoc user supplied chunk. We will
    # do so via the method return_the_body_content().
    # ===================================================================== #
    _ << return_the_body_content
    # ===================================================================== #
    # Close the body-tag and the HTML tag.
    # ===================================================================== #
    _ << "</body>\n" # Close the body-tag here.
    _ << '</html>' # This does not need a trailing newline.
    # ===================================================================== #
    # Now we must honour the prepend-string and append-string, since as
    # of August 2023.
    # ===================================================================== #
    prepend_this = @internal_hash[:prepend_before_the_body_tag]
    unless prepend_this.empty?
      _[0,0] = prepend_this
    end
    append_this = @internal_hash[:append_after_the_closing_body_tag]
    unless append_this.empty?
      _ << append_this
    end
    set_result(_) # And assign the result here.
    # ===================================================================== #
    # Also determine the amount of lines. This should always come last
    # in this method invocation.
    # ===================================================================== #
    set_n_total_lines
  end
end

#button(optional_text = '', optional_css_class = '', &block) ⇒ Object

#

button (button tag)

This method will “generate” a HTML button. Since as of October 2022 this uses its own HTML element; before that input(:button) was in use.

The following example shows how this method could be used:

button {{
  text: 'Hey there!'
}}

A slightly more advanced example is the following variant:

button {{
  text: 'Hey there - with more css and a Hello World alert-box in javascript when clicked by the user!',
  css_class: 'bblack1 darkgreen pad8px BOLD',
  javascript_function: 'msg("Hello world!!!")'
}}

Here is another variant, by specifically responding to a click-event, to call a specific function:

button {{
  text:           'Click here'
  css_class:      'bblack1 pad8px'
  on_click_event: :on_click_event_hello_world
}}

And yet another variant, similar to the one above:

button {{
 text:      'Refresh this page',
 css_class: 'bblack2 pad5px marl1em',
 on_click:  :reload_this_page
}}

And another variant, without a block:

button text: 'OK!',
       css_class: 'glow_on_hover'
#


6449
6450
6451
6452
6453
6454
6455
6456
6457
6458
6459
6460
# File 'lib/cyberweb/html_template/html_template.rb', line 6449

def button(
    optional_text      = '',
    optional_css_class = '',
    &block
  )
  _ = HtmlTags.button(
    optional_text,
    optional_css_class,
    &block
  )
  append_onto_the_body_tag_nl(_)
end

#call(env = nil) ⇒ Object

#

call (call tag)

Rack expects an application to be an object with a .call() method accepting env (hash containing all the information about a request) and returning a 3-element tuple.

Note that Rack expects the body portion of the response array to respond to .each(), so bare strings have to be wrapped into an Array

The structure for this Array should be as follows:

[status_code, headers_hash, body_array]
#


3341
3342
3343
3344
3345
3346
3347
3348
3349
3350
3351
3352
3353
3354
# File 'lib/cyberweb/html_template/html_template.rb', line 3341

def call(
    env = nil
  )
  internal_render
  result = main_string?
  [
    200, # Status code.
    {
      'Content-Type'   => 'text/html',
      'Content-Length' => result.size # Headers.
    },
    [result] # The body Array.
  ]
end

#cbodyObject

#

cbody

#


3997
3998
3999
# File 'lib/cyberweb/html_template/html_template.rb', line 3997

def cbody
  close(:body)
end

#cdivObject

#

cdiv

#


4132
4133
4134
# File 'lib/cyberweb/html_template/html_template.rb', line 4132

def cdiv
  close(:div)
end

#cdlObject

#

cdl

#


4095
4096
4097
# File 'lib/cyberweb/html_template/html_template.rb', line 4095

def cdl
  close(:dl)
end

#cfieldsetObject

#

cfieldset

#


4081
4082
4083
# File 'lib/cyberweb/html_template/html_template.rb', line 4081

def cfieldset
  close(:fieldset)
end

#cformObject

#

cform

#


4074
4075
4076
# File 'lib/cyberweb/html_template/html_template.rb', line 4074

def cform
  close(:form)
end

#cframesetObject

#

cframeset

#


4004
4005
4006
# File 'lib/cyberweb/html_template/html_template.rb', line 4004

def cframeset
  close(:frameset)
end

#check_this_css_class_for_select_rules(optional_css_class) ⇒ Object

#

check_this_css_class_for_select_rules

#


779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
# File 'lib/cyberweb/html_template/html_template.rb', line 779

def check_this_css_class_for_select_rules(
    optional_css_class
  )
  if optional_css_class.include? 'ON_TEXT_SELECT'
    regex_to_use = /#ON_TEXT_SELECT_COLOU?R_(.+)_BACKGROUND_COLOUR_(.+)/ # See: https://rubular.com/r/VKnuPcxalehCVj
    optional_css_class =~ regex_to_use
    colour            = $1.to_s.dup.downcase
    background_colour = $2.to_s.dup.downcase
    # optional_the_id   = "selection_colour_#{colour}_background_colour_#{background_colour}"
    optional_css_class = optional_css_class.dup # if optional_css_class.frozen?
    optional_css_class.sub!(regex_to_use, "selection_colour_#{colour}_background_colour_#{background_colour}")
    complete_css_rule = <<-EOF

.selection_colour_#{colour}_background_colour_#{background_colour}::selection {
background-color: #{colour};
color:            #{background_colour};
}

EOF
    append_onto_the_CSS_rules(complete_css_rule)
    return optional_css_class
  end
  return optional_css_class
end

#chtmlObject

#

chtml

#


3981
3982
3983
# File 'lib/cyberweb/html_template/html_template.rb', line 3981

def chtml
  close(:html)
end

#circle(hash = { height: 150, colour: :yellow, radius: :quarter_default_width, stroke_width: 10 }) ⇒ Object

#

circle

#


3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
# File 'lib/cyberweb/html_template/html_template.rb', line 3534

def circle(
    hash = {
      height: 150,
      colour: :yellow,
      radius: :quarter_default_width,
      stroke_width: 10
    }
  )
  _ = Cyberweb.circle(hash)
  append_onto_the_body_tag_nl(_)
end

#clabelObject

#

clabel

#


4125
4126
4127
# File 'lib/cyberweb/html_template/html_template.rb', line 4125

def clabel
  close(:label)
end

#clear_leftObject

#

clear_left

#


3759
3760
3761
3762
3763
# File 'lib/cyberweb/html_template/html_template.rb', line 3759

def clear_left
  append_onto_the_body_tag_nl(
    '<br style="clear: left;" />'
  )
end

#clear_the_main_stringObject Also known as: reset_the_main_string, reset_main_string, reset_result

#

clear_the_main_string

The simple purpose of this method is to reset the main string variable.

#


4337
4338
4339
# File 'lib/cyberweb/html_template/html_template.rb', line 4337

def clear_the_main_string
  main_string?.clear # This resets :result.
end

#clegendObject

#

clegend

#


4060
4061
4062
# File 'lib/cyberweb/html_template/html_template.rb', line 4060

def clegend
  close(:legend)
end

#cliObject

#

cli

#


4018
4019
4020
# File 'lib/cyberweb/html_template/html_template.rb', line 4018

def cli
  close(:li)
end

#close(i) ⇒ Object Also known as: c

#

close (close tag)

The close() method will always call the other method called append_onto_the_body_nl(). It is thus a rather generic method, used by several other methods of this class.

#


3964
3965
3966
3967
3968
# File 'lib/cyberweb/html_template/html_template.rb', line 3964

def close(i)
  append_onto_the_body_nl(
    sclose(i)
  )
end

#close_aObject Also known as: ca

#

close_a

#


4067
4068
4069
# File 'lib/cyberweb/html_template/html_template.rb', line 4067

def close_a
  close(:a)
end

#close_htmlObject

#

close_html

#


3973
3974
3975
3976
# File 'lib/cyberweb/html_template/html_template.rb', line 3973

def close_html
  cbody
  chtml
end

#cmapObject

#

cmap

#


4032
4033
4034
# File 'lib/cyberweb/html_template/html_template.rb', line 4032

def cmap
  close(:map)
end

#cmd1(content = '', css_rules_to_use = Cyberweb.cmd1_css_rules?, optional_id = '', optional_css_style = '', &block) ⇒ Object Also known as: cmd, rc1, command

#

cmd1 (cmd tag)

#


2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
# File 'lib/cyberweb/html_template/html_template.rb', line 2968

def cmd1(
    content            = '',
    css_rules_to_use   = Cyberweb.cmd1_css_rules?,
    optional_id        = '',
    optional_css_style = '',
    &block
  )
  if block_given? and (yield == :no_break)
    ee "#{Cyberweb.cmd1(content, css_rules_to_use, optional_id, optional_css_style)}"
  else
    ee "#{Cyberweb.cmd1(content, css_rules_to_use, optional_id, optional_css_style)}#{BR}\n"
  end
end

#cmd1?Boolean Also known as: cmd?, command1?

#

cmd1?

This method also has a constant as an “alias” to its value.

#

Returns:

  • (Boolean)


2928
2929
2930
# File 'lib/cyberweb/html_template/html_template.rb', line 2928

def cmd1?
  Cyberweb.cmd1?
end

#cmd1_is(i) ⇒ Object Also known as: cmd_is, set_cmd1

#

cmd1_is

#


2219
2220
2221
# File 'lib/cyberweb/html_template/html_template.rb', line 2219

def cmd1_is(i)
  Cyberweb.cmd1 = i
end

#cmd2(content = '', css_rules_to_use = Cyberweb.cmd2_css_rules?, optional_id = '', optional_css_style = '', &block) ⇒ Object Also known as: rc2, command2

#

cmd2

#


2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
# File 'lib/cyberweb/html_template/html_template.rb', line 2987

def cmd2(
    content     = '',
    css_rules_to_use   = Cyberweb.cmd2_css_rules?,
    optional_id        = '',
    optional_css_style = '',
    &block
  )
  if block_given? and (yield == :no_break)
    ee "#{Cyberweb.cmd2(content, css_rules_to_use, optional_id, optional_css_style)}"
  else
    ee "#{Cyberweb.cmd2(content, css_rules_to_use, optional_id, optional_css_style)}#{BR}\n"
  end
end

#cmd2_is(i) ⇒ Object Also known as: set_cmd2

#

cmd2_is

#


2227
2228
2229
# File 'lib/cyberweb/html_template/html_template.rb', line 2227

def cmd2_is(i)
  Cyberweb.cmd2 = i
end

#cmd3(content = '', css_rules_to_use = Cyberweb.cmd3_css_rules?, optional_id = '', optional_css_style = '', &block) ⇒ Object Also known as: rc3, command3

#

cmd3

#


2871
2872
2873
2874
2875
2876
2877
2878
2879
2880
2881
2882
2883
# File 'lib/cyberweb/html_template/html_template.rb', line 2871

def cmd3(
    content = '',
    css_rules_to_use   = Cyberweb.cmd3_css_rules?,
    optional_id        = '',
    optional_css_style = '',
    &block
  )
  if block_given? and (yield == :no_break)
    ee "#{Cyberweb.cmd3(content, css_rules_to_use, optional_id, optional_css_style)}"
  else
    ee "#{Cyberweb.cmd3(content, css_rules_to_use, optional_id, optional_css_style)}#{BR}\n"
  end
end

#cmd3_is(i) ⇒ Object Also known as: set_cmd3

#

cmd3_is

#


2234
2235
2236
# File 'lib/cyberweb/html_template/html_template.rb', line 2234

def cmd3_is(i)
  Cyberweb.cmd3 = i
end

#cmd4(content = '', css_rules_to_use = Cyberweb.cmd4_css_rules?, optional_id = '', optional_css_style = '', &block) ⇒ Object Also known as: rc4, command4

#

cmd4

#


3102
3103
3104
3105
3106
3107
3108
3109
3110
3111
3112
3113
3114
# File 'lib/cyberweb/html_template/html_template.rb', line 3102

def cmd4(
    content = '',
    css_rules_to_use   = Cyberweb.cmd4_css_rules?,
    optional_id        = '',
    optional_css_style = '',
    &block
  )
  if block_given? and (yield == :no_break)
    ee "#{Cyberweb.cmd4(content, css_rules_to_use, optional_id, optional_css_style)}"
  else
    ee "#{Cyberweb.cmd4(content, css_rules_to_use, optional_id, optional_css_style)}#{BR}\n"
  end
end

#cmd4_is(i) ⇒ Object Also known as: set_cmd4

#

cmd4_is

#


2241
2242
2243
# File 'lib/cyberweb/html_template/html_template.rb', line 2241

def cmd4_is(i)
  Cyberweb.cmd4 = i
end

#cmd5(content = '', css_rules_to_use = Cyberweb.cmd5_css_rules?, optional_id = '', optional_css_style = '', &block) ⇒ Object Also known as: rc5, command5

#

cmd5

#


3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
# File 'lib/cyberweb/html_template/html_template.rb', line 3005

def cmd5(
    content = '',
    css_rules_to_use   = Cyberweb.cmd5_css_rules?,
    optional_id        = '',
    optional_css_style = '',
    &block
  )
  if block_given? and (yield == :no_break)
    ee "#{Cyberweb.cmd5(content, css_rules_to_use, optional_id, optional_css_style)}"
  else
    ee "#{Cyberweb.cmd5(content, css_rules_to_use, optional_id, optional_css_style)}#{BR}\n"
  end
end

#cmd5_is(i) ⇒ Object Also known as: set_cmd5

#

cmd5_is

#


2248
2249
2250
# File 'lib/cyberweb/html_template/html_template.rb', line 2248

def cmd5_is(i)
  Cyberweb.cmd5 = i
end

#cmd_pre(i) ⇒ Object Also known as: pre_cmd

#

cmd_pre

#


3087
3088
3089
3090
# File 'lib/cyberweb/html_template/html_template.rb', line 3087

def cmd_pre(i)
  splitted = i.split(N)
  splitted.each {|entry| cmd(entry) }
end

#cmdbold(i = '') ⇒ Object

#

cmdbold

#


3068
3069
3070
# File 'lib/cyberweb/html_template/html_template.rb', line 3068

def cmdbold(i = '')
  cmd(i, 'BOLD mars1em')
end

#cobjectObject

#

cobject

#


4025
4026
4027
# File 'lib/cyberweb/html_template/html_template.rb', line 4025

def cobject
  close(:object)
end

#col_cmd(i = '', optional_id = '') ⇒ Object Also known as: col

#

col_cmd

#


3075
3076
3077
3078
3079
3080
3081
3082
# File 'lib/cyberweb/html_template/html_template.rb', line 3075

def col_cmd(
    i           = '',
    optional_id = ''
  )
  ee(
    i, Cyberweb.internal_hash?[:col_cmd], optional_id
  )
end

#colour_chartObject

#

colour_chart

#


2739
2740
2741
2742
2743
# File 'lib/cyberweb/html_template/html_template.rb', line 2739

def colour_chart
  append_onto_the_body_tag_nl(
    Cyberweb.colour_chart
  )
end

#colour_gradient_left_to_right(colour1 = :steelblue, colour2 = :darkgreen, css_name_that_will_be_returned = '.gradient1') ⇒ Object Also known as: colour_gradient

#

colour_gradient_left_to_right

This method will “return” a CSS class, for a colour-gradient left to right.

#


5155
5156
5157
5158
5159
5160
5161
5162
5163
# File 'lib/cyberweb/html_template/html_template.rb', line 5155

def colour_gradient_left_to_right(
    colour1 = :steelblue,
    colour2 = :darkgreen,
    css_name_that_will_be_returned = '.gradient1'
  )
  return "#{css_name_that_will_be_returned} {
background: linear-gradient(to right, #{colour1}, #{colour2});
}"
end

#colour_gradient_right_to_left(colour1 = :steelblue, colour2 = :darkgreen, css_name_that_will_be_returned = '.gradient1') ⇒ Object

#

colour_gradient_right_to_left

This method will “return” a CSS class, for a colour-gradient left to right.

#


766
767
768
769
770
771
772
773
774
# File 'lib/cyberweb/html_template/html_template.rb', line 766

def colour_gradient_right_to_left(
    colour1 = :steelblue,
    colour2 = :darkgreen,
    css_name_that_will_be_returned = '.gradient1'
  )
  return "#{css_name_that_will_be_returned} {
background: linear-gradient(to left, #{colour1}, #{colour2});
}"
end

#complex_handle_this_language(i = language? ) ⇒ Object

#

complex_handle_this_language

#


1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
# File 'lib/cyberweb/html_template/html_template.rb', line 1467

def complex_handle_this_language(
    i = language?
  )
  case i
  # ======================================================================= #
  # === :german
  # ======================================================================= #
  when :german
    german_trinity
  # ======================================================================= #
  # === :english
  # ======================================================================= #
  when :english
    english_trinity
  end
end

#consider_appending_when_the_webpage_was_originally_createdObject

#

consider_appending_when_the_webpage_was_originally_created

#


2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
# File 'lib/cyberweb/html_template/html_template.rb', line 2691

def consider_appending_when_the_webpage_was_originally_created
  # ===================================================================== #
  # The next line was added in March 2023:
  # ===================================================================== #
  _ = @internal_hash[:additional_meta_collection]
  if _ and !_.empty?
    add_html_comment(
      'This website was originally created on '+
      _.scan(/content="(.+)"/).
      flatten.first.to_s
    )
    # append(_)
  end
end

#consider_returning_the_css_styleObject

#

consider_returning_the_css_style

This method will basically append the custom CSS rules onto the webpage.

#


5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
5762
5763
5764
5765
5766
5767
5768
5769
5770
5771
# File 'lib/cyberweb/html_template/html_template.rb', line 5749

def consider_returning_the_css_style
  _ = ''.dup
  # ======================================================================= #
  # === Add the proper font-size, if requested to do so
  # ======================================================================= #
  if raw_font_size?
    _ << "\nbody { \nfont-size: #{raw_font_size?};\n}\n\n"
  end
  special_CSS_classes_to_use = return_the_css_classes
  if special_CSS_classes_to_use and !special_CSS_classes_to_use.empty?
    _ << special_CSS_classes_to_use
  else # This is the default entry point.
    if use_local_CSS_files?
      _ << return_the_CSS_rules_from_the_local_CSS_files
    end
  end
  # ======================================================================= #
  # Next, we ALWAYS have to append the ad-hoc CSS rules that the
  # user may have wanted to append onto the webpage, as-is.
  # ======================================================================= #
  _ << "#{return_css_style}\n"
  return "#{HtmlTags.style(_)}\n" # We tap into HtmlTags here for the desired functionality.
end

#counter_eight(i) ⇒ Object Also known as: c_eight

#

counter_eight

#


4752
4753
4754
# File 'lib/cyberweb/html_template/html_template.rb', line 4752

def counter_eight(i)
  e "(8) #{i}"
end

#counter_five(i) ⇒ Object Also known as: c_five

#

counter_five

#


4731
4732
4733
# File 'lib/cyberweb/html_template/html_template.rb', line 4731

def counter_five(i)
  e "(5) #{i}"
end

#counter_four(i) ⇒ Object Also known as: c_four

#

counter_four

#


4724
4725
4726
# File 'lib/cyberweb/html_template/html_template.rb', line 4724

def counter_four(i)
  e "(4) #{i}"
end

#counter_nine(i) ⇒ Object Also known as: c_nine

#

counter_nine

#


4759
4760
4761
# File 'lib/cyberweb/html_template/html_template.rb', line 4759

def counter_nine(i)
  e "(9) #{i}"
end

#counter_one(i) ⇒ Object Also known as: c_one

#

counter_one

#


4703
4704
4705
# File 'lib/cyberweb/html_template/html_template.rb', line 4703

def counter_one(i)
  e "(1) #{i}"
end

#counter_seven(i) ⇒ Object Also known as: c_seven

#

counter_seven

#


4745
4746
4747
# File 'lib/cyberweb/html_template/html_template.rb', line 4745

def counter_seven(i)
  e "(7) #{i}"
end

#counter_six(i) ⇒ Object Also known as: c_six

#

counter_six

#


4738
4739
4740
# File 'lib/cyberweb/html_template/html_template.rb', line 4738

def counter_six(i)
  e "(6) #{i}"
end

#counter_ten(i) ⇒ Object Also known as: c_ten

#

counter_ten

#


4766
4767
4768
# File 'lib/cyberweb/html_template/html_template.rb', line 4766

def counter_ten(i)
  e "(10) #{i}"
end

#counter_three(i) ⇒ Object Also known as: c_three

#

counter_three

#


4717
4718
4719
# File 'lib/cyberweb/html_template/html_template.rb', line 4717

def counter_three(i)
  e "(3) #{i}"
end

#counter_two(i) ⇒ Object Also known as: c_two

#

counter_two

#


4710
4711
4712
# File 'lib/cyberweb/html_template/html_template.rb', line 4710

def counter_two(i)
  e "(2) #{i}"
end

#cpObject

#

cp

#


4139
4140
4141
# File 'lib/cyberweb/html_template/html_template.rb', line 4139

def cp
  close(:p)
end

#cpreObject

#

cpre

#


4053
4054
4055
# File 'lib/cyberweb/html_template/html_template.rb', line 4053

def cpre
  close(:pre)
end

#created_when(i = '20.08.2021') ⇒ Object Also known as: created_on, set_created_on

#

created_when

This method can be used to add a meta-tag to the web-object (web-page) at hand.

To read up more about that meta-tag, the following document is recommended:

https://dublincore.org/resources/userguide/publishing_metadata/#dcterms:created

Usage example for the method:

created_when('22.10.2021')
#


2761
2762
2763
2764
2765
2766
# File 'lib/cyberweb/html_template/html_template.rb', line 2761

def created_when(
    i = '20.08.2021'
  )
  @internal_hash[:additional_meta_collection] =
    '<meta name="DCTERMS.created"           content="'+i.to_s+'"/>'
end

#cselectObject

#

cselect

#


4046
4047
4048
# File 'lib/cyberweb/html_template/html_template.rb', line 4046

def cselect
  close(:select)
end

#css_class_or_no_class(i = '') ⇒ Object

#

css_class_or_no_class

#


4306
4307
4308
4309
4310
4311
# File 'lib/cyberweb/html_template/html_template.rb', line 4306

def css_class_or_no_class(i = '')
  unless i.to_s.empty?
    i = " class=\"#{i}\""
  end
  return i
end

#css_classes?Boolean

#

css_classes?

#

Returns:

  • (Boolean)


1993
1994
1995
# File 'lib/cyberweb/html_template/html_template.rb', line 1993

def css_classes?
  @internal_hash[:use_only_these_CSS_classes]
end

#css_for_cmd1(i = '') ⇒ Object Also known as: css_for_cmd

#

css_for_cmd1

#


3023
3024
3025
3026
3027
# File 'lib/cyberweb/html_template/html_template.rb', line 3023

def css_for_cmd1(
    i = ''
  )
  Cyberweb.css_for_cmd1 = i
end

#css_for_cmd2(i = '') ⇒ Object

#

css_for_cmd2

#


3032
3033
3034
3035
3036
# File 'lib/cyberweb/html_template/html_template.rb', line 3032

def css_for_cmd2(
    i = ''
  )
  Cyberweb.css_for_cmd2 = i
end

#css_for_cmd3(i = '') ⇒ Object

#

css_for_cmd3

#


3041
3042
3043
3044
3045
# File 'lib/cyberweb/html_template/html_template.rb', line 3041

def css_for_cmd3(
    i = ''
  )
  Cyberweb.css_for_cmd3 = i
end

#css_for_cmd4(i = '') ⇒ Object

#

css_for_cmd4

#


3050
3051
3052
3053
3054
# File 'lib/cyberweb/html_template/html_template.rb', line 3050

def css_for_cmd4(
    i = ''
  )
  Cyberweb.css_for_cmd4 = i
end

#css_for_cmd5(i = '') ⇒ Object

#

css_for_cmd5

#


3059
3060
3061
3062
3063
# File 'lib/cyberweb/html_template/html_template.rb', line 3059

def css_for_cmd5(
    i = ''
  )
  Cyberweb.css_for_cmd5 = i
end

#css_rule_for_this_background_image(i = :parchment2) ⇒ Object

#

css_rule_for_this_background_image

The following method was added in September 2023. The purpose of this method is to return the valic CSS rule for a background-image.

The method only allows working on local images - such images may be included in the cyberweb gem, to simplify handling some background images. The reason for this is that we currently use a hardcoded path in this method, that is the assumption that all such images will be kept in a local copy of the temp-subdirectory. See below for that hardcoded entry.

#


1063
1064
1065
1066
1067
# File 'lib/cyberweb/html_template/html_template.rb', line 1063

def css_rule_for_this_background_image(
    i = :parchment2
  )
  "background-image: url(\"#{converted_path?}Temp/cyberweb/images/#{File.basename(path_to_this_background_image(i))}\");"
end

#css_style_or_no_style(i = '') ⇒ Object

#

css_style_or_no_style

#


2727
2728
2729
2730
2731
2732
2733
2734
# File 'lib/cyberweb/html_template/html_template.rb', line 2727

def css_style_or_no_style(
    i = ''
  )
  unless i.to_s.empty?
    i = " style=\"#{i}\""
  end
  return i
end

#css_template1Object

#

css_template1

Before this method was added in April 2022 I used to invoke the method css_style() via :template1 as the first argument. Using a single method instead, aka css_template1(), made more sense though.

#


3428
3429
3430
# File 'lib/cyberweb/html_template/html_template.rb', line 3428

def css_template1
  css_style :template1
end

#ctableObject

#

ctable

#


4118
4119
4120
# File 'lib/cyberweb/html_template/html_template.rb', line 4118

def ctable
  close(:table)
end

#ctdObject

#

ctd

#


4039
4040
4041
# File 'lib/cyberweb/html_template/html_template.rb', line 4039

def ctd
  close(:td)
end

#ctdctrObject

#

ctdctr

#


3988
3989
3990
3991
3992
# File 'lib/cyberweb/html_template/html_template.rb', line 3988

def ctdctr
  append_onto_the_body_tag_nl(
    '</td></tr>'
  )
end

#ctdtdObject

#

ctdtd

#


4109
4110
4111
4112
4113
# File 'lib/cyberweb/html_template/html_template.rb', line 4109

def ctdtd
  append_onto_the_body_tag_nl(
    '</td><td>'
  )
end

#ctextareaObject

#

ctextarea

#


4146
4147
4148
# File 'lib/cyberweb/html_template/html_template.rb', line 4146

def ctextarea
  close(:textarea)
end

#ctrObject

#

ctr

#


4102
4103
4104
# File 'lib/cyberweb/html_template/html_template.rb', line 4102

def ctr
  close(:tr)
end

#culObject

#

cul

#


4011
4012
4013
# File 'lib/cyberweb/html_template/html_template.rb', line 4011

def cul
  close(:ul)
end

#current_height?Boolean

#

current_height?

This method uses JavaScript to return the current height of the monitor, in n px.

#

Returns:

  • (Boolean)


3836
3837
3838
3839
3840
3841
3842
3843
# File 'lib/cyberweb/html_template/html_template.rb', line 3836

def current_height?
  append_onto_the_body_tag_nl(
    '<script>
    var height = screen.height;
    document.write(height)
    </script>'
  )
end

#current_ruby_version?Boolean

#

current_ruby_version?

This will return the current ruby sitelib dir version.

Note that the method depends on another method called sitelibdir?().

#

Returns:

  • (Boolean)


5439
5440
5441
# File 'lib/cyberweb/html_template/html_template.rb', line 5439

def current_ruby_version?
  sitelibdir?.split('/').last
end

#cursor(i = :wait) ⇒ Object

#

cursor

#


2063
2064
2065
2066
2067
# File 'lib/cyberweb/html_template/html_template.rb', line 2063

def cursor(
    i = :wait
  )
  append_onto_the_body_css_class "cursor_#{i}"
end

#date_todayObject

#

date_today

#


1892
1893
1894
# File 'lib/cyberweb/html_template/html_template.rb', line 1892

def date_today
  Cyberweb.date_today
end

#default_font_sizeObject Also known as: use_default_font_size_as_specified_in_the_project_settings

#

default_font_size

#


6767
6768
6769
# File 'lib/cyberweb/html_template/html_template.rb', line 6767

def default_font_size
  font_size(:default_font_size)
end
#
#


6792
6793
6794
6795
# File 'lib/cyberweb/html_template/html_template.rb', line 6792

def default_font_size_and_hyperlinks
  default_font_size
  default_hyperlinks
end
#

This method will add the default-hyperlink behaviour onto the main CSS rules.

#


4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
# File 'lib/cyberweb/html_template/html_template.rb', line 4319

def default_hyperlink_behaviour
  append_onto_the_main_CSS_rules '
a,
a:link {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
  '
end
#
#


6845
6846
6847
6848
6849
6850
6851
6852
6853
6854
# File 'lib/cyberweb/html_template/html_template.rb', line 6845

def default_hyperlinks_template1(i = '')
  default_hyperlink_behaviour
  if i
    if use_local_CSS_files?
      append_onto_the_main_CSS_rules(i)
    else
      template1(i)
    end
  end
end

#details(i = '', optional_css_class = '', optional_the_id = '', optional_css_style = '', optional_javascript = '', &block) ⇒ Object

#

details

This will return a <details> tag.

#


3617
3618
3619
3620
3621
3622
3623
3624
3625
3626
3627
3628
3629
3630
3631
3632
3633
3634
3635
# File 'lib/cyberweb/html_template/html_template.rb', line 3617

def details(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = '',
    &block
  )
  append_onto_the_body_tag_nl(
    return_details(
      i,
      optional_css_class,
      optional_the_id,
      optional_css_style,
      optional_javascript,
      &block
    )
  )
end

#disable_body_tagObject

#

disable_body_tag

Use only this method to disable the <body> tag on display.

#


5132
5133
5134
# File 'lib/cyberweb/html_template/html_template.rb', line 5132

def disable_body_tag
  @internal_hash[:use_body_tag] = false
end

#display_this_file(this_file, optional_css_class = '', optional_the_id = '', optional_css_style = '', &block) ⇒ Object Also known as: read_and_display_this_file, read_and_display, read_file_content, embed_this_file, show_this_file, display_file

#

display_this_file

This method can be used to “embed”, aka show, a locally existing file on a webpage.

This method must be able to respond to code such as this:

http://localhost/data/games/ultima/ultima_6/ultima6.cgi

Typical parameters may include this:

embed_this_file('lyxandras.md','','','font-size: 2em;')
display_this_file('/home/x/Temp/opened_files.yml','mar8px pad12px','','font-size: 2.5em;')
#


355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
# File 'lib/cyberweb/html_template/html_template.rb', line 355

def display_this_file(
    this_file,
    optional_css_class = '',
    optional_the_id    = '',
    optional_css_style = '',
    &block
  )
  # ======================================================================= #
  # === First check whether the file exists
  # ======================================================================= #
  if this_file and File.exist?(this_file)
    dataset = File.read(this_file)
    dataset = ensure_main_encoding(dataset)
    # ===================================================================== #
    # === Handle blocks next
    # ===================================================================== #
    if block_given?
      yielded = yield
      case yielded
      # =================================================================== #
      # === :use_bold_dates
      #
      # This entry point will make dates, such as 11.02.2021, appear
      # bold.
      # =================================================================== #
      when :use_bold_dates
        dataset = dataset.gsub(/(^\d{2}\.\d{2}\.\d{4}$)/,'<b>\1</b>')
      # =================================================================== #
      # === :use_bold_dates_and_larger_font
      #
      # Similar to the above, but with a larger font size.
      # =================================================================== #
      when :use_bold_dates_and_larger_font
        dataset = dataset.gsub(/(^\d{2}\.\d{2}\.\d{4}$)/,'<b class="larger">\1</b>')
      # =================================================================== #
      # === :strip_the_parts_after_a_comment
      # =================================================================== #
      when :strip_the_parts_after_a_comment
        dataset = return_dataset_without_any_comments(dataset)
        block = nil
      end
    end
    pre(
      dataset,
      optional_css_class,
      optional_the_id,
      optional_css_style,
      &block
    )
  else
    e "No file exists at #{this_file}. The "\
      "current working directory is: #{Dir.pwd}", 'crimson'
  end
end

#display_this_file_without_comments(this_file, optional_css_class = '', optional_the_id = '', optional_css_style = '', &block) ⇒ Object

#

display_this_file_without_comments

This method is similar to the method defined above; it will read in the dataset, before it will then remove all parts after ‘ #’ in a given line. Furthermore, any lines starting with ‘#’ will also be removed entirely.

#


324
325
326
327
328
329
330
331
332
333
334
335
336
337
# File 'lib/cyberweb/html_template/html_template.rb', line 324

def display_this_file_without_comments(
    this_file,
    optional_css_class = '',
    optional_the_id    = '',
    optional_css_style = '',
    &block
  )
  display_this_file(
    this_file,
    optional_css_class = '',
    optional_the_id    = '',
    optional_css_style
  ) { :strip_the_parts_after_a_comment }
end

#div(optional_css_class = '', optional_the_id = '', optional_css_style = '', optional_javascript = '', &block) ⇒ Object

#

div (div tag)

Input to this method can be in this format:

div(id: 'drag_div_sitemap_table', css_style: 'z-index: 1') {

So the first argument to this method can be a Hash.

#


845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
# File 'lib/cyberweb/html_template/html_template.rb', line 845

def div(
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = '',
    &block
  )
  # ======================================================================= #
  # === Handle Hashes first, on the variable optional_css_class
  # ======================================================================= #
  if optional_css_class.is_a? Hash
    # ===================================================================== #
    # === :css_style
    # ===================================================================== #
    if optional_css_class.has_key? :css_style
      optional_css_style = optional_css_class.delete(:css_style)
    end
    # ===================================================================== #
    # === :id
    # ===================================================================== #
    if optional_css_class.has_key? :id
      optional_the_id = optional_css_class.delete(:id)
    end
    # ===================================================================== #
    # === :css_class
    # ===================================================================== #
    if optional_css_class.has_key? :css_class
      optional_css_class = optional_css_class.delete(:css_class)
    # ===================================================================== #
    # === :class
    # ===================================================================== #
    elsif optional_css_class.has_key? :class
      optional_css_class = optional_css_class.delete(:class)
    end
    if optional_css_class.is_a? Hash
      optional_css_class = ''
    end
  end
  # ======================================================================= #
  # We need to delegate to a toplevel method, in order to create
  # the correct <div> tag.
  # ======================================================================= #
  add_this_div(
    optional_css_class,
    optional_the_id,
    optional_css_style,
    optional_javascript
  )
  # ======================================================================= #
  # === Handle blocks given to <div> next
  # ======================================================================= #
  if block_given?
    yield
    cdiv
  end
end

#dnd_faviconObject

#

dnd_favicon

#


5525
5526
5527
# File 'lib/cyberweb/html_template/html_template.rb', line 5525

def dnd_favicon
  favicon :dnd_favicon
end

#do_not_use_jqueryObject

#

do_not_use_jquery

#


2709
2710
2711
# File 'lib/cyberweb/html_template/html_template.rb', line 2709

def do_not_use_jquery
  @internal_hash[:shall_we_use_jquery] = false
end

#do_not_use_local_CSS_filesObject Also known as: do_not_use_the_internal_CSS_files

#

do_not_use_the_internal_CSS_files

#


5354
5355
5356
# File 'lib/cyberweb/html_template/html_template.rb', line 5354

def do_not_use_local_CSS_files
  @internal_hash[:use_local_CSS_files] = false
end

#do_serveObject Also known as: eserve, erender, print_the_result, display, report, serve_again, serve_webpage, serve, serv, ser, start

#

do_serve (display tag, report tag, render tag, serve tag, main serve)

This method can be used to report (output) the content of the main string (stored in :result, in the primary Hash of this class).

This method always has to set the “already served the web content” variable to true, when called.

You may have to properly build up the main string before invoking this method.

This method will do the actual serving the webpage part.

It can only serve the value that is stored under result?. Since as of May 2023, the main String will be rebuilt whenever this method is called.

#


2458
2459
2460
2461
2462
# File 'lib/cyberweb/html_template/html_template.rb', line 2458

def do_serve
  render # Re-build the main String (result) here.
  we_have_now_already_served_the_web_content # Always set it to true in this case.
  print result?
end

#do_shall_we_use_jqueryObject Also known as: do_use_jquery, append_jquery_string

#

do_shall_we_use_jquery

This method will enable the use of jquery.

#


994
995
996
# File 'lib/cyberweb/html_template/html_template.rb', line 994

def do_shall_we_use_jquery
  @internal_hash[:shall_we_use_jquery] = true
end

#do_show_the_linesObject

#

do_show_the_lines

#


3120
3121
3122
# File 'lib/cyberweb/html_template/html_template.rb', line 3120

def do_show_the_lines
  @internal_hash[:show_the_lines] = true
end

#do_use_local_CSS_filesObject

#

do_use_local_CSS_files

This method is specifically called by Cyberweb::WebObject.

#


5347
5348
5349
# File 'lib/cyberweb/html_template/html_template.rb', line 5347

def do_use_local_CSS_files
  @internal_hash[:use_local_CSS_files] = true
end

#do_use_utf_charsetObject

#

do_use_utf_charset

#


5324
5325
5326
5327
5328
5329
5330
5331
5332
# File 'lib/cyberweb/html_template/html_template.rb', line 5324

def do_use_utf_charset
  if @internal_hash[:meta_content].nil?
    @internal_hash[:meta_content] = ''.dup
  end
  _ = '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'+N
  unless @internal_hash[:meta_content].include? _
    @internal_hash[:meta_content] << _
  end
end

#document_ready(i = '$("p").text("Hello World!");') ⇒ Object

#

document_ready

This is specifically for jquery-related javascript code.

#


1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
# File 'lib/cyberweb/html_template/html_template.rb', line 1960

def document_ready(
    i = '$("p").text("Hello World!");'
  )
  content = <<-EOF
$(document).ready(function(){
#{i}
});
EOF
  ejavascript(content)
end

#document_write(i) ⇒ Object Also known as: dwrite

#

document_write

This is a simple wrapper over JavaScript’s document.write() functionality.

#


3851
3852
3853
# File 'lib/cyberweb/html_template/html_template.rb', line 3851

def document_write(i)
  ejavascript 'document.write("'+i.to_s+'")'
end
#

dropdown_box

#


4367
4368
4369
4370
4371
# File 'lib/cyberweb/html_template/html_template.rb', line 4367

def dropdown_box(i)
  append_onto_the_body_tag_nl(
    Cyberweb.dropdown_box(i)
  )
end

#e(i = '', optional_css_class = '', optional_the_id = '', optional_css_style = '', show_the_lines = show_the_lines?, , &block) ⇒ Object Also known as: ebr, sbr

#

e (e tag)

This is essentially sbr(), which stands for “string span”, and “breakline”. It is like “puts” in regular ruby really, so a newline will be shown (registered onto the main string).

Note that the method must be able to respond to more than one argument too.

This method must be able to respond to the following code as well:

e('This text should now be editable.') { :editable }
#


1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
# File 'lib/cyberweb/html_template/html_template.rb', line 1706

def e(
    i                  = '',
    optional_css_class = '',
    optional_the_id    = '',
    optional_css_style = '',
    show_the_lines     = show_the_lines?,
    &block
  )
  _ = ''.dup
  if optional_css_class.is_a? Hash
    # ===================================================================== #
    # === :id
    # ===================================================================== #
    if optional_css_class.has_key? :id
      optional_the_id = optional_css_class.delete(:id)
    end
    if optional_css_class.empty?
      optional_css_class = ''
    end
  end
  if optional_css_class and !optional_css_class.empty?
    optional_css_class = optional_css_class.to_s if optional_css_class.is_a? Symbol
    optional_css_class = optional_css_class.dup if optional_css_class.frozen?
    optional_css_class.strip! if optional_css_class
  end
  if show_the_lines
    @internal_hash[:counter_for_show_the_lines] += 1
    i.prepend(
      '<b class="darkblue">'+
      @internal_hash[:counter_for_show_the_lines].to_s+
      ')</b> '
    )
  end
  _ << string_s2(i, optional_css_class, optional_the_id, optional_css_style)
  set_last_tag_used('span', optional_the_id)
  # ======================================================================= #
  # Handle blocks next.
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :editable
    #
    # This will also set spellcheck to false, because I find it to be
    # very annoying otherwise.
    # ===================================================================== #
    when :editable
      index = _.index('>')
      _ = _.dup if _.frozen?
      _[index,0] = ' contenteditable="true" spellcheck="false"'
    end
  end
  # ======================================================================= #
  # Next we have to distinguish between e() and le(), since as of
  # January 2023.
  # ======================================================================= #
  sanitized_caller = ensure_main_encoding(caller())
  method_name = Cyberweb.return_the_method_name_from_this_array(
    sanitized_caller
  )
  # ======================================================================= #
  # We handle only two cases here so far - p_default and p_default_le.
  # If we ever want to add more cases, we should extend this comment
  # as well.
  # ======================================================================= #
  case method_name
  # ======================================================================= #
  # === p_default_le
  #
  # Display the content of the p {} tag next.
  # ======================================================================= #
  when /p_default_le$/
    append_onto_the_body_tag_nl(
      string_s2(
        i,
        ("#{optional_css_class} l1em").strip,
        optional_the_id,
        optional_css_style
      )
    )
    br # And the <br> tag.
  # ======================================================================= #
  # === div_default
  # ======================================================================= #
  when 'div_default'
    append_onto_the_body_tag_nl(_.dup)
    br # And the <br> tag.
  # ======================================================================= #
  # === p_default
  # ======================================================================= #
  when /p_default$/
    append_onto_the_body_tag_nl(_.dup)
    br # And the <br> tag.
  # ======================================================================= #
  # === div_default_le
  # ======================================================================= #
  when 'div_default_le'
    append_onto_the_body_tag_nl(
      string_s2(
        i,
        ("#{optional_css_class} l1em").strip,
        optional_the_id,
        optional_css_style
      )
    )
    br # And the <br> tag.
  else
    append_onto_the_body_tag_nl(_.dup)
    br # And the <br> tag.
  end
end

#earrow(i = '', optional_css_class = '') ⇒ Object

#

earrow

#


3485
3486
3487
3488
3489
3490
# File 'lib/cyberweb/html_template/html_template.rb', line 3485

def earrow(
    i                  = '',
    optional_css_class = ''
  )
  e "#{i}", optional_css_class
end

#edot(i = 108, optional_css_class = '', optional_the_id = '', optional_css_style = '') ⇒ Object

#

edot

#


4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
# File 'lib/cyberweb/html_template/html_template.rb', line 4987

def edot(
    i                  = 108,
    optional_css_class = '',
    optional_the_id    = '',
    optional_css_style = ''
  )
  append_onto_the_body_tag_nl(
    string_dot(i, optional_css_class, optional_the_id, optional_css_style)
  )
end

#ee(i = '') ⇒ Object

#

ee (ee tag)

This is sort of like print(), so it will not add a newline by default. If you need a newline use ee_nl() or eenl().

#


1826
1827
1828
# File 'lib/cyberweb/html_template/html_template.rb', line 1826

def ee(i = '')
  append_onto_the_body_tag(i)
end

#ee_nl(i = '') ⇒ Object Also known as: eenl

#

ee_nl

#


1833
1834
1835
# File 'lib/cyberweb/html_template/html_template.rb', line 1833

def ee_nl(i = '')
  append_onto_the_body_tag_nl(i)
end

#eearrow(i = '', optional_css_class = '') ⇒ Object

#

eearrow

#


3475
3476
3477
3478
3479
3480
# File 'lib/cyberweb/html_template/html_template.rb', line 3475

def eearrow(
    i                  = '',
    optional_css_class = ''
  )
  ee string_span("#{i}", optional_css_class)
end

#ejavascript(i = '') ⇒ Object Also known as: javascript, embed_javascript, embed_this_javascript, ejavascript_code, add_this_javascript_code, custom_javascript_code, javascript_code, escript, script

#

ejavascript

The name of this method indicates “echo javascript”, mostly for historic/legacy reasons.

#


1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
# File 'lib/cyberweb/html_template/html_template.rb', line 1144

def ejavascript(
    i = ''
  )
  if i.is_a? Symbol
    case i
    # ===================================================================== #
    # === :popup_open
    # ===================================================================== #
    when :popup_open
      i = '
function popup_open(name_of_the_id = "popup_element") {
var popup = document.getElementById(name_of_the_id);
popup.classList.toggle("show");
}
'
    else
      i = Cyberweb.map_symbol_to_javascript_file(i)
      # =================================================================== #
      # This may now be:
      #
      #   /javascript_code/games/tetris.js
      #
      # =================================================================== #
      if i.is_a? String
        i = File.read(project_base_dir?+i)
        # ================================================================= #
        # Next ad-hoc fix the path for the game snake - this is disabled
        # though.
        # ================================================================= #
        # if i.include? '"ground.png'
        #   i.sub!(
        #     /^ground.src = "ground.png";$/,
        #     'ground.src = "'+relative_path?+'raw_images/ground.png";'
        #   )
        # end
        # if i.include? '"food.png"'
        #   i.sub!(
        #     /^foodImg.src = "food.png";$/,
        #     'foodImg.src = "'+relative_path?+'raw_images/food.png";'
        #   )
        # end
      end
    end
  end
  append_onto_the_body_tag_nl(
    return_javascript(i)
  )
end

#embed_youtube_video(src = 'gexazLr6pSY', width = '640', height = '385') ⇒ Object Also known as: eyv, youtube, youtube_links, youtube_link, youtube_video, embed_video_file, embed_video, embed_youtube_link

#

embed_youtube_video

This method will “embed” a youtube video into the local web-app.

Usage example:

embed_youtube_video 'https://www.youtube.com/watch?v=sAeMTsvGmoQ',
                     css_class: 'rounded_black2'
#


2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
# File 'lib/cyberweb/html_template/html_template.rb', line 2647

def embed_youtube_video(
    src    = 'gexazLr6pSY',
    width  = '640',
    height = '385'
  )
  append_onto_the_body_tag_nl(
    return_youtube_video(
      src,
      width,
      height
    )
  )
end

#enable_namespaceObject Also known as: autoextend

#

enable_namespace

This simply includes the main Cyberweb “namespace”.

#


6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
# File 'lib/cyberweb/html_template/html_template.rb', line 6812

def enable_namespace
  Object.send(:include, Cyberweb)
  require 'cyberweb/predefined_and_freeform_methods/predefined_methods.rb'
  Object.send(
    :include, Cyberweb::PredefinedMethods
  )
  # ======================================================================= #
  # The next line was added in March 2022.
  # ======================================================================= #
  Object.send(
    # :include, Cyberweb::Objectified::Mask
    :include, Cyberweb::Objectified::ShorterHelperMethods # And changed in July 2023.
  )
end

#encoding_to_use?Boolean Also known as: main_encoding?, use_which_encoding?

#

encoding_to_use?

#

Returns:

  • (Boolean)


5482
5483
5484
# File 'lib/cyberweb/html_template/html_template.rb', line 5482

def encoding_to_use?
  @internal_hash[:encoding_to_use]
end

#english_html_commentObject

#

english_html_comment

#


1399
1400
1401
# File 'lib/cyberweb/html_template/html_template.rb', line 1399

def english_html_comment
  add_html_comment("\nThis website is making use of english.")
end

#english_unicode_and_english_html_commentObject

#

english_unicode_and_english_html_comment

This is a slight misnomer, but we’ll keep it nonetheless.

#


1408
1409
1410
# File 'lib/cyberweb/html_template/html_template.rb', line 1408

def english_unicode_and_english_html_comment
  english_html_comment
end

#english_unicode_and_jqueryObject

#

english_unicode_and_jquery

#


1302
1303
1304
1305
# File 'lib/cyberweb/html_template/html_template.rb', line 1302

def english_unicode_and_jquery
  do_use_jquery
  english_trinity
end

#escape_html(i) ⇒ Object Also known as: htmlsanitize, return_htmlentities, return_htmlsanitized, html_ready, html_escape, htitties

#

escape_html

Simply delegate towards the class-method here.

#


5303
5304
5305
# File 'lib/cyberweb/html_template/html_template.rb', line 5303

def escape_html(i)
  htmlescape(i)
end

#external_javascript_file(i) ⇒ Object Also known as: external_script, javascript_file

#

external_javascript_file

#


1002
1003
1004
1005
1006
# File 'lib/cyberweb/html_template/html_template.rb', line 1002

def external_javascript_file(i)
  i = i.to_s
  @internal_hash[:javascript_code] <<
    N+load_this_external_javascript_file(i) # This is in javascript.rb
end

#favicon_scannerObject Also known as: scanner_favicon

#

favicon_scanner

#


5550
5551
5552
# File 'lib/cyberweb/html_template/html_template.rb', line 5550

def favicon_scanner
  favicon :scanner
end

#fetch_css_classes(i = CSS_DIRECTORY) ⇒ Object

#

fetch_css_classes

Use this method to find matching entries. Invoke it at the end after loading your web object. It will then return an array with your css class (which you can then inject).

Usage example:

w.fetch_css_classes
w.print_this_css(web_object.fetch_css_classes)
#


1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
# File 'lib/cyberweb/html_template/html_template.rb', line 1909

def fetch_css_classes(
    i = CSS_DIRECTORY
  )
  array_collection = []
  these_classes_exist = Cyberweb.found_these_css_classes
  # ======================================================================= #
  # For the following code to work, CSS_DIRECTORY must obviously exist.
  # This constant will refer to the css classes that are part of Cyberweb.
  # ======================================================================= #
  Dir.foreach(i) {|file|
    next if File.directory?(file)
    if File.exist? css_dir+'/'+file
      _ = readlines(css_dir+'/'+file)
      _.each {|line|
        these_classes_exist.each { |entry|
          array_collection << line if line.include? entry and line =~ /^\.#{entry} /
        }
      }
    end
  }
  return array_collection
end

#files_from(from = return_pwd, include_subdirectories = false) ⇒ Object

#

files_from

This method will obtain all files from a given (sub)directory.

#


1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
# File 'lib/cyberweb/html_template/html_template.rb', line 1026

def files_from(
    from                   = return_pwd,
    include_subdirectories = false
  )
  case include_subdirectories
  # ======================================================================= #
  # === :do_include_the_subdirectories
  # ======================================================================= #
  when :do_include_the_subdirectories
    include_subdirectories = true
  end
  if from.frozen?
    from = from.dup
  end
  unless from.end_with? '*'
    from << '/' unless from.end_with? '/'
  end
  from << '*' unless from.end_with? '*'
  if include_subdirectories
    from << '*/**'
  end
  return Dir[from].reject {|entry| File.directory? entry }
end

#font_family=(i = 'sans-serif') ⇒ Object

#

font_family

Use this method to set a specific font family.

#


3551
3552
3553
3554
3555
3556
3557
3558
3559
# File 'lib/cyberweb/html_template/html_template.rb', line 3551

def font_family=(
    i = 'sans-serif'
  )
  append_onto_the_main_CSS_rules(
    return_this_css_style(
      "body { font-family: #{i}; }\n"
    )
  )
end

#frameset(i, &block) ⇒ Object

#

frameset

Shell out towards frameset().

#


5218
5219
5220
5221
# File 'lib/cyberweb/html_template/html_template.rb', line 5218

def frameset(i, &block)
  disable_body_tag
  Cyberweb.frameset(i, &block) # Call the other method. Where is this?
end

#german_trinityObject Also known as: use_unicode_german_and_jquery, trinity_german, trinity

#

german_trinity

This variant specifically does NOT force the use of jquery since as of May 2021. If you want to force jquery, use the method called german_unicode_and_jquery() instead.

Strictly speaking the word “trinity” is thus no longer correct, but for the time being it will be retained.

#


1441
1442
1443
1444
# File 'lib/cyberweb/html_template/html_template.rb', line 1441

def german_trinity
  german_unicode_and_german_html_comment
  # add_relevant_meta_entries(:ignore_checks)
end

#german_unicodeObject

#

german_unicode (german unicode tag, german_unicode tag)

This method simply combines use_german() and use_unicode().

#


1294
1295
1296
1297
# File 'lib/cyberweb/html_template/html_template.rb', line 1294

def german_unicode
  use_german
  use_unicode
end

#german_unicode_and_german_html_commentObject

#

german_unicode_and_german_html_comment

#


1361
1362
1363
1364
# File 'lib/cyberweb/html_template/html_template.rb', line 1361

def german_unicode_and_german_html_comment
  german_unicode # This method essentially bundles "use_german" and "use_unicode".
  add_html_comment("\nThis website is making use of german.")
end

#german_unicode_and_jqueryObject Also known as: german_unicode_jquery, use_jquery_german_and_unicode

#

german_unicode_and_jquery

This convenience method will enable german language layout for a webpage, jquery-drag-and-drop support, as well as declare that the page at hand uses unicode characters (and thus needs support for unicode).

#


1492
1493
1494
1495
# File 'lib/cyberweb/html_template/html_template.rb', line 1492

def german_unicode_and_jquery
  do_use_jquery
  german_trinity
end

#get_all_files_from(this_directory = return_pwd) ⇒ Object

#

get_all_files_from

#


1840
1841
1842
1843
1844
1845
1846
1847
# File 'lib/cyberweb/html_template/html_template.rb', line 1840

def get_all_files_from(
    this_directory = return_pwd
  )
  all_files = Dir["#{this_directory}/**/**"].select {|entry|
    File.file?(entry)
  }.map {|inner_entry| inner_entry.squeeze('/') }
  return all_files
end

#get_images(from_this_dir = return_pwd) ⇒ Object Also known as: get_images_from, return_all_images_from

#

get_images

This method will obtain all files from all subdirectories there as well.

#


3861
3862
3863
3864
3865
3866
3867
# File 'lib/cyberweb/html_template/html_template.rb', line 3861

def get_images(
    from_this_dir = return_pwd
  )
  Dir["#{from_this_dir}/**/**"].select {|entry|
    Cyberweb.is_an_image?(entry)
  }
end

#gleichgewichtObject Also known as: chem_gleichgewicht

#

gleichgewicht

#


3136
3137
3138
# File 'lib/cyberweb/html_template/html_template.rb', line 3136

def gleichgewicht
  ''
end

#glossar_table(*use_this_dataset, &block) ⇒ Object Also known as: glossar, table_for_glossar

#

glossar_table

This method can also be invoked via a block argument such as:

{{
  css_class: 'mart1em'
}}
#


4599
4600
4601
4602
4603
4604
4605
4606
4607
4608
4609
4610
4611
4612
4613
4614
4615
4616
4617
4618
4619
4620
4621
4622
4623
4624
4625
4626
4627
# File 'lib/cyberweb/html_template/html_template.rb', line 4599

def glossar_table(
    *use_this_dataset,
    &block
  )
  use_this_dataset.flatten!
  use_this_dataset.compact!
  use_these_css_classes = 'pad0_5em pretty_table'
  # ======================================================================= #
  # === Handle blocks next
  # ======================================================================= #
  if block_given?
    yielded = yield
    # ===================================================================== #
    # === Handle Hashes next
    # ===================================================================== #
    if yielded.is_a? Hash
      # =================================================================== #
      # === :css_class
      # =================================================================== #
      if yielded.has_key? :css_class
        use_these_css_classes = use_these_css_classes.dup if use_these_css_classes.frozen?
        use_these_css_classes << " #{yielded.delete(:css_class)}"
      end
    end
  end
  table2(use_these_css_classes,'glossar') {{
    with_this_data: use_this_dataset
  }}
end

#handle_these_calls(&block) ⇒ Object

#

handle_these_calls

#


3820
3821
3822
3823
3824
3825
3826
3827
3828
# File 'lib/cyberweb/html_template/html_template.rb', line 3820

def handle_these_calls(&block)
  # ======================================================================= #
  # Delegate the block given to this class here, so that we can handle
  # method calls properly.
  # ======================================================================= #
  if block_given?
    instance_exec(&block)
  end
end

#hide_scrollbarsObject Also known as: disable_scrollbars

#

hide_scrollbars

This method can be used to hide the scrollbars, by using CSS.

I do not recommend to use it, but it exists mostly due to convenience - and perhaps the user may have a real use case for this, such as browser-kiosk mode, or something similar.

The idea I had when reading this description:

https://www.w3schools.com/howto/howto_css_hide_scrollbars.asp
#


3789
3790
3791
3792
3793
# File 'lib/cyberweb/html_template/html_template.rb', line 3789

def hide_scrollbars
  append_this_to_the_body_css '
    overflow: hidden; /* Hide scrollbars */
  '
end

#hr(optional_css_class = '') ⇒ Object

#

hr (hr tag)

Usage example:

hr('gold wid80')
#


3928
3929
3930
3931
3932
3933
3934
# File 'lib/cyberweb/html_template/html_template.rb', line 3928

def hr(
    optional_css_class = ''
  )
  append_onto_the_body_tag_nl(
    "<hr#{css_class_or_no_class(optional_css_class)}>"
  )
end

#hr_starsObject Also known as: star_spacer, fancy_stars, pretty_spacer, pretty_stars, pretty_star, pretty_hsep, pretty_separator

#

hr_stars

This method call displays three stars in one row, if all goes well.

See this image for how this may look on the website:

https://i.imgur.com/moDx2f1.png
#


4780
4781
4782
4783
4784
# File 'lib/cyberweb/html_template/html_template.rb', line 4780

def hr_stars
  append_onto_the_body_tag_nl(
    Cyberweb.return_pretty_stars
  )
end

#hsepObject

#

hsep

#


2798
2799
2800
# File 'lib/cyberweb/html_template/html_template.rb', line 2798

def hsep
  return '<hr>'
end

#hspacer(optional_css_class = nil) ⇒ Object

#

hspacer

Usage example:

hspacer css_class: 'marb1em'
#


4800
4801
4802
4803
4804
# File 'lib/cyberweb/html_template/html_template.rb', line 4800

def hspacer(
    optional_css_class = nil
  )
  spacer(:center, optional_css_class)
end

#html_title?(i = web_title? ) ⇒ Boolean

#

html_title?

This will return a proper <title> tag.

#

Returns:

  • (Boolean)


5669
5670
5671
5672
5673
# File 'lib/cyberweb/html_template/html_template.rb', line 5669

def html_title?(
    i = web_title?
  )
  HtmlTags.title(i.to_s) { :newline }
end

#htmlescape(i) ⇒ Object Also known as: htmlentities, hescape, htmltitties

#

htmlescape

#


5315
5316
5317
# File 'lib/cyberweb/html_template/html_template.rb', line 5315

def htmlescape(i)
  return Cyberweb.escape_html(i)
end

#id_or_no_id(i = '', optional_url = nil) ⇒ Object

#

id_or_no_id

The second argument is in particular used for draggable images.

#


2828
2829
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
2851
2852
2853
2854
2855
2856
# File 'lib/cyberweb/html_template/html_template.rb', line 2828

def id_or_no_id(
    i            = '',
    optional_url = nil
  )
  if i.is_a?(Hash) and i.has_key?(:id)
    i = i.delete(:id)
  end
  unless i.to_s.empty?
    case i
    # =============================================================== #
    # === :guess_draggable_id
    # =============================================================== #
    when :guess_draggable_id
      i = 'drag_'+File.basename(optional_url).
          gsub(File.extname(optional_url),'')
    end
    i = i.to_s
    # ===================================================================== #
    # We enable drag-support next. Keep in mind that the input can be
    # a symbol such as :drag, so we must check for that leading
    # string.
    # ===================================================================== #
    if i.start_with?('drag')
      register_this_id(i)
    end
    i = " id=\"#{i}\""
  end
  return i
end

#in_file(this_file) ⇒ Object

#

in_file

#


4207
4208
4209
4210
# File 'lib/cyberweb/html_template/html_template.rb', line 4207

def in_file(this_file)
  e dot(102, 'marr6px')+this_file,
    'orange BO'
end

#in_ruby(i, make_newline = true) ⇒ Object

#

in_ruby

This method can be used to quickly indicate how syntax should be shown in ruby. Note that this is currently hardcoded to german.

#


3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
3163
# File 'lib/cyberweb/html_template/html_template.rb', line 3153

def in_ruby(
    i,
    make_newline = true
  )
  result = sg(:ruby,'marr8px')+
           '<b>In Ruby wäre dies: </b>'+
           string_s2(i,'darkblue BOLD')
  result = result.dup
  result.prepend('<br>') if make_newline
  e result, 'italic darkgreen'
end

#inject_this_onto_that(this, that) ⇒ Object

#

inject_this_onto_that

This method has been added specifically for UniversalWidgets support.

It is highly experimental as of September 2021.

#


5183
5184
5185
5186
5187
5188
5189
5190
# File 'lib/cyberweb/html_template/html_template.rb', line 5183

def inject_this_onto_that(
    this,
    that
  )
  position = that.to_s.index('</div>')
  that[position,0] = this
  return that
end

#input(type = :submit, default_value = '', css_class = Input.to_s, name_to_use = '', css_style = '', accesskey = '', my_javascript = '', id = nil, hash = {}, &block) ⇒ Object

#

input (input tag)

Note that some values are ignored for now.

#


6243
6244
6245
6246
6247
6248
6249
6250
6251
6252
6253
6254
6255
6256
6257
6258
6259
6260
6261
6262
6263
# File 'lib/cyberweb/html_template/html_template.rb', line 6243

def input(
    type          = :submit,    # (1) type
    default_value = '',         # (2) default value
    css_class     = Input.to_s, # (3) css class
    name_to_use   = '',         # (4) name to use
    css_style     = '',         # (5) css style
    accesskey     = '',         # (6) accesskey
    my_javascript = '',         # (7) javascript
    id            = nil,        # (8) id
    hash          = {},         # (9) an additional hash
    &block
  )
  append_onto_the_body_tag_nl(
    HtmlTags.input(
      type:       type,
      value:      default_value,
      css_class:  css_class,
      javascript: my_javascript
    )
  )
end

#is_a_sinatra_applicationObject Also known as: enable_sinatra_application, is_a_rack_application

#

is_a_sinatra_application

Setter method to designate a given application as a sinatra-application.

#


5566
5567
5568
5569
# File 'lib/cyberweb/html_template/html_template.rb', line 5566

def is_a_sinatra_application
  @internal_hash[:is_a_sinatra_application] = true
  do_use_base64_for_all_images # Trying this since as of May 2023.
end

#is_a_sinatra_application?Boolean Also known as: uses_sinatra?, are_we_using_sinatra?, is_sinatra?

#

is_a_sinatra_application?

This method is necessary to support sinatra-applications as well.

#

Returns:

  • (Boolean)


2718
2719
2720
# File 'lib/cyberweb/html_template/html_template.rb', line 2718

def is_a_sinatra_application?
  @internal_hash[:is_a_sinatra_application]
end

#is_localhost?Boolean

#

is_localhost?

#

Returns:

  • (Boolean)


5209
5210
5211
# File 'lib/cyberweb/html_template/html_template.rb', line 5209

def is_localhost?
  return ('127.0.0.1' == Cyberweb::YOUR_IP)
end

#italic(content = '', optional_css_class = '', optional_the_id = '', optional_css_style = '', &block) ⇒ Object Also known as: i

#

italic (italic tag)

This method makes the content (the first argument) italic, that is the font-style is italic for that particular content.

#


4156
4157
4158
4159
4160
4161
4162
4163
4164
4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
4179
4180
4181
# File 'lib/cyberweb/html_template/html_template.rb', line 4156

def italic(
    content            = '',
    optional_css_class = '',
    optional_the_id    = '',
    optional_css_style = '',
    &block
  )
  if optional_css_class.frozen?
    optional_css_class = optional_css_class.dup
  end
  unless optional_css_class.include? ' italic'
    optional_css_class << ' italic'
  end
  append_onto_the_body_tag_nl(
    '<span'+
    css_class_or_no_class(optional_css_class)+
    id_or_no_id(optional_the_id)+
    css_style_or_no_style(optional_css_style)+
    '>'
  )
  append_onto_the_body_tag_nl(content)
  if block_given?
    yield
  end
  close :span
end

#javascript_code?Boolean Also known as: javascript?

#

javascript_code?

Query-method over the javascript-code that is to be added onto the webpage at hand.

#

Returns:

  • (Boolean)


978
979
980
# File 'lib/cyberweb/html_template/html_template.rb', line 978

def javascript_code?
  @internal_hash[:javascript_code]
end

#javascript_file=(i) ⇒ Object Also known as: link_in_javascript, load_javascript

#

javascript_file=

A wrapper towards cyberweb.rb and javascript_file() method.

Usage example:

w.javascript_file = :fader
#


1121
1122
1123
1124
# File 'lib/cyberweb/html_template/html_template.rb', line 1121

def javascript_file=(i)
  _ = "#{javascript_file(i.dup)}#{N}"
  @internal_hash[:javascript_code] << _
end

#javascript_script=(i) ⇒ Object Also known as: javascript_in_head_tag, addnl_javascript_code

#

javascript_script=

This method assigns to the @javascript variable. We expect it to hold strings related to javascript-code.

#


3949
3950
3951
3952
3953
3954
# File 'lib/cyberweb/html_template/html_template.rb', line 3949

def javascript_script=(i)
  if @internal_hash[:javascript_code].frozen?
    @internal_hash[:javascript_code] = @internal_hash[:javascript_code].dup
  end
  @internal_hash[:javascript_code] << return_javascript(i) # Tap into javascript/ subdirectory.
end

#jquery(i = '+') ⇒ Object

#

jquery

An alias to enabling the use of jquery on a website, through the method call do_use_jquery().

#


1133
1134
1135
1136
# File 'lib/cyberweb/html_template/html_template.rb', line 1133

def jquery(i = '+')
  i = i.to_s # We definitely do want a String here.
  do_use_jquery if i == '+'
end

#jquery_version?Boolean Also known as: this_jquery_version

#

jquery_version?

This method will always return the latest jquery version to use.

It will query a toplevel method for this, rather than storing this internally.

#

Returns:

  • (Boolean)


3269
3270
3271
# File 'lib/cyberweb/html_template/html_template.rb', line 3269

def jquery_version?
  Cyberweb.jquery_version? # Ought to be a String, always.
end

#label(i) ⇒ Object

#

label (label tag)

This may look like so:

<label for="male">Male</label><br>
#


5587
5588
5589
5590
5591
# File 'lib/cyberweb/html_template/html_template.rb', line 5587

def label(i)
  append_onto_the_body_content_newline(
    "<label>#{i}</label>"
  )
end

#language(which_language = nil) ⇒ Object Also known as: set_language

#

language

You can use this method to specify a certain language in order to use for the given web page. I tend to use this to remind myself in which language I shall write a web-page in, e. g. usually either in german, or more commonly these days, in english.

Invocation example:

language :english
#


5606
5607
5608
5609
5610
5611
5612
5613
5614
5615
5616
5617
5618
5619
5620
5621
5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
5633
# File 'lib/cyberweb/html_template/html_template.rb', line 5606

def language(
    which_language = nil
  )
  case which_language
  # ======================================================================= #
  # === eng
  # ======================================================================= #
  when 'eng',
       'e',
       'en',
       'default'
    which_language = 'english'
  # ======================================================================= #
  # === ger
  # ======================================================================= #
  when 'ger',
       'g',
       'ge',
       'german',
       'deutsch'
    which_language = 'german'
  end
  # ======================================================================= #
  # Since as of May 2023, the language that will be used will be kept
  # as a Symbol.
  # ======================================================================= #
  @internal_hash[:language_to_use_for_this_webpage] = which_language.to_sym
end

#language?Boolean

#

language?

Note that the default value is :english.

#

Returns:

  • (Boolean)


1427
1428
1429
# File 'lib/cyberweb/html_template/html_template.rb', line 1427

def language?
  @internal_hash[:language_to_use_for_this_webpage]
end

#larger_font_sizeObject

#

larger_font_size

This is for using a larger font-size. The exact value is derived from the file named “project_configuration.yml”.

#


6777
6778
6779
# File 'lib/cyberweb/html_template/html_template.rb', line 6777

def larger_font_size
  font_size(:larger_font_size)
end
#
#


6784
6785
6786
6787
# File 'lib/cyberweb/html_template/html_template.rb', line 6784

def larger_font_size_and_hyperlinks
  larger_font_size
  default_hyperlinks
end

#left_to_right_gradient(first_colour = :steelblue, second_colour = :lightgreen) ⇒ Object Also known as: gradient_left_to_right, left_to_right

#

left_to_right_gradient

This method is basically a wrapper over the CSS code for “background-image: linear-gradient(to bottom right …)

#


740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
# File 'lib/cyberweb/html_template/html_template.rb', line 740

def left_to_right_gradient(
    first_colour  = :steelblue,
    second_colour = :lightgreen
  )
  _ = "
.main_background_gradient {
background-image: linear-gradient(to bottom right, #{first_colour}, #{second_colour});
background-repeat: no-repeat;
background-attachment: fixed;
}\n"
  add_to_CSS(_)
  # ======================================================================= #
  # We capture this in the main background gradient, via a special CSS
  # class.
  # ======================================================================= #
  append_onto_the_default_body_CSS_class('main_background_gradient')
end

#legend(content = '', optional_css_class = '', optional_the_id = '', optional_css_style = '', &block) ⇒ Object

#

legend

#


3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
3886
3887
3888
3889
3890
3891
3892
# File 'lib/cyberweb/html_template/html_template.rb', line 3873

def legend(
    content            = '',
    optional_css_class = '',
    optional_the_id    = '',
    optional_css_style = '',
    &block
  )
  append_onto_the_body_tag_nl(
    '<legend'+
    css_class_or_no_class(optional_css_class)+
    id_or_no_id(optional_the_id)+
    css_style_or_no_style(optional_css_style)+
    '>'
  )
  append_onto_the_body_tag_nl(content)
  if block_given?
    yield
    clegend
  end
end

#less_than_or_equalObject Also known as: kleiner_gleich

#

less_than_or_equal

#


4872
4873
4874
# File 'lib/cyberweb/html_template/html_template.rb', line 4872

def less_than_or_equal
  ''
end

#linear_gradient_background(degree_to_use = (0..180).to_a.sample.to_s+'deg', colour1 = random_colour, colour2 = random_colour, colour3 = random_colour) ⇒ Object

#

linear_gradient_background

Usage examples:

linear_gradient_background(90, :steelblue, :darkgreen, :tomato)
linear_gradient_background(90, :steelblue, :darkgreen, :royalblue)
#


704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
# File 'lib/cyberweb/html_template/html_template.rb', line 704

def linear_gradient_background(
    degree_to_use = (0..180).to_a.sample.to_s+'deg',
    colour1       = random_colour,
    colour2       = random_colour,
    colour3       = random_colour
  )
  degree_to_use = degree_to_use.to_s.dup
  unless degree_to_use.end_with? 'deg'
    degree_to_use << 'deg'
  end
  return 'background: linear-gradient('+
            degree_to_use+', '+
            colour1.to_s+', '+
            colour2.to_s+', '+
            colour3.to_s+
          ');'
end

#linux_faviconObject

#

linux_favicon

#


5497
5498
5499
# File 'lib/cyberweb/html_template/html_template.rb', line 5497

def linux_favicon
  favicon :linux_favicon
end

#map_symbol_to_image_location(i) ⇒ Object

#

map_symbol_to_image_location

#


5475
5476
5477
# File 'lib/cyberweb/html_template/html_template.rb', line 5475

def map_symbol_to_image_location(i)
  return Cyberweb::WebImages.map_symbol_to_image_location(i)
end

#markdown(i = '') ⇒ Object Also known as: markdown_display_this_file, read_and_display_markdown, show_md, display_markdown

#

markdown

#


3911
3912
3913
3914
3915
# File 'lib/cyberweb/html_template/html_template.rb', line 3911

def markdown(i = '')
  append_onto_the_body_tag_nl(
    Cyberweb.markdown(i)
  )
end

#mars1em(i = '') ⇒ Object

#

mars1em

#


2084
2085
2086
# File 'lib/cyberweb/html_template/html_template.rb', line 2084

def mars1em(i = '')
  e(i, 'mars1em')
end

#mars2em(i = '', optional_css_class = '') ⇒ Object

#

mars2em

#


2072
2073
2074
2075
2076
2077
2078
2079
# File 'lib/cyberweb/html_template/html_template.rb', line 2072

def mars2em(
    i                  = '',
    optional_css_class = ''
  )
  optional_css_class = optional_css_class.dup if optional_css_class.frozen?
  optional_css_class << ' mars2em'
  e(i, optional_css_class.squeeze(' '))
end

#mathml(optional_css_class = '') ⇒ Object Also known as: mathml_start

#

Cyberweb.mathml

This is a simplified way to use mathml in a webpage.

#


4912
4913
4914
4915
4916
4917
4918
# File 'lib/cyberweb/html_template/html_template.rb', line 4912

def mathml(
    optional_css_class = ''
  )
  append_onto_the_body_tag_nl(
    Cyberweb.mathml(optional_css_class)
  )
end

#meta_content?Boolean Also known as: meta_collection?

#

meta_content?

#

Returns:

  • (Boolean)


6472
6473
6474
# File 'lib/cyberweb/html_template/html_template.rb', line 6472

def meta_content?
  @internal_hash[:meta_content]
end

#n_steps_to_the_base_directory?Boolean Also known as: n_times_to_the_base_dir?

#

n_steps_to_the_base_directory?

#

Returns:

  • (Boolean)


5860
5861
5862
# File 'lib/cyberweb/html_template/html_template.rb', line 5860

def n_steps_to_the_base_directory?
  Cyberweb.n_slashes_towards_the_server_base_directory
end

#n_total_lines?Boolean Also known as: n_total_lines, n_lines?

#

n_total_lines?

How many lines we will serve.

#

Returns:

  • (Boolean)


2365
2366
2367
# File 'lib/cyberweb/html_template/html_template.rb', line 2365

def n_total_lines?
  @internal_hash[:n_total_lines]
end
#

This method assumingly sets the CSS rules towards “normal”, in regard to hyperlinks.

#


6369
6370
6371
6372
6373
6374
6375
6376
# File 'lib/cyberweb/html_template/html_template.rb', line 6369

def normal_hyperlinks
  append_to_CSS <<-EOF
a {
text-decoration: none;
}

EOF
end

#on_click_change_opacity(use_this_id = 'pic', which_opacity_value_to_use = '0.92') ⇒ Object Also known as: on_click_highlight, highlight_tag, highlight

#

on_click_change_opacity

#


3730
3731
3732
3733
3734
3735
3736
3737
3738
3739
# File 'lib/cyberweb/html_template/html_template.rb', line 3730

def on_click_change_opacity(
    use_this_id                = 'pic',
    which_opacity_value_to_use = '0.92'
  )
  append_onto_the_body_tag_nl(
    Cyberweb.return_on_click_change_opacity(
      use_this_id, which_opacity_value_to_use
    )
  )
end

#on_click_make_darker(this_id, opacity = '0.90') ⇒ Object

#

on_click_make_darker

#


3443
3444
3445
3446
3447
3448
3449
# File 'lib/cyberweb/html_template/html_template.rb', line 3443

def on_click_make_darker(
    this_id, opacity = '0.90'
  )
  append_onto_the_body_tag_nl(
    Cyberweb.on_click_make_darker(this_id, opacity)
  )
end

#on_hover_colour(i) ⇒ Object

#

on_hover_colour

This method can be used to quickly change the on-mouse-hover colour from HTML links.

#


2051
2052
2053
2054
2055
2056
2057
2058
# File 'lib/cyberweb/html_template/html_template.rb', line 2051

def on_hover_colour(i)
  append_onto_CSS(
    "a:hover {
      color: #{i};
    }
    "
  )
end

#onload_or_no_onload(i = body_javascript? ) ⇒ Object

#

onload_or_no_onload

#


2814
2815
2816
2817
2818
2819
2820
2821
# File 'lib/cyberweb/html_template/html_template.rb', line 2814

def onload_or_no_onload(
    i = body_javascript?
  )
  unless i.to_s.empty?
    i = " onload=\"#{i}\""
  end
  return i
end

#ordered_list(array = %w( cat dog parrot deer horse )) ⇒ Object

#

ordered_list

This method can be used to show an ordered list.

#


4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
# File 'lib/cyberweb/html_template/html_template.rb', line 4449

def ordered_list(
    array = %w( cat dog parrot deer horse )
  )
  _ = "<ol>\n".dup
  array.each {|this_entry|
    _ << "<li>#{this_entry}</li>\n"
  }
  _ << "</ol>\n\n"
  append_onto_the_body_tag_nl(_)
end

#original_input(type = :submit, default_value = '', css_class = Input.to_s, name_to_use = '', css_style = '', accesskey = '', my_javascript = '', id = nil, hash = {}, &block) ⇒ Object

#

original_input

This variant should be merged with the replacement method.

HTML defines the following input-types:

<input type="text">      Displays a single-line text input field
<input type="radio">     Displays a radio button (for selecting one of many choices)
<input type="checkbox">  Displays a checkbox (for selecting zero or more of many choices)
<input type="submit">    Displays a submit button (for submitting the form)
<input type="button">    Displays a clickable button

A button would look like this:

button = input(:button)

A form may look like this:

input_submit css_class: 'bblack1'
#


5911
5912
5913
5914
5915
5916
5917
5918
5919
5920
5921
5922
5923
5924
5925
5926
5927
5928
5929
5930
5931
5932
5933
5934
5935
5936
5937
5938
5939
5940
5941
5942
5943
5944
5945
5946
5947
5948
5949
5950
5951
5952
5953
5954
5955
5956
5957
5958
5959
5960
5961
5962
5963
5964
5965
5966
5967
5968
5969
5970
5971
5972
5973
5974
5975
5976
5977
5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
6011
6012
6013
6014
6015
6016
6017
6018
6019
6020
6021
6022
6023
6024
6025
6026
6027
6028
6029
6030
6031
6032
6033
6034
6035
6036
6037
6038
6039
6040
6041
6042
6043
6044
6045
6046
6047
6048
6049
6050
6051
6052
6053
6054
6055
6056
6057
6058
6059
6060
6061
6062
6063
6064
6065
6066
6067
6068
6069
6070
6071
6072
6073
6074
6075
6076
6077
6078
6079
6080
6081
6082
6083
6084
6085
6086
6087
6088
6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
6111
6112
6113
6114
6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
6127
6128
6129
6130
6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
6155
6156
6157
6158
6159
6160
6161
6162
6163
6164
6165
6166
6167
6168
6169
6170
6171
6172
6173
6174
6175
6176
6177
6178
6179
6180
6181
6182
6183
6184
6185
6186
6187
6188
6189
6190
6191
6192
6193
6194
6195
6196
6197
6198
6199
6200
6201
6202
6203
6204
6205
6206
6207
6208
6209
6210
6211
6212
6213
6214
6215
6216
6217
6218
6219
6220
6221
6222
6223
6224
6225
6226
6227
6228
6229
6230
6231
6232
6233
6234
6235
6236
# File 'lib/cyberweb/html_template/html_template.rb', line 5911

def original_input(
    type          = :submit,    # (1) type
    default_value = '',         # (2) default value
    css_class     = Input.to_s, # (3) css class
    name_to_use   = '',         # (4) name to use
    css_style     = '',         # (5) css style
    accesskey     = '',         # (6) accesskey
    my_javascript = '',         # (7) javascript
    id            = nil,        # (8) id
    hash          = {},         # (9) an additional hash
    &block
  )
  case css_class
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default
    css_class = Input.to_s
  end
  _ = ''.dup
  if type.is_a? Hash
    if type.has_key? :id
      id = type.delete(:id)
    end
    if type.empty?
      type = :text
    end
  end
  # ======================================================================= #
  # First, let's start to assemble our main string that we will return.
  # This must come before we handle anything else.
  # ======================================================================= #
  _ << '<input'
  # ======================================================================= #
  # === Handle blocks next, if given
  #
  # Check for block-supplied to the method. Note that this must come
  # before the call to return_css_class(), as the blocks passed into
  # this method may also modify the css-class in use.
  # ======================================================================= #
  if block_given?
    yielded = yield # yield the block here.
    case yielded
    # ===================================================================== #
    # === :select_on_click
    # ===================================================================== #
    when :select_on_click
      my_javascript = :select_on_click
    # ===================================================================== #
    # === :is_checked
    #
    # This variant is specifically for HTML checkboxes.
    # ===================================================================== #
    when :is_checked
      _ << ' checked="checked"'
    else
      # =================================================================== #
      # Handle Hashes next
      # =================================================================== #
      if yielded.is_a? Hash
        # ================================================================= #
        # === :css_class
        #
        # Handle situations like the following:
        #
        #   input_submit {{ css_class: 'bblack1' }}
        #
        # ================================================================= #
        if yielded.has_key? :css_class
          css_class = yielded.delete(:css_class)
        end
        # ================================================================= #
        # === :javascript_function
        #
        # This variant is for invoking a javascript-function.
        #
        # A simple example for this is the following:
        #
        #   javascript_function: 'msg("hello_world")'
        #
        # ================================================================= #
        if yielded.has_key? :javascript_function
          string = yielded.delete(:javascript_function).dup
          if string.include? '(' # Assume something like: msg("hello_world")
            splitted = string.split('(')
            function_to_call = splitted.first.to_s
            argument_to_use  = splitted[1 .. -1].join('(').
                               delete('()').to_s.delete('"')
            case function_to_call
            when 'msg'
              _ << '  onclick="window.alert(\''+argument_to_use+'\');"'
            end
          end
        # ================================================================= #
        # === :on_click_event
        # ================================================================= #
        elsif yielded.has_key? :on_click_event
          _ << ' onclick="'+yielded.delete(:on_click_event).to_s+'()"'
        end
        # ================================================================= #
        # === :text
        #
        # Handle situations like the following:
        #
        #   input_submit {{ text: 'submit' }}
        #
        # ================================================================= #
        if yielded.has_key? :text
          default_value = yielded.delete(:text)
        end
      end
    end
  end
  # ======================================================================= #
  # === Handle Hashes next, for the variable default_value
  #
  # Second, let's check if the second argument is a hash. We have to be
  # careful here: if the Hash contains a key called :text, then this
  # must be evaluated last.
  # ======================================================================= #
  if default_value.is_a? Hash
    # ===================================================================== #
    # === :css_class
    # ===================================================================== #
    if default_value.has_key? :css_class
      css_class = default_value.delete(:css_class)
    end
    # ===================================================================== #
    # === :accesskey
    # ===================================================================== #
    if default_value.has_key? :accesskey
      accesskey = default_value[:accesskey]
    end
    # ===================================================================== #
    # === :id
    #
    # Handle the :id entry. This will become id="" in HTML.
    # ===================================================================== #
    if default_value.has_key? :id
      id = default_value[:id].to_s # Keep it as a String.
    end
    # ===================================================================== #
    # === :name
    # ===================================================================== #
    if default_value.has_key? :name
      name_to_use = default_value.delete(:name)
    end
    # ===================================================================== #
    # === :text
    #
    # This should come last, or at the least very late.
    # ===================================================================== #
    if default_value.has_key? :text
      default_value = default_value.delete(:text)
    end
    if default_value.is_a?(Hash) and default_value.empty?
      default_value = 'Submit'
    end
  end
  case type.to_sym # case tag
  # ======================================================================= #
  # === :radio
  #
  # This variant will display a radio button. A radio button can be used
  # for selecting one of many choices.
  # ======================================================================= #
  when :radio
    _ << ' type="radio"'
  # ======================================================================= #
  # === :checkbox
  # ======================================================================= #
  when :checkbox
    _ << ' type="checkbox"'
  # ======================================================================= #
  # === :datetime
  # ======================================================================= #
  when :datetime
    _ << ' type="datetime-local"'
  # ======================================================================= #
  # === :month
  # ======================================================================= # 
  when :month
    _ << ' type="month"'
  # ======================================================================= #
  # === :week
  # ======================================================================= #
  when :week
    _ << ' type="week"'
  # ======================================================================= #
  # === :image
  # ======================================================================= #
  when :image,
       :img,
       :i
    _ << ' type="image"'
  # ======================================================================= #
  # === :button
  # ======================================================================= #
  when :button,
       :b
    _ << ' type="button"'
  # ======================================================================= #
  # === :hidden
  # ======================================================================= #
  when :hidden,
       :h
    _ << ' type="hidden"'
  # ======================================================================= #
  # === :submit
  # ======================================================================= #
  when :submit,
       :s
    _ << ' type="submit"'
  # ======================================================================= #
  # === :reset
  # ======================================================================= #
  when :reset,
       :r
    _ << ' type="reset"'
  # ======================================================================= #
  # === :text
  # ======================================================================= #
  when :text,
       :field,
       :default,
       :t
    _ << ' type="text"'
  # ======================================================================= #
  # === :file
  # ======================================================================= #
  when :file,
       :file_uploads,
       :upload,
       :file_dialogue,
       :f,
       :file_handle  # File uploads are handled here.
    _ << ' type="file"'
    id = 'input_file_upload' if id.nil?
  else
    _ = type.to_s+' was not found ...'+NL
  end
  # ======================================================================= #
  # Next, handle Symbol input given to css_class.
  #
  # This can be a Symbol such as:
  #
  #   :select_on_click
  #
  # or such as:
  #
  #   :focus_with_deepskyblue_background
  #
  # ======================================================================= #
  if css_class.is_a? Symbol
    case css_class # case tag
    when :select_on_click
      css_class = Input.to_s
      if my_javascript.empty? # If it is empty then we can populate it.
        my_javascript = :select_on_click
      end
    else
      # =================================================================== #
      # The next line will handle cases such as:
      #   :focus_with_yellow_background
      # =================================================================== #
      if css_class.to_s.start_with? 'focus_with'
        # ================================================================= #
        # Delegate towards class InputFocus next.
        # ================================================================= #
        input_focus = Cyberweb::InputFocus.new(css_class)
        add_css_style input_focus.string?
        css_class = input_focus.css_class?.dup
        # ================================================================= #
        # Keep in mind that the user may have set a default value for
        # a css class, via Input.set_css_class(). If this is the case
        # then we have to honour this setting and will simply append it.
        # ================================================================= #
        unless Cyberweb::Input.to_s.empty?
          css_class << N+Input.to_s.dup
        end
      end
    end
  end
  _ = _.dup if _.frozen?
  _ << css_class_or_no_class(css_class.to_s)
  _ << css_style_or_no_style(css_style)

  if name_to_use.is_a? Symbol # This is copy/paste of the above.
    case name_to_use
    when :select_on_click
      name_to_use = ''
      if my_javascript.empty? # If it is empty then we can populate it.
        my_javascript = :select_on_click
      end
    end
  end
  _ << return_the_name(name_to_use) unless name_to_use.to_s.empty?
  _ << return_accesskey(accesskey)
  if id
    if id.is_a? String
      _ << ' id="'+id.to_s+'"'
    end
  end
  my_javascript = sanitize_javascript(my_javascript)
  _ << " #{my_javascript}" unless my_javascript.empty?
  if default_value.is_a? Hash
    if default_value.has_key? :value
      _ << ' value="'+default_value[:value].to_s+'"'
    end
  else
    unless _.include?('value') 
      unless default_value.to_s.empty? # then add our default value
        _ << ' value="'+default_value.to_s+'"'
      end
    end
  end
  # ======================================================================= #
  # Next handle a possible hash-argument here.
  # ======================================================================= #
  if hash.is_a? Hash
    _ << ' size="'+hash[:size].to_s+'"' if hash[:size]
    _ << ' maxlength="'+hash[:max_length].to_s+'"' if hash[:max_length]
  end
  _ << " />#{NL}"
  append_onto_the_body_tag_nl(_)
end

#p(optional_css_class = '', the_id = '', optional_css_style = '', &block) ⇒ Object

#

p (p tag)

This method handles the creation of <p> tags ultimately.

#


3193
3194
3195
3196
3197
3198
3199
3200
3201
3202
3203
3204
3205
3206
3207
3208
3209
3210
3211
3212
3213
3214
3215
3216
3217
3218
3219
3220
3221
3222
3223
3224
3225
3226
3227
3228
3229
3230
3231
3232
3233
3234
3235
3236
3237
3238
3239
3240
3241
3242
3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
# File 'lib/cyberweb/html_template/html_template.rb', line 3193

def p(
    optional_css_class = '',
    the_id             = '',
    optional_css_style = '',
    &block
  )
  # ======================================================================= #
  # === Handle Hashes next
  # ======================================================================= #
  if optional_css_class.is_a? Hash
    # ===================================================================== #
    # === :id
    # ===================================================================== #
    if optional_css_class.has_key? :id
      the_id = optional_css_class.delete(:id)
    end
    # ===================================================================== #
    # === :css_style
    #
    # Must come before :css_class.
    # ===================================================================== #
    if optional_css_class.has_key? :css_style
      optional_css_style = optional_css_class.delete(:css_style)
    end
    # ===================================================================== #
    # === :css_class
    #
    # Must come after :id.
    # ===================================================================== #
    if optional_css_class.has_key? :css_class
      optional_css_class = optional_css_class.delete(:css_class)
    # ===================================================================== #
    # === :class
    # ===================================================================== #
    elsif optional_css_class.has_key? :class
      optional_css_class = optional_css_class.delete(:class)
    end
    if optional_css_class.is_a?(Hash) and
      optional_css_class.empty?
      optional_css_class = ''
    end
  end
  if optional_css_class.include? '#'
    # ===================================================================== #
    # Handle entries such as:
    #
    #   #ON_TEXT_SELECT_COLOUR_GREEN_BACKGROUND_COLOUR_BLUE
    #
    # next.
    # ===================================================================== #
    optional_css_class = check_this_css_class_for_select_rules(optional_css_class)
  end
  append_onto_the_body_with_newline(
    '<p'+
    css_class_or_no_class(optional_css_class)+
    id_or_no_id(the_id.to_s)+
    css_style_or_no_style(optional_css_style)+
    '>'
  )
  # ======================================================================= #
  # === Handle blocks next:
  # ======================================================================= #
  if block_given?
    yield
    append_onto_the_body_with_newline('</p>')
  end
end

#page_css_classesObject

#

return_css_style

This method will simply return the <style>CONTENT_HERE</style> variant.

#

page_css_classes



1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
# File 'lib/cyberweb/html_template/html_template.rb', line 1988

def return_css_style(
    i = main_CSS_rules?
  )
  if i.is_a? Hash
    _ = ''.dup
    i.each_pair {|key, value|
      _ << "#{key} = #{value};"
    }
    i = _
  end
  return Cyberweb::CssStyle.style(i) # This will do something such as"<style>\n\n</style>\n"
end

#parse_table(*args) ⇒ Object

#

parse_table

#


4507
4508
4509
4510
4511
# File 'lib/cyberweb/html_template/html_template.rb', line 4507

def parse_table(*args)
  append_onto_the_body_tag_nl(
    Cyberweb.parse_table(args)
  )
end

#parse_this_hash(hash) ⇒ Object

#

parse_this_hash (parse tag)

This method is very important, because it will parse the given Hash into constituent members.

#


2480
2481
2482
2483
2484
2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
2498
2499
2500
2501
2502
2503
2504
2505
2506
2507
2508
2509
2510
2511
2512
2513
2514
2515
2516
2517
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529
2530
2531
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579
2580
2581
2582
2583
2584
2585
2586
2587
2588
2589
2590
2591
2592
2593
2594
2595
2596
2597
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
# File 'lib/cyberweb/html_template/html_template.rb', line 2480

def parse_this_hash(
    hash
  )
  return unless hash.is_a?(Hash)
  # ======================================================================= #
  # === :css_style
  #
  # This entry point is for styling the web-object's css style.
  # ======================================================================= #
  if hash.has_key? :css_style
    append_these_CSS_rules(
      hash.delete(:css_style)
    )
  # ======================================================================= #
  # === :main_css
  # ======================================================================= #
  elsif hash.has_key? :main_css
    append_these_CSS_rules(hash.delete(:main_css))
  # ======================================================================= #
  # === :style
  # ======================================================================= #
  elsif hash.has_key? :style
    append_these_CSS_rules(hash.delete(:style))
  # ======================================================================= #
  # === :css_rules_to_use
  # ======================================================================= #
  elsif hash.has_key? :css_rules_to_use
    append_these_CSS_rules(hash.delete(:css_rules_to_use))
  end
  # ======================================================================= #
  # === :favicon
  #
  # This entry point exists to support favicons for the
  # HtmlTemplate.
  # ======================================================================= #
  if hash.has_key? :favicon
    set_favicon(hash.delete(:favicon))
  end
  # ======================================================================= #
  # === :title
  # ======================================================================= #
  if hash.has_key? :title
    set_use_this_title(hash.delete(:title))
  end
  # ======================================================================= #
  # === :body_css_style
  #
  # This entry point enables support for the <body> tag, in regards to
  # CSS rules.
  # ======================================================================= #
  if hash.has_key? :body_css_style
    set_body_css_style(hash.delete(:body_css_style))
  end
  # ======================================================================= #
  # === :body_css_class
  # ======================================================================= #
  if hash.has_key? :body_css_class
    set_body_css_class(hash.delete(:body_css_class))
  end
  # ======================================================================= #
  # === :font_size
  # ======================================================================= #
  if hash.has_key? :font_size
    set_font_size(hash.delete(:font_size))
  end
  # ======================================================================= #
  # === :body
  # ======================================================================= #
  if hash.has_key? :body
    set_body_content(hash.delete(:body))
  # ======================================================================= #
  # === :content
  #
  # This refers to the "content of the body".
  # ======================================================================= #
  elsif hash.has_key? :content
    set_body_content(hash.delete(:content))
  # ======================================================================= #
  # === :body_content
  #
  # This refers to the "content of the body".
  # ======================================================================= #
  elsif hash.has_key? :body_content
    set_body_content(hash.delete(:body_content))
  end
  # ======================================================================= #
  # === :css_classes
  # ======================================================================= #
  if hash.has_key? :css_classes
    @internal_hash[:use_only_these_CSS_classes] = hash.delete(:css_classes)
  # ======================================================================= #
  # === :use_these_css_classes
  #
  # This is a slightly longer "alias" to the above.
  # ======================================================================= #
  elsif hash.has_key? :use_these_css_classes
    @internal_hash[:use_only_these_CSS_classes] = hash.delete(:use_these_css_classes)
  # ======================================================================= #
  # === :css_class
  # ======================================================================= #
  elsif hash.has_key? :css_class
    @internal_hash[:use_only_these_CSS_classes] = hash.delete(:css_class)
  end
  # ======================================================================= #
  # === :javascript_code
  # ======================================================================= #
  if hash.has_key? :javascript_code
    @internal_hash[:javascript_code] = hash.delete(:javascript_code)
  # ======================================================================= #
  # === :javascript
  # ======================================================================= #
  elsif hash.has_key? :javascript
    @internal_hash[:javascript_code] = hash.delete(:javascript)
  end
  # ======================================================================= #
  # === :use_jquery
  # ======================================================================= #
  if hash.has_key? :use_jquery
    set_shall_we_use_jquery(hash.delete(:use_jquery))
  end
  # ======================================================================= #
  # === :special_actions
  #
  # This is special and must come last. We can, for example, use
  # this to read in a .html file and display that.
  # ======================================================================= #
  if hash.has_key? :special_actions
    @internal_hash[:special_actions] = hash.delete(:special_actions)
  end
end

#path?Boolean Also known as: fixed_path, converted_path, converted_path?

#

path?

Reader method for the @fixed_path variable, which stores the relative path to our LOCALHOST.

#

Returns:

  • (Boolean)


1015
1016
1017
# File 'lib/cyberweb/html_template/html_template.rb', line 1015

def path?
  Cyberweb.converted_path
end

#path_to_this_background_image(i = :parchment1) ⇒ Object

#

path_to_this_background_image

Usage examples:

path_to_this_background_image(:parchment1)
path_to_this_background_image(:parchment2)
#


643
644
645
646
647
648
649
650
651
# File 'lib/cyberweb/html_template/html_template.rb', line 643

def path_to_this_background_image(
    i = :parchment1
  )
  target = project_base_directory?+'images/background_images/'
  possible_files = Dir[target+i.to_s+'*']
  unless possible_files.empty?
    return possible_files.first
  end
end

#pi?Boolean

#

pi?

#

Returns:

  • (Boolean)


5202
5203
5204
# File 'lib/cyberweb/html_template/html_template.rb', line 5202

def pi?
  PI
end

#prepend_before_the_body_tag(i) ⇒ Object

#

prepend_before_the_body_tag

This method can be used to prepend content before the body tag.

Note that this will always prepend onto the very first position, so it is guaranteed to prepend to the start of the result String.

#


6665
6666
6667
# File 'lib/cyberweb/html_template/html_template.rb', line 6665

def prepend_before_the_body_tag(i)
  @internal_hash[:prepend_before_the_body_tag][0,0] = i
end

#prepend_doc_typeObject

#

prepend_doc_type

#


3127
3128
3129
3130
3131
# File 'lib/cyberweb/html_template/html_template.rb', line 3127

def prepend_doc_type
  @internal_hash[:result].prepend(
    "#{default_doc_type?}\n"
  )
end

#pull_in(i) ⇒ Object

#

pull_in

#


6830
6831
6832
# File 'lib/cyberweb/html_template/html_template.rb', line 6830

def pull_in(i)
  Object.send(:include, i)
end

#pull_in_the_jquery_moduleObject

#

pull_in_the_jquery_module

#


6837
6838
6839
6840
# File 'lib/cyberweb/html_template/html_template.rb', line 6837

def pull_in_the_jquery_module
  require 'cyberweb/jquery_module/jquery_module.rb'
  extend(Cyberweb::JqueryModule)
end

#quote(text, css_class = '', the_id = '', css_style = '') ⇒ Object

#

quote

#


2255
2256
2257
2258
2259
2260
2261
2262
2263
2264
# File 'lib/cyberweb/html_template/html_template.rb', line 2255

def quote(
    text,
    css_class = '',
    the_id    = '',
    css_style = ''
  )
  append_onto_the_body_tag_nl(
    Cyberweb.quote(text, css_class, the_id, css_style)
  )
end

#random_background_image_from(this_directory = Dir.pwd) ⇒ Object

#

random_background_image_from

#


656
657
658
659
660
661
662
663
664
# File 'lib/cyberweb/html_template/html_template.rb', line 656

def random_background_image_from(
    this_directory = Dir.pwd
  )
  sample = Dir[rds(this_directory+'/*')].sample.dup
  if sample.include? '/home/x/data/images'
    sample.sub!(Regexp.new('/home/x/data/images/'), '')
  end
  relative_background_image(sample)
end

#random_faviconObject

#

random_favicon

This method will be like set_favicon_string(), but we will randomly set to a specific favicon.

#


5389
5390
5391
# File 'lib/cyberweb/html_template/html_template.rb', line 5389

def random_favicon
  ::Cyberweb.random_favicon
end

#raw_favicon_string?Boolean Also known as: raw_favicon?, use_favicon?

#

raw_favicon_string?

#

Returns:

  • (Boolean)


2000
2001
2002
# File 'lib/cyberweb/html_template/html_template.rb', line 2000

def raw_favicon_string?
  @internal_hash[:favicon]
end

#raw_font_size?Boolean Also known as: current_font_size?

#

raw_font_size?

#

Returns:

  • (Boolean)


6760
6761
6762
# File 'lib/cyberweb/html_template/html_template.rb', line 6760

def raw_font_size?
  @internal_hash[:font_size]
end

#readonly_input(i = nil) ⇒ Object

#

readonly_input

Usage example:

readonly_input id: 'result_for_circle_calculations'
#


4928
4929
4930
4931
4932
4933
4934
4935
4936
4937
4938
4939
# File 'lib/cyberweb/html_template/html_template.rb', line 4928

def readonly_input(
    i = nil
  )
  _ = '<input type="text"'.dup
  if i and i.is_a? Hash
    if i.has_key?(:id)
      _ << ' id="'+i[:id].to_s+'"'
    end
  end
  _ << ' readonly>'
  append_onto_the_body_tag_nl(_)
end

#red(i = '') ⇒ Object

#

red

#


4478
4479
4480
4481
4482
# File 'lib/cyberweb/html_template/html_template.rb', line 4478

def red(i = '')
  append_onto_the_body_tag_nl(
    string_s2(i, 'red')
  )
end

#redirect_to(this_url = 'http://www.w3schools.com') ⇒ Object

#

redirect_to

The first argument to this method should be the URL to which we redirect visitors.

#


3810
3811
3812
3813
3814
3815
# File 'lib/cyberweb/html_template/html_template.rb', line 3810

def redirect_to(
    this_url = 'http://www.w3schools.com'
  )
  #'window.location.href = "'+this_url.to_s+'";'
  ejavascript 'window.location.replace("'+this_url.to_s+'");'
end

#renderObject Also known as: internal_render, generate_the_main_string, rebuild_the_main_string, rebuild_the_HTML_string, rebuild_main_string, build_up_the_html_string, primary_render

#

render (internal_render tag)

The render() method will build onto our :result variable. It will not modify other variables, such as via reset_the_body_content().

#


2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
# File 'lib/cyberweb/html_template/html_template.rb', line 2617

def render
  reset_the_result # Always reset the :result here.
  we_have_not_yet_served_the_web_content
  build_up_the_result
  if respond_to?(:check_syntax_then_compress_the_main_string_then_remove_newlines)
    # ===================================================================== #
    # This is only available for Cyberweb::WebObject instances.
    # ===================================================================== #
    check_syntax_then_compress_the_main_string_then_remove_newlines
  end
end

#repeat(which_tag = '<br>', how_many_times = '12') ⇒ Object

#

repeat

#


1852
1853
1854
1855
1856
1857
# File 'lib/cyberweb/html_template/html_template.rb', line 1852

def repeat(
    which_tag      = '<br>',
    how_many_times = '12'
  )
  return which_tag * how_many_times.to_i
end

#request_uri?Boolean

#

request_uri?

#

Returns:

  • (Boolean)


4299
4300
4301
# File 'lib/cyberweb/html_template/html_template.rb', line 4299

def request_uri?
  ENV['REQUEST_URI'].to_s
end

#resetObject

#

reset (reset tag)

#


112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
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
191
192
193
194
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
# File 'lib/cyberweb/html_template/html_template.rb', line 112

def reset
  super()
  infer_the_namespace
  try_to_require_rack
  # ======================================================================= #
  # === :use_jquery
  # ======================================================================= #
  pull_in_the_jquery_module # The jquery-module will always be included.
  reset_the_result
  reset_the_body_content
  # ======================================================================= #
  # === :js_files_to_load
  #
  # This variable is an Array at all times. It specifies which local
  # .js files are to be loaded.
  # ======================================================================= #
  @internal_hash[:js_files_to_load] = []
  # ======================================================================= #
  # === :use_local_CSS_files
  #
  # If the following variable is set to true then this class will use
  # local CSS files, as specified by a certain constant. These are
  # locally existing files with a .css file extension.
  #
  # Allowed values for this boolean value are "true" or "false".
  # ======================================================================= #
  @internal_hash[:use_local_CSS_files] = false
  # ======================================================================= #
  # === :additional_CSS_rules_to_use
  #
  # This variable will keep track of additional CSS rules that will be
  # added onto the HtmlTemplate object at hand.
  # ======================================================================= #
  @internal_hash[:additional_CSS_rules_to_use] = ''.dup
  # ======================================================================= #
  # === :use_only_these_CSS_classes
  # ======================================================================= #
  @internal_hash[:use_only_these_CSS_classes] = nil
  # ======================================================================= #
  # === :favicon
  #
  # By default we will not use a favicon. This is denoted by setting
  # the following variable to nil.
  # ======================================================================= #
  @internal_hash[:favicon] = nil
  # ======================================================================= #
  # === :n_total_lines
  #
  # Keep track how many lines we generated in total.
  # ======================================================================= #
  @internal_hash[:n_total_lines] = 0
  # ======================================================================= #
  # === :shall_we_use_jquery
  #
  # By default HtmlTemplate does NOT make use of jquery. This has to
  # be specifically requested.
  # ======================================================================= #
  @internal_hash[:shall_we_use_jquery] = false # We have to disable it initially.
  # ======================================================================= #
  # === :body_css_class
  #
  # The following variable will handle CSS classes for the <body> tag.
  # ======================================================================= #
  @internal_hash[:body_css_class] = nil
  # ======================================================================= #
  # === :body_id
  #
  # Populate the id of the <body> tag as an empty String.
  # ======================================================================= #
  @internal_hash[:body_id] = ''.dup
  # ======================================================================= #
  # === :body_css_style
  # ======================================================================= #
  @internal_hash[:body_css_style] = ''.dup
  # ======================================================================= #
  # === :relative_path
  # ======================================================================= #
  @internal_hash[:relative_path] = nil
  # ======================================================================= #
  # === :link_in_these_remote_CSS_files
  #
  # This Array can be used to link in remote .css files. The user can
  # add more .css files that way, by calling methods such as
  # add_this_remote_css_page().
  # ======================================================================= #
  @internal_hash[:link_in_these_remote_CSS_files] = []
  # ======================================================================= #
  # === :font_size
  # ======================================================================= #
  @internal_hash[:font_size] = '1.0em'
  # ======================================================================= #
  # === :already_served
  #
  # This variable keeps track whether we already served the webpage.
  # ======================================================================= #
  @internal_hash[:already_served] = false
  # ======================================================================= #
  # === :use_unicode
  #
  # Whether we want to make use of Unicode or not, in a given .cgi or
  # html page.
  # ======================================================================= #
  @internal_hash[:use_unicode] = true
  # ======================================================================= #
  # === :use_body_tag
  #
  # If this variable is false then we won't use the <body> tag.
  #
  # This is needed when we want to use framesets specifically.
  # ======================================================================= #
  @internal_hash[:use_body_tag] = true
  # ======================================================================= #
  # === :special_actions
  # ======================================================================= #
  @internal_hash[:special_actions] = nil
  # ======================================================================= #
  # === :prepend_before_the_body_tag
  # ======================================================================= #
  @internal_hash[:prepend_before_the_body_tag] = ''.dup
  # ======================================================================= #
  # === :append_after_the_closing_body_tag
  # ======================================================================= #
  @internal_hash[:append_after_the_closing_body_tag] = ''.dup
  # ======================================================================= #
  # === :javascript_code
  #
  # This variable can be used to add additional javascript code,
  # within <script></script> tags.
  #
  # Note that jquery is special and decoupled from this variable.
  # ======================================================================= #
  @internal_hash[:javascript_code] = nil
  # ======================================================================= #
  # === :body_javascript
  #
  # This is the JavaScript that will be appended onto the <body> tag.
  # ======================================================================= #
  @internal_hash[:body_javascript] = ''.dup
  # ======================================================================= #
  # Obtain which .js files have to be loaded. This is done via a
  # .yml file that is distributed by the cyberweb-gem. 
  # ======================================================================= #
  this_file = "#{project_directory?}yaml/js_files_to_load.yml"
  if File.exist? this_file
    @internal_hash[:js_files_to_load] = YAML.load_file(this_file)
  end
  # ======================================================================= #
  # === :is_a_sinatra_application
  #
  # If this is true then we are running a sinatra application; the custom
  # extension that I use in this case is .sinatra.
  # ======================================================================= #
  @internal_hash[:is_a_sinatra_application] = false
  # ======================================================================= #
  # === :frame_string
  #
  # The frame string. It is only rarely used these days, though.
  # ======================================================================= #
  @internal_hash[:frame_string] = ''.dup
  # ======================================================================= #
  # === :language_to_use_for_this_webpage
  #
  # This variable will keep track as to which language a website is
  # mostly written in. It defaults to english.
  #
  # Keep in mind that this is more of a "recommendation"; I myself use
  # websites that mix german with english, so it may not be 100%
  # correct to denote such a website as pure-language in either
  # of these two. Thus, assume it refers mostly to "the main
  # language" used on a website.
  # ======================================================================= #
  @internal_hash[:language_to_use_for_this_webpage] = :english
  # ======================================================================= #
  # === :meta_content
  #
  # If the following variable is non-empty, then this will be added
  # as the meta-content of the webpage at hand.
  #
  # This will be a String by default.
  # ======================================================================= #
  @internal_hash[:meta_content] = ''.dup
  # ======================================================================= #
  # === :show_the_lines
  #
  # If this variable is true then we will display the line number next
  # to the displayed text.
  # ======================================================================= #
  @internal_hash[:show_the_lines] = false
  # ======================================================================= #
  # === :counter_for_show_the_lines
  # ======================================================================= #
  @internal_hash[:counter_for_show_the_lines] = 0
  set_web_title(:default) # Setting the web-title should come fairly late here.
  # ======================================================================= #
  # We have to load the cyberweb-configuration if the image-directory
  # is not known. The next if-clause handles that situation.
  # ======================================================================= #
  if image_directory?.nil? or
     image_directory?.empty?
    load_the_configuration
    update_the_image_directory
  end
end

#reset_the_body_contentObject

#

reset_the_body_content

#


725
726
727
728
729
730
731
732
# File 'lib/cyberweb/html_template/html_template.rb', line 725

def reset_the_body_content
  # ======================================================================= #
  # === :body_content
  #
  # This variable will contain the body of the given HTML page at hand.
  # ======================================================================= #
  @internal_hash[:body_content] = ''.dup
end

#reset_the_resultObject

#

reset_the_result

#


2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
# File 'lib/cyberweb/html_template/html_template.rb', line 2199

def reset_the_result
  # ======================================================================= #
  # === :result
  #
  # This variable will initially be an empty String. It will eventually
  # contain the full HTML code for the webpage at hand. Thus, we can
  # also call this variable the main String of this class. It should
  # ideally be called very early on.
  #
  # All the HTML code, all CSS components and so forth will be stored
  # into this String. This String will become the one that is served to
  # the visitor by the web_object, such as as the result of a .cgi
  # page.
  # ======================================================================= #
  @internal_hash[:result] = ''.dup
end

#result?Boolean Also known as: to_html, main_string?, string?, string_that_is_to_be_served?, html_string?, to_s

#

result?

This method will return the instance-variable that will be served by the HtmlTemplate (or WebObject) instance at hand.

It is the very string that will be shown to the visitor of a webpage in question, containing the full HTML code.

#

Returns:

  • (Boolean)


2677
2678
2679
# File 'lib/cyberweb/html_template/html_template.rb', line 2677

def result?
  @internal_hash[:result]
end

#return_accesskey(accesskey = '') ⇒ Object

#

return_accesskeys

#


2373
2374
2375
2376
2377
# File 'lib/cyberweb/html_template/html_template.rb', line 2373

def return_accesskey(
    accesskey = ''
  )
  Cyberweb.return_accesskey(accesskey)
end

#return_assumed_javascriptObject

#

return_assumed_javascript

This method will ultimately yield a <script> tag, denoting the use of javascript.

#


1271
1272
1273
1274
1275
1276
1277
# File 'lib/cyberweb/html_template/html_template.rb', line 1271

def return_assumed_javascript
  _ = ''.dup
  if javascript_code?
    _ << HtmlTags.script(javascript_code?)
  end
  return _
end

#return_copy_to_clipboard_button(use_this_value = 'XXX', use_this_id = 'clipboard_button', hide_the_input_field = false, text_shown_on_the_button = 'Copy text', css_rules_for_the_button = '') ⇒ Object

#

return_copy_to_clipboard_button

The signature for this method must be synced with the method called .create_copy_to_clipboard_button().

#


3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706
3707
3708
3709
3710
3711
3712
3713
3714
3715
3716
3717
3718
3719
3720
3721
3722
3723
3724
3725
# File 'lib/cyberweb/html_template/html_template.rb', line 3696

def return_copy_to_clipboard_button(
    use_this_value           = 'XXX',
    use_this_id              = 'clipboard_button',
    hide_the_input_field     = false,
    text_shown_on_the_button = 'Copy text',
    css_rules_for_the_button = ''
  )
  _ = ''.dup
  use_this_id = use_this_id.to_s
  # ======================================================================= #
  # Next we will use an <input> element that will use the ID that was just
  # defined above.
  # ======================================================================= #
  if hide_the_input_field
    _ << '<input type="hidden" value="'+use_this_value.to_s+'" id="'+use_this_id+'">'
  else
    _ << '<input type="text" value="'+use_this_value.to_s+'" id="'+use_this_id+'">'
  end
  id_for_the_button = 'button_id_for_the_'+use_this_id
  # ======================================================================= #
  # Since as of November 2023, the following button will get an ID
  # assigned automatically.
  # ======================================================================= #
  _ << "\n"+'<button id="'+id_for_the_button.to_s+
       '" class="'+css_rules_for_the_button.to_s+
       '" onclick="copy_to_the_clipboard(\''+use_this_id+'\')">'+
       text_shown_on_the_button.to_s+
       '</button>'
  return _
end

#return_css_for_tetrisObject

#

return_css_for_tetris

This is the CSS that will be returned when we want to enable the small tetris-game that is distributed with the cyberweb project.

#


5371
5372
5373
# File 'lib/cyberweb/html_template/html_template.rb', line 5371

def return_css_for_tetris
  return Cyberweb.return_css_for_tetris
end

#return_css_styleObject

#

return_css_style

This method will return the full CSS style for the web-page at hand.

#


1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
# File 'lib/cyberweb/html_template/html_template.rb', line 1976

def return_css_style(
    i = main_CSS_rules?
  )
  if i.is_a? Hash
    _ = ''.dup
    i.each_pair {|key, value|
      _ << "#{key} = #{value};"
    }
    i = _
  end
  return Cyberweb::CssStyle.style(i) # This will do something such as"<style>\n\n</style>\n"
end

#return_default_javascriptObject

#

return_default_javascript

#


1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
# File 'lib/cyberweb/html_template/html_template.rb', line 1072

def return_default_javascript#(
  #  i = Cyberweb.converted_path_to_data # Disabled this line as of October 2022.
  #)
  # Cyberweb.return_default_javascript(i)
  _ = ''.dup
  # path_to_use = Cyberweb.converted_path_to_project_base_dir
  # path_to_use = Cyberweb.log_dir?+'javascript_code/'
  path_to_use = Cyberweb.converted_path_to_the_directory_containing_the_copied_javascript_files
  array = ARRAY_DEFAULT_JAVASCRIPT_LIBRARIES
  _ = ''.dup # This String will be returned.
  array.each {|entry|
   full_path = "#{path_to_use}#{entry}".dup
    _ << '<script src="'+full_path+'"'
    _ = _.ljust(48)
    _ << ' type="text/javascript"></script>'
    _ << NL
  }
  return _
end

#return_favicon_string(i = raw_favicon_string? ) ⇒ Object Also known as: favicon_string?, favicon_path, favicon?, favicon_path?

#

return_favicon_string

This will return the proper HTML variant for a favicon.

#


4348
4349
4350
4351
4352
# File 'lib/cyberweb/html_template/html_template.rb', line 4348

def return_favicon_string(
    i = raw_favicon_string?
  )
  '<link rel="icon" href="'+i.to_s+'">'+"\n"
end

#return_gradient(i) ⇒ Object Also known as: gradient, gradients

#

return_gradient (gradient tag)

This method will return the proper CSS rule for a gradient. It was added in August 2023.

#


908
909
910
911
# File 'lib/cyberweb/html_template/html_template.rb', line 908

def return_gradient(i)
  sanitized = i.to_s.downcase.tr(' ','_')+'_effect'
  return sanitized
end

#return_html_comment(i) ⇒ Object

#

return_html_comment

#


549
550
551
# File 'lib/cyberweb/html_template/html_template.rb', line 549

def return_html_comment(i)
  Cyberweb.html_comment(i)
end

#return_html_to_head_startObject

#

return_html_to_head_start

This method will delegate to a toplevel method and ultimately return a String such as:

"Content-type: text/html\n\n<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n"
#


5145
5146
5147
# File 'lib/cyberweb/html_template/html_template.rb', line 5145

def return_html_to_head_start
  Cyberweb.return_html_to_head_start
end

#return_javascript(i) ⇒ Object

#

return_javascript

This method would yield a String such as:

"\n<script>\n\nabc\n</script>\n"
#


1100
1101
1102
# File 'lib/cyberweb/html_template/html_template.rb', line 1100

def return_javascript(i)
  Cyberweb.return_javascript(i)
end

#return_omega_symbolObject Also known as: omega_symbol, omega

#

return_omega_symbol

This is for the greek symbol omega.

#


4226
4227
4228
# File 'lib/cyberweb/html_template/html_template.rb', line 4226

def return_omega_symbol
  return '&quot;Omega&quot;'
end

#return_omega_symbol_semanticsObject

#

return_omega_symbol_semantics

This will return the <math> tag.

#


3361
3362
3363
3364
3365
3366
3367
3368
# File 'lib/cyberweb/html_template/html_template.rb', line 3361

def return_omega_symbol_semantics
  return '<math xmlns="http://www.w3.org/1998/Math/MathML">
<semantics>
<mrow><mi>ω</mi></mrow>
<annotation encoding="application/x-tex">\omega</annotation>
</semantics>
</math>'
end

#return_stars(n_stars = 1, optional_css_class = '') ⇒ Object

#

return_stars

#


4416
4417
4418
4419
4420
4421
4422
4423
4424
4425
4426
4427
4428
4429
4430
4431
4432
4433
4434
4435
4436
4437
4438
4439
4440
4441
4442
# File 'lib/cyberweb/html_template/html_template.rb', line 4416

def return_stars(
    n_stars            = 1,
    optional_css_class = ''
  )
  case n_stars.to_s
  when '1'
    sg(:one_star, optional_css_class)
  when '2'
    sg(:two_stars, optional_css_class)
  when '3'
    sg(:three_stars, optional_css_class)
  when '4'
    sg(:four_stars, optional_css_class)
  when '5'
    sg(:five_stars, optional_css_class)
  when '1x'
    sg(:one_and_half_star, optional_css_class)
  when '2x'
    sg(:two_and_half_star, optional_css_class)
  when '3x'
    sg(:three_and_half_star, optional_css_class)
  when '4x'
    sg(:four_and_half_star, optional_css_class)
  when '5x'
    sg(:five_and_half_star, optional_css_class)
  end
end

#return_the_body_contentObject

#

return_the_body_content

This method will simply return the body-content.

#


5116
5117
5118
# File 'lib/cyberweb/html_template/html_template.rb', line 5116

def return_the_body_content
  return @internal_hash[:body_content] # .rstrip # Disabled the latter in August 2023.
end

#return_the_body_string(optional_css_class = , optional_the_id = , optional_css_style = , optional_body_javascript = body_javascript? ) ⇒ Object Also known as: return_the_body_tag, return_body_tag, string_body_start, start_the_body_tag

#

return_the_body_string

Note that this method will append a trailing newline.

#


5680
5681
5682
5683
5684
5685
5686
5687
5688
5689
5690
5691
5692
# File 'lib/cyberweb/html_template/html_template.rb', line 5680

def return_the_body_string(
    optional_css_class       = @internal_hash[:body_css_class],
    optional_the_id          = @internal_hash[:body_id],
    optional_css_style       = @internal_hash[:body_css_style],
    optional_body_javascript = body_javascript?
  )
  return '<body'+
          css_class_or_no_class(optional_css_class.to_s)+
          id_or_no_id(optional_the_id.to_s)+
          css_style_or_no_style(optional_css_style.to_s)+
          onload_or_no_onload(optional_body_javascript.to_s)+
          ">\n" # Add the trailing newline here.
end

#return_the_css_classes(css_classes = css_classes? ) ⇒ Object

#

return_the_css_classes

This method will identify the correct CSS class that should be used by the HtmlTemplate. It works on the assumption that the user only wants to use as little CSS as possible, rather than ALL local css files.

In order for this to work, the class must have been defined in one of the default .css files. And these files have to be found by ruby as well - otherwise the method will not work properly.

#


5249
5250
5251
5252
5253
5254
5255
5256
5257
5258
5259
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270
5271
5272
5273
5274
5275
5276
5277
5278
5279
5280
5281
5282
5283
5284
5285
5286
5287
5288
5289
5290
5291
5292
5293
5294
5295
5296
# File 'lib/cyberweb/html_template/html_template.rb', line 5249

def return_the_css_classes(
    css_classes = css_classes?
  )
  if css_classes
    css_classes = [css_classes].flatten.map {|entry|
      entry = entry.split(' ') if entry.include? ' '
      entry
    }.flatten
    _ = ''.dup
    css_content = ''.dup
    # ===================================================================== #
    # Obtain the various .css files next and store them in `css_content`
    # temporarily:
    # ===================================================================== #
    Dir["#{project_base_dir?}cascading_style_sheets/*.css"].each {|entry|
      css_content << "#{File.read(entry, encoding: 'UTF-8')}#{N}"
    }
    css_classes.each {|this_css_class|
      # ===================================================================== #
      # See: https://rubular.com/r/7LUM1vaN45GDQ6
      # ===================================================================== #
      use_this_regex =
        /(\.#{this_css_class}).+{(.+)}$/u # For unicode encoding.
      css_content =~ use_this_regex
      # ================================================================= #
      # else, since as of December 2021, try to read in from a .css
      # file if this one exists.
      # ================================================================= #
      assumed_path = "#{project_base_directory?}"\
                     "cascading_style_sheets/"\
                     "#{this_css_class}.css"
      if File.exist?(assumed_path)
        _ << File.read(assumed_path)
      else
        if $2
          _ << $1.to_s.ljust(15)+' { '+$2.to_s.lstrip.squeeze(' ')+' }'+N
        end
      end
    }
    if _.to_s.empty?
      return ''
    else # Return it next.
      return _
    end
  else
    ''
  end
end

#return_the_CSS_rules_from_the_local_CSS_files(i = Cyberweb::ARRAY_LOCAL_CSS_FILES) ⇒ Object

#

return_the_CSS_rules_from_the_local_CSS_files

This method will simply return all local .css files.

The term “local” refers to the .css files that come distributed via the cyberweb gem by default.

Since as of November 2021 this can be controlled by the user, whether the .css files are added or whether they are not added.

#


2311
2312
2313
2314
2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
# File 'lib/cyberweb/html_template/html_template.rb', line 2311

def return_the_CSS_rules_from_the_local_CSS_files(
    i = Cyberweb::ARRAY_LOCAL_CSS_FILES
  )
  css_rules = ''.dup
  i.each {|this_CSS_file|
    target = "#{PROJECT_CSS_DIRECTORY}#{this_CSS_file}"
    # ===================================================================== #
    # Append the content of these .css style-sheets as-is.
    # ===================================================================== #
    if File.exist? target
      css_rules << "#{File.read(target, encoding: use_which_encoding?)}\n" # Append a trailing newline here.
    end
  }
  return css_rules
end

#return_the_doctype(optional_language = language? ) ⇒ Object Also known as: return_doctype

#

return_the_doctype

#


6400
6401
6402
6403
6404
# File 'lib/cyberweb/html_template/html_template.rb', line 6400

def return_the_doctype(
    optional_language = language?
  )
  doctype?(optional_language)
end

#return_the_id(the_id = '') ⇒ Object Also known as: turn_into_html_id

#

return_the_id

#


4668
4669
4670
4671
4672
4673
4674
# File 'lib/cyberweb/html_template/html_template.rb', line 4668

def return_the_id(
    the_id = ''
  )
  append_onto_the_body_tag_nl(
    Cyberweb.return_the_id(the_id)
  )
end

#return_the_jquery_stringObject

#

return_the_jquery_string

#


5102
5103
5104
5105
5106
5107
5108
5109
# File 'lib/cyberweb/html_template/html_template.rb', line 5102

def return_the_jquery_string
  # ======================================================================= #
  # We have to attach the jquery string next:
  # ======================================================================= #
  return return_html_comment("Adding support for jquery (version: #{jquery_version?}) next:")+
         "\n"+
         Cyberweb.return_jquery_string
end

#return_this_css_styleObject

#

return_css_style

This method will simply return the <style>CONTENT_HERE</style> variant.

#

return_this_css_style



1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
# File 'lib/cyberweb/html_template/html_template.rb', line 1987

def return_css_style(
    i = main_CSS_rules?
  )
  if i.is_a? Hash
    _ = ''.dup
    i.each_pair {|key, value|
      _ << "#{key} = #{value};"
    }
    i = _
  end
  return Cyberweb::CssStyle.style(i) # This will do something such as"<style>\n\n</style>\n"
end

#return_this_default_javascript_file(i) ⇒ Object

#

return_this_default_javascript_file

This method will ultimately return the path to a .js file that is distributed in the cyberweb project.

This method will not check whether the file exists, so you may have to do the checking by yourself, if you need it.

#


1210
1211
1212
1213
1214
1215
1216
1217
# File 'lib/cyberweb/html_template/html_template.rb', line 1210

def return_this_default_javascript_file(i)
  base_path = File.absolute_path("#{project_base_dir?}/javascript_code/")+'/'
  unless i.end_with? '.js'
    i = i.dup if i.frozen?
    i << '.js'
  end
  return "#{base_path}#{i}"
end

#rpg_faviconObject

#

rpg_favicon

#


5543
5544
5545
# File 'lib/cyberweb/html_template/html_template.rb', line 5543

def rpg_favicon
  favicon :rpg
end

#ruby_faviconObject

#

ruby_favicon

#


5490
5491
5492
# File 'lib/cyberweb/html_template/html_template.rb', line 5490

def ruby_favicon
  favicon :ruby_favicon
end

#runObject

#

run (run tag)

#


6633
6634
6635
# File 'lib/cyberweb/html_template/html_template.rb', line 6633

def run
  do_use_utf_charset
end

#s2(i = '', optional_css_class = '', optional_the_id = '', optional_css_style = '') ⇒ Object Also known as: espan, span

#

s2 (s2 tag)

This method ultimately adds a <span> tag at the position where it is called.

#


3171
3172
3173
3174
3175
3176
3177
3178
3179
3180
3181
3182
3183
3184
3185
# File 'lib/cyberweb/html_template/html_template.rb', line 3171

def s2(
    i                  = '',
    optional_css_class = '',
    optional_the_id    = '',
    optional_css_style = ''
  )
  append_onto_the_body_tag_nl(
    string_s2(
      i.to_s,
      optional_css_class,
      optional_the_id,
      optional_css_style
    )
  )
end

#science_faviconObject

#

science_favicon

#


5518
5519
5520
# File 'lib/cyberweb/html_template/html_template.rb', line 5518

def science_favicon
  favicon :science_favicon
end

#sclose(i) ⇒ Object

#

sclose

#


4088
4089
4090
# File 'lib/cyberweb/html_template/html_template.rb', line 4088

def sclose(i)
  "</#{i}>"
end

#set_additional_CSS_rules_to_use(i) ⇒ Object Also known as: set_css_style

#

set_additional_CSS_rules_to_use

#


5405
5406
5407
# File 'lib/cyberweb/html_template/html_template.rb', line 5405

def set_additional_CSS_rules_to_use(i)
  @internal_hash[:additional_CSS_rules_to_use] = i
end

#set_background(colour = 'black') ⇒ Object Also known as: background_colour, background_color, background_color=, background_colour=, background

#

set_background

Use this to set a specific background colour.

Usage example:

w.background = 'black'

Hmm doesn’t seem to work … odd.

#


677
678
679
680
681
682
683
684
685
686
687
688
689
# File 'lib/cyberweb/html_template/html_template.rb', line 677

def set_background(
    colour = 'black'
  )
  _ = 'body { '.dup
  case colour # Handle symbols here, since Jan 2014.
  when :scroll
    _ << ' background-attachment: scroll; ' 
  else
    _ << "background-color: #{colour};" # Handle cases such as :steelblue here.
  end
  _ << ' }'
  add_this_css_style(_)
end

#set_body_content(i) ⇒ Object

#

set_body_content

#


1862
1863
1864
1865
1866
1867
1868
1869
# File 'lib/cyberweb/html_template/html_template.rb', line 1862

def set_body_content(i)
  i = i.to_s unless i.is_a? String
  i = i.dup if i.frozen?
  unless i.end_with? "\n"
    i << "\n" # Trying this since as of August 2023.
  end
  @internal_hash[:body_content] = i
end

#set_body_css_class(i = '') ⇒ Object Also known as: body_css_class, body_css_class=, body_css_classes, body_css=, bcc=, bcc, main_body=, main_body, body=, body, b1=, b1

#

set_body_css_class

This method can be used to designate a (or several) css_class(es) in the <body> tag of a webpage.

#


2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
# File 'lib/cyberweb/html_template/html_template.rb', line 2018

def set_body_css_class(
    i = ''
  )
  case i
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default
    i = 'mar0px pad0px VERDANAs'
  end
  @internal_hash[:body_css_class] = i.to_s
end

#set_body_css_style(i) ⇒ Object Also known as: body_css, body_css_style, body_css_style=, body_style=, body_style, bcs=, bcs, css1=, css1

#

set_body_css_style

Use this to specify a css style for use in the <body> tag.

An example for this may be the following:

{ padding: 25em; }
#


5453
5454
5455
5456
5457
5458
5459
5460
5461
5462
# File 'lib/cyberweb/html_template/html_template.rb', line 5453

def set_body_css_style(i)
  # ======================================================================= #
  # Since as of Apr 2016, we get rid of all newlines too.
  # ======================================================================= #
  if i
    i = i.dup if i.frozen?
    i.delete!("\n") if i.include? "\n"
  end
  @internal_hash[:body_css_style] = i
end

#set_body_id(i = '') ⇒ Object Also known as: body_id, body_id=, id=, id

#

set_body_id (id tag)

This method can be used to set the body_id attribute.

#


5414
5415
5416
5417
# File 'lib/cyberweb/html_template/html_template.rb', line 5414

def set_body_id(i = '')
  i = i.tr(' ','_') if i.include?(' ')
  @internal_hash[:body_id] = i
end

#set_encoding_to_use(i = :default) ⇒ Object Also known as: charset

#

set_encoding_to_use

Set the specific encoding to use. In general, you may wish to use either UTF or ISO, I would guess.

#


1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
# File 'lib/cyberweb/html_template/html_template.rb', line 1313

def set_encoding_to_use(
    i = :default
  )
  case i.to_sym # case tag
  # ======================================================================= #
  # === :utf
  # ======================================================================= #
  when :utf,
       :default,
       1
    i = 'UTF-8'
  # ======================================================================= #
  # === :iso
  # ======================================================================= #
  when :iso,
       2
    i = 'ISO-8859-1'
  end
  # ======================================================================= #
  # For now, we store it as String, not Symbol.
  # ======================================================================= #
  i = i.to_s
  @internal_hash[:encoding_to_use] = i
end

#set_favicon(i = 'RPG/RPG_FAVICON.png') ⇒ Object Also known as: favicon=, favicon, fav=, fav, f=, f, set_favicon_string, print_favicon

#

set_favicon

This method will “enable” a favicon.

The first argument to this method should hold the (relative) path to our favicon icon.

You can also use a :symbol as first argument, which will be assumed to mean that we wish to use a certain webimage. This is mostly just useful on my home system, but in the future we may add more code support for flexibility in this regard, so that other users can integrate their own favicons more readily so.

Remember that the favicon comes between the <head> tag.

It may look like so:

<link rel="icon" type="image/png" href="/somewhere/myicon.png" />
#


2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
# File 'lib/cyberweb/html_template/html_template.rb', line 2421

def set_favicon(
    i = 'RPG/RPG_FAVICON.png'
  )
  i = Cyberweb::Favicon.path_of?(i)
  unless i.start_with? 'http' # Direct http-links are exempt from the next check.
    if respond_to? :return_path_to_the_images_directory
      i = "#{return_path_to_the_images_directory}#{i}"
    end
  end
  @internal_hash[:favicon] = i
end

#set_font_size(this_font_size = 'default') ⇒ Object Also known as: font_size=, font_size, use_this_font_size

#

set_font_size

Set the font size to use via this method.

Usage example for this:

w.font_size = '1.1em'
#


6679
6680
6681
6682
6683
6684
6685
6686
6687
6688
6689
6690
6691
6692
6693
6694
6695
6696
6697
6698
6699
6700
6701
6702
6703
6704
6705
6706
6707
6708
6709
6710
6711
6712
6713
6714
6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
6726
6727
6728
6729
6730
6731
6732
6733
6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
# File 'lib/cyberweb/html_template/html_template.rb', line 6679

def set_font_size(
    this_font_size = 'default'
  )
  # ======================================================================= #
  # We will work on Strings past the next point.
  # ======================================================================= #
  this_font_size = this_font_size.to_s.strip
  # ======================================================================= #
  # Remove leading 'FS' strings - at the least this is the main rationale
  # for the following .sub!() method call.
  # ======================================================================= #
  this_font_size.sub!(/FS/,'')  if this_font_size.include? 'FS'
  case this_font_size
  # ======================================================================= #
  # === default
  # ======================================================================= #
  when 'default',
       'def',
       :use_the_default_font_size,
       /default_font_size$/
    # ===================================================================== #
    # === Default font size
    #
    # The default font size. Can be found in the config file.
    # constant still has it though.
    # ===================================================================== #
    if @config
      this_font_size = @config['default_font_size']
    else # else the configuration object has not yet been initialized.
      if Cyberweb.configuration_object?.nil?
        Cyberweb.initialize_the_configuration_object
      end
      this_font_size = Cyberweb.configuration_object?['default_font_size']
    end
  # ======================================================================= #
  # === larger
  # ======================================================================= #
  when 'larger',
       'bigger',
       /larger(_|-)font(_|-)size$/
    this_font_size = '1.10em;'
    if @config
      this_font_size = @config['default_larger_font_size']
    else # else the configuration object has not yet been initialized.
      if Cyberweb.configuration_object?.nil?
        Cyberweb.initialize_the_configuration_object
      end
      this_font_size = Cyberweb.configuration_object?['default_larger_font_size']
    end
  # ======================================================================= #
  # === smaller
  # ======================================================================= #
  when 'smaller'
    this_font_size = @config['default_smaller_font_size']
  end
  # ======================================================================= #
  # Do the next modification after the above case/when menu:
  # ======================================================================= #
  this_font_size.gsub!(/_/,'.') if this_font_size.include? '_'
  # ======================================================================= #
  # Now sanitize it a bit.
  # ======================================================================= #
  this_font_size = this_font_size.to_s.delete(' ')
  set_raw_font_size(this_font_size)
  append_onto_the_CSS_style(
    "\nbody { font-size: #{this_font_size}; }\n"
  )
end

#set_n_total_lines(i = result? ) ⇒ Object

#

set_n_total_lines

#


2354
2355
2356
2357
2358
# File 'lib/cyberweb/html_template/html_template.rb', line 2354

def set_n_total_lines(
    i = result?
  )
  @internal_hash[:n_total_lines] = i.count(N) if i
end

#set_raw_font_size(i) ⇒ Object

#

set_raw_font_size

#


6753
6754
6755
# File 'lib/cyberweb/html_template/html_template.rb', line 6753

def set_raw_font_size(i)
  @internal_hash[:font_size] = i.to_s
end

#set_result(i = '') ⇒ Object Also known as: set_main_string, set_string, set_string_that_is_to_be_served

#

set_result

This method will directly modify :result, without any further checking.

#


5640
5641
5642
5643
# File 'lib/cyberweb/html_template/html_template.rb', line 5640

def set_result(i = '')
  i = i.first if i.is_a? Array
  @internal_hash[:result] = i
end

#set_shall_we_use_jquery(i) ⇒ Object

#

set_shall_we_use_jquery

#


985
986
987
# File 'lib/cyberweb/html_template/html_template.rb', line 985

def set_shall_we_use_jquery(i)
  @internal_hash[:shall_we_use_jquery] = i
end

#set_title(i) ⇒ Object

#

set_title

#


4960
4961
4962
4963
4964
4965
4966
4967
4968
# File 'lib/cyberweb/html_template/html_template.rb', line 4960

def set_title(i)
  # ======================================================================= #
  # The title will be stored in the toplevel-module namespace, as we
  # may wish to make use of this elsewhere on a page. Strictly speaking
  # this should be on a per-instance basis instead, but for now we
  # will simply store it on the toplevel.
  # ======================================================================= #
  Cyberweb.set_title(i) # Delegate towards Cyberweb.set_title() here.
end

#set_use_these_css_classes(i) ⇒ Object

#

set_use_these_css_classes

#


5123
5124
5125
# File 'lib/cyberweb/html_template/html_template.rb', line 5123

def set_use_these_css_classes(i)
  @internal_hash[:use_only_these_CSS_classes] = i
end

#set_web_title(i = filename? ) ⇒ Object Also known as: set_use_this_title, t, t=, title=

#

set_web_title (title tag)

This is the method that can be used to set the title of the given html document. Every HTML page may have a title entry.

For this method it is assumed that ONLY the new title is passed to this method - and nothing else.

This will also delegate onto set_title().

We will then set the complete @html_title and append the latter onto our @result instance variable.

Usage example for this method here goes like this:

w.title = 'foo'
w.title 'SELF'
#


1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
# File 'lib/cyberweb/html_template/html_template.rb', line 1525

def set_web_title(
    i = filename?
  )
  # ======================================================================= #
  # First, handle Symbols - some symbols will be interpreted in a
  # special manner.
  # ======================================================================= #
  if i.is_a? Symbol # Handle exclusively Symbols here
    case i
    # ===================================================================== #
    # === :filename_capitalized_no_extension
    #
    # This is also :default. The :default entry should come first in
    # this case/when menu.
    # ===================================================================== #
    when :filename_capitalized_no_extension,
         :filename_capitalized_no_ext,
         :filename_upcased,
         :default,
         :pretty
      i = return_program_name.capitalize.
          delete_suffix(File.extname($PROGRAM_NAME))
    # ===================================================================== #
    # === :capitalize
    #
    # Note that :autotitle is an "alias" to this since as of October 2021.
    # ===================================================================== #
    when :capitalize,
         :capitalized,
         :autotitle
      _ = return_program_name
      i = _.capitalize.sub(/#{File.extname(_)}$/,'')
    # ===================================================================== #
    # === :assume_pretty_name
    # ===================================================================== #
    when :assume_pretty_name
      i = return_program_name.tr('_',' ').capitalize
    # ===================================================================== #
    # === :upcase
    # ===================================================================== #
    when :upcase,
         :upcased
      i = 'SELF_UPCASED' # ← Will be sanitized lateron.
    # ===================================================================== #
    # === :filename_capitalized
    # ===================================================================== #
    when :filename_capitalized
      i = return_program_name.capitalize
    # ===================================================================== #
    # === :filename
    # ===================================================================== #
    when :filename
      i = return_program_name.
          delete_suffix(File.extname($PROGRAM_NAME))
    end
    i = i.to_s unless i.is_a?(String)
  end # end check for a Symbol
  case i
  # ======================================================================= #
  # === SELF_NO_EXT
  # ======================================================================= #
  when 'SELF NO EXT',
       'SELF_NO_FILEEND',
       'SELF_NO_END',
       'SELF_BASENAME',
       'SELF#NO_EXTENSION',
       'SELF_NOEXT',
       'SELF_NO_EXT',
       /NO_EXT/
    # ===================================================================== #
    # As above, but without the extname.
    # ===================================================================== #
    i = File.basename($PROGRAM_NAME).gsub(
          File.extname($PROGRAM_NAME), ''
        )
  # ======================================================================= #
  # === SELF
  # ======================================================================= #
  when /^self$/i,
       'NAME',
       'DEF'
    i = File.basename($PROGRAM_NAME)
  # ======================================================================= #
  # === SELF_UPCASED
  # ======================================================================= #
  when 'SELF_UPCASED'
    i = File.basename($PROGRAM_NAME).
        sub(/#{File.extname($PROGRAM_NAME)}$/,'').
        upcase
  # ======================================================================= #
  # === use_default_file
  #
  # This entry point allows support for e. g. "TITLE.md".
  # ======================================================================= #
  when 'use_default_file',
       'markdown_file'
    unless File.exist? i
      if    File.exist? 'TITLE.md'
        i = File.read('TITLE.md').chomp
      elsif File.exist? 'TITEL.md' # German here.
        i = File.read('TITEL.md').chomp.strip
        i[0,1] = '' if i.start_with? '-'
      end
    end
  end
  # ======================================================================= #
  # === Read in a file if this was given as argument
  #
  # This can be problematic though, in all those events that the user
  # may really wish to name the file in that way. For example, a
  # file called "index.cgi" or "index.html".
  #
  # So as of Jul 2017, an exception was added for some file extensions,
  # namely .php, .html and .cgi.
  # ======================================================================= #
  ignored_file_extensions = %w( php html cgi ) # ← These are the exceptions.
  if i and File.exist?(i.to_s) and File.file?(i.to_s) and
    !ignored_file_extensions.include?(File.extname(i).delete('.'))
    i = File.read(i).chomp
  end
  i = i.dup if i.is_a?(String) and i.frozen?
  @internal_hash[:web_title] = i
  set_title(i)
end

#shall_we_add_the_meta_content?Boolean

#

shall_we_add_the_meta_content?

#

Returns:

  • (Boolean)


6465
6466
6467
# File 'lib/cyberweb/html_template/html_template.rb', line 6465

def shall_we_add_the_meta_content?
  !@internal_hash[:meta_content].to_s.empty?
end

#shall_we_use_jquery?Boolean Also known as: use_jquery?

#

shall_we_use_jquery?

#

Returns:

  • (Boolean)


3321
3322
3323
# File 'lib/cyberweb/html_template/html_template.rb', line 3321

def shall_we_use_jquery? 
  @internal_hash[:shall_we_use_jquery]
end

#show_pdf(i) ⇒ Object

#

show_pdf

#


5867
5868
5869
5870
5871
# File 'lib/cyberweb/html_template/html_template.rb', line 5867

def show_pdf(i)
  append_onto_the_body_tag_nl(
    Cyberweb.embed_this_pdf(i)
  )
end

#show_the_lines?Boolean

#

show_the_lines?

#

Returns:

  • (Boolean)


5378
5379
5380
# File 'lib/cyberweb/html_template/html_template.rb', line 5378

def show_the_lines?
  @internal_hash[:show_the_lines]
end

#show_this_svg(i) ⇒ Object

#

show_this_svg

#


3939
3940
3941
# File 'lib/cyberweb/html_template/html_template.rb', line 3939

def show_this_svg(i)
  append_onto_the_body_tag_nl(i)
end

#sin_file(i, css_class = 'orange BO') ⇒ Object

#

sin_file

#


4215
4216
4217
4218
4219
# File 'lib/cyberweb/html_template/html_template.rb', line 4215

def sin_file(
    i, css_class = 'orange BO'
  )
  return string_s2(i, css_class)
end

#sitelibdir?Boolean

#

sitelibdir?

This method will return a String such as “/usr/lib/ruby/site_ruby/3.2.0/”.

#

Returns:

  • (Boolean)


5428
5429
5430
# File 'lib/cyberweb/html_template/html_template.rb', line 5428

def sitelibdir?
  return RbConfig::CONFIG['sitelibdir'].to_s+'/'
end

#sitemap_faviconObject

#

sitemap_favicon

#


5511
5512
5513
# File 'lib/cyberweb/html_template/html_template.rb', line 5511

def sitemap_favicon
  favicon :sitemap_favicon
end

#slight_indent(i = '', optional_css_class = '') ⇒ Object Also known as: slight_ind, sind

#

slight_indent

#


5168
5169
5170
5171
5172
5173
# File 'lib/cyberweb/html_template/html_template.rb', line 5168

def slight_indent(
    i                  = '',
    optional_css_class = ''
  )
  e i, "padl0_5em #{optional_css_class}"
end

#spacer(i = :middle, optional_css_class = '') ⇒ Object Also known as: trenner, spalter, space, spacer_center, beautiful_spacer, fancy_spacer, fancy_separator

#

spacer (spacer tag)

#


4809
4810
4811
4812
4813
4814
4815
4816
4817
4818
4819
4820
4821
4822
4823
4824
4825
4826
4827
4828
4829
4830
4831
4832
4833
4834
4835
4836
4837
4838
4839
4840
4841
4842
4843
4844
4845
4846
4847
4848
4849
4850
4851
4852
4853
4854
# File 'lib/cyberweb/html_template/html_template.rb', line 4809

def spacer(
    i                  = :middle,
    optional_css_class = ''
  )
  if optional_css_class and optional_css_class.is_a?(Hash)
    _ = optional_css_class
    # ===================================================================== #
    # === :css_class
    # ===================================================================== #
    if _.has_key? :css_class
      optional_css_class = _.delete(:css_class)
    end
  end
  case i
  # ======================================================================= #
  # === :left
  # ======================================================================= #
  when :left
    result = sg(
      :spacer,
      optional_css_class,
      '',
      'display:      block;
       margin-left:  auto;
       margin-right: auto;'.delete("\n").squeeze(' ')
    )
  # ======================================================================= #
  # === :middle
  # ======================================================================= #
  when :middle,
       :center,
       :default
    result = sg(
      :spacer,
      optional_css_class,
      '',
      'text-align:   center;
       display:      block;
       margin-left:  auto;
       margin-right: auto;'.delete("\n").squeeze(' ')
    )
  end
  append_onto_the_body_tag_nl(
    result
  )
end

#string_bold(i = '', optional_css_class = '', optional_the_id = '') ⇒ Object Also known as: stringbold

#

string_bold

#


3388
3389
3390
3391
3392
3393
3394
3395
3396
# File 'lib/cyberweb/html_template/html_template.rb', line 3388

def string_bold(
    i                  = '',
    optional_css_class = '',
    optional_the_id    = ''
  )
  optional_css_class = optional_css_class.to_s.dup
  optional_css_class << ' BOLD'
  string_s2(i, optional_css_class.strip, optional_the_id)
end
#

This method essentially creates a String representation of the HTML <a> tag.

Since as of April 2022 the method “slink” is now an alias to string_link; it used to be an alias towards “def a()”, but this was changed - the word string_link more logically may refer to slink as its intrinsic abbreviation.

#


2120
2121
2122
2123
2124
2125
2126
2127
2128
2129
2130
2131
2132
2133
2134
2135
2136
2137
2138
2139
2140
2141
2142
2143
2144
2145
2146
2147
2148
2149
2150
2151
2152
2153
2154
2155
2156
2157
2158
2159
2160
2161
2162
2163
2164
2165
2166
2167
2168
2169
2170
2171
2172
2173
2174
2175
2176
2177
# File 'lib/cyberweb/html_template/html_template.rb', line 2120

def string_link(
    i           = '',
    option_hash = {},
    &block
  )
  # ======================================================================= #
  # === Handle blocks given to this method next
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :pretty
    # ===================================================================== #
    when :pretty
      option_hash[:remote_URL] = beautiful_url(i)
    end
  end
  if i.is_a?(Symbol)
    if i.start_with?('local_')
      i = BeautifulUrl.local_menu(i)
    else
      i = beautiful_url(i)
      # =================================================================== #
      # Also check if the second argument is a String. In this case we
      # must modify it. Example for input that fulfils this criterium:
      #
      #   remote_link(:hydrogenase, 'Hydrogenase')+
      #
      # =================================================================== #
      if option_hash.is_a? String
        option_hash = { content: option_hash }
      end
    end
  end
  # ======================================================================= #
  # === Handle local entries for the "/home/x" directory layout.
  # ======================================================================= #
  if i.start_with? '/home/x'
    i = i.dup
    i.sub!(/\/home\/x\//, relative_path?)
  end
  # ======================================================================= #
  # Next, double forward slashes, aka //, will be removed. However had
  # this also cripples links such as "chrome://extensions/", which is
  # bad. Thus, in February 2023, the following line was commented
  # out; in the event we want to re-enable it, we may have to think
  # more about the use cases.
  # ======================================================================= #
  # i = rds(i.to_s.dup)
  # ======================================================================= #
  # Delegate onto HtmlTags.a().
  # ======================================================================= #
  return HtmlTags.a(
    i,
    option_hash
  )
end

#string_s2(i = '', optional_css_class = '', optional_the_id = '', optional_css_style = '') ⇒ Object Also known as: string_s, string_span, string_espan, return_span, sspan

#

string_s2

This method ultimately returns a <span> tag.

#


919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
# File 'lib/cyberweb/html_template/html_template.rb', line 919

def string_s2(
    i                  = '',
    optional_css_class = '',
    optional_the_id    = '',
    optional_css_style = ''
  )
  # ======================================================================= #
  # === Handle Hashes next
  # ======================================================================= #
  if optional_css_class.is_a? Hash
    # ===================================================================== #
    # === :css_style
    # ===================================================================== #
    if optional_css_class.has_key? :css_style
      optional_css_style = optional_css_class[:css_style]
    end
    # ===================================================================== #
    # === :id
    # ===================================================================== #
    if optional_css_class.has_key? :id
      optional_the_id = optional_css_class.delete(:id)
    end
    # ===================================================================== #
    # === :css_class
    #
    # This has to come after the :id and :css_style.
    #
    # Example for how this may look:
    #
    #   cmd 'git config --global user.name "foobar"', css_class: 's1em'
    #
    # ===================================================================== #
    if optional_css_class.has_key? :css_class
      optional_css_class = optional_css_class[:css_class]
    end
    if optional_css_class.is_a?(Hash) and
       optional_css_class.empty?
      optional_css_class = ''
    end
  end
  return '<span'+
         css_class_or_no_class(optional_css_class).to_s+
         id_or_no_id(optional_the_id.to_s)+
         css_style_or_no_style(optional_css_style)+
         '>'+
         i.to_s+
         '</span>'
end

#string_table11_with_heading(css_class = '', id = '', css_style = '', *content) ⇒ Object

#

string_table11_with_heading

#


4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
# File 'lib/cyberweb/html_template/html_template.rb', line 4516

def string_table11_with_heading(
    css_class = '',
    id        = '',
    css_style = '',
    *content
  )
  Cyberweb.string_table11_with_heading(
    css_class, id, css_style,
    content
  )
end

#string_table2(css_class = '', the_id = '', css_style = '', *content, &block) ⇒ Object

#

string_table2

This method will delegate towards Cyberweb.string_table2().

#


442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
# File 'lib/cyberweb/html_template/html_template.rb', line 442

def string_table2(
    css_class = '',
    the_id    = '',
    css_style = '',
    *content,
    &block
  )
  Cyberweb.string_table2(
    css_class,
    the_id,
    css_style,
    content,
    &block
  )
end

#string_table2_with_heading(css_class = '', id = '', css_style = '', *content) ⇒ Object

#

string_table2_with_heading

#


534
535
536
537
538
539
540
541
542
543
544
# File 'lib/cyberweb/html_template/html_template.rb', line 534

def string_table2_with_heading(
    css_class = '',
    id        = '',
    css_style = '',
    *content
  )
  Cyberweb.string_table2_with_heading(
    css_class, id, css_style,
    content
  )
end

#string_table3(css_class = '', id = '', css_style = '', *content, &block) ⇒ Object

#

string_table3

We will delegate towards Cyberweb.string_table3 for the functionality here.

#


3404
3405
3406
3407
3408
3409
3410
3411
3412
3413
3414
3415
3416
3417
3418
# File 'lib/cyberweb/html_template/html_template.rb', line 3404

def string_table3(
    css_class = '',
    id        = '',
    css_style = '',
    *content,
    &block
  )
  Cyberweb.string_table3(
    css_class,
    id,
    css_style,
    content,
    &block
  )
end

#string_table4(css_class = '', the_id = '', css_style = '', *content, &block) ⇒ Object

#

string_table4

#


4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
# File 'lib/cyberweb/html_template/html_template.rb', line 4567

def string_table4(
    css_class = '',
    the_id    = '',
    css_style = '',
    *content,
    &block
  )
  # ======================================================================= #
  # To test, try:
  #
  #   puts Cyberweb.string_table4('','','',%w( ah asjhk avshvasjkh vajhksavjhk avsjhvashkjavs ))
  #
  # ======================================================================= #
  Cyberweb.string_table4(
    css_class,
    the_id,
    css_style,
    content,
    &block
  )
end

#string_table5(css_class = '', id = '', css_style = '', *content) ⇒ Object

#

string_table5

#


5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
5812
5813
5814
5815
# File 'lib/cyberweb/html_template/html_template.rb', line 5797

def string_table5(
    css_class = '',
    id        = '',
    css_style = '',
    *content
  )
  # ======================================================================= #
  # To test, try:
  #
  #   puts Cyberweb.string_table5('','','',%w( ah asjhk avshvasjkh vajhksavjhk avsjhvashkjavs ))
  #
  # ======================================================================= #
  Cyberweb.string_table5(
    css_class,
    id,
    css_style,
    content
  )
end

#string_table5_with_heading(css_class = '', id = '', css_style = '', *content) ⇒ Object

#

string_table5_with_heading

#


4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
# File 'lib/cyberweb/html_template/html_template.rb', line 4644

def string_table5_with_heading(
    css_class = '',
    id        = '',
    css_style = '',
    *content
  )
  Cyberweb.string_table5_with_heading(
    css_class, id, css_style,
    content
  )
end

#string_table6(css_class = '', id = '', css_style = '', *content) ⇒ Object

#

string_table6

#


4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
# File 'lib/cyberweb/html_template/html_template.rb', line 4531

def string_table6(
    css_class = '',
    id        = '',
    css_style = '',
    *content
  )
  Cyberweb.string_table6(
    css_class,
    id,
    css_style,
    content
  )
end

#string_table7(css_class = '', id = '', css_style = '', *content) ⇒ Object

#

string_table7

#


4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
# File 'lib/cyberweb/html_template/html_template.rb', line 4487

def string_table7(
    css_class = '',
    id        = '',
    css_style = '',
    *content
  )
  # ======================================================================= #
  # To test, try:
  #
  #   puts Cyberweb.string_table5('','','',%w( ah asjhk avshvasjkh vajhksavjhk avsjhvashkjavs ))
  #
  # ======================================================================= #
  Cyberweb.string_table7(
    css_class, id, css_style, content
  )
end

#string_table8(css_class = '', the_id = '', css_style = '', *content, &block) ⇒ Object

#

string_table8

#


5041
5042
5043
5044
5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
# File 'lib/cyberweb/html_template/html_template.rb', line 5041

def string_table8(
    css_class = '',
    the_id    = '',
    css_style = '',
    *content,
    &block
  )
  Cyberweb.string_table8(
    css_class,
    the_id,
    css_style,
    content,
    &block
  )
end

#string_table9(css_class = '', the_id = '', css_style = '', *content, &block) ⇒ Object

#

string_table9

#


5022
5023
5024
5025
5026
5027
5028
5029
5030
5031
5032
5033
5034
5035
5036
# File 'lib/cyberweb/html_template/html_template.rb', line 5022

def string_table9(
    css_class = '',
    the_id    = '',
    css_style = '',
    *content,
    &block
  )
  Cyberweb.string_table9(
    css_class,
    the_id,
    css_style,
    content,
    &block
  )
end

#string_tag(which_tag = 'span', css_class = '', the_id = '', css_style = '', javascript_code = '', &block) ⇒ Object Also known as: stag, make_tag, string_stag

#

string_tag

#


4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
# File 'lib/cyberweb/html_template/html_template.rb', line 4879

def string_tag(
    which_tag       = 'span',
    css_class       = '',
    the_id          = '',
    css_style       = '',
    javascript_code = '',
    &block
  )
  return Cyberweb.string_tag(
    which_tag,
    css_class,
    the_id,
    css_style,
    javascript_code,
    &block
  )
end

#string_textarea(default_content = '', css_class = '', the_id = '', css_style = '', n_cols = 25, n_rows = 8, javascript = '', name = '', &block) ⇒ Object

#

string_textarea

#


6313
6314
6315
6316
6317
6318
6319
6320
6321
6322
6323
6324
6325
6326
6327
6328
6329
6330
6331
6332
6333
6334
6335
# File 'lib/cyberweb/html_template/html_template.rb', line 6313

def string_textarea(
    default_content = '', # (1) content
    css_class       = '', # (2) css-class
    the_id          = '', # (3) the id
    css_style       = '', # (4) css_style
    n_cols          = 25, # (5) n columns
    n_rows          =  8, # (6) n rows
    javascript      = '', # (7) javascript
    name            = '', # (8) name
    &block
  )
  return ::HtmlTags.textarea(
    default_content,
    css_class,
    the_id,
    css_style,
    n_cols,
    n_rows,
    javascript,
    name,
    &block
  ) 
end
#
#


5532
5533
5534
5535
5536
5537
5538
# File 'lib/cyberweb/html_template/html_template.rb', line 5532

def svg_link(i)
  if File.exist? i
    append_onto_the_body_tag_nl(
      File.read(i)
    )
  end
end

#table(optional_css_class = '', optional_the_id = '', optional_css_style = '') ⇒ Object

#

table

#


4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
# File 'lib/cyberweb/html_template/html_template.rb', line 4679

def table(
    optional_css_class = '',
    optional_the_id    = '',
    optional_css_style = ''
  )
  append_onto_the_body_nl(
    '<table'+
    css_class_or_no_class(optional_css_class)+
    id_or_no_id(optional_the_id)+
    css_style_or_no_style(optional_css_style)+
    '>'
  )
end

#table11_with_heading(css_class = '', id = '', css_style = '', *content) ⇒ Object

#

table11_with_heading

#


3897
3898
3899
3900
3901
3902
3903
3904
3905
# File 'lib/cyberweb/html_template/html_template.rb', line 3897

def table11_with_heading(
    css_class = '', id = '', css_style = '', *content
  )
  append_onto_the_body_tag_nl(
    string_table11_with_heading(
      css_class, id, css_style, content
    )
  )
end

#table12_with_heading(css_class = '', id = '', css_style = '', *content) ⇒ Object

#

table12_with_heading

#


3746
3747
3748
3749
3750
3751
3752
3753
3754
# File 'lib/cyberweb/html_template/html_template.rb', line 3746

def table12_with_heading(
    css_class = '', id = '', css_style = '', *content
  )
  append_onto_the_body_tag_nl(
    string_table12_with_heading(
      css_class, id, css_style, content
    )
  )
end

#table2(css_class = '', id = '', css_style = '', *content, &block) ⇒ Object

#

table2 (table2 tag)

This variant will yield a two-elements-per-row HTML table.

The last variable is the content; keep it even, if possible, e. g 2 elements or 4 or 6 and so forth.

#


466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
# File 'lib/cyberweb/html_template/html_template.rb', line 466

def table2(
    css_class = '',
    id        = '',
    css_style = '',
    *content,
    &block
  )
  append_onto_the_body_tag_nl(
    string_table2(
      css_class,
      id,
      css_style,
      content.flatten,
      &block
    )
  )
end

#table2_from_this_file(optional_css_class = '', optional_the_id = '', optional_css_style = '', this_file = 'games_timeline.md', &block) ⇒ Object

#

table2_from_this_file

This variant will read from an existing file, ideally a markdown file .md. One row in the HTML table corresponds to one line in the original markdown file.

Note that currently we will split on ‘:’ which is hardcoded; not sure whether this will change in the future or not.

#


494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
# File 'lib/cyberweb/html_template/html_template.rb', line 494

def table2_from_this_file(
    optional_css_class = '',
    optional_the_id    = '',
    optional_css_style = '',
    this_file          = 'games_timeline.md',
    &block
  )
  if File.exist? this_file
    # ===================================================================== #
    # Read in the file here:
    # ===================================================================== #
    dataset = File.readlines(this_file, encoding: 'UTF-8').reject {|line|
      line.start_with?('#') or line.strip.empty? # Ignore comments and empty lines.
    }
    splitted_dataset = dataset.map {|entry|
      if entry.include? ':'
        splitted = entry.split(':')
        entry = [
          splitted[0 .. -2].join(':'),
          splitted[-1].strip
        ]
      end
      entry
    }
    dataset = splitted_dataset
    table2(
      optional_css_class,
      optional_the_id,
      optional_css_style,
      *dataset,
      &block
    )
  else
    e '(line 5806) No file exists at '+this_file
  end
end

#table2_with_heading(css_class = '', id = '', css_style = '', *content) ⇒ Object

#

table2_with_heading

#


4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
# File 'lib/cyberweb/html_template/html_template.rb', line 4548

def table2_with_heading(
    css_class = '',
    id        = '',
    css_style = '',
    *content
  )
  append_onto_the_body_tag_nl(
    string_table2_with_heading(
      css_class,
      id,
      css_style,
      content
    )
  )
end

#table3(css_class = '', id = '', css_style = '', *content, &block) ⇒ Object

#

table3

#


5839
5840
5841
5842
5843
5844
5845
5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
# File 'lib/cyberweb/html_template/html_template.rb', line 5839

def table3(
    css_class = '',
    id        = '',
    css_style = '',
    *content,
    &block
  )
  append_onto_the_body_tag_nl(
    string_table3(
      css_class,
      id,
      css_style,
      content,
      &block
    )
  )
end

#table4(css_class = '', the_id = '', css_style = '', *content, &block) ⇒ Object

#

table4

#


5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
# File 'lib/cyberweb/html_template/html_template.rb', line 5081

def table4(
    css_class = '',
    the_id    = '',
    css_style = '',
    *content,
    &block
  )
  append_onto_the_body_tag_nl(
    string_table4(
      css_class,
      the_id,
      css_style,
      content,
      &block
    )
  )
end

#table5(css_class = '', id = '', css_style = '', *content, &block) ⇒ Object

#

table5

#


5776
5777
5778
5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
# File 'lib/cyberweb/html_template/html_template.rb', line 5776

def table5(
    css_class = '',
    id        = '',
    css_style = '',
    *content,
    &block
  )
  append_onto_the_body_tag_nl(
    string_table5(
      css_class,
      id,
      css_style,
      content,
      &block
    )
  )
end

#table5_with_heading(css_class = '', id = '', css_style = '', *content) ⇒ Object

#

table5_with_heading

#


5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
# File 'lib/cyberweb/html_template/html_template.rb', line 5820

def table5_with_heading(
    css_class = '',
    id        = '',
    css_style = '',
    *content
  )
  append_onto_the_body_tag_nl(
    string_table5_with_heading(
      css_class,
      id,
      css_style,
      content
    )
  )
end

#table6(css_class = '', id = '', css_style = '', *content, &block) ⇒ Object

#

table6

#


2091
2092
2093
2094
2095
2096
2097
2098
2099
2100
2101
2102
2103
2104
2105
2106
2107
# File 'lib/cyberweb/html_template/html_template.rb', line 2091

def table6(
    css_class = '',
    id        = '',
    css_style = '',
    *content,
    &block
  )
  append_onto_the_body_tag_nl(
    string_table6(
      css_class,
      id,
      css_style,
      content,
      &block
    )
  )
end

#table7(css_class = '', id = '', css_style = '', *content) ⇒ Object

#

table7

#


4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
# File 'lib/cyberweb/html_template/html_template.rb', line 4944

def table7(
    css_class = '',
    id        = '',
    css_style = '',
    *content
  )
  append_onto_the_body_tag_nl(
    string_table7(
      css_class, id, css_style, content
    )
  )
end

#table8(css_class = '', the_id = '', css_style = '', *content, &block) ⇒ Object

#

table8

#


5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
# File 'lib/cyberweb/html_template/html_template.rb', line 5060

def table8(
    css_class = '',
    the_id    = '',
    css_style = '',
    *content,
    &block
  )
  append_onto_the_body_tag_nl(
    string_table8(
      css_class,
      the_id,
      css_style,
      content,
      &block
    )
  )
end

#table9(css_class = '', the_id = '', css_style = '', *content, &block) ⇒ Object

#

table9

#


5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
# File 'lib/cyberweb/html_template/html_template.rb', line 5001

def table9(
    css_class = '',
    the_id    = '',
    css_style = '',
    *content,
    &block
  )
  append_onto_the_body_tag_nl(
    string_table9(
      css_class,
      the_id,
      css_style,
      content,
      &block
    )
  )
end

#table_clearObject

#

table_clear

#


2396
2397
2398
# File 'lib/cyberweb/html_template/html_template.rb', line 2396

def table_clear
  Cyberweb::Table.clear
end

#table_padding=(i = 10) ⇒ Object

#

table_padding=

#


2389
2390
2391
# File 'lib/cyberweb/html_template/html_template.rb', line 2389

def table_padding=(i = 10)
  Cyberweb::Table.padding = i
end

#table_parse(*i) ⇒ Object

#

table_parse

#


3508
3509
3510
3511
3512
# File 'lib/cyberweb/html_template/html_template.rb', line 3508

def table_parse(*i)
  append_onto_the_body_tag_nl(
    Cyberweb::Table.parse(i)
  )
end

#table_set_css_class(i = 'marl2em') ⇒ Object

#

table_set_css_class

#


4659
4660
4661
4662
4663
# File 'lib/cyberweb/html_template/html_template.rb', line 4659

def table_set_css_class(
    i = 'marl2em'
  )
  Cyberweb::Table.set_css_class(i)
end

#tag(this_tag, optional_css_class = '', optional_the_id = '', optional_css_style = '', optional_javascript = '') ⇒ Object

#

tag

#


4186
4187
4188
4189
4190
4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
# File 'lib/cyberweb/html_template/html_template.rb', line 4186

def tag(
    this_tag,
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = ''
  )
  _ = '<'+this_tag.to_s+
      css_class_or_no_class(optional_css_class)+
      id_or_no_id(optional_the_id)+
      css_style_or_no_style(optional_css_style).dup
  if optional_javascript and !optional_javascript.empty?
    _ << ' javascript="'+javascript+'"'
  end
  _ << '>'
  append_onto_the_body_tag_nl(_)
end

#td(content = '', optional_css_class = '', optional_the_id = '') ⇒ Object

#

td

This method will ultimately yield a <td>CONTENT_HERE</td> String.

td(content, optional_css_class, optional_the_id)
#


2274
2275
2276
2277
2278
2279
2280
2281
2282
2283
2284
2285
2286
2287
2288
2289
2290
2291
# File 'lib/cyberweb/html_template/html_template.rb', line 2274

def td(
    content            = '',
    optional_css_class = '',
    optional_the_id    = ''
  )
  append_onto_the_body_tag_nl(
    '<td'+
    css_class_or_no_class(optional_css_class)+
    id_or_no_id(optional_the_id)+
    '>'
  )
  if block_given?
    append_onto_the_body_tag_nl(yield)
  else
    append_onto_the_body_tag_nl(content)
  end
  ctd
end

#td_row(array) ⇒ Object

#

td_row

This method will create a <td>-row, that is, each Array member will be positioned into a <td></td> tag.

An example Array may be this one:

%w( 256 128 64 32 16 8 4 2 1 )
#


3572
3573
3574
3575
3576
3577
3578
3579
3580
3581
3582
# File 'lib/cyberweb/html_template/html_template.rb', line 3572

def td_row(
    array
  )
  unless array.is_a? Array
    raise ArgumentError,
         'must provide a valid Array as input to this method'
  end
  array.each {|this_entry|
    td(this_entry)
  }
end

#template1(i) ⇒ Object

#

template1

#


2861
2862
2863
2864
2865
2866
# File 'lib/cyberweb/html_template/html_template.rb', line 2861

def template1(i)
  append_onto_the_main_CSS_rules(:template1)
  if i and !i.empty?
    append_onto_the_main_CSS_rules(i)
  end
end

#textarea(default_content = '', css_class = '', the_id = '', css_style = '', n_cols = 25, n_rows = 8, javascript = '', name = '', &block) ⇒ Object Also known as: textview, add_write_area, add_textfield

#

textarea

This method essentially creates a HTML <textarea> tag.

Usage example:

textarea('foobar','bblack1 pad1em','textarea_id')

This method also works via a block. Example for this:

add_textfield {{
   width:  50,
   height: 50
 }}
#


6282
6283
6284
6285
6286
6287
6288
6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
# File 'lib/cyberweb/html_template/html_template.rb', line 6282

def textarea(
    default_content = '', # (1) content
    css_class       = '', # (2) css-class
    the_id          = '', # (3) the id
    css_style       = '', # (4) css_style
    n_cols          = 25, # (5) n columns
    n_rows          =  8, # (6) n rows
    javascript      = '', # (7) javascript
    name            = '', # (8) name
    &block
  )
  append_onto_the_body_tag_nl(
    string_textarea(
      default_content,
      css_class,
      the_id,
      css_style,
      n_cols,
      n_rows,
      javascript,
      name,
      &block
    )
  )
end

#th(optional_input = '') ⇒ Object

#

th

This method will yield the <th> tag, ultimately.

#


6642
6643
6644
6645
6646
6647
6648
6649
6650
6651
6652
6653
6654
# File 'lib/cyberweb/html_template/html_template.rb', line 6642

def th(
    optional_input = ''
  )
  _ = '<th'.dup
  case optional_input
  when :left
    _ << 'align="left"'
  when :right
    _ << 'align="right"'
  end
  _ << '>'
  append_onto_the_body_tag(_)
end

#theadObject

#

thead

#


5195
5196
5197
# File 'lib/cyberweb/html_template/html_template.rb', line 5195

def thead
  append_onto_the_body_tag('<thead>')
end

#thick_hrObject

#

thick_hr

#


2296
2297
2298
# File 'lib/cyberweb/html_template/html_template.rb', line 2296

def thick_hr
  hr 'thick'
end

#to_binary(i) ⇒ Object

#

to_binary

#


1884
1885
1886
# File 'lib/cyberweb/html_template/html_template.rb', line 1884

def to_binary(i)
  return Roebe::ToBinary.to(i)
end

#trObject

#

tr

This method will create a <tr> tag.

#


3642
3643
3644
3645
3646
3647
3648
3649
3650
# File 'lib/cyberweb/html_template/html_template.rb', line 3642

def tr
  append_onto_the_body_tag_nl(
    '<tr>'
  )
  if block_given?
    yield
    ctr
  end
end

#trtd(optional_input = '', optional_css_class = '', &block) ⇒ Object

#

trtd

Usage for this method can be quite complex, as the following example may show:

trtd {
  p('wid98'){
    s2 '13.09.2003:','yel'
  }
}

Thus, the method has to handle blocks as well.

#


3666
3667
3668
3669
3670
3671
3672
3673
3674
3675
3676
3677
3678
# File 'lib/cyberweb/html_template/html_template.rb', line 3666

def trtd(
    optional_input     = '',
    optional_css_class = '',
    &block
  )
  tr
  td(optional_input, optional_css_class)
  if block_given?
    yield
    ctd # Then close the <td> tag.
    ctr # And next the <tr> tag.
  end
end

#unicode_plus_minusObject

#

unicode_plus_minus

#


4865
4866
4867
# File 'lib/cyberweb/html_template/html_template.rb', line 4865

def unicode_plus_minus
  UNICODE_PLUS_MINUS
end

#upcase_the_titleObject

#

upcase_the_title

#


4902
4903
4904
# File 'lib/cyberweb/html_template/html_template.rb', line 4902

def upcase_the_title
  set_web_title(:upcase)
end

#use_body_tag?Boolean

#

use_body_tag?

#

Returns:

  • (Boolean)


5226
5227
5228
# File 'lib/cyberweb/html_template/html_template.rb', line 5226

def use_body_tag?
  @internal_hash[:use_body_tag]
end

#use_englishObject Also known as: do_use_english

#

use_english

#


4360
4361
4362
# File 'lib/cyberweb/html_template/html_template.rb', line 4360

def use_english # An easier shortcut.
  language :english
end

#use_germanObject

#

use_german

This is an easier shortcut to designate that the current webpage makes use of the german language as part of its content primarily.

#


1285
1286
1287
# File 'lib/cyberweb/html_template/html_template.rb', line 1285

def use_german # An easier shortcut.
  language :german
end

#use_iso_encodingObject

#

use_iso_encoding

This uses the ISO Encoding for Europe.

#


5398
5399
5400
# File 'lib/cyberweb/html_template/html_template.rb', line 5398

def use_iso_encoding
  set_encoding_to_use :iso
end

#use_local_CSS_files?Boolean Also known as: use_the_internal_CSS_files?, use_internal_css_files?

#

use_local_CSS_files?

#

Returns:

  • (Boolean)


5337
5338
5339
# File 'lib/cyberweb/html_template/html_template.rb', line 5337

def use_local_CSS_files?
  @internal_hash[:use_local_CSS_files]
end

#use_monospace_font(use_this_font = '"Lucida Console", Monaco, monospace') ⇒ Object Also known as: monospace_font

#

use_monospace_font

By default this will use the “Lucida Console” font.

#


2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
# File 'lib/cyberweb/html_template/html_template.rb', line 2783

def use_monospace_font(
    use_this_font = '"Lucida Console", Monaco, monospace'
  )
  use_this_font = use_this_font.dup if use_this_font.frozen? 
  use_this_font << ';' unless use_this_font.end_with? ';'
  append_to_css_style '
body {
font-family: '+use_this_font+'
}
  '
end

#wasserstoffObject

#

wasserstoff

#


4377
4378
4379
# File 'lib/cyberweb/html_template/html_template.rb', line 4377

def wasserstoff
  'H₂'
end

#we_have_not_yet_served_the_web_contentObject

#

we_have_not_yet_served_the_web_content

#


2337
2338
2339
# File 'lib/cyberweb/html_template/html_template.rb', line 2337

def we_have_not_yet_served_the_web_content
  @internal_hash[:already_served] = false
end

#we_have_now_already_served_the_web_contentObject

#

we_have_now_already_served_the_web_content

#


2330
2331
2332
# File 'lib/cyberweb/html_template/html_template.rb', line 2330

def we_have_now_already_served_the_web_content
  @internal_hash[:already_served] = true
end

#web_title?Boolean Also known as: title?

#

web_title?

The query-method over the current title of the web-app at hand.

#

Returns:

  • (Boolean)


5660
5661
5662
# File 'lib/cyberweb/html_template/html_template.rb', line 5660

def web_title?
  @internal_hash[:web_title]
end

#white_fontObject

#

white_font

#


2772
2773
2774
2775
2776
# File 'lib/cyberweb/html_template/html_template.rb', line 2772

def white_font
  add_this_css_style(
    'body { color: white; }'
  )
end

#wings_faviconObject

#

wings_favicon

#


5557
5558
5559
# File 'lib/cyberweb/html_template/html_template.rb', line 5557

def wings_favicon
  set_favicon :wings
end

#wlan_faviconObject Also known as: favicon_wlan

#

wlan_favicon

#


5504
5505
5506
# File 'lib/cyberweb/html_template/html_template.rb', line 5504

def wlan_favicon
  favicon :wlan_favicon
end