Class: Cyberweb::WebObject

Inherits:
HtmlTemplate show all
Defined in:
lib/cyberweb/web_object/web_object.rb,
lib/cyberweb/web_object/javascript_and_jquery.rb

Overview

Cyberweb::WebObject

Constant Summary collapse

UNICODE_PLUS_MINUS =
#

UNICODE_PLUS_MINUS

#
'±'
'mars1em BOLD pad4px '\
'flashy_surroundings BLOCK martb1px'
'mars3em BOLD flashy_surroundings pad12px'
'mars4em BOLD flashy_surroundings pad12px'

Constants inherited from Base

Base::HOME_DIRECTORY_OF_THE_USER_X, Base::NAMESPACE

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from HtmlTemplate

#a, #add_content_type_html, #add_html_comment, #add_javascript_file, #add_omega_symbol, #add_omega_symbol_semantics, #add_relevant_meta_entries, #add_svg_table, #add_the_content_from_the_default_js_files, #add_this_div, #add_this_remote_css_page, #add_unicode_charset, #additional_CSS_rules_to_use?, #advanced_handle_these_calls_for_english, #advanced_handle_these_calls_for_german, #already_served?, #alt_text_or_no_alt_text, #angstrom?, #append_after_the_closing_body_tag, #append_newline, #append_onto_the_body_content, #append_onto_the_body_css_class, #append_onto_the_js_files_to_load, #append_onto_the_main_CSS_rules, #append_onto_the_main_javascript_variable, #append_path_to_dragula_js_file, #append_raw, #append_this_css, #append_this_to_the_body_css, #append_this_to_the_meta_collection, #append_to_cmd, #append_to_cmd1, #append_to_cmd2, #append_to_cmd3, #append_to_cmd4, #append_to_cmd5, #area, #arrow_right?, #audio, #background_image=, #background_scroll, #black_background, #black_white, #blockquote, #body_addnl, #body_content?, #body_css_class?, #body_css_style?, #body_javascript=, #body_javascript?, #bold, #boldbr, #br, #brbr, #build_up_the_result, #button, #call, #cbody, #cdiv, #cdl, #cfieldset, #cform, #cframeset, #check_this_css_class_for_select_rules, #chtml, #circle, #clabel, #clear_left, #clear_the_main_string, #clegend, #cli, #close, #close_a, #close_html, #cmap, #cmd1, #cmd1?, #cmd1_is, #cmd2, #cmd2_is, #cmd3, #cmd3_is, #cmd4, #cmd4_is, #cmd5, #cmd5_is, #cmd_pre, #cmdbold, #cobject, #col_cmd, #colour_chart, #colour_gradient_left_to_right, #colour_gradient_right_to_left, #complex_handle_this_language, #consider_appending_when_the_webpage_was_originally_created, #consider_returning_the_css_style, #counter_eight, #counter_five, #counter_four, #counter_nine, #counter_one, #counter_seven, #counter_six, #counter_ten, #counter_three, #counter_two, #cp, #cpre, #created_when, #cselect, #css_class_or_no_class, #css_classes?, #css_for_cmd1, #css_for_cmd2, #css_for_cmd3, #css_for_cmd4, #css_for_cmd5, #css_rule_for_this_background_image, #css_style_or_no_style, #css_template1, #ctable, #ctd, #ctdctr, #ctdtd, #ctextarea, #ctr, #cul, #current_height?, #current_ruby_version?, #cursor, #date_today, #default_font_size, #default_font_size_and_hyperlinks, #default_hyperlink_behaviour, #default_hyperlinks_template1, #details, #disable_body_tag, #display_this_file, #display_this_file_without_comments, #div, #dnd_favicon, #do_not_use_jquery, #do_not_use_local_CSS_files, #do_serve, #do_shall_we_use_jquery, #do_show_the_lines, #do_use_local_CSS_files, #do_use_utf_charset, #document_ready, #document_write, #dropdown_box, #e, #earrow, #edot, #ee, #ee_nl, #eearrow, #ejavascript, #embed_youtube_video, #enable_namespace, #encoding_to_use?, #english_html_comment, #english_unicode_and_english_html_comment, #english_unicode_and_jquery, #escape_html, #external_javascript_file, #favicon_scanner, #fetch_css_classes, #files_from, #font_family=, #frameset, #german_trinity, #german_unicode, #german_unicode_and_german_html_comment, #german_unicode_and_jquery, #get_all_files_from, #get_images, #gleichgewicht, #glossar_table, #handle_these_calls, #hide_scrollbars, #hr, #hr_stars, #hsep, #hspacer, #html_title?, #htmlescape, #id_or_no_id, #in_file, #in_ruby, #inject_this_onto_that, #input, #is_a_sinatra_application, #is_a_sinatra_application?, #is_localhost?, #italic, #javascript_code?, #javascript_file=, #javascript_script=, #jquery, #jquery_version?, #label, #language, #language?, #larger_font_size, #larger_font_size_and_hyperlinks, #left_to_right_gradient, #legend, #less_than_or_equal, #linear_gradient_background, #linux_favicon, #map_symbol_to_image_location, #markdown, #mars1em, #mars2em, #mathml, #meta_content?, #n_steps_to_the_base_directory?, #n_total_lines?, #normal_hyperlinks, #on_click_change_opacity, #on_click_make_darker, #on_hover_colour, #onload_or_no_onload, #ordered_list, #original_input, #p, #page_css_classes, #parse_table, #parse_this_hash, #path?, #path_to_this_background_image, #pi?, #prepend_before_the_body_tag, #prepend_doc_type, #pull_in, #pull_in_the_jquery_module, #quote, #random_background_image_from, #random_favicon, #raw_favicon_string?, #raw_font_size?, #readonly_input, #red, #redirect_to, #render, #repeat, #request_uri?, #reset_the_body_content, #reset_the_result, #result?, #return_accesskey, #return_assumed_javascript, #return_copy_to_clipboard_button, #return_css_for_tetris, #return_css_style, #return_default_javascript, #return_favicon_string, #return_gradient, #return_html_comment, #return_html_to_head_start, #return_javascript, #return_omega_symbol, #return_omega_symbol_semantics, #return_stars, #return_the_CSS_rules_from_the_local_CSS_files, #return_the_body_content, #return_the_body_string, #return_the_css_classes, #return_the_doctype, #return_the_id, #return_the_jquery_string, #return_this_css_style, #return_this_default_javascript_file, #rpg_favicon, #ruby_favicon, #s2, #science_favicon, #sclose, #set_additional_CSS_rules_to_use, #set_background, #set_body_content, #set_body_css_class, #set_body_css_style, #set_body_id, #set_encoding_to_use, #set_favicon, #set_font_size, #set_n_total_lines, #set_raw_font_size, #set_result, #set_shall_we_use_jquery, #set_title, #set_use_these_css_classes, #set_web_title, #shall_we_add_the_meta_content?, #shall_we_use_jquery?, #show_pdf, #show_the_lines?, #show_this_svg, #sin_file, #sitelibdir?, #sitemap_favicon, #slight_indent, #spacer, #string_bold, #string_link, #string_s2, #string_table11_with_heading, #string_table2, #string_table2_with_heading, #string_table3, #string_table4, #string_table5, #string_table5_with_heading, #string_table6, #string_table7, #string_table8, #string_table9, #string_tag, #string_textarea, #svg_link, #table, #table11_with_heading, #table12_with_heading, #table2, #table2_from_this_file, #table2_with_heading, #table3, #table4, #table5, #table5_with_heading, #table6, #table7, #table8, #table9, #table_clear, #table_padding=, #table_parse, #table_set_css_class, #tag, #td, #td_row, #template1, #textarea, #th, #thead, #thick_hr, #to_binary, #tr, #trtd, #unicode_plus_minus, #upcase_the_title, #use_body_tag?, #use_english, #use_german, #use_iso_encoding, #use_local_CSS_files?, #use_monospace_font, #wasserstoff, #we_have_not_yet_served_the_web_content, #we_have_now_already_served_the_web_content, #web_title?, #white_font, #wings_favicon, #wlan_favicon

Methods inherited from Base

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

Methods included from BaseModule::FileRelatedFunctionality

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

Methods included from BaseModule

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

Methods included from BaseModule::ContentType

#content_type_is_html, #content_type_is_jpeg, #content_type_is_json, #content_type_is_plain_text

Methods included from BaseModule::CommandlineArguments

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

Methods included from BaseModule::Colours

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

Constructor Details

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

#

initialize

Do note that all the methods that must be run everytime a new web_object is instantiated, are bundled together in the method called run(). This method is NOT automatically called from initialize(), though.

As of March 2014 the option to pass an argument to this class was re-enabled again. This can be used to pass a HTML string into the class as-is.

An invocation example for this follows:

x = Cyberweb::WebObject.new('<html><head></head><body><h1>Hello world!</body></html>')
#


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

def initialize(
    commandline_arguments = ARGV,
    run_already           = true,
    &block
  )
  super
  # ======================================================================= #
  # Designate a default title, if the configuration option determines so.
  #
  # This should come BEFORE we handle blocks but AFTER we called
  # set_commandline_arguments(), which will be handled via super.
  # ======================================================================= #
  set_web_title('SELF_NO_EXT') if use_title_automatically?
  if block_given?
    # ===================================================================== #
    # Handle all blocks given to this method. This should come after
    # we called set_web_title().
    # ===================================================================== #
    handle_these_calls(&block)
  end
  # ======================================================================= #
  # === Register the primary web_object
  #
  # Next register this as the new web-object. This should come AFTER
  # we handled block invocation via .handle_these_calls().
  # ======================================================================= #
  Cyberweb.set_web_object(self)
end

Class Method Details

.[](i = ARGV) ⇒ Object

#

Cyberweb::WebObject[]

#


9660
9661
9662
# File 'lib/cyberweb/web_object/web_object.rb', line 9660

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

.evaluate_from_the_same_named_file_then_serve(output_the_result = :default, optional_use_this_name_instead = nil) ⇒ Object

#

Cyberweb::WebObject.evaluate_from_the_same_named_file_then_serve

This is the simplified variant that can be used for .cgi files, if a nearby .rb file exists - that is, in the same working directory.

In order for this to work, the file must have the same name, minus the extension (which can be different).

#


9647
9648
9649
9650
9651
9652
9653
9654
9655
# File 'lib/cyberweb/web_object/web_object.rb', line 9647

def self.evaluate_from_the_same_named_file_then_serve(
    output_the_result              = :default,
    optional_use_this_name_instead = nil
  )
  _ = Cyberweb::WebObject.new
  Cyberweb.set_web_object(_) # Keep track of the current primary web-object.
  _.evaluate_from_the_same_named_file(optional_use_this_name_instead)
  return _.do_serve
end

.evaluate_from_this_file_via_beautiful_url(this_file) ⇒ Object

#

Cyberweb::WebObject.evaluate_from_this_file_via_beautiful_url

#


9628
9629
9630
9631
9632
9633
9634
9635
9636
# File 'lib/cyberweb/web_object/web_object.rb', line 9628

def self.evaluate_from_this_file_via_beautiful_url(
    this_file
  )
  _ = Cyberweb::WebObject.new
  Cyberweb.set_web_object(_) # Keep track of the current primary web-object.
  _.is_a_sinatra_application # This is hardcoded for now - we will assume that only Sinatra uses this.
  _.evaluate_from_this_file_via_beautiful_url(this_file)
  return _.do_serve
end

Instance Method Details

#absolute_image(remote_url, css_class = '', the_id = '', css_style = '') ⇒ Object Also known as: absolute_img, display_this_remote_image

#

absolute_image

#


6452
6453
6454
6455
6456
6457
6458
6459
6460
6461
6462
6463
6464
6465
6466
6467
# File 'lib/cyberweb/web_object/web_object.rb', line 6452

def absolute_image(
    remote_url,
    css_class = '',
    the_id    = '',
    css_style = ''
  )
  register_this_id(the_id)
  result = string_absolute_img(
             remote_url,
             css_class,
             the_id,
             css_style
           )
  append_onto_the_body_tag_nl(result)
  return result
end

#add_dragula_drag_for(i = 'ul') ⇒ Object

#

add_dragula_drag_for

The argument should be an existing HTML tag, such as <ul> and so forth.

#


1366
1367
1368
# File 'lib/cyberweb/web_object/web_object.rb', line 1366

def add_dragula_drag_for(i = 'ul')
  Cyberweb.add_dragula_drag_for(i)
end

#add_dynamic_text_shadow(optional_hash = { padding_to_use: '4vmin', background_hsl: 'hsl(200 50% 50%)' }) ⇒ Object

#

add_dynamic_text_shadow

#


7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
# File 'lib/cyberweb/web_object/web_object.rb', line 7987

def add_dynamic_text_shadow(
    optional_hash = {
      padding_to_use: '4vmin',
      background_hsl: 'hsl(200 50% 50%)'
    }
  )
  add_to_CSS_rules(
    return_dynamic_text_shadow(optional_hash)
  )
end
#

This method will add a link to my (local) sitemap. This is fairly useless for other people, so don’t use this method really.

#


6289
6290
6291
6292
6293
6294
6295
6296
6297
6298
6299
6300
6301
6302
6303
6304
6305
6306
# File 'lib/cyberweb/web_object/web_object.rb', line 6289

def add_roebe_sitemap_link(
    optional_css_class = 'mars1em steelblue BOLD'
  )
  use_this_as_the_content = :self
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :right_arrow
    # ===================================================================== #
    when :right_arrow
      use_this_as_the_content = '→ Local Sitemap'
    end
  end
  abr :local_sitemap,
      content:   use_this_as_the_content,
      css_class: optional_css_class
end

#add_simple_javascript_calculatorObject

#

add_simple_javascript_calculator

#


2389
2390
2391
2392
2393
2394
# File 'lib/cyberweb/web_object/web_object.rb', line 2389

def add_simple_javascript_calculator
  add_javascript_file :simple_calculator
  append_onto_the_body_tag_nl(
    ::Cyberweb.return_html_code_for_the_javascript_calculator
  )
end

#add_the_title_to_the_webobject(i = Cyberweb.title?.to_s.lstrip) ⇒ Object Also known as: append_title

#

add_the_title_to_the_webobject

#


8507
8508
8509
8510
8511
8512
8513
8514
# File 'lib/cyberweb/web_object/web_object.rb', line 8507

def add_the_title_to_the_webobject(
    i = Cyberweb.title?.to_s.lstrip
  )
  # ======================================================================= #
  # Next, set the title to the web-object.
  # ======================================================================= #
  set_webtitle(i)
end

#add_this_base64_image(i, optional_css_class = '', optional_css_id = '') ⇒ Object

#

add_this_base64_image

#


6412
6413
6414
6415
6416
6417
6418
6419
6420
6421
6422
6423
6424
# File 'lib/cyberweb/web_object/web_object.rb', line 6412

def add_this_base64_image(
    i,
    optional_css_class = '',
    optional_css_id    = ''
  )
  append_onto_the_body_tag_nl(
    return_this_base64_image(
      i,
      optional_css_class,
      optional_css_id
    )
  )
end
#

This method can be used to style all abr() links on a webpage in a uniform manner.

#


7208
7209
7210
# File 'lib/cyberweb/web_object/web_object.rb', line 7208

def all_hyperlinks_use_this_CSS_class(i)
  @internal_hash[:css_classes_to_be_used_by_default_for_abr_links] = i.to_s
end

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

#

anm

Note that “anm” is short for “anmerkung”, which can roughly be translated to mean “important annotation” in English.

#


2887
2888
2889
2890
2891
2892
2893
2894
2895
2896
2897
2898
2899
2900
2901
2902
2903
2904
2905
2906
2907
2908
2909
2910
2911
2912
2913
2914
2915
2916
# File 'lib/cyberweb/web_object/web_object.rb', line 2887

def anm(
    i                  = '', # Should be an empty String.
    optional_css_class = '',
    optional_the_id    = '',
    optional_css_style = '',
    &block
  )
  css_for_the_anmerkung_symbol = 'marr10px'
  if block_given?
    yielded = yield
    if yielded.is_a? Hash
      # =================================================================== #
      # === :outer_CSS
      #
      # This entry point allows the user to override the default CSS
      # for anm().
      # =================================================================== #
      if yielded.has_key? :outer_CSS
        css_for_the_anmerkung_symbol = yielded.delete(:outer_CSS)
      end
    end
  end
  anmerkung_symbol = sg(:anmerkung, css_for_the_anmerkung_symbol)
  append_onto_the_body_tag_nl(
    anmerkung_symbol+
    string_span(
      i, optional_css_class, optional_the_id, optional_css_style
    )
  )
end

#array_for_sitemap?Boolean Also known as: array_for_sitemap

#

array_for_sitemap?

Accessor-method towards the array-constant.

#

Returns:

  • (Boolean)


8613
8614
8615
# File 'lib/cyberweb/web_object/web_object.rb', line 8613

def array_for_sitemap?
  Cyberweb.array_for_sitemap?
end

#arrow_selfy(remote_url = 'https://en.wikipedia.org/wiki/SimAnt', optional_hash = {}) ⇒ Object Also known as: selfy_arrow

#

arrow_selfy

#


1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
# File 'lib/cyberweb/web_object/web_object.rb', line 1503

def arrow_selfy(
    remote_url    = 'https://en.wikipedia.org/wiki/SimAnt',
    optional_hash = {}
  )
  optional_hash[:description] = "#{remote_url}"
  selfy(
    remote_url,
    optional_hash
  )
end

#aself(url, optional_css_class = '') ⇒ Object Also known as: a_self

#

aself

#


6762
6763
6764
6765
6766
6767
6768
6769
6770
6771
# File 'lib/cyberweb/web_object/web_object.rb', line 6762

def aself(
    url,
    optional_css_class = ''
  )
  a(
    url,
    content: :self,
    css_class: optional_css_class
  )
end

#autogenerated_sitemap(css_class = '', optional_id = '', optional_css_style = 'top: 2px; right: 2px; background-color: #eee;', append_css = true, &block) ⇒ Object Also known as: show_sitemap, display_sitemap, asitemap, add_sitemap

#

autogenerated_sitemap

This method will autogenerate a default Sitemap (an intralink).

If the second argument for ‘optional_id` is :sort, then this method will sort the result first before displaying it.

#


4213
4214
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226
4227
4228
4229
4230
4231
4232
4233
4234
4235
4236
4237
4238
4239
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
# File 'lib/cyberweb/web_object/web_object.rb', line 4213

def autogenerated_sitemap(
    css_class          = '',
    optional_id        = '', # This could be :sort.
    optional_css_style = 'top: 2px; right: 2px; background-color: #eee;',
    append_css         = true, # By default we will append more CSS rules.
    &block
  )
  # ======================================================================= #
  # Obtain the dataset first.
  # ======================================================================= #
  registered_sitemaps = Cyberweb.array_registered_sitemaps?
  css_for_li_elements = 'marl1px darkblue'
  default_css_class_to_use = 'pad5px bblack1 black posab'
  if block_given?
    yielded = yield
    # ===================================================================== #
    # === Handle Blocks next
    # ===================================================================== #
    if yielded.is_a? Hash
      # =================================================================== #
      # === :css_style
      # =================================================================== #
      if yielded.has_key? :css_style
        _ = yielded.delete :css_style
        default_css_class_to_use = ''
        optional_css_style = _
      end
    end
  end
  case optional_id
  # ======================================================================= #
  # === :sort
  # ======================================================================= #
  when :sort
    registered_sitemaps.sort!
    optional_id = ''
  end
  if css_class.empty?
    if append_css # This is the default.
      css_class = css_class.dup if css_class.frozen?
      css_class << " #{default_css_class_to_use}"
    end
  else # Else, user passed arguments here.
    css_class = css_class.dup if css_class.frozen?
    css_class << " #{default_css_class_to_use}"
  end
  # ======================================================================= #
  # Next comes the <div> that will hold our sitemap. For now this
  # will always be a <div> element.
  # ======================================================================= #
  div(css_class, optional_id, optional_css_style) {
    ee html_comment('Sitemap tag')
    h2 'Sitemap','black whi martb2px pad2px s4px yel mar1px',
       'SitemapHeader',
       'background-color:darkblue;'
    # ===================================================================== #
    # Build up the proper <ul> tag next.
    # ===================================================================== #
    ul(id: 'SitemapNavigation') {
      registered_sitemaps.each { |sitemap_id|
        ee '<li class="'+css_for_li_elements+'">'
        a '#'+sanitize_id(sitemap_id),
           content: sitemap_id,
           css_class: 'darkblue'
        ee '</li>'
      }
    }
  }
end

#autotitleObject

#

autotitle

This will simply capitalize the title in use.

#


3750
3751
3752
# File 'lib/cyberweb/web_object/web_object.rb', line 3750

def autotitle
  set_title :capitalized
end

#back_to_games(optional_css_class = 'steelblue BOLD') ⇒ Object Also known as: to_the_games

#

back_to_games

#


6776
6777
6778
6779
6780
6781
6782
# File 'lib/cyberweb/web_object/web_object.rb', line 6776

def back_to_games(
    optional_css_class = 'steelblue BOLD'
  )
  abr :local_games,
      content: :self,
      css_class: optional_css_class
end

#base64_image(i, image_type_to_use = :infer, optional_css_class = '', optional_the_id = '', optional_css_style = '') ⇒ Object

#

base64_image

This is distinct to other base64-related images within the Cyberweb project. It will simply, and directly, add the given data onto the body-tag.

#


8204
8205
8206
8207
8208
8209
8210
8211
8212
8213
8214
8215
8216
8217
8218
8219
8220
# File 'lib/cyberweb/web_object/web_object.rb', line 8204

def base64_image(
    i,
    image_type_to_use = :infer,
    optional_css_class = '',
    optional_the_id    = '',
    optional_css_style = ''
  )
  append_onto_the_body_tag_nl(
    return_base64_image(
      i,
      image_type_to_use,
      optional_css_class,
      optional_the_id,
      optional_css_style
    )
  )
end

#batch_href(*i) ⇒ Object

#

batch_href

This method will always yield the given input as Array, and then call selfy() on it. This will thus create HTML links, with the remote URL as the description shown on the HTML link at hand.

#


857
858
859
860
861
# File 'lib/cyberweb/web_object/web_object.rb', line 857

def batch_href(*i)
  i.flatten.each {|entry|
    selfy(entry)
  }
end

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

#

bold_counter

This is identical to counter_li() - or, counter(), which is an alias, anyway - except that the index that is shown, is shown in a bold way.

#


2874
2875
2876
2877
2878
2879
# File 'lib/cyberweb/web_object/web_object.rb', line 2874

def bold_counter(
    i                  = '',
    optional_css_class = ''
  )
  counter(i, optional_css_class) { :counter_is_bold }
end

#bold_string_n_fotos(i = :manuela_r) ⇒ Object

#

bold_string_n_fotos

This is part of the “show local fotos” custom method.

#


9037
9038
9039
9040
9041
9042
9043
9044
# File 'lib/cyberweb/web_object/web_object.rb', line 9037

def bold_string_n_fotos(
    i = :manuela_r
  )
  n_fotos = return_n_fotos_in(i)
  return '<b>'+n_fotos.to_s+'</b> '+
         foto_oder_fotos(n_fotos)+
         '</b>'
end

#br_counterObject Also known as: brcounter

#

br_counter

#


9293
9294
9295
# File 'lib/cyberweb/web_object/web_object.rb', line 9293

def br_counter
  br; reset_the_counter
end

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

#

brcmd

#


8365
8366
8367
8368
8369
8370
8371
# File 'lib/cyberweb/web_object/web_object.rb', line 8365

def brcmd(
    i                  = '',
    optional_css_class = ''
  )
  br
  cmd(i, optional_css_class)
end

#bruch(a, b) ⇒ Object

#

bruch

#


8620
8621
8622
8623
8624
# File 'lib/cyberweb/web_object/web_object.rb', line 8620

def bruch(a, b)
  append_onto_the_body_tag_nl(
    Cyberweb.bruch(a, b)
  )
end

#caps(i = '') ⇒ Object Also known as: cap

#

caps

#


9229
9230
9231
# File 'lib/cyberweb/web_object/web_object.rb', line 9229

def caps(i = '')
  return '<span class="pretty_caps">'+i.to_s+'</span>'
end

#center_td(i = '40%') ⇒ Object

#

center_td

#


1494
1495
1496
1497
1498
# File 'lib/cyberweb/web_object/web_object.rb', line 1494

def center_td(
    i = '40%'
  )
  td i,'center'
end

#cgi?Boolean

#

cgi?

#

Returns:

  • (Boolean)


8232
8233
8234
# File 'lib/cyberweb/web_object/web_object.rb', line 8232

def cgi?
  Cyberweb::CGI.new
end

#cheader_h1(i = '', optional_css_class = '', optional_the_id = '', optional_css_style = '', optional_javascript = '', use_fancy_id = false, &block) ⇒ Object Also known as: fancy_h1, fancy1

#

cheader_h1

#


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

def cheader_h1(
    i                   = '',    # 1st argument
    optional_css_class  = '',    # 2nd argument
    optional_the_id     = '',    # 3rd argument
    optional_css_style  = '',    # 4rd argument
    optional_javascript = '',    # 5th argument
    use_fancy_id        = false, # 6th argument
    &block
  )
  hash = {}
  yielded = nil
  yielded = yield if block_given?
  hash.update(yielded) if yielded # First update the hash.
  # ======================================================================= #
  # === :clickable
  # ======================================================================= #
  unless hash.has_key? :clickable
    hash[:clickable] = true
  end
  # ======================================================================= #
  # Assign the tag to use to h1 in the next line:
  # ======================================================================= #
  hash[:use_this_tag] = __method__.to_s.split('_').last.to_sym
  header(
    i,
    optional_css_class,
    optional_the_id,
    optional_css_style,
    optional_javascript,
    use_fancy_id
  ) { hash }
end

#cheader_h2(i = '', optional_css_class = '', optional_the_id = '', optional_css_style = '', optional_javascript = '', use_fancy_id = false, &block) ⇒ Object Also known as: fancy_h2, fancy2, fancy

#

cheader_h2

Usage example:

cheader_h2 'Das WASB-Schema', id: 'WASB'
#


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

def cheader_h2(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = '',
    use_fancy_id        = false,
    &block
  )
  hash = {}
  yielded = nil
  yielded = yield if block_given?
  hash.update(yielded) if yielded and yielded.is_a?(Hash) # First update the hash.
  # ======================================================================= #
  # === :clickable
  #
  # This is always clickable - the "c" indicates "clickable".
  # ======================================================================= #
  unless hash.has_key? :clickable
    hash[:clickable] = true
  end
  # ======================================================================= #
  # Assign the tag to use to h1 in the next line:
  # ======================================================================= #
  hash[:use_this_tag] = __method__.to_s.split('_').last.to_sym
  header(
    i,
    optional_css_class,
    optional_the_id,
    optional_css_style,
    optional_javascript,
    use_fancy_id
  ) { hash }
end

#cheader_h3(i = '', optional_css_class = '', optional_the_id = '', optional_css_style = '', optional_javascript = '', use_fancy_id = false, &block) ⇒ Object Also known as: fancy_h3, fancy3

#

cheader_h3

#


8986
8987
8988
8989
8990
8991
8992
8993
8994
8995
8996
8997
8998
8999
9000
9001
9002
9003
9004
9005
9006
9007
9008
9009
9010
9011
9012
9013
9014
9015
9016
9017
# File 'lib/cyberweb/web_object/web_object.rb', line 8986

def cheader_h3(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = '',
    use_fancy_id        = false,
    &block
  )
  hash = {}
  yielded = nil
  yielded = yield if block_given?
  hash.update(yielded) if yielded # First update the hash.
  # ======================================================================= #
  # === :clickable
  # ======================================================================= #
  unless hash.has_key? :clickable
    hash[:clickable] = true
  end
  # ======================================================================= #
  # Assign the tag to use to h1 in the next line:
  # ======================================================================= #
  hash[:use_this_tag] = __method__.to_s.split('_').last.to_sym
  header(
    i,
    optional_css_class,
    optional_the_id,
    optional_css_style,
    optional_javascript,
    use_fancy_id
  ) { hash }
end

#cheader_h4(i = '', optional_css_class = '', optional_the_id = '', optional_css_style = '', optional_javascript = '', use_fancy_id = false, &block) ⇒ Object Also known as: fancy_h4, fancy4

#

cheader_h4

#


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

def cheader_h4(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = '',
    use_fancy_id        = false,
    &block
  )
  hash = {}
  yielded = nil
  yielded = yield if block_given?
  hash.update(yielded) if yielded # First update the hash.
  # ======================================================================= #
  # === :clickable
  # ======================================================================= #
  unless hash.has_key? :clickable
    hash[:clickable] = true
  end
  # ======================================================================= #
  # Assign the tag to use to h1 in the next line:
  # ======================================================================= #
  hash[:use_this_tag] = __method__.to_s.split('_').last.to_sym
  header(
    i,
    optional_css_class,
    optional_the_id,
    optional_css_style,
    optional_javascript,
    use_fancy_id
  ) { hash }
end

#cheader_h5(i = '', optional_css_class = '', optional_the_id = '', optional_css_style = '', optional_javascript = '', use_fancy_id = false, &block) ⇒ Object Also known as: fancy_h5, fancy5

#

cheader_h5

#


5875
5876
5877
5878
5879
5880
5881
5882
5883
5884
5885
5886
5887
5888
5889
5890
5891
5892
5893
5894
5895
5896
5897
5898
5899
5900
5901
5902
5903
5904
5905
5906
# File 'lib/cyberweb/web_object/web_object.rb', line 5875

def cheader_h5(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = '',
    use_fancy_id        = false,
    &block
  )
  hash = {}
  yielded = nil
  yielded = yield if block_given?
  hash.update(yielded) if yielded # First update the hash.
  # ======================================================================= #
  # === :clickable
  # ======================================================================= #
  unless hash.has_key? :clickable
    hash[:clickable] = true
  end
  # ======================================================================= #
  # Assign the tag to use to h1 in the next line:
  # ======================================================================= #
  hash[:use_this_tag] = __method__.to_s.split('_').last.to_sym
  header(
    i,
    optional_css_class,
    optional_the_id,
    optional_css_style,
    optional_javascript,
    use_fancy_id
  ) { hash }
end

#cheader_h6(i = '', optional_css_class = '', optional_the_id = '', optional_css_style = '', optional_javascript = '', use_fancy_id = false, &block) ⇒ Object Also known as: fancy_h6, fancy6

#

cheader_h6

#


7092
7093
7094
7095
7096
7097
7098
7099
7100
7101
7102
7103
7104
7105
7106
7107
7108
7109
7110
7111
7112
7113
7114
7115
7116
7117
7118
7119
7120
7121
7122
7123
# File 'lib/cyberweb/web_object/web_object.rb', line 7092

def cheader_h6(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = '',
    use_fancy_id        = false,
    &block
  )
  hash = {}
  yielded = nil
  yielded = yield if block_given?
  hash.update(yielded) if yielded # First update the hash.
  # ======================================================================= #
  # === :clickable
  # ======================================================================= #
  unless hash.has_key? :clickable
    hash[:clickable] = true
  end
  # ======================================================================= #
  # Assign the tag to use to h1 in the next line:
  # ======================================================================= #
  hash[:use_this_tag] = __method__.to_s.split('_').last.to_sym
  header(
    i,
    optional_css_class,
    optional_the_id,
    optional_css_style,
    optional_javascript,
    use_fancy_id
  ) { hash }
end

#check_for_a_file_called_config_mdObject

#

check_for_a_file_called_config_md

This method will check for a file called ‘config.md’ in the current working directory.

#


4862
4863
4864
4865
4866
4867
4868
4869
4870
4871
4872
4873
4874
4875
4876
4877
4878
4879
4880
4881
4882
4883
4884
4885
4886
4887
4888
4889
4890
4891
4892
4893
4894
4895
4896
4897
4898
4899
4900
4901
4902
4903
4904
4905
4906
4907
4908
4909
4910
4911
4912
4913
4914
4915
# File 'lib/cyberweb/web_object/web_object.rb', line 4862

def check_for_a_file_called_config_md
  _ = "#{return_pwd}config.md"
  if File.exist? _
    dataset = YAML.load_file(_)
    # ===================================================================== #
    # === title
    # ===================================================================== #
    if dataset.has_key?('title')
      title_to_use = dataset['title']
      set_title(title_to_use)
      # =================================================================== #
      # We also have to update the old title, should it exist.
      # e. g. <title>title_from_the_config_file</title>
      # =================================================================== #
      html_string?.sub!(
        /<title>(.+)<\/title>/,
        "<title>#{title_to_use}</title>"
      )
    end
    # ===================================================================== #
    # === favicon
    # ===================================================================== #
    if dataset.has_key?('favicon')
      favicon = dataset['favicon']
      set_favicon(favicon)
    end
    # ===================================================================== #
    # === font_size
    # ===================================================================== #
    if dataset.has_key?('font_size')
      font_size = dataset['font_size']
      set_raw_font_size(font_size)
    end
    # ===================================================================== #
    # === created_on
    # ===================================================================== #
    if dataset.has_key?('created_on')
      _ = dataset['created_on']
      set_created_on(_)
    end
    # ===================================================================== #
    # === autoextend
    # ===================================================================== #
    if dataset.has_key?('autoextend')
      autoextend if dataset['autoextend']
    end
    # ===================================================================== #
    # === body_css_class
    # ===================================================================== #
    if dataset.has_key?('body_css_class')
      set_body_css_class(dataset['body_css_class'])
    end
  end
end
#

This method will check for a file called “links.md”.

#


7622
7623
7624
7625
7626
7627
7628
7629
7630
7631
7632
7633
7634
7635
7636
7637
7638
7639
7640
7641
7642
7643
7644
7645
7646
7647
7648
7649
# File 'lib/cyberweb/web_object/web_object.rb', line 7622

def check_for_links_markdown_file
  _ = 'links.md'
  # Also check for LINKS.md
  unless File.exist? _
    _ = 'LINKS.md'
  end
  if File.exist? _
    use_this_css_class = ''.dup # A default value.
    lines = File.readlines(_)
    lines.each {|this_entry|
      if this_entry.include? '# ' # Assume a "hidden" CSS class in this case.
        splitted = this_entry.split('# ')
        use_this_css_class = splitted.last.strip
        this_entry = splitted.first
      end
      if this_entry.is_a?(String) and this_entry.start_with?(':')
        this_entry = Cyberweb.sanitize_url(
          this_entry.delete(':').to_sym
        )
      end
      selfy(
        this_entry,
        css_class: use_this_css_class
      )
    }
    br # And one last trailing newline.
  end
end

#check_on_paramsObject

#

check_on_params (params tag, param tag)

We check on the parameter issued here, and enable/disable certain functionality based on that.

You can try these when you append a ? to the URL, such as:

?disable_webimages
?time
?view_source
#


4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
4590
4591
4592
4593
4594
4595
4596
4597
4598
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
4628
4629
4630
4631
4632
4633
4634
4635
4636
4637
4638
4639
4640
4641
4642
4643
4644
4645
4646
4647
4648
4649
4650
4651
4652
4653
4654
4655
4656
4657
4658
4659
4660
4661
4662
4663
4664
4665
4666
4667
4668
4669
4670
4671
4672
4673
4674
4675
4676
4677
4678
4679
4680
4681
4682
4683
4684
4685
4686
4687
4688
4689
4690
4691
4692
4693
4694
4695
4696
4697
4698
4699
4700
4701
4702
4703
4704
4705
4706
4707
4708
4709
4710
4711
4712
4713
4714
4715
4716
4717
4718
4719
4720
4721
4722
4723
4724
4725
4726
4727
4728
4729
4730
4731
4732
4733
4734
4735
4736
4737
4738
4739
4740
4741
4742
4743
4744
4745
4746
4747
4748
4749
4750
4751
4752
4753
4754
4755
4756
4757
4758
4759
4760
4761
4762
4763
4764
4765
4766
4767
4768
4769
4770
4771
4772
4773
4774
4775
4776
4777
4778
# File 'lib/cyberweb/web_object/web_object.rb', line 4536

def check_on_params
  _ = return_params_hash # Remember that this is a Hash.
  unless _.empty?
    # ===================================================================== #
    # Grab the keys in String-form next.
    # ===================================================================== #
    keys = _.keys.join(' ').strip
    # ===================================================================== #
    # First, use a simpler case-menu to check for real keys.
    # ===================================================================== #
    case keys # case tag
    # ===================================================================== #
    # === jquery?
    #
    # Specific examples for this flag:
    #
    #   http://localhost/data/personal/fotos/fotos.cgi?jquery?
    #   http://localhost/data/personal/fotos/fotos.cgi?jquery
    #
    # ===================================================================== #
    when /^jquery\??$/i
      e 'Is jquery used? '+
         use_jquery?.to_s
    # ===================================================================== #
    # === show_lines
    #
    # Specific example for this entry point:
    #
    #   http://localhost/programming/ruby/src/roebe/lib/roebe/www/yeast/yeast.cgi?show_lines
    #
    # ===================================================================== #
    when /^show(_|-)?lines$/i,
         /^lines$/
      do_show_the_lines
    # ===================================================================== #
    # === view_source
    #
    # Specific example for this:
    #
    #   http://localhost/data/video/play_this_video_file.cgi?source
    #   http://localhost/data/images/fotos/responsive_image_gallery.cgi?source
    #   http://localhost/programming/ruby/src/roebe/lib/roebe/www/yeast/yeast.cgi?view_source
    #
    # ===================================================================== #
    when /^view(_|-)?source$/i,
         /^source$/
      do_show_source
    # ===================================================================== #
    # === log_directory?
    #
    # Specific usage example for this:
    #
    #   http://localhost/data/images/fotos/responsive_image_gallery.cgi?log_directory?
    #
    # ===================================================================== #
    when /^-?-?log(_|-)?directory\??$/i
      result = Cyberweb.raw_template(
        title: 'The log directory can be found at ...',
        body:  '<div class="BG_Black White" style="padding: 0.25em">Log directory: '+
               '<b>'+Cyberweb.log_directory?+'</b>'+
               '</div>'
      ).to_s
      print result
      exit
    # ===================================================================== #
    # === to_html
    #
    # This entry point will create a corresponding .html file.
    #
    # Specific example for this:
    #
    #   http://localhost/data/images/fotos/responsive_image_gallery.cgi?to_html
    #
    # ===================================================================== #
    when /^to(_|-)?html$/i,
         /^html$/
      dump_the_html
    # ===================================================================== #
    # === time?
    #
    # This entry point shows the current time.
    #
    #   http://localhost/data/personal/fotos/fotos.cgi?time?
    #   http://localhost/data/images/fotos/responsive_image_gallery.cgi?time?
    #
    # ===================================================================== #
    when /^time\??/i
      result = Cyberweb::HtmlTemplate[
        title: 'Show the current time',
        body:  '<div class="BG_Black White" style="padding: 0.25em">Time: '+
               Time.now.strftime('%d.%m.%Y')+
               ' '+
               Time.now.strftime('%H:%M:%S')+
               '</div>'
      ].to_s
      print result
      exit
    # ===================================================================== #
    # === config?
    #
    # Specific example for this flag:
    #
    #   http://localhost/data/personal/fotos/fotos.cgi?config?
    #
    # ===================================================================== #
    when /^config\?/i,
         /^quit/i
      pp @config
      exit
    # ===================================================================== #
    # === debug
    # ===================================================================== #
    when 'debug' # ?debug
      Cyberweb.enable_debug
    # ===================================================================== #
    # === view_file=ruby_todo
    #
    # This entry point can be used to view a file specifically,
    # globally.
    #
    # Usage example:
    #
    #   http://localhost/data/personal/sitemap/sitemap.cgi?view_file=ruby_todo
    #
    # ===================================================================== #
    when /^view(_|-)?file/i
      if view_file?
        # ================================================================== #
        # In this case the Hash may look like this:
        #
        #   {"view_file"=>["beautiful_url"]}
        #
        # ================================================================== #
        result = _['view_file']
        result = result.first if result.is_a? Array
        result = Cyberweb.sanitize_url(result)
        if result.start_with? 'http://localhost/'
          result = result.dup if result.frozen?
          result.sub!(/^http:\/\/localhost\//, USER_X)
        end
        read_and_display(result)
      else
        clear_the_main_string
        print 'Viewing a file has been disabled in the configuration setting.'
        serve
        exit
      end
    # ===================================================================== #
    # === redirect_to=ruby_todo
    #
    # This entry point can be used to redirect to another page.
    #
    # Usage example:
    #
    #   http://localhost/data/personal/sitemap/sitemap.cgi?redirect_to=ruby_todo
    #
    # ===================================================================== #
    when /^redirect(_|-)?to/i
      # ==================================================================== #
      # In this case the Hash may look like this:
      #
      #   {"redirect_to"=>["ruby_todo"]}
      #
      # ==================================================================== #
      result = _['redirect_to']
      result = result.first if result.is_a? Array
      result = Cyberweb.sanitize_url(result)
      result = result.sub(/\/home\/x\//,'')
      redirect_to(result)
    # ===================================================================== #
    # === hello_world
    # ===================================================================== #
    when 'hello_world'
      h2 'Hello World!'
    else
      # ===================================================================== #
      # === use_jquery
      #
      # Ok, next use a somewhat more flexible if/else/elsif conditional.
      #
      # First, enable the use of jquery, if the user supplied use_jquery.
      # ===================================================================== #
      if keys.include? 'use_jquery' # This should be enough.
        use_jquery
      # ===================================================================== #
      # === time
      # ===================================================================== #
      elsif keys.include? 'time'
        result = Cyberweb::HtmlTemplate[
        title: 'Show the current time',
        body:  '<div class="BG_Black White" style="padding: 0.25em">Time: '+
               Time.now.strftime('%H:%M:%S')+
               '-'+
               Time.now.strftime('%d.%m.%Y')+
               '</div>'
        ].to_s
        print result
        exit
      # ===================================================================== #
      # === ?show_source
      # ===================================================================== #
      elsif keys.include? 'show_source' or keys.include? 'source'
        do_show_source # This allows us to display the source of a given file.
      # ===================================================================== #
      # === ?pdf
      # ===================================================================== #
      elsif keys.include? 'pdf'
        if use_prawn?
          try_to_generate_pdf_file # Bundled into this method here.
        else
          e 'You normally do not seem to want to use prawn.'
          e 'Shall we override this? Not yet sure. (Stub).'
        end
      # ===================================================================== #
      # === disable_webimages
      # ===================================================================== #
      elsif keys.include? 'disable_webimages'
        disable_webimages
      # ===================================================================== #
      # === environment
      # ===================================================================== #
      elsif keys.include? 'environment'
        display_environmental_variables
      # ===================================================================== #
      # === sys_information
      # ===================================================================== #
      elsif keys =~ /sys_information/ or keys =~ /sys/ or keys =~ /status/
        display_system_information
      else
        # ================================================================= #
        # Next, things did fail. If we are in debug mode, we
        # show more information.
        # ================================================================= #
        if debug? # Ok, we may want to show more debug information.
          e 'Showing more debug-information next (since '\
            'Cyberweb.debug was set to true):'
          pp params?
          exit
        end
      end
    end
  end
end

#check_syntax_then_compress_the_main_string_then_remove_newlinesObject

#

check_syntax_then_compress_the_main_string_then_remove_newlines

#


755
756
757
758
759
# File 'lib/cyberweb/web_object/web_object.rb', line 755

def check_syntax_then_compress_the_main_string_then_remove_newlines
  consider_checking_for_new_syntax
  consider_compressing_main_string
  consider_removing_newlines
end

#check_whether_to_show_the_source_codeObject

#

check_whether_to_show_the_source_code

This is the method that can display the source code of a given .cgi page.

#


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
6957
6958
6959
6960
6961
6962
6963
6964
6965
6966
6967
6968
6969
6970
6971
6972
6973
6974
6975
6976
6977
6978
6979
6980
6981
# File 'lib/cyberweb/web_object/web_object.rb', line 6931

def check_whether_to_show_the_source_code
  # ======================================================================= #
  # We must also check whether the configuration file allows us to
  # show the source code.
  # ======================================================================= #
  if show_source? and Cyberweb.config['may_show_source']
    _ = this_file?(:full_path)
    ee '<html>'
    ee '<head>'
    # ===================================================================== #
    # Add the following in order to enable on-click highlight at a later time.
    # ===================================================================== #
    ee HtmlTags.style('.highlight {
         background:yellow;
       }')
    ee '</head>'
    ee '<body>'
    ee 'Next displaying the source code of the file <b>'+_+'</b>'
    # ===================================================================== #
    # The following has not yet been enabled. It shall follow this
    # here:
    #
    #   http://jsfiddle.net/kB7u2/1/
    #
    # ===================================================================== #
if false
    output_this_javascript "
    $('.stripe_table').hover(
function() {
  $(this).addClass('highlight');
}, function() {
  $(this).removeClass('highlight');
}
)"
end
    dataset = File.readlines(_)
    n_lines = dataset.size
    ee '<h4>'+n_lines.to_s+' lines</h4>'
    ee '<pre>'
    # ===================================================================== #
    # Presently, we will always display the index-number.
    # ===================================================================== #
    dataset.each_with_index {|content, index|
      index += 1
      ee '<span class="line_'+index.to_s+'"><b>'+index.to_s.ljust(5)+'</b>'+content+'</span>'
    }
    ee '</pre>'
    ee '</body></html>'
    exit
  end
end

#checked_checkbox(hash = {}) ⇒ Object

#

checked_checkbox

#


6115
6116
6117
6118
6119
6120
6121
6122
6123
6124
6125
6126
# File 'lib/cyberweb/web_object/web_object.rb', line 6115

def checked_checkbox(
    # hash = { name: 'valid_ninja' }
    hash = {}
  )
  name_to_use = ''
  if hash.is_a? Hash
    if hash.has_key? :name
      name_to_use = hash[:name]
    end
  end
  input_checkbox('', :default, name_to_use) { :is_checked }
end

#chmod_displayer(i = :default) ⇒ Object

#

chmod_displayer

#


5660
5661
5662
5663
5664
5665
5666
# File 'lib/cyberweb/web_object/web_object.rb', line 5660

def chmod_displayer(
    i = :default
  )
  append_onto_the_body_tag_nl(
    Cyberweb.chmod_displayer(i)
  )
end

#christmas_snow_globe_animationObject

#

christmas_snow_globe_animation

#


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

def christmas_snow_globe_animation
  ee '<div class="xmas_container">
<div class="xmas_snow"></div>
<div class="tree1"></div>
<div class="tree2"></div>
<div class="house">
  <div class="roof1">
    <div class="b1"></div>
    <div class="b2"></div>
  </div>
  <div class="wall1">
    <div class="w3">
      <div class="window1">
        <div class="glass1"></div>
      </div>
    </div>
  </div>
  <div class="wall2">
    <div class="light">
      <div class="w1">
        <div class="window">
          <div class="glass"></div>
        </div>
      </div>
      <div class="w2">
        <div class="window">
          <div class="glass"></div>
        </div>
      </div>
    </div>
    <div class="door">
      <div class="handle"></div>
    </div>
    <div class="snw1"></div>
    <div class="snw2"></div>
  </div>
  <div class="wall3">
    <div class="b3"></div>
    <div class="b4"></div>
    <div class="chimney">
      <div class="top">
        <div class="smoke">
          <div class="s1"></div>
          <div class="s2"></div>
          <div class="s3"></div>
        </div>
        <div class="shne1"></div>
        <div class="shne2"></div>
      </div>
    </div>
    <div class="sn">
      <div class="dr1"></div>
      <div class="dr2"></div>
      <div class="dr3"></div>
    </div>
    <div class="sn1">
      <div class="dr4"></div>
    </div>
    <div class="sh1"></div>
    <div class="sh2"></div>
    <div class="sh3"></div>
    <div class="sh4"></div>
    <div class="sh5"></div>
  </div>
</div>
<div class="snowfall"></div>
<div class="cover"></div>
<div class="xmas_bottom">
  <div class="bt1"></div>
  <div class="bt2"></div>
</div>
<div class="fence">
<div class="xmas_fn1">
  <div class="xmas_screw"></div>
</div>
<div class="xmas_fn2">
  <div class="xmas_screw"></div>
</div>
<div class="xmas_fn3">
  <div class="xmas_screw"></div>
</div>
<div class="xmas_stck"></div>
</div>
'
end

#clever_to_imagesObject

#

clever_to_images

This variant should be “clever” about inferring the base directory towards the images automatically.

#


6583
6584
6585
# File 'lib/cyberweb/web_object/web_object.rb', line 6583

def clever_to_images
  return_dot_dot_slash_to_the_data_directory(:infer_automatically)+'images/'
end

#clickable_header(i = '', optional_css_class = '', optional_the_id = '', optional_css_style = '', optional_javascript = '', &block) ⇒ Object Also known as: cheader

#

clickable_header

The idea for this method is to make a “clickable” header, that is, a h-tag that has an icon (a small image) on the left side. The user can only click on that icon, though, not the whole header.

Upon clicking on that icon an intralink is used, a “jumper” link.

#


3313
3314
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
3327
3328
# File 'lib/cyberweb/web_object/web_object.rb', line 3313

def clickable_header(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = '',
    &block
  )
  header(
    i,
    optional_css_class,
    optional_the_id,
    optional_css_style,
    optional_javascript
  ) { :clickable }
end

#clickable_image?Boolean

#

clickable_image?

This must stay a simpler getter - no sanitizing is allowed.

#

Returns:

  • (Boolean)


6848
6849
6850
# File 'lib/cyberweb/web_object/web_object.rb', line 6848

def clickable_image?
  @internal_hash[:clickable_image]
end

#clickable_image_as_string?Boolean

#

clickable_image_as_string?

#

Returns:

  • (Boolean)


8923
8924
8925
8926
8927
8928
8929
8930
8931
8932
8933
8934
8935
8936
8937
8938
8939
8940
8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
# File 'lib/cyberweb/web_object/web_object.rb', line 8923

def clickable_image_as_string?
  _ = clickable_image? # First get a reference.
  # ======================================================================= #
  # === Handle Symbols next
  #
  # Symbols have to be expanded towards their local path.
  # ======================================================================= #
  if _.is_a? Symbol
    _ = map_symbol_to_image_location(_) # Now we have the real path.
    if _.start_with? '/usr/lib/ruby/'
      # =================================================================== #
      # This can clearly not work, so we must rewrite the whole
      # line to ad-hoc fit to a roebe layout of the filesystem.
      # Clearly this will only work on my home system, but I am
      # the only one using this right now anyway.
      # =================================================================== #
      input_target       = ruby_sitelib_dir?
      replacement_target = relative_path?+'programming/ruby/src/cyberweb/lib/'
      _.gsub!(
        Regexp.new(input_target),
        replacement_target
      )
    else
      unless _.start_with? 'images/standard_images/'
        _.prepend(prepend_path_to_the_images?.dup)
      end
    end
    _ = '<img src="'+_+'" class="marr10px">'
  end
  return _.to_s # Must guarantee that it is a String.
end

#clinerObject

#

cliner

This methods creates a “colourized” horizontal line.

#


2340
2341
2342
2343
# File 'lib/cyberweb/web_object/web_object.rb', line 2340

def cliner
  _ = "<span>#{'=' * 80}<br>"
  append_onto_the_body_tag(_)
end

#cmd_counter(i = '', &block) ⇒ Object

#

cmd_counter

#


6171
6172
6173
6174
6175
6176
# File 'lib/cyberweb/web_object/web_object.rb', line 6171

def cmd_counter(
    i = '',
    &block
  )
  counter_li(i, Cyberweb.cmd1_css_rules?, &block)
end

#colourize_ruby_code(i) ⇒ Object

#

colourize_ruby_code

#


8500
8501
8502
# File 'lib/cyberweb/web_object/web_object.rb', line 8500

def colourize_ruby_code(i)
  Cyberweb.colourize_ruby_code(i)
end

#compress_main_string?Boolean

#

compress_main_string?

#

Returns:

  • (Boolean)


1691
1692
1693
# File 'lib/cyberweb/web_object/web_object.rb', line 1691

def compress_main_string?
  @config['compress_main_string']
end

#config?Boolean Also known as: web_object_config?, configuration?

#

config?

A getter-method towards the config dataset.

Usage Example:

w.config['use_jquery']
#

Returns:

  • (Boolean)


873
874
875
# File 'lib/cyberweb/web_object/web_object.rb', line 873

def config?
  @config
end

#consider_checking_for_new_syntaxObject

#

consider_checking_for_new_syntax

This method can be used to check whether we are using the new syntax style in .cgi files already or whether we are not.

New syntax means w {} rather than w.method_call_here.

#


5706
5707
5708
5709
5710
5711
5712
5713
5714
5715
5716
5717
5718
5719
5720
5721
5722
5723
5724
5725
5726
5727
5728
5729
5730
5731
5732
5733
5734
# File 'lib/cyberweb/web_object/web_object.rb', line 5706

def consider_checking_for_new_syntax
  if use_verbose_warnings?
    _ = (base_dir?.to_s+request_uri?.to_s).squeeze '/' # This is the file that we can check.
    if File.exist?(_) and !File.empty?(_) and File.file?(_)
      dataset = File.read(_, encoding: ENCODING_UTF8) # We will have the dataset as a String.
      # =================================================================== #
      # Query for 'w.title =' components and variations of it next.
      # =================================================================== #
      if dataset.include?('w.t "') or dataset.include?("w.t '") or
         dataset.include?('w.title =') or dataset.include?('w.t = ')
        # ================================================================= #
        # If the line starts with a "w.t" entry. Other entries, such as
        # cmd '  w.t' will be ignored.
        # ================================================================= #
        if dataset =~ /(^\s+w\.t)/ # http://rubular.com/r/2ocG6eqLm9
          h1 sg(:small_plane,'marr1em')+'Warning: Old syntax style '+
             'found at file <b class="lightgreen">'+_+'</b>', 'red larger FW3'
          spacer
          h2 '! You may consider wanting to replace this with the '+
             'newer syntax !'
          h4 'If you are unsure about the syntax, look at <b>
             USAGE.md</b>.','marl5em'
          spacer
        end
      # else # Don't show the following regularly, only for debugging.
      end
    end
  end
end

#consider_compressing_main_stringObject

#

consider_compressing_main_string

Right now this just removes all newlines, if the configuration option was set.

#


1354
1355
1356
1357
1358
# File 'lib/cyberweb/web_object/web_object.rb', line 1354

def consider_compressing_main_string
  if compress_main_string?
    result?.delete!(N)
  end
end

#consider_loading_addons_based_on_the_config_fileObject

#

consider_loading_addons_based_on_the_config_file

This presently only attempts to load prawn.

#


9272
9273
9274
9275
9276
9277
9278
9279
9280
9281
# File 'lib/cyberweb/web_object/web_object.rb', line 9272

def consider_loading_addons_based_on_the_config_file
  if use_prawn?
    # ===================================================================== #
    # Then we try to load prawn. We are silent about this.
    # ===================================================================== #
    begin
      require 'prawn'
    rescue LoadError; end
  end
end

#consider_removing_newlines(shall_we_remove_newlines = remove_newlines? ) ⇒ Object

#

consider_removing_newlines

#


293
294
295
296
297
# File 'lib/cyberweb/web_object/web_object.rb', line 293

def consider_removing_newlines(
    shall_we_remove_newlines = remove_newlines?
  ) 
  result?.delete!(N) if shall_we_remove_newlines
end

#container_for_the_CSS_coffee_animationObject

#

container_for_the_CSS_coffee_animation

The method Cyberweb.container_for_the_CSS_coffee_animation will return mostly some <div>-tags.

#


7710
7711
7712
7713
7714
# File 'lib/cyberweb/web_object/web_object.rb', line 7710

def container_for_the_CSS_coffee_animation
  append_onto_the_body_tag_nl(
    Cyberweb.container_for_the_CSS_coffee_animation
  )
end

#convert_image_to_base64(this_image) ⇒ Object

#

convert_image_to_base64

This functionality depends on imagemagick, so make sure to install it if you wish to make use of this method.

#


7294
7295
7296
# File 'lib/cyberweb/web_object/web_object.rb', line 7294

def convert_image_to_base64(this_image)
  return Cyberweb.convert_image_to_base64(this_image)
end

#countdown_timer(start_at = 100, target_this_div = 'countdown_timer') ⇒ Object

#

countdown_timer

This method can be used to use a countdown-timer in JavaScript.

#


2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
# File 'lib/cyberweb/web_object/web_object.rb', line 2401

def countdown_timer(
    start_at        = 100,
    target_this_div = 'countdown_timer'
  )
  ejavascript '
  const target = document.getElementById("'+target_this_div+'");
  for (let i = '+start_at.to_s+'; i >= 0; i--) {
    target.innerHTML = i;
    sleep(1000);
  }
  '
end

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

#

counter_is_bold

#


1608
1609
1610
1611
1612
1613
1614
1615
1616
# File 'lib/cyberweb/web_object/web_object.rb', line 1608

def counter_is_bold(
    i                  = '',
    optional_css_class = ''
  )
  counter(
    i,
    optional_css_class
  ) { :counter_is_bold }
end

#counter_li(i = '', optional_css_class = '', &block) ⇒ Object Also known as: listing, counter, li_counter

#

counter_li (counter tag)

This method was added in June 2021. It combines counter() with li().

#


1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
# File 'lib/cyberweb/web_object/web_object.rb', line 1239

def counter_li(
    i                  = '',
    optional_css_class = '',
    &block
  )
  @internal_hash[:listing_counter] += 1
  yielded = nil
  if block_given?
    yielded = yield
  end
  index = @internal_hash[:listing_counter].to_s
  case yielded
  # ======================================================================= #
  # === :counter_is_bold
  # ======================================================================= #
  when :counter_is_bold
    index = "<b>#{index}</b>"
  end
  e '('+index+') '+i.to_s,
    optional_css_class
end

#create_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

#

create_copy_to_clipboard_button

The third argument determines whether the “associated” input field will be hidden or not.

This would then generate an input-field such as this:

<input type="hidden">
#


2106
2107
2108
2109
2110
2111
2112
2113
2114
2115
2116
2117
2118
2119
2120
# File 'lib/cyberweb/web_object/web_object.rb', line 2106

def create_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 = ''
  )
  ee return_copy_to_clipboard_button(
    use_this_value,
    use_this_id,
    hide_the_input_field,
    text_shown_on_the_button,
    css_rules_for_the_button
  )
end

#create_databaseObject

#

create_database

#


8450
8451
8452
8453
8454
8455
8456
8457
8458
8459
8460
8461
8462
8463
8464
8465
8466
8467
8468
8469
8470
8471
8472
8473
8474
8475
8476
8477
8478
8479
8480
# File 'lib/cyberweb/web_object/web_object.rb', line 8450

def create_database
  case database?
  # === :sqlite
  when :sqlite
    require 'sqlite3'
    db = SQLite3::Database.new '/Depot/j/test.db' # Open a database
    # ===================================================================== #
    # Create a database
    # ===================================================================== #
    # rows = db.execute <<-SQL
    db.execute <<-SQL
      create table numbers (
        name varchar(30),
        val int
      );
SQL
    {
      'one' => 1,
      'two' => 2,
    }.each { |pair|
      db.execute 'insert into numbers values ( ?, ? )', pair
    }
    # Execute inserts with parameter markers
    db.execute("INSERT INTO students (name, email, grade, blog) 
                VALUES (?, ?, ?, ?)", ['joe', 'hoe@hotmail.com', '5', 'yo'])
    # Find a few rows
    db.execute( "select * from numbers" ) do |row|
      p row
    end
  end
end

#create_standalone_html_page(use_this_filename = filename? ) ⇒ Object Also known as: dump_the_html

#

create_standalone_html_page

This method can be used to create a standalone .html page, representing the WebObject content.

#


2174
2175
2176
2177
2178
2179
2180
2181
2182
2183
2184
2185
2186
2187
2188
2189
2190
# File 'lib/cyberweb/web_object/web_object.rb', line 2174

def create_standalone_html_page(
    use_this_filename = filename?
  )
  Cyberweb.set_log_directory(:classic_FHS_structure)
  what = to_html
  # ======================================================================= #
  # We will store into the log-directory of the Cyberweb project.
  # ======================================================================= #
  into = log_directory?+
         use_this_filename.delete_suffix(
           File.extname(use_this_filename)
         )+'.html' # This must be accessible.
  message = 'Storing into the local file '+sfile(into)+'.'
  e message
  puts message
  write_what_into(what, into)
end

#csectionObject

#

csection

#


8689
8690
8691
# File 'lib/cyberweb/web_object/web_object.rb', line 8689

def csection
  Cyberweb.csection
end

#css_rules_for_the_coffee_animationObject

#

css_rules_for_the_coffee_animation

#


8001
8002
8003
8004
8005
# File 'lib/cyberweb/web_object/web_object.rb', line 8001

def css_rules_for_the_coffee_animation
  add_onto_the_CSS_rules(
    return_css_rules_for_the_coffee_animation
  )
end

#ctbodyObject

#

ctbody

#


4005
4006
4007
# File 'lib/cyberweb/web_object/web_object.rb', line 4005

def ctbody
  close(:tbody)
end

#current_temperature?Boolean

#

current_temperature?

#

Returns:

  • (Boolean)


5530
5531
5532
5533
5534
5535
# File 'lib/cyberweb/web_object/web_object.rb', line 5530

def current_temperature?
  begin
    require 'wetter'
  rescue LoadError; end
  return Wetter.simplified_current_degrees # Wetter.current_degrees
end

#current_width?Boolean

#

current_width?

This method uses JavaScript to return the current width of the monitor, such as “2560” (for 2560 pixel).

#

Returns:

  • (Boolean)


2859
2860
2861
2862
2863
2864
2865
2866
# File 'lib/cyberweb/web_object/web_object.rb', line 2859

def current_width?
  append_onto_the_body_tag_nl(
    '<script>
    var width = window.innerWidth;
    document.write(width)
    </script>'
  )
end

#database=(i = :sqlite) ⇒ Object

#

database=

Which database to use, if any at all.

Possible databases include:

sqlite
mysql
postgresql
#


5314
5315
5316
5317
5318
# File 'lib/cyberweb/web_object/web_object.rb', line 5314

def database=(
    i = :sqlite
  )
  @internal_hash[:database] = i.to_sym
end

#database?Boolean

#

database?

#

Returns:

  • (Boolean)


9317
9318
9319
# File 'lib/cyberweb/web_object/web_object.rb', line 9317

def database?
  @internal_hash[:database]
end

#datum(welches_datum = '', css_class = 'martb4px s2px yel', optional_id = nil, optional_css_style = '') ⇒ Object Also known as: show_datum, datumg

#

datum

Display datum. The argument ‘welches_datum` will be empty by default and will in this case call the method date_today().

Usage examples:

datum '06.08.2008','BG_Black yel wid20 pad4px', id: 'datum'
#


7927
7928
7929
7930
7931
7932
7933
7934
7935
7936
7937
7938
7939
7940
7941
7942
# File 'lib/cyberweb/web_object/web_object.rb', line 7927

def datum(
    welches_datum      = '',
    css_class          = 'martb4px s2px yel',
    optional_id        = nil,
    optional_css_style = ''
  )
  if optional_id.is_a? Hash
    optional_id = optional_id.delete(:id)
  end
  optional_id = optional_id.to_s
  welches_datum = date_today if welches_datum.empty? # Ask the method above.
  p(css_class, optional_id, optional_css_style) {
    espan "<ud class=\"BOLD\">Datum</ud>: "\
          "<b>#{welches_datum}</b>"
  }
end

#datume(welches_datum = '', css_class = 'martb4px s2px yel', optional_id = nil, optional_css_style = '') ⇒ Object

#

datume

Like datum() but for english.

#


5995
5996
5997
5998
5999
6000
6001
6002
6003
6004
6005
6006
6007
6008
6009
6010
# File 'lib/cyberweb/web_object/web_object.rb', line 5995

def datume(
    welches_datum      = '',
    css_class          = 'martb4px s2px yel',
    optional_id        = nil,
    optional_css_style = ''
  )
  if optional_id.is_a? Hash
    optional_id = optional_id.delete(:id)
  end
  optional_id = optional_id.to_s
  welches_datum = date_today if welches_datum.empty? # Ask the method above.
  p(css_class, optional_id, optional_css_style) {
    espan "<ud class=\"BOLD\">Date</ud>: "\
          "<b>#{welches_datum}</b>"
  }
end

#debug?Boolean

#

debug?

Note that we need @debug rather than Cyberweb.debug? because we may want to enable debugging of a web_object at any moment in time lateron.

#

Returns:

  • (Boolean)


1074
1075
1076
# File 'lib/cyberweb/web_object/web_object.rb', line 1074

def debug?
  @internal_hash[:debug]
end

#decode_this_image_to_base64(this_image) ⇒ Object

#

decode_this_image_to_base64

This method will first decode the image at hand into base64, and then embed it directly, by calling base64_image(). The latter will make use of addnl(), which will add the “converted” image to the WebObject instance.

#


6478
6479
6480
6481
# File 'lib/cyberweb/web_object/web_object.rb', line 6478

def decode_this_image_to_base64(this_image)
  dataset = convert_image_to_base64(this_image)
  base64_image(dataset, :infer)
end
#
#


1266
1267
1268
# File 'lib/cyberweb/web_object/web_object.rb', line 1266

def default_CSS_class_for_hyperlinks
  'marl3em BOLD'
end

#default_CSS_for_the_calculatorObject

#

default_CSS_for_the_calculator

The first ID, that is “screen_for_the_simple_javascript_calculator”, is the top-screen that appears on the calculator, showcasing what the user did input, as well as the results from it.

#


1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
# File 'lib/cyberweb/web_object/web_object.rb', line 1897

def default_CSS_for_the_calculator
  return '
#screen_for_the_simple_javascript_calculator {
background-color: #fffc95;
color:  black;
border: 4px solid black;
}

#simple_javascript_calculator {
background-color: white;
}

'+Cyberweb.return_css_for_the_simple_calculator(
  {
    font_size_to_use:  '18px'
  }
) # Font size to use.
end

#default_simple_clock(css_classes_to_use_for_the_outer_div = :default, css_style_to_use_for_the_outer_div = 'margin-top: 0.2em; margin-right: 8%; width: 280px; font-size: 2.0em;') ⇒ Object

#

default_simple_clock

This method can be used to embed a simple clock into a webpage.

If you dislike the defaults, you can re-model them to your needs; I do the same for different websites.

#


6340
6341
6342
6343
6344
6345
6346
6347
6348
6349
6350
6351
6352
6353
6354
6355
6356
6357
6358
6359
6360
6361
6362
6363
# File 'lib/cyberweb/web_object/web_object.rb', line 6340

def default_simple_clock(
    css_classes_to_use_for_the_outer_div = :default,
    css_style_to_use_for_the_outer_div   = 'margin-top:   0.2em; 
     margin-right:   8%;
     width:        280px;
     font-size:    2.0em;'
  )
  case css_classes_to_use_for_the_outer_div
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default
    css_classes_to_use_for_the_outer_div = 'FLR TAC center'
  end
  div(css_classes_to_use_for_the_outer_div,'',
      css_style_to_use_for_the_outer_div) {
    p(
      id:        'a_simple_clock',
      css_class: 'round_black3 BG_Black',
      css_style: 'margin: 0.4em; color: lightblue') {
    }
  }
  display_a_simple_javascript_clock
end

#determine_the_relative_pathObject

#

determine_the_relative_path

This method is normally called only once, on startup.

#


4093
4094
4095
4096
4097
4098
4099
4100
4101
4102
4103
4104
4105
4106
4107
4108
4109
4110
4111
4112
4113
4114
4115
# File 'lib/cyberweb/web_object/web_object.rb', line 4093

def determine_the_relative_path
  _ = ''.dup
  if return_pwd.start_with? '/home/x/studium/'
    regex = Regexp.quote('/home/x/studium/')
  else
    regex = Regexp.quote(HOME_X_DATA)
  end
  # ======================================================================= #
  # Calculate the difference next.
  # ======================================================================= #
  difference = return_pwd.sub(regex, '').count('/')
  if difference > 0
    _ << '../' * (difference+1)
  end
  # ======================================================================= #
  # Next, some paths on my home system require modifications.
  # ======================================================================= #
  # if return_pwd.start_with?('/home/x/studium/') or
  #    return_pwd.start_with?('/home/x/programming/')
  #   _ << '../data/'
  # end
  set_relative_path("#{_}")
end

#dimgbr(url = '', css_class = '', the_id = '', css_style = '', alt_text = '', &block) ⇒ Object

#

dimgbr

This method combines dimg() and br().

#


6517
6518
6519
6520
6521
6522
6523
6524
6525
6526
6527
# File 'lib/cyberweb/web_object/web_object.rb', line 6517

def dimgbr(
    url       = '',
    css_class = '', 
    the_id    = '',
    css_style = '',
    alt_text  = '',
    &block
  )
  dimg(url, css_class, the_id, css_style, alt_text, &block)
  br
end

#disable_right_clickObject Also known as: no_right_click

#

disable_right_click

This is jquery-specific code, which can be used to disable the right-mouse button click.

Personally I dislike this functionality a lot - the user should be in control at all times, not the website developer. But because other people may for whatever reason wish to have this (perhaps), I have decided to include it as part of the cyberweb framework. It is then their responsibility to use it or not use it - for my own sites I won’t use it.

Note that for this method to work, you must have jquery enabled prior to calling this method, through something such as a use_jquery() directive, followed by the disable_right_click directive. Or simply enable the use of jquery via the configuration file.

#


2162
2163
2164
2165
2166
# File 'lib/cyberweb/web_object/web_object.rb', line 2162

def disable_right_click
  _ = ::Cyberweb.disable_right_click(:return_it)
  # add_to_main_string_lateron(_) # Disabled at 05.05.2023.
  append_onto_the_body_tag_nl(_)
end

#disable_webimagesObject

#

disable_webimages

We wont use the webimages if we use this method here.

#


1700
1701
1702
# File 'lib/cyberweb/web_object/web_object.rb', line 1700

def disable_webimages
  Cyberweb.config?['use_webimages'] = false
end

#display_a_simple_javascript_clockObject

#

display_a_simple_javascript_clock

This method was added in June 2023, to compensate for the older JavaScript-clock no longer working.

A typical use case follows:

div('FLR TAC center','',
    'margin-top:   0.2em; 
     margin-right:   8%;
     width:        280px;
     font-size:    2.0em;') {
  p(
    id:        'a_simple_clock',
    css_class: 'round_black3 BG_Black',
    css_style: 'margin: 0.4em; color: lightblue') {
  }
}
#


9148
9149
9150
9151
9152
9153
# File 'lib/cyberweb/web_object/web_object.rb', line 9148

def display_a_simple_javascript_clock
  ejavascript(
    # return_this_default_javascript_file('a_simple_clock.js')
    return_the_content_of_this_default_javascript_file('a_simple_clock.js')
  )
end

#display_all_images(dir = Cyberweb.return_pwd, optional_css = 'bblack1') ⇒ Object Also known as: display_images_from, display_images

#

display_all_images

Use this when you just want to display all images.

The first argument should be the location towards the directory that holds all images.

#


7362
7363
7364
7365
7366
7367
7368
7369
7370
7371
7372
7373
7374
7375
7376
7377
7378
7379
7380
7381
7382
7383
7384
# File 'lib/cyberweb/web_object/web_object.rb', line 7362

def display_all_images(
    dir          = Cyberweb.return_pwd,
    optional_css = 'bblack1'
  )
  if dir.is_a? Hash
    dir = dir.delete(:from) if dir.has_key? :from
  end
  if dir.include? '$'
    dir = ConvertGlobalEnv[dir]
  end
  unless Dir.exist? dir
    e 'It seems as if the directory at `'+dir+'` does not exist.'
  end
  all_the_images = get_images_from(dir)
  all_the_images.each {|file|
    file = rds(file)
    h3 file, 'slateblue'
    imgbr(
      file,
      optional_css
    )
  }
end

#display_directoriesObject

#

display_directories

#


8485
8486
8487
8488
8489
8490
8491
8492
8493
8494
8495
# File 'lib/cyberweb/web_object/web_object.rb', line 8485

def display_directories
  image_directory = sg(:directory, 'marr8px')
  Dir['**'].each {|entry|
    if File.directory? entry
      abr(
        entry,
        content: image_directory+'SELF'
      )
    end
  }
end

#display_ruby_code(content = '', optional_css_class = '') ⇒ Object

#

display_ruby_code

#


7875
7876
7877
7878
7879
7880
7881
7882
7883
7884
# File 'lib/cyberweb/web_object/web_object.rb', line 7875

def display_ruby_code(
    content            = '',
    optional_css_class = ''
  )
  pre(
    colourize_ruby_code(content),
    'code_body',
    optional_css_class
  ) # Alias to the <pre> tag.
end

#display_simple_clock(optional_css_class = '') ⇒ Object

#

display_simple_clock

This is a simpler clock variant.

#


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

def display_simple_clock(
    optional_css_class = ''
  )
  ee '<p id="id_for_the_simple_clock_timer" class="'+optional_css_class.to_s+'"></p>'
  append_onto_the_body_tag_nl(
    return_javascript '
    simple_clock_timer();
var timer = setInterval(function() {
simple_clock_timer();
}, 1000);

function return_formatted_time() {
var d = new Date();
var formatted_time = ("0"+d.getHours()).slice(-2)+":"+
                     ("0"+d.getMinutes()).slice(-2)+":"+
                     ("0"+d.getSeconds()).slice(-2);
return formatted_time;
}

function simple_clock_timer() {
document.getElementById("id_for_the_simple_clock_timer").innerHTML = return_formatted_time();
}
'
  )
end

#display_the_registered_base64_imagesObject

#

display_the_registered_base64_images

#


8023
8024
8025
8026
8027
# File 'lib/cyberweb/web_object/web_object.rb', line 8023

def display_the_registered_base64_images
  return_the_registered_base64_images.each {|this_base64_image|
    add_this_base64_image(this_base64_image)
  }
end

#display_time(in_what_format = :javascript, css_style = '') ⇒ Object

#

display_time

Simply display the time.

#


8378
8379
8380
8381
8382
8383
8384
8385
8386
8387
8388
8389
8390
8391
8392
8393
8394
8395
8396
8397
8398
# File 'lib/cyberweb/web_object/web_object.rb', line 8378

def display_time(
    in_what_format = :javascript,
    css_style      = ''
  )
  if in_what_format.is_a?(Hash) and in_what_format.has_key?(:css_style)
    css_style = in_what_format.delete(:css_style)
    in_what_format = :javascript
  end
  div('','clock',css_style) {
    case in_what_format
    # ===================================================================== #
    # === :javascript
    # ===================================================================== #
    when :javascript,
         :default
      return_javascript "updateClock(); setInterval('updateClock()', 1000 )"
    when :ruby
      e Time.now.strftime('%H:%M:%S') 
    end
  }
end

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

#

div_default

This method will yield a <div> tag ultimately, with the additional class=“default” setting. So, in other words, it would generate this raw content:

<div class="default"></div>

The method has to be somewhat flexible. Invocation examples such as div_default(css_style: AQUAMARINE_BORDER) must be supported.

#


2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
2650
2651
2652
2653
2654
2655
2656
2657
2658
2659
2660
# File 'lib/cyberweb/web_object/web_object.rb', line 2616

def div_default(
    optional_css_class = '',
    the_id             = '',
    optional_css_style = '',
    &block
  )
  if optional_css_style.is_a? Hash
    # ===================================================================== #
    # === css_style
    # ===================================================================== #
    if optional_css_style.has_key? :css_style
      optional_css_style = optional_css_style.delete(:css_style)
    end
  end
  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
    # ===================================================================== #
    if optional_css_class.has_key? :css_style
      optional_css_style = optional_css_class.delete(:css_style)
    end
    # ===================================================================== #
    # === css_class
    #
    # This entry must come last.
    # ===================================================================== #
    if optional_css_class.has_key? :css_class
      optional_css_class = optional_css_class.delete(:css_class)
    end
  end
  optional_css_class = optional_css_class.to_s.dup
  optional_css_class.prepend('default ') # Make it the first argument, always.
  div(
    optional_css_class.strip,
    the_id,
    optional_css_style,
    &block
  )
end

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

#

div_default_english

#


2686
2687
2688
2689
2690
2691
2692
2693
2694
2695
2696
2697
2698
2699
2700
# File 'lib/cyberweb/web_object/web_object.rb', line 2686

def div_default_english(
    optional_css_class = '',
    the_id             = '',
    optional_css_style = '',
    &block
  )
  add_this_div(
    optional_css_class,
    the_id,
    optional_css_style
  )
  ee sg(:english_flag, 'mar8px')
  yield if block_given?
  cdiv
end

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

#

div_default_le

#


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

def div_default_le(
    optional_css_class = '',
    the_id             = '',
    optional_css_style = '',
    &block
  )
  # ======================================================================= #
  # === Handle Hashes
  #
  # Next handle Hashes given to this method
  # ======================================================================= #
  if optional_css_class.is_a? Hash
    # ===================================================================== #
    # === :id
    # ===================================================================== #
    if optional_css_class.has_key? :id
      the_id = optional_css_class.delete(:id)
    # ===================================================================== #
    # === :the_id
    # ===================================================================== #
    elsif optional_css_class.has_key? :the_id
      the_id = optional_css_class.delete(:the_id)
    end
    # ===================================================================== #
    # === :css_style
    # ===================================================================== #
    if optional_css_class.has_key? :css_style
      optional_css_style = optional_css_class.delete(:css_style)
    end
    if optional_css_class.is_a?(Hash) and optional_css_class.empty?
      optional_css_class = ''
    end
  end
  if the_id.is_a? Hash
    # ===================================================================== #
    # === :id
    # ===================================================================== #
    if the_id.has_key? :id
      the_id = the_id.delete(:id)
    end
  end
  optional_css_class = optional_css_class.to_s.dup
  optional_css_class.prepend('default ') # Make it the first argument.
  div(
    optional_css_class.strip,
    the_id,
    optional_css_style,
    &block
  )
end

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

#

div_p_default

#


5516
5517
5518
5519
5520
5521
5522
5523
5524
5525
# File 'lib/cyberweb/web_object/web_object.rb', line 5516

def div_p_default(
    optional_css_class = '',
    the_id             = '',
    optional_css_style = '',
    &block
  )
  div_default(optional_css_class, the_id, optional_css_style) {
    p_default(optional_css_class, the_id, optional_css_style, &block)
  }
end

#do_copy_the_javascript_code_files_into_current_working_directoryObject

#

do_copy_the_javascript_code_files_into_current_working_directory

This method will copy the javascript code to a path such as “/home/x/Temp/cyberweb/javascript_code/custom_functions.js”.

Note that this refers to my home setup, so for other users this may be largely irrelevant.

#


6374
6375
6376
6377
6378
6379
6380
6381
6382
6383
6384
6385
6386
6387
6388
6389
6390
6391
6392
6393
6394
6395
6396
6397
6398
6399
6400
6401
6402
6403
6404
6405
6406
6407
# File 'lib/cyberweb/web_object/web_object.rb', line 6374

def do_copy_the_javascript_code_files_into_current_working_directory
  use_this_path = "#{project_base_directory?}javascript_code/"
  current_directory = return_pwd
  # ======================================================================= #
  # The next clause will only copy files - at a later time this may
  # have to be changed to also copy directories, but for now (Oct 2022)
  # this is the way to go.
  #
  # Since as of December 2022, the file will always be copied if the
  # File.mtime() is more recent. That has been enabled specifically
  # for my home system.
  # ======================================================================= #
  Dir["#{use_this_path}*"].select {|entry| File.file?(entry) }.each {|entry|
    mtime_of_the_file_to_be_copied = File.mtime(entry)
    location_for_the_new_file = current_directory+File.basename(entry)
    if File.exist? location_for_the_new_file
      mtime_location_for_the_new_file = File.mtime(location_for_the_new_file)
      # ===================================================================== #
      # target will be a String such as:
      #
      #   "/home/x/Temp/cyberweb/javascript_code/chmod_displayer.js"
      #
      # ===================================================================== #
      if File.exist?(location_for_the_new_file)
        if mtime_of_the_file_to_be_copied > mtime_location_for_the_new_file
          copy_this_file(entry, location_for_the_new_file)
        else # else we don't have to do anything.
        end
      else
        copy_this_file(entry, location_for_the_new_file)
      end
    end
  }
end

#do_not_display_empty_filesObject

#

do_not_display_empty_files

This method disallows us from displaying empty files. If true then we will not display empty files. We can probably get rid of the global variable here.

#


1947
1948
1949
# File 'lib/cyberweb/web_object/web_object.rb', line 1947

def do_not_display_empty_files
  @internal_hash[:do_not_display_empty_files] = true
end

#do_show_sourceObject

#

do_show_source

#


5739
5740
5741
# File 'lib/cyberweb/web_object/web_object.rb', line 5739

def do_show_source
  @internal_hash[:show_source] = true
end

#do_show_sys_info(css_class = 'FS1_1em bblack1 pad1empx BG_Black White') ⇒ Object

#

do_show_sys_info

This method will show some system-related information about the environment.

#


8242
8243
8244
8245
8246
8247
8248
8249
8250
8251
8252
8253
8254
8255
8256
8257
8258
8259
8260
8261
8262
8263
8264
8265
8266
8267
8268
8269
8270
8271
8272
8273
8274
8275
8276
8277
8278
8279
8280
8281
8282
8283
8284
8285
8286
8287
8288
8289
8290
8291
8292
8293
8294
8295
8296
8297
8298
8299
8300
8301
8302
8303
8304
8305
8306
8307
8308
8309
8310
8311
8312
8313
8314
# File 'lib/cyberweb/web_object/web_object.rb', line 8242

def do_show_sys_info(
    css_class = 'FS1_1em bblack1 pad1empx BG_Black White'
  )
  div(css_class,'','margin:0.25em'){
    h2 sg(:wings,'marr8px')+'Displaying some Sys Info stuff:',
       'lightblue'
    p('pad4px'){
      uptime = `uptime`
      e 'Uptime since:','lgreen BOLD'
      br
      e uptime,'yel padl1em'
    }
    p('pad4px'){
      ruby_version = `ruby --version`
      e 'Ruby version:','lgreen BOLD'
      br
      e ruby_version,'yel padl1em BOLD'
      br
      ruby_gem_version = `gem --version`
      e 'Ruby gem version:','lgreen BOLD'
      br
      e ruby_gem_version,'yel padl1em BOLD'
      br
      path_to_the_rubygem_installation_directory = Gem.vendor_dir
      e 'Ruby installation directory:','lgreen BOLD'
      br
      e path_to_the_rubygem_installation_directory,'yel padl1em'
      ruby_user_home = Gem.user_home
      br
      e 'Ruby user home:','lgreen BOLD'
      br
      e ruby_user_home.to_s,'yel padl1em'
    }
    p('pad4px mart0_2em') {
      e 'Free Memory:','lgreen BOLD'
      free = `free -l`
      pre free
    }
    begin
      p('pad4px mart0_2em'){
        e 'Hdparm Settings:','lgreen BOLD'
        # bl $LINUX_YAML/*roeb*
        festplatte = '/dev/sda1'
        hdparm = `hdparm -Tt #{festplatte}`
        e hdparm,'yel padl1em'
        br
        e 'CPU-Info:','lgreen BOLD'
        if File.exist? '/proc/cpuinfo' # We can run this only when that file exists.
          begin
            cpuinfo = `cat /proc/cpuinfo`
            pre cpuinfo,'default'
          rescue; end
        end
      }
    rescue; end
    h4 sg(:black_dot, 'marr10px')+
       'LSPCI','yellow'
    p('pad4px mart0_2em'){
      lspci = `lspci -v 2>&1`
      pre lspci if lspci
    }
    p('pad4px mart0_2em'){
      e 'Vmstat Settings:','lgreen'
      vmstat=`vmstat`
      pre vmstat
      e 'Disk Free:','lgreen'
      df=`df -ha`
      df.gsub!(/\/dev\/hda1/,'<b class="lightblue">
        <a href="file:///dev/">/dev/hda1</a></b>')
      pre df
    }
  }
end

#do_use_base64_encoding_for_all_local_imagesObject Also known as: all_images_via_base64, do_use_base64_for_all_images

#

do_use_base64_encoding_for_all_local_images

#


6896
6897
6898
# File 'lib/cyberweb/web_object/web_object.rb', line 6896

def do_use_base64_encoding_for_all_local_images
  @internal_hash[:use_base64_encoding_for_all_local_images] = true
end

#do_use_exceptionsObject Also known as: use_exceptions

#

do_use_exceptions

#


3910
3911
3912
# File 'lib/cyberweb/web_object/web_object.rb', line 3910

def do_use_exceptions
  @config['print_cgi_exceptions'] = true
end

#do_use_in_dir_imagesObject Also known as: use_in_dir_images

#

do_use_in_dir_images

#


6569
6570
6571
6572
6573
6574
6575
# File 'lib/cyberweb/web_object/web_object.rb', line 6569

def do_use_in_dir_images
  @config['use_in_dir_images'] = true
  # ======================================================================= #
  # Also keep track of the new path.
  # ======================================================================= #
  Cyberweb.set_path_to_images('')
end

#do_use_jqueryObject Also known as: use_jquery, enable_drag, enable_jquery

#

do_use_jquery

Use this method to enable jquery support.

I recommend to use this method, rather than use_jquery, but if you want to be lazy, feel free to use either variant. I just think that the explicit “do_” implies an action, which I think is more logical.

#


6325
6326
6327
6328
# File 'lib/cyberweb/web_object/web_object.rb', line 6325

def do_use_jquery
  do_shall_we_use_jquery
  @config['use_jquery'] = true # Do a batch-assignment here.
end

#do_use_sendmailObject Also known as: use_sendmail

#

do_use_sendmail

Enable the use of sendmail via this method. The mail gem must have been installed in order for this to work.

#


3893
3894
3895
3896
# File 'lib/cyberweb/web_object/web_object.rb', line 3893

def do_use_sendmail
  @internal_hash[:mail] = Mail.new unless @internal_hash[:mail]
  @internal_hash[:mail].delivery_method :sendmail
end

#do_use_unicodeObject Also known as: use_unicode

#

use_unicode

#


6904
6905
6906
# File 'lib/cyberweb/web_object/web_object.rb', line 6904

def do_use_unicode
  @internal_hash[:use_unicode] = true
end

#do_we_use_jquery?Boolean Also known as: report_whether_this_webobject_makes_use_of_jquery, report_use_jquery?, jquery_is_used?

#

do_we_use_jquery?

This method can be used to report whether a particular web-object makes use of jquery or whether it does not.

#

Returns:

  • (Boolean)


5611
5612
5613
# File 'lib/cyberweb/web_object/web_object.rb', line 5611

def do_we_use_jquery?
  e "Does this web_object make use of jquery? #{use_jquery?}"
end

#doc(optional_css_class = 'pad5px', optional_the_id = '', optional_css_style = '', &block) ⇒ Object Also known as: document

#

doc (doc tag)

doc() is essentially a wrapper over div() - the primary <div> tag for the web-page at hand.

#


265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
# File 'lib/cyberweb/web_object/web_object.rb', line 265

def doc(
    optional_css_class = 'pad5px',
    optional_the_id    = '',
    optional_css_style = '',
    &block
  )
  check_for_a_file_called_config_md
  if raw_favicon_string?
    html_string?.sub!(
      /<\/head>/,
      return_favicon_string(raw_favicon_string?)+"\n"+
      "</head>\n"
    )
  end
  # ======================================================================= #
  # === Simply pass onto div() next
  # ======================================================================= #
  div(
    optional_css_class,
    optional_the_id,
    optional_css_style,
    &block
  )
end

#doc_default_width(optional_css_class = 'pad5px', optional_the_id = '', optional_css_style = '', &block) ⇒ Object Also known as: doc_preferred_width, preferred_width, default_width, regular_width

#

doc_default_width

This method is similar to doc(), but it has the mandatory CSS class .my_preferred_width passed into doc() in a guaranteed manner.

Usage example:

doc_default_width('mar0px pad0px s0_8em') {
}
#


341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
# File 'lib/cyberweb/web_object/web_object.rb', line 341

def doc_default_width(
    optional_css_class = 'pad5px',
    optional_the_id    = '',
    optional_css_style = '',
    &block
  )
  unless optional_css_class.is_a? String
    optional_css_class = optional_css_class.to_s
  end
  if optional_css_class.frozen?
    optional_css_class = optional_css_class.dup
  end
  unless optional_css_class.include? 'my_preferred_width'
    optional_css_class << ' my_preferred_width'
    optional_css_class.squeeze! ' '
  end
  doc(optional_css_class, optional_the_id, optional_css_style, &block)
end

#doc_skeleton(this_file) ⇒ Object

#

doc_skeleton (main tag)

This method has been specifically created to allow support of .md (markdown) files in different languages - either german or english.

This method may also be called via a Symbol, such as:

doc_skeleton(:english_or_german)
#


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
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
# File 'lib/cyberweb/web_object/web_object.rb', line 1788

def doc_skeleton(this_file)
  if this_file.is_a? Symbol
    case this_file
    # ===================================================================== #
    # === :english_or_german
    #
    # This will default to german. We have to determine the assumed
    # .md file name.
    # ===================================================================== #
    when :english_or_german
      this_file = filename_without_extension?+'_german.md' # 'luft_german.md'
    end
  end
  # ======================================================================= #
  # Next, check for arguments given to the .cgi file at hand.
  # ======================================================================= #
  parameters_as_string = parameters_as_string?
  case parameters_as_string
  # ======================================================================= #
  # === use_english
  #
  # This can be invoked via:
  #
  #   http://localhost/programming/ruby/src/roebe/lib/roebe/www/luft/luft.cgi?english
  #
  # ======================================================================= #
  when /use_english/,
       /english$/
    this_file = filename_without_extension?+'_english.md'
  # ======================================================================= #
  # === use_german
  # ======================================================================= #
  when /use_german/,
       /german$/
    this_file = filename_without_extension?+'_german.md'
  end
  if this_file and File.exist?(this_file)
    file_content = File.read(this_file, encoding: 'utf-8')
    dataset = remove_comments_from_this_string(file_content)
    eval(dataset)
    # ===================================================================== #
    # Next simply evaluate it.
    # ===================================================================== #
  else
    no_file_exists_at(this_file)
  end
end

#doc_slightly_smaller_width(optional_css_class = 'pad5px', optional_the_id = '', optional_css_style = '', &block) ⇒ Object Also known as: doc_smaller_preferred_width, doc_smaller_width, doc_small_width, smaller_width

#

doc_slightly_smaller_width

This is similar to doc_default_width(), but the default width used is 200px less than the preferred width. This may be more useful on smaller laptop screens.

#


724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
# File 'lib/cyberweb/web_object/web_object.rb', line 724

def doc_slightly_smaller_width(
    optional_css_class = 'pad5px',
    optional_the_id    = '',
    optional_css_style = '',
    &block
  )
  unless optional_css_class.is_a? String
    optional_css_class = optional_css_class.to_s
  end
  if optional_css_class.frozen?
    optional_css_class = optional_css_class.dup
  end
  # ======================================================================= #
  # Next we will append the CSS class that this method prioritizes:
  # ======================================================================= #
  unless optional_css_class.include? 'slightly_smaller_width'
    optional_css_class << ' slightly_smaller_width'
    optional_css_class.squeeze! ' '
  end
  # ======================================================================= #
  # Next we will delegate towards doc().
  # ======================================================================= #
  doc(optional_css_class, optional_the_id, optional_css_style, &block)
end

#doc_width_1600(optional_css_class = 'pad2px', optional_the_id = '', optional_css_style = '', &block) ⇒ Object

#

doc_width_1600

#


7129
7130
7131
7132
7133
7134
7135
7136
7137
7138
7139
7140
7141
7142
7143
7144
7145
7146
# File 'lib/cyberweb/web_object/web_object.rb', line 7129

def doc_width_1600(
    optional_css_class = 'pad2px',
    optional_the_id    = '',
    optional_css_style = '',
    &block
  )
  unless optional_css_class.is_a? String
    optional_css_class = optional_css_class.to_s
  end
  if optional_css_class.frozen?
    optional_css_class = optional_css_class.dup
  end
  unless optional_css_class.include? 'width_1600px'
    optional_css_class << ' width_1600px'
    optional_css_class.squeeze! ' '
  end
  doc(optional_css_class, optional_the_id, optional_css_style, &block)
end

#doc_write(i = '') ⇒ Object

#

doc_write

#


844
845
846
847
848
# File 'lib/cyberweb/web_object/web_object.rb', line 844

def doc_write(i = '')
  append_onto_the_body_tag_nl(
    return_doc_write(i)
  )
end

#done_imageObject

#

done_image

#


7672
7673
7674
# File 'lib/cyberweb/web_object/web_object.rb', line 7672

def done_image
  sg(:done, 'marr10px')
end

#dot101?Boolean

#

dot101?

This simply wraps over dot() with a default value and default CSS.

#

Returns:

  • (Boolean)


9374
9375
9376
# File 'lib/cyberweb/web_object/web_object.rb', line 9374

def dot101?
  string_dot(101, 'marr10px')
end

#dot102?Boolean

#

dot102?

This simply wraps over dot() with a default value and default CSS.

#

Returns:

  • (Boolean)


9383
9384
9385
# File 'lib/cyberweb/web_object/web_object.rb', line 9383

def dot102?
  string_dot(102, 'marr10px')
end

#dot103?Boolean

#

dot103?

This simply wraps over dot() with a default value and default CSS.

#

Returns:

  • (Boolean)


9392
9393
9394
# File 'lib/cyberweb/web_object/web_object.rb', line 9392

def dot103?
  string_dot(103, 'marr10px')
end

#dot104?Boolean

#

dot104?

This simply wraps over dot() with a default value and default CSS.

#

Returns:

  • (Boolean)


9401
9402
9403
# File 'lib/cyberweb/web_object/web_object.rb', line 9401

def dot104?
  string_dot(104, 'marr10px')
end

#dot105?Boolean

#

dot105?

This simply wraps over dot() with a default value and default CSS.

#

Returns:

  • (Boolean)


9410
9411
9412
# File 'lib/cyberweb/web_object/web_object.rb', line 9410

def dot105?
  string_dot(105, 'marr10px')
end

#dot106?Boolean

#

dot106?

This simply wraps over dot() with a default value and default CSS.

#

Returns:

  • (Boolean)


9419
9420
9421
# File 'lib/cyberweb/web_object/web_object.rb', line 9419

def dot106?
  string_dot(106, 'marr10px')
end

#dot107?Boolean

#

dot107?

This simply wraps over dot() with a default value and default CSS.

#

Returns:

  • (Boolean)


9428
9429
9430
# File 'lib/cyberweb/web_object/web_object.rb', line 9428

def dot107?
  string_dot(107, 'marr10px')
end

#dot108?Boolean

#

dot108?

This simply wraps over dot() with a default value and default CSS.

#

Returns:

  • (Boolean)


9437
9438
9439
# File 'lib/cyberweb/web_object/web_object.rb', line 9437

def dot108?
  string_dot(108, 'marr10px')
end

#dot109?Boolean

#

dot109?

This simply wraps over dot() with a default value and default CSS.

#

Returns:

  • (Boolean)


3367
3368
3369
# File 'lib/cyberweb/web_object/web_object.rb', line 3367

def dot109?
  string_dot(109, 'marr10px')
end

#dot110?Boolean

#

dot110?

This simply wraps over dot() with a default value and default CSS.

#

Returns:

  • (Boolean)


9490
9491
9492
# File 'lib/cyberweb/web_object/web_object.rb', line 9490

def dot110?
  string_dot(110, 'marr10px')
end

#drag_all_images?Boolean

#

drag_all_images?

This query method can be used to determine whether all images should be dragged.

#

Returns:

  • (Boolean)


1636
1637
1638
# File 'lib/cyberweb/web_object/web_object.rb', line 1636

def drag_all_images?
  @config['drag_all_images']
end

#drag_last_idObject

#

drag_last_id

This method will always enable dragging for the last registered ID, even if said ID does not start with “_drag”. So use carefully.

In my custom system I use it only after I specifically registered a drag-ID, such as “drag_spider_silk”, as ID to a picture showing a spider silk image, for instance.

Note that this will only be done if at the least one ID is registered. If there is no element yet then this method does nothing on its own.

#


3471
3472
3473
3474
# File 'lib/cyberweb/web_object/web_object.rb', line 3471

def drag_last_id
  _ = @internal_hash[:register_ids].last # Point to the last element in use here.
  enable_drag_for(_) if _
end

#drag_local_image_or_remote_image(local_image = '', remote_image_substitute = '', optional_css_class = '', optional_the_id = :drag, optional_css_style = '', alt_text = '', &block) ⇒ Object Also known as: dlocal_image_or_remote_image, dimg2

#

drag_local_image_or_remote_image

As local_image_or_remote_image(), but with the default id argument to refer to :drag.

#


6865
6866
6867
6868
6869
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879
6880
6881
# File 'lib/cyberweb/web_object/web_object.rb', line 6865

def drag_local_image_or_remote_image(
    local_image             = '',
    remote_image_substitute = '', # This one should be the remote URL.
    optional_css_class      = '',
    optional_the_id         = :drag,
    optional_css_style      = '',
    alt_text                = '',
    &block
  )
  local_image_or_remote_image(
    local_image,
    remote_image_substitute,
    optional_css_class,
    optional_the_id,
    optional_css_style
  ) { :drag }
end

#draggable_image(url = '', css_class = :empty_string_or_global_css_rules_for_images, the_id = '', css_style = '', alt_text = '', &block) ⇒ Object Also known as: draggable_img, dimg, dimage

#

draggable_image (dimg tag)

Example code how to tap into this method:

draggable_image 'STD/USB_CONNECTION_DEVICE.png',
                'mar1em bblack1 mars3em'

It may be more convenient to use the alias name dimg().

#


8160
8161
8162
8163
8164
8165
8166
8167
8168
8169
8170
8171
8172
8173
8174
8175
8176
8177
8178
8179
8180
8181
8182
8183
8184
8185
8186
8187
8188
8189
8190
8191
8192
8193
# File 'lib/cyberweb/web_object/web_object.rb', line 8160

def draggable_image(
    url       = '',
    css_class = :empty_string_or_global_css_rules_for_images, 
    the_id    = '',
    css_style = '',
    alt_text  = '',
    &block
  )
  if the_id and the_id.empty?
    the_id = (
              'drag_'+
               File.basename(url.to_s).
               downcase.
               delete_suffix(
                 File.extname(url.to_s)
               )
             ).tr('.','_')
  end
  if the_id and !the_id.empty? and !the_id.start_with?('drag_')
    the_id = the_id.dup
    the_id.prepend('drag_')
  end
  if uses_sinatra? # Handle sinatra first.
    draggable_img_base64(url, css_class, css_style)
  else # delegate towards img() next.
    img(
      url,
      css_class,
      the_id,
      css_style,
      alt_text
    ) { :draggable_attribute }
  end
end

#draggable_image_nbr(url = '', css_class = '', the_id = '', css_style = '', alt_text = '', &block) ⇒ Object

#

draggable_image_nbr

#


8032
8033
8034
8035
8036
8037
8038
8039
8040
8041
8042
8043
8044
8045
8046
8047
8048
8049
# File 'lib/cyberweb/web_object/web_object.rb', line 8032

def draggable_image_nbr(
    url       = '',
    css_class = '', 
    the_id    = '',
    css_style = '',
    alt_text  = '',
    &block
  )
  draggable_image(
    url,
    css_class, 
    the_id,
    css_style,
    alt_text,
    &block
  )
  br
end

#draggable_img_base64(i, css_class = '', css_style = '') ⇒ Object Also known as: draggable_base64img

#

draggable_img_base64

This method has to respond to css_class and css_style as well. This may also be provided via a Hash.

#


8537
8538
8539
8540
8541
8542
8543
8544
8545
8546
8547
8548
8549
8550
8551
8552
8553
8554
8555
8556
8557
8558
8559
8560
8561
8562
8563
8564
8565
8566
8567
8568
8569
8570
8571
8572
8573
# File 'lib/cyberweb/web_object/web_object.rb', line 8537

def draggable_img_base64(
    i,
    css_class = '',
    css_style = ''
  )
  if css_class.is_a? Hash
    # ===================================================================== #
    # === :css_style
    # ===================================================================== #
    if css_class.has_key? :css_style
      css_style = css_class.delete(:css_style)
    end
    # ===================================================================== #
    # === :css_class
    #
    # This variant must come last.
    # ===================================================================== #
    if css_class.has_key? :css_class
      css_class = css_class.delete(:css_class)
    end
  end
  absolute_path_to_the_image = File.absolute_path(
    path_to_the_main_image_directory?.to_s+
    i.to_s
  )
  use_this_id = 'drag_'+File.basename(
    absolute_path_to_the_image
  ).delete_suffix(
    File.extname(absolute_path_to_the_image)
  ).downcase
  dataset = convert_image_to_base64(absolute_path_to_the_image)
  append_onto_the_body_tag_nl(
    return_base64_image(
      dataset, :infer, css_class, use_this_id, css_style
    )
  )
end

#draggable_string_image(url = '', css_class = '', the_id = '', css_style = '', alt_text = '', &block) ⇒ Object

#

draggable_string_image

#


7679
7680
7681
7682
7683
7684
7685
7686
7687
7688
7689
7690
7691
7692
7693
7694
7695
# File 'lib/cyberweb/web_object/web_object.rb', line 7679

def draggable_string_image(
    url       = '',
    css_class = '', 
    the_id    = '',
    css_style = '',
    alt_text  = '',
    &block
  )
  if the_id and the_id.empty?
    the_id = 'drag_'+File.basename(url).downcase.delete_suffix(File.extname(url))
  end
  if the_id and !the_id.empty? and !the_id.start_with?('drag_')
    the_id = the_id.dup
    the_id.prepend('drag_')
  end
  string_img(url, css_class, the_id, css_style, alt_text) { :draggable_attribute }
end

#draw_circle(hash = { width: 200, # in px height: 200, # in px background_color: :crimson, border_radius: '50%' }) ⇒ Object

#

draw_circle

#


8779
8780
8781
8782
8783
8784
8785
8786
8787
8788
8789
8790
# File 'lib/cyberweb/web_object/web_object.rb', line 8779

def draw_circle(
    hash = {
      width:            200, # in px
      height:           200, # in px
      background_color: :crimson,
      border_radius:    '50%'
    }
  )
  append_onto_the_body_tag_nl(
    Cyberweb.draw_circle(hash)
  )
end

#draw_triangle(hash = { width: 200, # in px height: 200, # in px background_color: :crimson, border_radius: '50%' }) ⇒ Object

#

draw_triangle

#


3631
3632
3633
3634
3635
3636
3637
3638
3639
3640
3641
3642
# File 'lib/cyberweb/web_object/web_object.rb', line 3631

def draw_triangle(
    hash = {
      width:            200, # in px
      height:           200, # in px
      background_color: :crimson,
      border_radius:    '50%'
    }
  )
  append_onto_the_body_tag_nl(
    Cyberweb.draw_triangle(hash)
  )
end

#dump_all_javascriptObject

#

dump_all_javascript

This method was added in February 2023. It can be used to read the content of all .js files that are distributed by the cyberweb project, and present it as one large string. This is an alternative to the requirement of the browser normally needing to read from a local .js file. I actually ran into permission issues in February 2023, so I decided to add a “hackish” work-around over that problem - thus the method was added.

#


5585
5586
5587
5588
5589
5590
5591
5592
5593
5594
5595
5596
5597
5598
5599
5600
5601
5602
5603
# File 'lib/cyberweb/web_object/web_object.rb', line 5585

def dump_all_javascript
  _ = ''.dup
  # ======================================================================= #
  # Build up the String next:
  # ======================================================================= #
  path_to_use = sitelibdir?+
                'cyberweb/javascript_code/'
  js_files_to_load?.each {|this_js_file|
    full_path = path_to_use+
                this_js_file
    if File.exist? full_path
      _ << File.read(full_path)+"\n"
    else
      # _ << "THE PATH IS\n"
      # _ << full_path+"\n"
    end
  }
  append_onto_the_main_javascript_variable(return_javascript(_))
end

#dynamic_text_shadow(optional_hash = { padding_to_use: '3vmin', background_hsl: 'hsl(200 50% 50%)' }) ⇒ Object Also known as: return_dynamic_text_shadow, dynamic_header

#

dynamic_text_shadow

This method can be used to generate a dynamic text shadow.

#


9181
9182
9183
9184
9185
9186
9187
9188
9189
9190
9191
9192
9193
9194
9195
9196
9197
9198
9199
9200
9201
9202
9203
9204
9205
9206
9207
9208
9209
9210
9211
9212
9213
9214
9215
9216
9217
9218
9219
9220
9221
9222
9223
# File 'lib/cyberweb/web_object/web_object.rb', line 9181

def dynamic_text_shadow(
    optional_hash = {
      padding_to_use: '3vmin',
      background_hsl: 'hsl(200 50% 50%)'
    }
  )
  _ = optional_hash
  # ======================================================================= #
  # === :padding
  # ======================================================================= #
  if _.has_key? :padding
    padding_to_use = _[:padding].to_s
  # ======================================================================= #
  # === :padding_to_use
  # ======================================================================= #
  elsif _.has_key? :padding_to_use
    padding_to_use = _[:padding_to_use].to_s
  end
  # ======================================================================= #
  # === :background_hsl
  # ======================================================================= #
  if _.has_key? :background_hsl
    background_hsl = _[:background_hsl].to_s
  else # else use a default
    background_hsl = 'hsl(200 50% 50%)'
  end
  # ======================================================================= #
  # Next add these to the main CSS rules:
  # ======================================================================= #
  return '
.dynamic_text_shadow {

/* larger font size, more shadow distance  */
font-family: "Fugaz One", cursive;
text-shadow: .1em .1em 0 hsl(200 50% 30%);
background: '+background_hsl+';
color:      hsl(200 50% 90%);
padding: '+padding_to_use+';
block-size: 100%;
display: grid;
    
}' # min-block-size: 100%;
end

#eesentence(i, optional_css_class = '') ⇒ Object Also known as: eequote

#

eesentence

#


3727
3728
3729
3730
3731
3732
3733
3734
3735
3736
# File 'lib/cyberweb/web_object/web_object.rb', line 3727

def eesentence(
    i,
    optional_css_class = ''
  )
  if optional_css_class and optional_css_class.empty? # Check for nil and non-empty.
    ee sentence(i)
  else
    espan sentence(i), optional_css_class
  end
end

#efive_stars(optional_css_class = '') ⇒ Object

#

efive_stars

#


8585
8586
8587
# File 'lib/cyberweb/web_object/web_object.rb', line 8585

def efive_stars(optional_css_class = '')
  ee five_stars(optional_css_class)
end

#embed_and_drag_remote_image(i = 'https://mikesrpgcenter.com/krondor/maps/timirianya.html', optional_hash = {}, optional_id = nil, &block) ⇒ Object

#

embed_and_drag_remote_image

This variant ensures that there is a leading ‘drag_’ for the id.

#


6431
6432
6433
6434
6435
6436
6437
6438
6439
6440
6441
6442
6443
6444
6445
6446
6447
# File 'lib/cyberweb/web_object/web_object.rb', line 6431

def embed_and_drag_remote_image(
    i             = 'https://mikesrpgcenter.com/krondor/maps/timirianya.html',
    optional_hash = {},
    optional_id   = nil,
    &block
  )
  if optional_id.nil?
    optional_id = 'drag_'+File.basename(i).to_s
  else
    unless optional_id.start_with? 'drag_'
      optional_id = optional_id.dup
      optional_id.prepend('drag_')
    end
  end
  embed_remote_image(i, optional_hash, optional_id, &block)
  enable_drag_for(optional_id.to_sym)
end

#embed_javascript_calendarObject Also known as: calendar

#

embed_javascript_calendar

Note that this method here depends on an external javascript resource, which may or may not work. I found it easier to use an external javascript resource, though - calendars are a bit complicated.

#


5206
5207
5208
5209
5210
5211
5212
5213
5214
5215
5216
5217
5218
5219
5220
5221
5222
5223
5224
5225
5226
5227
5228
5229
# File 'lib/cyberweb/web_object/web_object.rb', line 5206

def embed_javascript_calendar
  _ = <<-EOF
<script src="https://jsuites.net/v4/jsuites.js"></script>
<link rel="stylesheet" href="https://jsuites.net/v4/jsuites.css" type="text/css" />
</head>
<body>
<div id='calendar' style="text-align: center; 
width: 350px;
padding: 8px;
margin: 0.5em;
margin-left: 2em;
border-radius: 12px;
border: 3px solid royalblue;
background-color: white;
min-height: 420px;
"></div>
<script>
jSuites.calendar(document.getElementById('calendar'), {
format: 'DD/MM/YYYY'
});
</script>
EOF
  append_onto_the_body_tag_nl(_)
end

#embed_opalObject

#

embed_opal

This method will currently hardcode the opal-runtime, and “embed” it.

#


176
177
178
179
180
181
182
183
# File 'lib/cyberweb/web_object/web_object.rb', line 176

def embed_opal
  add_javascript_file(
    'https://cdn.opalrb.com/opal/current/opal.js'
  )
  add_javascript_file(
    'https://cdn.opalrb.com/opal/current/opal-parser.js',"Opal.load('opal-parser')"
  )
end

#embed_this_image(i = 'lyxandras-das-Dorf-Nadorp.jpg', optional_css_class = 'bblack1', optional_the_id = '') ⇒ Object

#

embed_this_image

#


8010
8011
8012
8013
8014
8015
8016
8017
8018
# File 'lib/cyberweb/web_object/web_object.rb', line 8010

def embed_this_image(
    i                  = 'lyxandras-das-Dorf-Nadorp.jpg',
    optional_css_class = 'bblack1',
    optional_the_id    = ''
  )
  append_onto_the_body_tag_nl(
    Cyberweb.embed_this_image(i, optional_css_class, optional_the_id)
  )
end

#embed_this_pdf(i, also_enable_link = false, width_to_use = '100%', height_to_use = '100%') ⇒ Object Also known as: add_pdf, embed_pdf, embed_this_pdf_file, view_this_pdf_file

#

embed_this_pdf

This method can be used to embed a .pdf file into your page. Using width and height values is recommended but not mandatory.

For more documentation, see these resources:

https://pdfobject.com/markup/
#


9514
9515
9516
9517
9518
9519
9520
9521
9522
9523
9524
9525
9526
9527
9528
9529
9530
9531
9532
9533
9534
9535
9536
9537
9538
9539
9540
9541
9542
9543
9544
# File 'lib/cyberweb/web_object/web_object.rb', line 9514

def embed_this_pdf(
    i,
    also_enable_link = false,
    width_to_use     = '100%',
    height_to_use    = '100%'
  )
  case also_enable_link
  # ======================================================================= #
  # === :also_enable_link
  # ======================================================================= #
  when :also_enable_link
    also_enable_link = true
  end
  if also_enable_link
    # ===================================================================== #
    # In this case we will use a HREF tag to link towards the .pdf file
    # at hand.
    # ===================================================================== #
    pdf_image = sg(:pdf,'marr6px','','width:28px') # The pdf image.
    abr(
      i,
      content: "#{pdf_image}SELF_BASENAME"
    )
  end
  result = '<object id="pdf1" data="'+i.to_s+'" '\
           'type="application/pdf" width="'+width_to_use.to_s+'" height="'+height_to_use.to_s+'">'+"\n"+
           '</object>'
  append_onto_the_body_tag_nl(
    result
  )
end

#embed_videos(these_videos, width = '640', height = '385') ⇒ Object

#

embed_videos

The first argument is typically a String.

#


2315
2316
2317
2318
2319
2320
2321
2322
2323
2324
2325
2326
2327
2328
2329
2330
2331
2332
2333
# File 'lib/cyberweb/web_object/web_object.rb', line 2315

def embed_videos(
    these_videos,
    width  = '640',
    height = '385'
  )
  if these_videos.is_a?(String) and these_videos.include?("\n")
    these_videos.strip.split("\n").each {|this_video|
      this_video = this_video.dup if this_video.frozen?
      this_video.strip!
      append_onto_the_body_tag('<object class="pad1em mar2em">'+N)
      append_onto_the_body_tag('<param name="movie" value="'+this_video+'" />'+N)
      append_onto_the_body_tag('<param name="wmode" value="transparent" />'+N)
      append_onto_the_body_tag('<param name="allowFullScreen" value="true" />'+N) # Allow fullscreen.
      append_onto_the_body_tag('<param name="allowscriptaccess" value="always" />'+N)
      append_onto_the_body_tag('<embed src="'+this_video+';autoplay=0" type="application/x-shockwave-flash" width="'+width.to_s+'" height="'+height.to_s+'"></embed>'+N)
      cobject
    }
  end
end

#enable(what = 'scroll') ⇒ Object

#

enable (enable tag)

#


4783
4784
4785
4786
4787
4788
4789
4790
4791
4792
4793
4794
4795
4796
4797
4798
4799
4800
4801
4802
4803
4804
4805
4806
# File 'lib/cyberweb/web_object/web_object.rb', line 4783

def enable(
    what = 'scroll'
  )
  case what.to_s
  # ======================================================================= #
  # === drag_all_images
  # ======================================================================= #
  when /drag(_|-)?all(_|-)?images$/,
       /all(_|-)?images$/,
       '+images',
       'images+'
    enable_drag_all_images
  # ======================================================================= #
  # === predefine_squares
  # ======================================================================= #
  when 'predefine_squares','predefinesquares','squares'
    predefine_squares
  # ======================================================================= #
  # === scroll
  # ======================================================================= #
  when 'scroll','default'
    enable_scrolling
  end
end

#enable_debuggingObject

#

enable_debugging

#


4169
4170
4171
# File 'lib/cyberweb/web_object/web_object.rb', line 4169

def enable_debugging
  @internal_hash[:debug] = true
end

#enable_drag_all_imagesObject Also known as: drag_all_images, drag_everything, do_drag_all_images, do_enable_drag_all_images, all_images_will_be_draggable, enable_dragging, enable_drag_and_drop

#

enable_drag_all_images

We enable a configuration option through this method call here.

Note that we will also automatically enable jquery in this case, as otherwise we could not drag the image in question around, which would sort of defeat the points of having this method in the first place - or it would require of you to manually enable jquery, which seems superfluous.

#


1660
1661
1662
1663
# File 'lib/cyberweb/web_object/web_object.rb', line 1660

def enable_drag_all_images
  do_use_jquery unless use_jquery?
  @config['drag_all_images'] = true
end

#enable_jquery_for_every_page?Boolean

#

enable_jquery_for_every_page?

Determine whether we are using jquery for every page.

#

Returns:

  • (Boolean)


1772
1773
1774
# File 'lib/cyberweb/web_object/web_object.rb', line 1772

def enable_jquery_for_every_page?
  @config['enable_jquery_for_every_page']
end

#enable_remove_newlinesObject

#

remove_all_newlines

If we make use of this, we will strip all newlines from our string.

#


3933
3934
3935
# File 'lib/cyberweb/web_object/web_object.rb', line 3933

def enable_remove_newlines
  @internal_hash[:remove_newlines] = true
end

#enable_scrollingObject Also known as: use_scrolling

#

enable_scrolling

#


3917
3918
3919
# File 'lib/cyberweb/web_object/web_object.rb', line 3917

def enable_scrolling
  background :scroll # Enable scrolling background.
end

#enable_title_for_reading_files?Boolean Also known as: enable_title_for_reading_files

#

enable_title_for_reading_files?

#

Returns:

  • (Boolean)


8629
8630
8631
# File 'lib/cyberweb/web_object/web_object.rb', line 8629

def enable_title_for_reading_files?
  @internal_hash[:enable_title_for_reading_files]
end

#equote2(i = '') ⇒ Object

#

equote2

This uses a stronger padding class.

#


3705
3706
3707
# File 'lib/cyberweb/web_object/web_object.rb', line 3705

def equote2(i = '')
  equote(i, 'l2em')
end

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

#

equote_nobr

#


1472
1473
1474
1475
1476
1477
1478
1479
1480
# File 'lib/cyberweb/web_object/web_object.rb', line 1472

def equote_nobr(
    i, optional_css_class = ''
  )
  if optional_css_class and optional_css_class.empty?
    e sentence(i)
  else
    espan sentence(i), optional_css_class
  end
end

#esentence(i, optional_css_class = '') ⇒ Object Also known as: equote

#

esentence

#


3676
3677
3678
3679
3680
3681
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
# File 'lib/cyberweb/web_object/web_object.rb', line 3676

def esentence(
    i,
    optional_css_class = ''
  )
  sanitized_caller = ensure_main_encoding(caller())
  method_name = Cyberweb.return_the_method_name_from_this_array(sanitized_caller)
  case method_name
  # ======================================================================= #
  # === p_default_le
  # ======================================================================= #
  when /p_default_le$/
    if optional_css_class.empty?
      optional_css_class = 'l1em'
    else
      optional_css_class = optional_css_class.dup if optional_css_class.frozen?
      unless optional_css_class.include?('l2em') # l2em is treated in a special way.
        optional_css_class.prepend('l1em ')
      end
    end
  end
  eesentence(i, optional_css_class.strip)
  br # This variant always ensure that br() will be called.
end

#espan_no_newline(i = '', optional_css_class = '', optional_the_id = '', optional_css_style = '') ⇒ Object Also known as: eee

#

espan_no_newline

#


2445
2446
2447
2448
2449
2450
2451
2452
2453
2454
2455
2456
2457
2458
2459
# File 'lib/cyberweb/web_object/web_object.rb', line 2445

def espan_no_newline(
    i                  = '',
    optional_css_class = '',
    optional_the_id    = '',
    optional_css_style = ''
  )
  append_onto_the_body_tag(
    string_s2(
      i.to_s,
      optional_css_class,
      optional_the_id,
      optional_css_style
    )
  )
end

#evaluate_beautiful_urlObject

#

evaluate_from_this_file_via_beautiful_url

This variant taps into BeautifulUrl to determine local files.

#

evaluate_beautiful_url



7045
7046
7047
7048
7049
7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
7066
# File 'lib/cyberweb/web_object/web_object.rb', line 7045

def evaluate_from_this_file_via_beautiful_url(i)
  unless Object.const_defined? :BeautifulUrl
    begin
      require 'beautiful_url'
    rescue LoadError; end
  end
  if i.start_with? 'local'
    i = BeautifulUrl.local_menu(i)
  else
    i = BeautifulUrl[i]
  end
  i = i.first if i.is_a? Array
  if i.end_with? '.cgi'
    # ===================================================================== #
    # Need the .rb variant instead.
    # ===================================================================== #
    i = i.dup if i.frozen?
    i.delete_suffix!('.cgi')
    i << '.rb'
  end
  evaluate_from_this_file(i)
end

#evaluate_from_the_same_named_file(i = $PROGRAM_NAME) ⇒ Object

#

evaluate_from_the_same_named_file

This method allows us to skip providing the name for the evaluation method defined below this method.

This is typically called from a .sinatra file.

In June 2021 this was a bit relaxed, in order to allow straight require() statements to work. Ruby does not accept .sinatra as a file end when require is used, so a .rb file has to be used instead. In that case, this method will strip away “_for_sinatra” if it is part of the file. Thus we will assume that such a file exists, with the trailing “_for_sinatra.rb” part.

Note that this method may fail if $PROGRAM_NAME is set improperly, which may be the case if it is started via a /usr/bin/ path rather than a .rb file.

#


7002
7003
7004
7005
7006
7007
7008
7009
7010
7011
7012
7013
7014
7015
7016
7017
# File 'lib/cyberweb/web_object/web_object.rb', line 7002

def evaluate_from_the_same_named_file(
    i = $PROGRAM_NAME
  )
  i = $PROGRAM_NAME if i.nil?
  if i.end_with? '.sinatra'
    is_a_sinatra_application # Enable this as well.
  end
  i = i.dup
  i.delete_suffix!(File.extname(i)) # Chop off the .sinatra part or other ends.
  if i.end_with? '_for_sinatra'
    i.delete_suffix!('_for_sinatra')
    is_a_sinatra_application # Enable this as well.
  end
  i << '.rb' unless i.end_with? '.rb'
  evaluate_from_this_file(i)
end

#evaluate_from_this_file(this_file) ⇒ Object

#

evaluate_from_this_file

This method can be used to simply read in from a local file, and evaluate the text as if it were ruby code, as-is.

#


778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
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
835
836
837
838
839
# File 'lib/cyberweb/web_object/web_object.rb', line 778

def evaluate_from_this_file(
    this_file
  )
  if this_file and File.file?(this_file)
    # ===================================================================== #
    # Read in the file content and assign it to file_content next:
    # ===================================================================== #
    file_content = File.read(this_file, encoding: 'utf-8').dup
    # ===================================================================== #
    # Next we will remove comments from the given String. However had,
    # this may also remove valid CSS instructions such as "#smoke_1 {"
    # which is evidently bad. Hence the next method call.
    # ===================================================================== #
    dataset = remove_comments_from_this_string_but_preserve_CSS_rules(file_content)
    # ===================================================================== #
    # Next we can delegate to certain sub-methods. This doesn't work
    # right now ... is this still needed after 2022? Not sure; we may
    # have to decide at a later time. I assume this tried to get
    # support for english() and german(). Past the rewrite in August
    # 2023 I think this is no longer necessary.
    # ===================================================================== #
    # if dataset.start_with?('german(') # Trigger-entry-clause is, for instance, this: "german('SITEMAP') {\n"
    #   # =================================================================== #
    #   # Example: german('SITEMAP') {
    #   # =================================================================== #
    #   first_line = dataset.split("\n").first.
    #                sub(/german/,'').
    #                delete('(){ ').
    #                delete("'")
    #   dataset = dataset.split("\n")[1 .. -1].join("\n")
    #   dataset.strip!
    #   dataset.chop! # This removes the last '}'.
    #   Cyberweb.web_object?.german { dataset }
    # elsif dataset.start_with?('english(')
    #   Cyberweb.web_object?.english { dataset }
    # else
      begin
        eval(dataset) # Pass it into eval() directly here.
      # We must also rescue a permission-denied error next:
      rescue Errno::EACCES => error # Report errors in this clause.
        p('tomato') {
          _ = error.to_s
          _ = _.split(' ').last.to_s if _.include? ' '
          e 'Permission denied error at: '
          br
          le "<b>#{_}</b>"
          br
          dimg(:angry_smiley, 'marl2em')
        }
      rescue SyntaxError => error
        e 'Syntax error:'
        e
        pp error
        e
      end
      #close_html
    # end
  else
    e "(line #{__LINE__}) No file exists at #{this_file.to_s}."
    pp caller()
  end
end

#evaluate_from_this_file_via_beautiful_url(i) ⇒ Object

#

evaluate_from_this_file_via_beautiful_url

This variant taps into BeautifulUrl to determine local files.

#


7024
7025
7026
7027
7028
7029
7030
7031
7032
7033
7034
7035
7036
7037
7038
7039
7040
7041
7042
7043
7044
7045
# File 'lib/cyberweb/web_object/web_object.rb', line 7024

def evaluate_from_this_file_via_beautiful_url(i)
  unless Object.const_defined? :BeautifulUrl
    begin
      require 'beautiful_url'
    rescue LoadError; end
  end
  if i.start_with? 'local'
    i = BeautifulUrl.local_menu(i)
  else
    i = BeautifulUrl[i]
  end
  i = i.first if i.is_a? Array
  if i.end_with? '.cgi'
    # ===================================================================== #
    # Need the .rb variant instead.
    # ===================================================================== #
    i = i.dup if i.frozen?
    i.delete_suffix!('.cgi')
    i << '.rb'
  end
  evaluate_from_this_file(i)
end

#field_with_legend(title_of_legend = 'example', css_class = '', the_id = '', css_style = 'width: 72%', javascript = '') ⇒ Object Also known as: beautiful_legend, mini_header

#

field_with_legend

This does a field with a legend (header).

It looks quite nifty on a webpage - see tests.cgi for an example.

Be aware that this method opens a <fieldset> tag but does not close it. If you wish to close it on your own, then you must do so manually, like by doing one of the following in the usage examples.

Usage Example:

field_with_legend 'Password'
e AUSRUFUNG+'Zum Einloggen benutzt man root/root'
cfieldset

Or:

div {
  mini_header 'Test'
    link :cpp,'CPP',1
  c :mini_header
}
#


2252
2253
2254
2255
2256
2257
2258
2259
2260
2261
2262
# File 'lib/cyberweb/web_object/web_object.rb', line 2252

def field_with_legend(
    title_of_legend = 'example',
    css_class       = '',
    the_id          = '',
    css_style       = 'width: 72%',
    javascript      = ''
  )
  fieldset(css_class, the_id, css_style, javascript)
  _ = HtmlTags.legend(HtmlTags.b(title_of_legend))
  append_onto_the_body_tag_nl(_) # Print it.
end

#fieldset(optional_css_class = Fieldset.to_s, optional_the_id = '', optional_css_style = '', optional_javascript = '', &block) ⇒ Object

#

fieldset

This will generate a HTML <fieldset> tag.

You can pass in a Hash, which allows us to do things like this here:

fieldset style: 'width: 70%'
#


2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
# File 'lib/cyberweb/web_object/web_object.rb', line 2424

def fieldset(
    optional_css_class  = Fieldset.to_s,
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = '',
    &block
  )
  if optional_css_class.is_a? Hash
    if optional_css_class.has_key? :style
      optional_css_style = optional_css_class[:style]
      optional_css_class = ''
    end
  end
  ee stag(:fieldset, optional_css_class, optional_the_id, optional_css_style, optional_javascript)
    yield if block_given? # Add the content.
  cfieldset
end

#find_image(i = :krebsnebel) ⇒ Object

#

find_image

#


8912
8913
8914
8915
8916
8917
8918
# File 'lib/cyberweb/web_object/web_object.rb', line 8912

def find_image(
    i = :krebsnebel
  )
  _ = Cyberweb::TryToMapThisInputToThatLocalImage[i]
  _.delete_prefix!('/home/x/data/images/') if _
  return _
end

#first_param_as_string?Boolean Also known as: first_param_as_string

#

first_param_as_string?

#

Returns:

  • (Boolean)


4406
4407
4408
4409
4410
4411
4412
# File 'lib/cyberweb/web_object/web_object.rb', line 4406

def first_param_as_string?
  _ = Cyberweb.params?
  if _.is_a? Hash
    _ = _.keys.first
  end
  return _
end

#five_stars(optional_css_class = '') ⇒ Object Also known as: return_five_stars

#

five_stars

#


8578
8579
8580
# File 'lib/cyberweb/web_object/web_object.rb', line 8578

def five_stars(optional_css_class = '')
  return_stars(5, optional_css_class)
end

#form(action = 'SELF', method_form = Form.mode, css_class = Form.to_s, the_id = '', css_style = '', accept_charset = nil, enctype = nil) ⇒ Object

#

form (form tag)

Usage example:

form 'SELF', :post, 'mars2em'
#


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
6629
# File 'lib/cyberweb/web_object/web_object.rb', line 6595

def form(
    action         = 'SELF',    # (1) action
    method_form    = Form.mode, # (2) method form, such as :get or :post
    css_class      = Form.to_s, # (3) css class
    the_id         = '',        # (4) the id
    css_style      = '',        # (5) css style
    accept_charset = nil,       # (6) charset
    enctype        = nil
  )
  if action.is_a? Hash
    if action.has_key? :action
      _ = action[:action]
      case _
      when :self
        action = return_program_name
      end
    end
  end
  case action
  when /SELF/i
    action = return_program_name
  end
  _ = '<form'.dup
  _ << ' action="'+action.to_s+'"'
  _ << ' method="'+method_form.to_s+'"'
  _ << css_class_or_no_class(css_class.to_s).to_s
  _ << id_or_no_id(the_id.to_s).to_s
  _ << css_style_or_no_style(css_style)
  _ << ">\n" # Close the <form> tag here.
  append_onto_the_body_tag_nl(_)
  if block_given?
    yield
    cform
  end
end

#foto_oder_fotos(n) ⇒ Object

#

foto_oder_fotos

#


3664
3665
3666
3667
3668
3669
3670
3671
# File 'lib/cyberweb/web_object/web_object.rb', line 3664

def foto_oder_fotos(n)
  case n
  when 1
    'Foto'
  else
    'Fotos'
  end
end

#found_these_css_classes?Boolean

#

found_these_css_classes?

To display all the CSS classes we use, do something like this:

pre found_these_css_classes?.join(''+"\n")
#

Returns:

  • (Boolean)


2755
2756
2757
# File 'lib/cyberweb/web_object/web_object.rb', line 2755

def found_these_css_classes?
  Cyberweb.found_these_css_classes?
end

#four_stars(optional_css_class = '') ⇒ Object Also known as: string_four_stars

#

four_stars

#


9497
9498
9499
9500
9501
# File 'lib/cyberweb/web_object/web_object.rb', line 9497

def four_stars(
    optional_css_class = ''
  )
  return_stars(4, optional_css_class)
end

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

#

frage

#


8429
8430
8431
8432
8433
8434
# File 'lib/cyberweb/web_object/web_object.rb', line 8429

def frage(
    i                  = '',
    optional_css_class = ''
  )
  h2 i, optional_css_class
end

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

#

fragebr

#


8439
8440
8441
8442
8443
8444
8445
# File 'lib/cyberweb/web_object/web_object.rb', line 8439

def fragebr(
    i                  = '',
    optional_css_class = ''
  )
  frage(i, optional_css_class)
  br
end

#frame_left(i) ⇒ Object

#

frame_left

Simply append to :frame_string.

#


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

def frame_left(i)
  @internal_hash[:frame_string] << ::Cyberweb.frame_left(i)
end

#frame_right(i) ⇒ Object

#

frame_right

Simply append to :frame_string, by calling the method in the Cyberweb module.

#


5481
5482
5483
# File 'lib/cyberweb/web_object/web_object.rb', line 5481

def frame_right(i)
  @internal_hash[:frame_string] << ::Cyberweb.frame_right(i)
end

#generate_cap_box(use_this_title_for_the_upper_box = 'Hello world!', title_for_the_content_header = '', inner_content = '', border_to_use = '3px solid #2a2a2a', box_width = '700px') ⇒ Object

#

generate_cap_box

Usage example:

generate_cap_box(
  string_h1(
    sg(:package,'marr8px','drag_job_listing')+
    'Job Listing',
    'job_listing'
  )
) {{ width: '95%' }}
#


9060
9061
9062
9063
9064
9065
9066
9067
9068
9069
9070
9071
9072
9073
9074
9075
9076
9077
9078
# File 'lib/cyberweb/web_object/web_object.rb', line 9060

def generate_cap_box(
    use_this_title_for_the_upper_box = 'Hello world!',
    # ===================================================================== #
    # The next variable is the inner content - by default it will
    # be empty.
    # ===================================================================== #
    title_for_the_content_header     = '',
    inner_content                    = '', # This is the inner content.<br>Looks fancy!<br>',
    border_to_use                    = '3px solid #2a2a2a',
    box_width                        = '700px'
  )
  Cyberweb.generate_cap_box(
    use_this_title_for_the_upper_box,
    title_for_the_content_header,
    inner_content,
    border_to_use,
    box_width
  )
end

#generate_drop_shadow(use_this_colour = '#585858', border = :default, use_this_name_for_the_CSS_class = 'drop_shadow') ⇒ Object

#

generate_drop_shadow

This method will “generate” a drop shadow.

Combined usage example:

generate_drop_shadow :red, :default, 'drop_shadow_red'
div('pad0_5em drop_shadow_red') {
#


3439
3440
3441
3442
3443
3444
3445
3446
3447
3448
3449
3450
3451
3452
3453
3454
3455
3456
# File 'lib/cyberweb/web_object/web_object.rb', line 3439

def generate_drop_shadow(
    use_this_colour                 = '#585858',
    border                          = :default,
    use_this_name_for_the_CSS_class = 'drop_shadow'
  )
  case border
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default
    border = '2px 4px 8px'
  end
  css_style(
    '.'+use_this_name_for_the_CSS_class.to_s+' {
filter: drop-shadow('+border.to_s+' '+use_this_colour.to_s+');
}'
  )
end

#get_param_called(i) ⇒ Object Also known as: get_param

#

get_param_called

Use this method to obtain a specific parameter. The argument given should be the name of the formular in question.

#


4513
4514
4515
4516
4517
4518
4519
4520
4521
# File 'lib/cyberweb/web_object/web_object.rb', line 4513

def get_param_called(i)
  i = i.to_s # Just in case.
  _ = obtain_the_parameters_passed # Tap into the params() method.
  if _.has_key? i # Should be a Hash.
    i = _[i]
    i = i.first if i.is_a? Array
  end
  return i # Return it.
end

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

#

h1 (h1 tag)

The first argument to this method is the content that will be shown via the generated <h1></h1> tag.

#


5749
5750
5751
5752
5753
5754
5755
5756
5757
5758
5759
5760
5761
# File 'lib/cyberweb/web_object/web_object.rb', line 5749

def h1(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = ''
  )
  append_onto_the_body_tag_nl(
    string_h1(
      i, optional_css_class, optional_the_id, optional_css_style
    )
  )
end

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

#

h1_id

#


7726
7727
7728
7729
7730
7731
7732
7733
7734
7735
7736
7737
7738
7739
7740
7741
7742
7743
7744
7745
7746
7747
7748
7749
7750
7751
7752
7753
7754
7755
7756
7757
7758
7759
7760
7761
7762
7763
7764
7765
7766
7767
7768
7769
7770
7771
7772
7773
7774
7775
7776
7777
7778
7779
7780
# File 'lib/cyberweb/web_object/web_object.rb', line 7726

def h1_id(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = '',
    &block
  )
  yielded = nil
  optional_the_id = optional_the_id.to_s
  if optional_the_id.empty?
    optional_the_id = i.dup
  end
  use_this_id = sanitize_this_id(optional_the_id)
  # ======================================================================= #
  # === Handle blocks next
  # ======================================================================= #
  if block_given?
    yielded = yield
    if yielded.is_a? Hash
      if yielded.has_key?(:clickable_image) and (yielded[:clickable_image] == true)
        if yielded.has_key?(:use_this_image)
          this_image = yielded[:use_this_image]
          i = "<a href=\"##{use_this_id}\">"+
            this_image+
            "</a>"+
            i.gsub(/#{Regexp.new(this_image)}/,'')
        else
          i = "<a href=\"##{use_this_id}\">"+
              clickable_image_as_string?+
              "</a>#{i}"
        end
      end
    else # Else assume a Symbol.
      case yielded
      # =================================================================== #
      # === :clickable_image
      #
      # The embedded image will be clickable, made possible via the
      # a-tag.
      # =================================================================== #
      when :clickable_image
        i = "<a href=\"##{use_this_id}\">"+
            clickable_image_as_string?+
            "</a>#{i}"
      end
    end
  end
  h1(
    i,
    id: use_this_id,
    css_class: optional_css_class,
    css_style: optional_css_style
  )
end

#h1_id_clickable(i = '', optional_css_class = '', optional_the_id = '', optional_css_style = '', optional_javascript = '', &block) ⇒ Object Also known as: clickable_h1, h1_fancy_id, h1_fid

#

h1_id_clickable

This method will yield a clickable <h1> tag.

#


5846
5847
5848
5849
5850
5851
5852
5853
5854
5855
5856
5857
5858
5859
5860
5861
5862
5863
5864
5865
5866
5867
5868
# File 'lib/cyberweb/web_object/web_object.rb', line 5846

def h1_id_clickable(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = '',
    &block
  )
  yielded = nil # Default.
  if block_given?
    yielded = yield
  end
  if yielded and yielded.is_a?(Hash) and !yielded.has_key?(:clickable_image)
    yielded.update(clickable_image: true)
  end
  h1_id(
    i,
    optional_css_class,
    optional_the_id,
    optional_css_style,
    optional_javascript
  ) { yielded }
end

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

#

h2 (h2 tag)

#


7813
7814
7815
7816
7817
7818
7819
7820
7821
7822
7823
7824
7825
7826
7827
7828
# File 'lib/cyberweb/web_object/web_object.rb', line 7813

def h2(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = ''
  )
  append_onto_the_body_content_newline(
    HtmlTags.h2(
      i,
      optional_css_class,
      optional_the_id,
      optional_css_style
    )
  )
end

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

#

h2_id

This must be somewhat flexible, to allow for use cases such as:

h2_id('Stickstofffixierung - eine symbiotische Beziehung, als '\
      'Teil des Stickstoffkreislaufs') { :clickable_image }
#


1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
# File 'lib/cyberweb/web_object/web_object.rb', line 1194

def h2_id(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = '',
    &block
  )
  optional_the_id = optional_the_id.to_s
  if optional_the_id.empty?
    optional_the_id = i.dup
  end
  use_this_id = sanitize_this_id(optional_the_id)
  # ======================================================================= #
  # === Handle blocks next
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :clickable_image
    #
    # The embedded image will be clickable, made possible via the
    # a-tag.
    # ===================================================================== #
    when :clickable_image
      i = "<a href=\"##{use_this_id}\">"+
          clickable_image_as_string?+
          "</a>#{i}"
    end
  end
  h2(
    i,
    id: use_this_id,
    css_class: optional_css_class,
    css_style: optional_css_style
  )
end

#h2_id_clickable(i = '', optional_css_class = '', optional_the_id = '', optional_css_style = '', optional_javascript = '', &block) ⇒ Object Also known as: clickable_h2, h2_fancy_id, h2_fid

#

h2_id_clickable

#


3552
3553
3554
3555
3556
3557
3558
3559
3560
3561
3562
3563
3564
3565
3566
3567
# File 'lib/cyberweb/web_object/web_object.rb', line 3552

def h2_id_clickable(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = '',
    &block
  )
  h2_id(
    i,
    optional_css_class,
    optional_the_id,
    optional_css_style,
    optional_javascript
  ) { :clickable_image }
end

#h2_lightblue(i = '') ⇒ Object

#

h2_lightblue

#


8653
8654
8655
# File 'lib/cyberweb/web_object/web_object.rb', line 8653

def h2_lightblue(i = '')
  h2 i, 'lightblue'
end

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

#

h3 (h3 tag)

#


3757
3758
3759
3760
3761
3762
3763
3764
3765
3766
3767
3768
3769
3770
3771
3772
3773
3774
# File 'lib/cyberweb/web_object/web_object.rb', line 3757

def h3(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = '',
    &block
  )
  append_onto_the_body_tag_nl(
    HtmlTags.h3(
      i,
      optional_css_class,
      optional_the_id,
      optional_css_style,
      &block
    )
  )
end

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

#

h3_id

#


1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
# File 'lib/cyberweb/web_object/web_object.rb', line 1105

def h3_id(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = '',
    &block
  )
  optional_the_id = optional_the_id.to_s
  if optional_the_id.empty?
    optional_the_id = i.dup
  end
  use_this_id = sanitize_this_id(optional_the_id)
  # ======================================================================= #
  # === Handle blocks next
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :clickable_image
    #
    # The embedded image will be clickable, made possible via the a-tag.
    # ===================================================================== #
    when :clickable_image
      i = "<a href=\"##{use_this_id}\">"+
          clickable_image_as_string?+
          "</a>#{i}"
    end
  end
  h3(
    i,
    id: use_this_id,
    css_class: optional_css_class,
    css_style: optional_css_style
  )
end

#h3_id_clickable(i = '', optional_css_class = '', optional_the_id = '', optional_css_style = '', optional_javascript = '', &block) ⇒ Object Also known as: h3_fancy_id, h3_fid

#

h3_id_clickable

#


7071
7072
7073
7074
7075
7076
7077
7078
7079
7080
7081
7082
7083
7084
7085
7086
# File 'lib/cyberweb/web_object/web_object.rb', line 7071

def h3_id_clickable(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = '',
    &block
  )
  h3_id(
    i,
    optional_css_class,
    optional_the_id,
    optional_css_style,
    optional_javascript
  ) { :clickable_image }
end

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

#

h4

#


6715
6716
6717
6718
6719
6720
6721
6722
6723
6724
6725
# File 'lib/cyberweb/web_object/web_object.rb', line 6715

def h4(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = ''
  )
  append_onto_the_body_tag_nl(
    HtmlTags.h4(i, optional_css_class, optional_the_id, optional_css_style)
  )
end

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

#

h4_id

#


3243
3244
3245
3246
3247
3248
3249
3250
3251
3252
3253
3254
3255
3256
3257
3258
3259
3260
3261
3262
3263
3264
3265
3266
3267
3268
3269
3270
3271
3272
3273
3274
3275
3276
3277
3278
3279
3280
# File 'lib/cyberweb/web_object/web_object.rb', line 3243

def h4_id(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = '',
    &block
  )
  optional_the_id = optional_the_id.to_s
  if optional_the_id.empty?
    optional_the_id = i.dup
  end
  use_this_id = sanitize_this_id(optional_the_id)
  # ======================================================================= #
  # === Handle blocks next
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :clickable_image
    #
    # The embedded image will be clickable, made possible via the
    # a-tag.
    # ===================================================================== #
    when :clickable_image
      i = "<a href=\"##{use_this_id}\">"+
          clickable_image_as_string?+
          "</a>#{i}"
    end
  end
  h4(
    i,
    id: use_this_id,
    css_class: optional_css_class,
    css_style: optional_css_style
  )
end

#h4_id_clickable(i = '', optional_css_class = '', optional_the_id = '', optional_css_style = '', optional_javascript = '', use_fancy_id = false, &block) ⇒ Object Also known as: h4_fancy_id, h4_fid

#

h4_id_clickable

#


3285
3286
3287
3288
3289
3290
3291
3292
3293
3294
3295
3296
3297
3298
3299
3300
3301
# File 'lib/cyberweb/web_object/web_object.rb', line 3285

def h4_id_clickable(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = '',
    use_fancy_id        = false,
    &block
  )
  h4_id(
    i,
    optional_css_class,
    optional_the_id,
    optional_css_style,
    optional_javascript
  ) { :clickable_image }
end

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

#

h5

#


5448
5449
5450
5451
5452
5453
5454
5455
5456
5457
5458
# File 'lib/cyberweb/web_object/web_object.rb', line 5448

def h5(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = ''
  )
  append_onto_the_body_tag_nl(
    HtmlTags.h5(i, optional_css_class, optional_the_id, optional_css_style)
  )
end

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

#

h5_id

#


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

def h5_id(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = '',
    &block
  )
  optional_the_id = optional_the_id.to_s
  if optional_the_id.empty?
    optional_the_id = i.dup
  end
  use_this_id = sanitize_this_id(optional_the_id)
  # ======================================================================= #
  # === Handle blocks next
  # ======================================================================= #
  if block_given?
    yielded = yield
    case yielded
    # ===================================================================== #
    # === :clickable_image
    #
    # The embedded image will be clickable, made possible via the
    # a-tag.
    # ===================================================================== #
    when :clickable_image
      i = "<a href=\"##{use_this_id}\">"+
          clickable_image_as_string?+
          "</a>#{i}"
    end
  end
  h5(
    i,
    id: use_this_id,
    css_class: optional_css_class,
    css_style: optional_css_style
  )
end

#h5_id_clickable(i = '', optional_css_class = '', optional_the_id = '', optional_css_style = '', optional_javascript = '', &block) ⇒ Object Also known as: h5_fancy_id, h5_fid

#

h5_id_clickable

#


7050
7051
7052
7053
7054
7055
7056
7057
7058
7059
7060
7061
7062
7063
7064
7065
# File 'lib/cyberweb/web_object/web_object.rb', line 7050

def h5_id_clickable(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = '',
    &block
  )
  h5_id(
    i,
    optional_css_class,
    optional_the_id,
    optional_css_style,
    optional_javascript
  ) { :clickable_image }
end

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

#

h6

#


5463
5464
5465
5466
5467
5468
5469
5470
5471
5472
5473
# File 'lib/cyberweb/web_object/web_object.rb', line 5463

def h6(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = ''
  )
  append_onto_the_body_tag_nl(
    HtmlTags.h6(i, optional_css_class, optional_the_id, optional_css_style)
  )
end

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

#

h6_id

#


1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
# File 'lib/cyberweb/web_object/web_object.rb', line 1273

def h6_id(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = '',
    &block
  )
  yielded = nil
  optional_the_id = optional_the_id.to_s
  if optional_the_id.empty?
    optional_the_id = i.dup
  end
  use_this_id = sanitize_this_id(optional_the_id)
  # ======================================================================= #
  # === Handle blocks next
  # ======================================================================= #
  if block_given?
    yielded = yield
    if yielded.is_a? Hash
      if yielded.has_key?(:clickable_image) and (yielded[:clickable_image] == true)
        if yielded.has_key?(:use_this_image)
          this_image = yielded[:use_this_image]
          i = "<a href=\"##{use_this_id}\">"+
            this_image+
            "</a>"+
            i.gsub(/#{Regexp.new(this_image)}/,'')
        else
          i = "<a href=\"##{use_this_id}\">"+
              clickable_image_as_string?+
              "</a>#{i}"
        end
      end
    else # Else assume a Symbol.
      case yielded
      # =================================================================== #
      # === :clickable_image
      #
      # The embedded image will be clickable, made possible via the
      # a-tag.
      # =================================================================== #
      when :clickable_image
        i = "<a href=\"##{use_this_id}\">"+
            clickable_image_as_string?+
            "</a>#{i}"
      end
    end
  end
  h6(
    i,
    id: use_this_id,
    css_class: optional_css_class,
    css_style: optional_css_style
  )
end

#h6_id_clickable(i = '', optional_css_class = '', optional_the_id = '', optional_css_style = '', optional_javascript = '', &block) ⇒ Object Also known as: h6_fancy_id, h6_fid

#

h6_id_clickable

#


5816
5817
5818
5819
5820
5821
5822
5823
5824
5825
5826
5827
5828
5829
5830
5831
5832
5833
5834
5835
5836
5837
5838
# File 'lib/cyberweb/web_object/web_object.rb', line 5816

def h6_id_clickable(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = '',
    &block
  )
  yielded = nil # Default.
  if block_given?
    yielded = yield
  end
  if yielded and yielded.is_a?(Hash) and !yielded.has_key?(:clickable_image)
    yielded.update(clickable_image: true)
  end
  h6_id(
    i,
    optional_css_class,
    optional_the_id,
    optional_css_style,
    optional_javascript
  ) { yielded }
end

#header(i = '', optional_css_class = '', optional_the_id = '', optional_css_style = '', optional_javascript = '', use_fancy_id = false, &block) ⇒ Object

#

header

This is a variant for h1() essentially, by default.

It can be used via modifications such as:

header('foobar') { :clickable }
#


4936
4937
4938
4939
4940
4941
4942
4943
4944
4945
4946
4947
4948
4949
4950
4951
4952
4953
4954
4955
4956
4957
4958
4959
4960
4961
4962
4963
4964
4965
4966
4967
4968
4969
4970
4971
4972
4973
4974
4975
4976
4977
4978
4979
4980
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004
5005
5006
5007
5008
5009
5010
5011
5012
5013
5014
5015
5016
5017
5018
# File 'lib/cyberweb/web_object/web_object.rb', line 4936

def header(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = '',
    use_fancy_id        = false,
    &block
  )
  yielded = nil # Default.
  use_this_tag = :h1
  # ======================================================================= #
  # === Handle blocks first
  # ======================================================================= #
  if block_given?
    yielded = yield
    if yielded.is_a? Hash
      # =================================================================== #
      # === :clickable
      # =================================================================== #
      if yielded.has_key? :clickable
        use_fancy_id = yielded.delete(:clickable)
      # =================================================================== #
      # === :fancy_id
      # =================================================================== #
      elsif yielded.has_key? :fancy_id
        use_fancy_id = yielded.delete(:fancy_id)
      end
      # =================================================================== #
      # === :use_this_tag
      # =================================================================== #
      if yielded.has_key? :use_this_tag
        use_this_tag = yielded.delete(:use_this_tag)
      end
    else
      case yielded
      # =================================================================== #
      # === :fancy_id
      # =================================================================== #
      when :fancy_id,
           :clickable
        use_fancy_id = true
      end
    end
  end
  if optional_the_id.empty?
    # ===================================================================== #
    # Determine the id next:
    # ===================================================================== #
    optional_the_id = Cyberweb.remove_html(i).tr(' ','_')
  end
  # ======================================================================= #
  # === Handle Hashes next
  # ======================================================================= #
  if optional_css_class.is_a? Hash
    if optional_css_class.has_key? :id
      optional_the_id = optional_css_class.delete(:id)
    end
  end
  if optional_css_class.is_a?(Hash) and optional_css_class.empty?
    optional_css_class = ''
  end
  if use_fancy_id
    method_name = "#{use_this_tag}_fancy_id".to_sym # For instance, h1_fancy_id().
    send(method_name,
      i,
      optional_css_class,
      optional_the_id,
      optional_css_style,
      optional_javascript
    ) { yielded }
  else
    send(
      use_this_tag,
      i,
      optional_css_class,
      optional_the_id,
      optional_css_style,
      optional_javascript
    )
  end
  @internal_hash[:register_ids] << register_this_id(optional_the_id) # optional_the_id
end

#header_for_sitemap(i) ⇒ Object

#

header_for_sitemap

This is a header that can be used to generate a sitemap.

Note that if it is used it will also automatically generate a sitemap on the top right of the page. This was one major reason why this method was created - I wanted to automatically use a sitemap if I use such a header.

#


2817
2818
2819
2820
2821
# File 'lib/cyberweb/web_object/web_object.rb', line 2817

def header_for_sitemap(i)
  id = i.tr(' ','_').delete('')
  register_sitemap(i, id)
  h2(i, '',id)
end

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

#

header_id

#


1373
1374
1375
1376
1377
1378
# File 'lib/cyberweb/web_object/web_object.rb', line 1373

def header_id(
    i, optional_css_class = ''
  )
  use_this_id = i.dup.tr(' ','_').downcase
  h2(i, optional_css_class, use_this_id)
end

#html(&block) ⇒ Object

#

html (html tag)

This method is normally not needed, because class HtmlTemplate will handle this as-is. But sometimes we may have to re-build a HTML page and may need this method.

#


9584
9585
9586
9587
9588
9589
9590
9591
9592
9593
9594
# File 'lib/cyberweb/web_object/web_object.rb', line 9584

def html(
    &block
  )
  prepend_before_the_body_tag(
    "<html>\n"
  )
  if block_given?
    yield
    append_after_the_closing_body_tag('</html>')
  end
end

#ibr(content, optional_css_class = '') ⇒ Object

#

ibr

#


3985
3986
3987
3988
3989
3990
3991
# File 'lib/cyberweb/web_object/web_object.rb', line 3985

def ibr(
    content,
    optional_css_class = ''
  )
  i(content)
  br
end

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

#

ie2

#


2464
2465
2466
2467
2468
2469
2470
2471
2472
2473
2474
2475
2476
2477
2478
2479
2480
# File 'lib/cyberweb/web_object/web_object.rb', line 2464

def ie2(
    content            = '',
    optional_css_class = '',
    optional_the_id    = '',
    optional_css_style = '',
    &block
  )
  optional_css_class = optional_css_class.to_s.dup
  optional_css_class << ' s1em'
  italicbr(
    content, 
    optional_css_class.strip,
    optional_the_id,
    optional_css_style,
    &block
  )
end

#image(url = 'RPG/YINYANG.png', css_class = :empty_string_or_global_css_rules_for_images, the_id = '', css_style = '', alt_text = '', &block) ⇒ Object Also known as: img, ig

#

image (img tag, image tag)

This method can be used to integrate (“embed”) an image into the local web-page at hand. This image can either be a local image, or a remote one.

The corresponding HTML code that governs this is the <img> tag. The first argument, called ‘url`, will become src=“”.

It should be kept in mind that this method has to remain quite flexible.

It has to be able to work with input such as this:

img(
  this_image.sub(Regexp.quote('/home/x/data/images/'),''),
  css_class: 'bblack3',
  width:  '528',
  height: '340',
  alt:    File.basename(this_image.delete_suffix(File.extname(this_image)))
)
#


2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
2992
2993
2994
2995
2996
2997
2998
2999
3000
3001
3002
3003
3004
3005
3006
3007
3008
3009
3010
3011
3012
3013
3014
3015
3016
3017
3018
3019
3020
3021
3022
3023
3024
3025
3026
3027
3028
3029
3030
3031
3032
3033
3034
3035
3036
3037
3038
3039
3040
3041
3042
3043
3044
3045
3046
3047
# File 'lib/cyberweb/web_object/web_object.rb', line 2980

def image(
    url       = 'RPG/YINYANG.png',
    css_class = :empty_string_or_global_css_rules_for_images,
    the_id    = '',
    css_style = '',
    alt_text  = '',
    &block
  )
  if drag_all_images?
    the_id = the_id.dup if the_id.frozen?
    the_id.prepend('drag_') unless the_id.start_with?('drag_')
  end
  # ======================================================================= #
  # === Delegate towards simpler_string_image()
  #
  # First we should obtain the corresponding <img> tag. This will be
  # delegated towards sg() which is an abbreviated name for
  # string_image():
  # ======================================================================= #
  content = sg(
    url,
    css_class,
    the_id,
    css_style,
    alt_text
  )
  # ======================================================================= #
  # === Handle blocks given to this method next
  # ======================================================================= #
  if block_given?
    yielded = yield
    # ===================================================================== #
    # === Handle Hashes next
    # ===================================================================== #
    if yielded.is_a? Hash
      # =================================================================== #
      # === :draggable_attribute
      # =================================================================== #
      if yielded.has_key? :draggable_attribute
        content = content.dup
        content[-1,0] = ' draggable="true"'
      end
      # =================================================================== #
      # === :usemap
      # =================================================================== #
      if yielded.has_key? :usemap
        content = content.dup
        content[-1,0] = ' usemap="'+yielded[:usemap].to_s+'"' 
      end
    # ===================================================================== #
    # === Handle Symbols next
    # ===================================================================== #
    elsif yielded.is_a? Symbol
      case yielded # case tag
      # =================================================================== #
      # === :draggable_attribute
      # =================================================================== #
      when :draggable_attribute,
           :drag
        content = content.dup
        content[-1,0] = ' draggable="true"'
      end
    end
  end
  append_onto_the_body_tag_nl(
    content
  )
end

#images_css(i) ⇒ Object

#

images_css

This method allows the user to set the same CSS rules for all images used on a given WebObject.

#


1756
1757
1758
# File 'lib/cyberweb/web_object/web_object.rb', line 1756

def images_css(i)
  @internal_hash[:global_CSS_rules_for_all_images] = i
end

#images_css_rules?Boolean

#

images_css_rules?

#

Returns:

  • (Boolean)


1763
1764
1765
# File 'lib/cyberweb/web_object/web_object.rb', line 1763

def images_css_rules?
  @internal_hash[:global_CSS_rules_for_all_images]
end

#img_base64(i, optional_css_class = '', optional_css_id = '') ⇒ Object Also known as: base64img

#

img_base64

#


7441
7442
7443
7444
7445
7446
7447
7448
7449
7450
# File 'lib/cyberweb/web_object/web_object.rb', line 7441

def img_base64(
    i,
    optional_css_class = '',
    optional_css_id    = ''
  )
  dataset = Cyberweb.convert_image_to_base64(i)
  append_onto_the_body_tag_nl(
    '<img src="data:image/png;base64,'+dataset+'">'
  )
end

#img_base64_absolute_path(i) ⇒ Object

#

img_base64_absolute_path

This is similar to img_base64(), but it will first obtain the image, then convert it into base64, then add it onto the webobject, making use of the absolute path.

#


7459
7460
7461
7462
7463
7464
7465
7466
7467
7468
7469
7470
7471
7472
7473
7474
7475
7476
7477
# File 'lib/cyberweb/web_object/web_object.rb', line 7459

def img_base64_absolute_path(i)
  absolute_path_to_the_image = File.absolute_path(
    path_to_the_main_image_directory?+
    i
  )
  # ======================================================================= #
  # Note that the variable absolute_path_to_the_image will have an
  # URL such as:
  #
  #  "/home/x/data/images/STD/ZAUBERHUT.png"
  #
  # now.
  # ======================================================================= #
  if File.exist? absolute_path_to_the_image
    decode_this_image_to_base64(absolute_path_to_the_image)
  else
    e 'No file exists at '+absolute_path_to_the_image
  end
end

#img_nbr(url = 'RPG/YINYANG.png', css_class = :empty_string_or_global_css_rules_for_images, the_id = '', css_style = '') ⇒ Object Also known as: img_br, imgbr

#

img_nbr

The fourth argument, called css_style, used to default to “border-width:1px”, but in May 2021 it was realized that this will conflict with e. g. a css class such as “bblack3”. In this case we would want to use a border width of 3px, but this would be ignored due to the default. Thus, the default was removed.

In October 2022 the second argument to this method was changed to a Symbol.

#


6496
6497
6498
6499
6500
6501
6502
6503
6504
6505
6506
6507
6508
6509
# File 'lib/cyberweb/web_object/web_object.rb', line 6496

def img_nbr(
    url       = 'RPG/YINYANG.png',
    css_class = :empty_string_or_global_css_rules_for_images, 
    the_id    = '',
    css_style = '' # Empty default since May 2021 - see above for an explanation.
  )
  img(
    url,
    css_class, 
    the_id,
    css_style
  )
  br # And then the separate call towards br().
end

#in_dir_image(path, optional_css_class = '', optional_id = :drag, optional_css_style = '') ⇒ Object Also known as: indir_img, img_in_dir

#

in_dir_image

This will use an image from the current working directory.

The first argument to it should be the target file path of your local file system.

#


7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
# File 'lib/cyberweb/web_object/web_object.rb', line 7306

def in_dir_image(
    path,
    optional_css_class = '',
    optional_id        = :drag,
    optional_css_style = ''
  )
  append_onto_the_body_tag_nl HtmlTags.img(
    path, optional_css_class, optional_id, optional_css_style
  )
  javascript_drag_and_drop(optional_id) if optional_id == :drag
end

#include_onto_the_webobject(i) ⇒ Object

#

include_onto_the_webobject

#


1563
1564
1565
# File 'lib/cyberweb/web_object/web_object.rb', line 1563

def include_onto_the_webobject(i) # Pass a constant to this method.
  self.class.include(i)
end

#ind1embr(i = '') ⇒ Object

#

ind1embr

#


2306
2307
2308
# File 'lib/cyberweb/web_object/web_object.rb', line 2306

def ind1embr(i = '')
  e i, 'padl1em'
end

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

#

input_checkbox

#


6131
6132
6133
6134
6135
6136
6137
6138
6139
6140
6141
6142
6143
6144
6145
6146
6147
6148
6149
6150
6151
6152
6153
6154
# File 'lib/cyberweb/web_object/web_object.rb', line 6131

def input_checkbox(
    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
  )
  input(
    :checkbox,
    default_value,
    css_class,
    name_to_use,
    css_style,
    accesskey,
    my_javascript,
    id,
    hash,
    &block
  )
end

#input_field(default_value = '', css_class = Input.to_s, name_to_use = '', css_style = '', accesskey = '', my_javascript = '', id = nil, hash = {}) ⇒ Object Also known as: input_entry

#

input_field

This is essentially a wrapper over <input type=“text”>.

Usage example:

input_field('','bblack1 pad8px')
#


6089
6090
6091
6092
6093
6094
6095
6096
6097
6098
6099
6100
6101
6102
6103
6104
6105
6106
6107
6108
6109
6110
# File 'lib/cyberweb/web_object/web_object.rb', line 6089

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

#input_file(default_value = '', css_class = Input.to_s, name_to_use = '', css_style = '', accesskey = '', my_javascript = '', id = nil, hash = {}, &block) ⇒ Object Also known as: input_type_file

#

input_file

#


7785
7786
7787
7788
7789
7790
7791
7792
7793
7794
7795
7796
7797
7798
7799
7800
7801
7802
7803
7804
7805
7806
7807
7808
# File 'lib/cyberweb/web_object/web_object.rb', line 7785

def input_file(
    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
  )
  input(
    :file,
    default_value,
    css_class,
    name_to_use,
    css_style,
    accesskey,
    my_javascript,
    id,
    hash,
    &block
  )
end

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

#

input_radio

#


4482
4483
4484
4485
4486
4487
4488
4489
4490
4491
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
# File 'lib/cyberweb/web_object/web_object.rb', line 4482

def input_radio(
    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
  )
  input(
    :radio,
    default_value,
    css_class,
    name_to_use,
    css_style,
    accesskey,
    my_javascript,
    id,
    hash,
    &block
  )
end

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

#

input_submit

This is essentially a submit-button, in HTML.

The first argument is the text that should be used for that button.

#


6734
6735
6736
6737
6738
6739
6740
6741
6742
6743
6744
6745
6746
6747
6748
6749
6750
6751
6752
6753
6754
6755
6756
6757
# File 'lib/cyberweb/web_object/web_object.rb', line 6734

def input_submit(
    default_value = '',
    css_class     = Input.to_s,
    name_to_use   = '',
    css_style     = '',
    accesskey     = '',
    my_javascript = '',
    id            = nil,
    hash          = {},
    &block
  )
  input(
    :submit,
    default_value,
    css_class,
    name_to_use,
    css_style,
    accesskey,
    my_javascript,
    id,
    hash,
    &block
  )
end

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

#

inputbr

This essentially combines input() with br().

#


4452
4453
4454
4455
4456
4457
4458
4459
4460
4461
4462
4463
4464
4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
4476
4477
# File 'lib/cyberweb/web_object/web_object.rb', line 4452

def inputbr(
    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
  )
  input(
    type,
    default_value,
    css_class,
    name_to_use,
    css_style,
    accesskey,
    my_javascript,
    id,
    hash,
    &block
  )
  br
end

#ip_is_allowed?Boolean Also known as: forbidden

#

ip_is_allowed?

This will forbid serving the site to unallowed visitors.

#

Returns:

  • (Boolean)


3998
3999
4000
# File 'lib/cyberweb/web_object/web_object.rb', line 3998

def ip_is_allowed?
  exit unless ALLOWED_IPS.include? VISITOR_IP
end

#is_a_duplicate_id?(i) ⇒ Boolean

#

is_a_duplicate_id?

#

Returns:

  • (Boolean)


9451
9452
9453
# File 'lib/cyberweb/web_object/web_object.rb', line 9451

def is_a_duplicate_id?(i)
  @internal_hash[:register_ids].include?(i)
end

#is_on_ingrid?Boolean

#

is_on_ingrid?

#

Returns:

  • (Boolean)


4154
4155
4156
4157
4158
4159
4160
4161
4162
4163
4164
# File 'lib/cyberweb/web_object/web_object.rb', line 4154

def is_on_ingrid?
  file = '/home/x/data/personal/controller/configuration.yml'
  result = false
  if File.exist? file
    dataset = YAML.load_file(file)
    if dataset['admin'] == 'ingrid'
      result = true
    end 
  end
  return result
end

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

#

italicbr

#


8749
8750
8751
8752
8753
8754
8755
8756
8757
8758
8759
8760
8761
8762
8763
8764
# File 'lib/cyberweb/web_object/web_object.rb', line 8749

def italicbr(
    content            = '',
    optional_css_class = '',
    optional_the_id    = '',
    optional_css_style = '',
    &block
  )
  italic(
    content,
    optional_css_class,
    optional_the_id,
    optional_css_style,
    &block
  )
  br
end

#javascript_defer(use_this_source) ⇒ Object

#

javascript_defer

The point of defer is to indicate that a javascript-file will not be changing structure of the page as it is being executed.

Note that the defer attribute is supported only for external script files; it is ignored for internal javascript code.

#


3653
3654
3655
3656
3657
3658
3659
# File 'lib/cyberweb/web_object/web_object.rb', line 3653

def javascript_defer(
    use_this_source
  )
  append_onto_the_body_tag_nl(
    '<script defer src="'+use_this_source+'"></script>'
  )
end

#javascript_drag_and_drop(i, use_jquery = use_jquery? ) ⇒ Object Also known as: drag_this, drag_this_id, drag_for, drag_it, drag_textarea, drag_and_drop

#

javascript_drag_and_drop

#


3179
3180
3181
3182
3183
3184
3185
3186
3187
3188
3189
3190
3191
# File 'lib/cyberweb/web_object/web_object.rb', line 3179

def javascript_drag_and_drop(
    i, use_jquery = use_jquery?
  )
  if i.is_a? Array
    i.each {|entry|
      javascript_drag_and_drop(entry, use_jquery)
    }
  else
    if use_jquery
      make_this_id_draggable(i)
    end
  end
end

#javascript_last_modified(i = '') ⇒ Object

#

javascript_last_modified

Usage example:

javascript_last_modified('22.10.2011')
#


5179
5180
5181
5182
5183
# File 'lib/cyberweb/web_object/web_object.rb', line 5179

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

#javascript_pop_up(this_text) ⇒ Object

#

javascript_pop_up

#


5034
5035
5036
5037
5038
# File 'lib/cyberweb/web_object/web_object.rb', line 5034

def javascript_pop_up(this_text)
  ejavascript '
    window.alert("'+this_text.to_s+'");
  '
end

#javascript_reveal_this_id_after_n_seconds(name_of_id = 'answer_div', delay = 2, name_of_the_function_to_use = 'reveal_the_answer()') ⇒ Object

#

javascript_reveal_this_id_after_n_seconds

Use this method to reveal a hidden element based on its ID, after some delay.

Invocation example:

javascript_reveal_this_id_after_n_seconds 'answer_div', 2
#


1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
# File 'lib/cyberweb/web_object/web_object.rb', line 1871

def javascript_reveal_this_id_after_n_seconds(
    name_of_id = 'answer_div',
    delay      = 2,
    name_of_the_function_to_use = 'reveal_the_answer()'
  )
  unless name_of_the_function_to_use.end_with? '()'
    name_of_the_function_to_use << '()'
  end
  javascript_in_head_tag '
window.onload  = function(){
var theDelay = 2;
var timer = setTimeout("'+name_of_the_function_to_use+'",theDelay*1000)
}
function '+name_of_the_function_to_use+'{
document.getElementById("'+name_of_id+'").style.visibility = "visible";
}
'
end

#javascript_show_the_browser_in_use(use_this_css_class = 'mars0_5em mart1px') ⇒ Object

#

javascript_show_the_browser_in_use

#


24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/cyberweb/web_object/javascript_and_jquery.rb', line 24

def javascript_show_the_browser_in_use(
    use_this_css_class = 'mars0_5em mart1px'
  )
  div_default(
    css_class: use_this_css_class,
    id:        'div_browser_in_use'
  ) {
    ejavascript '
    document.getElementById("div_browser_in_use").innerHTML = "<span style=\"font-size: smaller;\">Browser in use: <b>"+navigator.userAgent+"</b></span>";
    '
  }
end

#javascript_show_the_browser_in_userObject

#

javascript_show_the_browser_in_user

#


1432
1433
1434
1435
1436
1437
1438
1439
1440
# File 'lib/cyberweb/web_object/web_object.rb', line 1432

def javascript_show_the_browser_in_user
  ejavascript '

let user_agent = navigator.userAgent;

document.getElementById("div_browser_in_use").innerHTML = "<span style=\"font-size: smaller;\">Browser in use: <b>"+user_agent+"</b></span>";

  '
end

#javascript_write(i = 'Hello world!') ⇒ Object

#

javascript_write

#


4050
4051
4052
4053
4054
4055
4056
4057
4058
# File 'lib/cyberweb/web_object/web_object.rb', line 4050

def javascript_write(
    i = 'Hello world!'
  )
  append_onto_the_body_tag_nl(
    return_javascript(
      'document.write('+i.to_s+')'
    )
  )
end

#jquery_append_this_text_onto_that_id(button_id, this_text, that_id) ⇒ Object

#

jquery_append_this_text_onto_that_id

Usage example:

jquery_append_this_text_onto_that_id('button2', 'Append list', 'foobar')
#


1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
# File 'lib/cyberweb/web_object/web_object.rb', line 1844

def jquery_append_this_text_onto_that_id(
    button_id,
    this_text,
    that_id
  )
  ejavascript '

$(document).ready(function(){
$("#'+button_id.to_s+'").click(function(){
  $("#'+that_id.to_s+'").append("'++this_text.to_s+'");
});
});

'
end

#jquery_hide_all_p_tags(hide_this_id = 'hide_all_paragraphs') ⇒ Object

#

jquery_hide_all_p_tags

#


5188
5189
5190
5191
5192
5193
5194
5195
5196
5197
# File 'lib/cyberweb/web_object/web_object.rb', line 5188

def jquery_hide_all_p_tags(
    hide_this_id = 'hide_all_paragraphs'
  )
  ejavascript '
$(document).ready(function(){
$("#'+hide_this_id.to_s+'").click(function(){
  $("p").hide();
});
});'
end

#jquery_resizable_via_the_mouse(hash_or_string = { id: :resizable_via_the_mouse }) ⇒ Object

#

jquery_resizable_via_the_mouse

This method can be used to resize an element via the mouse.

#


5622
5623
5624
5625
5626
5627
5628
5629
5630
5631
5632
# File 'lib/cyberweb/web_object/web_object.rb', line 5622

def jquery_resizable_via_the_mouse(
    hash_or_string = { id: :resizable_via_the_mouse }
  )
  if hash_or_string and hash_or_string.is_a?(Hash) and
     hash_or_string.has_key?(:id)
    hash_or_string = hash_or_string[:id].to_s
  end
  ejavascript '$( function() {
    $("#'+hash_or_string.to_s+'").resizable();
  } );'
end

#js_files_to_load?Boolean

#

js_files_to_load?

This method will return which .js files are to be loaded by the cyberweb project. This is normally defined in the file at ‘cyberweb/yaml/js_files_to_load.yml’.

#

Returns:

  • (Boolean)


768
769
770
# File 'lib/cyberweb/web_object/web_object.rb', line 768

def js_files_to_load?
  ARRAY_DEFAULT_JAVASCRIPT_LIBRARIES
end

#l1(i = '', optional_css_class = '', optional_the_id = '') ⇒ Object Also known as: l1em, l1m, lem1, padlem, padl1em

#

l1 (l1 tag)

The second argument to this method may sometimes be a Hash, such as:

'foobar', id: 'mini-car'
#


3579
3580
3581
3582
3583
3584
3585
3586
3587
3588
3589
3590
3591
3592
3593
3594
3595
3596
3597
3598
3599
3600
# File 'lib/cyberweb/web_object/web_object.rb', line 3579

def l1(
    i                  = '',
    optional_css_class = '',
    optional_the_id    = ''
  )
  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.is_a?(Hash) and optional_css_class.empty?
      optional_css_class = optional_css_class.to_s
    end
  end
  optional_css_class = optional_css_class.dup
  optional_css_class << ' padl1em' # Add the padl1em CSS class here.
  s2(
    i, optional_css_class.strip, optional_the_id
  )
end

#l2(i = '', optional_css_class = '', optional_the_id = '') ⇒ Object Also known as: l2em, padl2em

#

l2

#


8830
8831
8832
8833
8834
8835
8836
8837
8838
8839
8840
8841
8842
8843
8844
8845
8846
8847
8848
8849
8850
# File 'lib/cyberweb/web_object/web_object.rb', line 8830

def l2(
    i                  = '',
    optional_css_class = '',
    optional_the_id    = ''
  )
  if optional_css_class.is_a? Hash
    # ======================================================================= #
    # === :id
    # ======================================================================= #
    if optional_css_class.has_key? :id
      optional_the_id = optional_css_class.delete(:id)
    end
  end
  if optional_css_class.frozen?
    optional_css_class = optional_css_class.dup
  end
  unless optional_css_class.include? 'padl2em'
    optional_css_class << ' padl2em'
  end 
  s2(i, optional_css_class.strip, optional_the_id)
end

#l2emb(i = '', optional_css_class = '') ⇒ Object Also known as: l2br, l2embr, lem2, lembre2, padl2embr, le2, lem2br, le2em, l2embre

#

l2emb

This method simply combines l2() with br().

#


9160
9161
9162
9163
9164
9165
9166
# File 'lib/cyberweb/web_object/web_object.rb', line 9160

def l2emb(
    i                  = '',
    optional_css_class = ''
  )
  l2(i, optional_css_class)
  br
end

#l3(i = '', optional_css_class = '', optional_the_id = '', optional_css_style = '') ⇒ Object Also known as: le3, l3em, lem3, padl3em

#

l3

#


1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
# File 'lib/cyberweb/web_object/web_object.rb', line 1980

def l3(
    i                  = '',
    optional_css_class = '',
    optional_the_id    = '',
    optional_css_style = ''
  )
  if optional_css_class.frozen?
    optional_css_class = optional_css_class.dup
  end
  optional_css_class << ' padl3em' unless optional_css_class.include? 'padl3em'
  s2(i, optional_css_class.strip, optional_the_id, optional_css_style)
end

#l4(i = '', optional_css_class = '', optional_the_id = '', optional_css_style = '') ⇒ Object Also known as: le4, l4em, lem4, padl4em

#

l4

#


2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
# File 'lib/cyberweb/web_object/web_object.rb', line 2014

def l4(
    i                  = '',
    optional_css_class = '',
    optional_the_id    = '',
    optional_css_style = ''
  )
  if optional_css_class.frozen?
    optional_css_class = optional_css_class.dup
  end
  optional_css_class << ' padl4em' unless optional_css_class.include? 'padl3em'
  s2(i, optional_css_class.strip, optional_the_id, optional_css_style)
end

#l5(i = '', optional_css_class = '', optional_the_id = '', optional_css_style = '') ⇒ Object Also known as: le5, l5em, lem5, padl5em

#

l5

#


2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
# File 'lib/cyberweb/web_object/web_object.rb', line 2047

def l5(
    i                  = '',
    optional_css_class = '',
    optional_the_id    = '',
    optional_css_style = ''
  )
  if optional_css_class.frozen?
    optional_css_class = optional_css_class.dup
  end
  optional_css_class << ' padl5em' unless optional_css_class.include? 'padl3em'
  s2(i, optional_css_class.strip, optional_the_id, optional_css_style)
end

#label_and_input_text(work_on_this_id = '', text_for_the_label = '', *remaining_arguments) ⇒ Object

#

label_and_input_text

This method essentially combines <label> and <input type=“text”>.

Usage examples:

label_and_input_text :foobar
label_and_input_text :foobar, 'Age: '
label_and_input_text id: :foobar
label_and_input_text id: :foobar, :br
label_and_input_text id: :foobar, :linebreak
label_and_input_text id: :foobar, :middle_break
label_and_input_text {id: :foobar}, :middle_break
#


5779
5780
5781
5782
5783
5784
5785
5786
5787
5788
5789
5790
5791
5792
5793
5794
5795
5796
5797
5798
5799
5800
5801
5802
5803
5804
5805
5806
5807
5808
5809
5810
5811
# File 'lib/cyberweb/web_object/web_object.rb', line 5779

def label_and_input_text(
    work_on_this_id    = '',
    text_for_the_label = '',
    *remaining_arguments # Store them in an Array.
  )
  use_a_new_line = false # Default.
  # ======================================================================= #
  # === Handle Hashes first
  # ======================================================================= #
  if work_on_this_id.is_a? Hash
    if work_on_this_id.has_key? :id
      work_on_this_id = work_on_this_id.delete(:id)
    end
  end
  work_on_this_id = work_on_this_id.to_s
  case text_for_the_label
  # ======================================================================= #
  # === :middle_break
  # ======================================================================= #
  when :middle_break,
       :linebreak,
       :br
    use_a_new_line = true
    text_for_the_label = ''
  end
  append_onto_the_body_tag_nl(
    '<label for="'+work_on_this_id+'">'+text_for_the_label+'</label>'
  )
  br if use_a_new_line
  append_onto_the_body_tag_nl(
    '<input type="text" id="'+work_on_this_id+'" name="'+work_on_this_id+'">'
  )
end

#last_modified?Boolean Also known as: last_update?, last_update

#

last_modified?

This method will show when the document was last modified. JavaScript must be available for this method to work properly.

#

Returns:

  • (Boolean)


9096
9097
9098
9099
9100
9101
9102
9103
9104
9105
9106
9107
9108
9109
9110
9111
9112
9113
9114
9115
9116
9117
9118
9119
9120
9121
9122
9123
9124
# File 'lib/cyberweb/web_object/web_object.rb', line 9096

def last_modified?
  div('pad5px FS1em',
      'last_modified'){
    # ===================================================================== #
    # === Handle blocks next
    # ===================================================================== #
    if block_given?
      yielded = yield
      case yielded
      # =================================================================== #
      # === :display_on_the_same_line
      # =================================================================== #
      when :display_on_the_same_line
        e 'This document was last modified at: '+
           string_s2(
             return_doc_write('document.lastModified'),
             'marl0_5em BOLD'
           )
      else # else is the default choice.
        e 'This document was last modified at: '
        br
        s2(
          return_doc_write('document.lastModified'),
          'marl0_5em'
        )    
      end
    end
  }
end

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

#

le3br

#


8769
8770
8771
8772
8773
8774
# File 'lib/cyberweb/web_object/web_object.rb', line 8769

def le3br(
    i = '', optional_css_class = ''
  )
  l3(i, optional_css_class)
  br
end

#lem3br(i = '', optional_css_class = '', optional_the_id = '', optional_css_style = '') ⇒ Object Also known as: padl3embr, l3embr, l3br

#

lem3br

#


1999
2000
2001
2002
2003
2004
2005
2006
2007
# File 'lib/cyberweb/web_object/web_object.rb', line 1999

def lem3br(
    i                  = '',
    optional_css_class = '',
    optional_the_id    = '',
    optional_css_style = ''
  )
  l3em(i, optional_css_class.strip, optional_the_id, optional_css_style)
  br
end

#lem4br(i = '', optional_css_class = '', optional_the_id = '', optional_css_style = '') ⇒ Object Also known as: padl4embr, l4embr

#

lem4br

#


2033
2034
2035
2036
2037
2038
2039
2040
2041
# File 'lib/cyberweb/web_object/web_object.rb', line 2033

def lem4br(
    i                  = '',
    optional_css_class = '',
    optional_the_id    = '',
    optional_css_style = ''
  )
  l4em(i, optional_css_class.strip, optional_the_id, optional_css_style)
  br
end

#lem5br(i = '', optional_css_class = '', optional_the_id = '', optional_css_style = '') ⇒ Object Also known as: padl5embr, l5embr

#

lem5br

#


2292
2293
2294
2295
2296
2297
2298
2299
2300
# File 'lib/cyberweb/web_object/web_object.rb', line 2292

def lem5br(
    i                  = '',
    optional_css_class = '',
    optional_the_id    = '',
    optional_css_style = ''
  )
  l5em(i, optional_css_class.strip, optional_the_id, optional_css_style)
  br
end

#lembre(i = '', optional_css_class = '', optional_the_id = '') ⇒ Object Also known as: lem1br, lem, lemspan, lee, lembr, padl1embr, le

#

lembre

#


3609
3610
3611
3612
3613
3614
3615
3616
3617
3618
3619
3620
# File 'lib/cyberweb/web_object/web_object.rb', line 3609

def lembre(
    i                  = '',
    optional_css_class = '',
    optional_the_id    = ''
  )
  l1(
    i,
    optional_css_class,
    optional_the_id
  )
  br
end

#lembre_quote(i = '', optional_css_class = '', optional_the_id = '') ⇒ Object

#

lembre_quote

This is like lembre(), but it additionally makes use of string_quote().

#


9302
9303
9304
9305
9306
9307
9308
9309
9310
9311
9312
# File 'lib/cyberweb/web_object/web_object.rb', line 9302

def lembre_quote(
    i                  = '',
    optional_css_class = '',
    optional_the_id    = ''
  )
  lembre(
    string_quote(i),
    optional_css_class,
    optional_the_id
  )
end

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

#

li (li tag)

This method should ultimately generate a String such as:

<li>foobar</li>

Invocation example:

li css_class: 'darkblue'
#


8705
8706
8707
8708
8709
8710
8711
8712
8713
8714
8715
8716
8717
8718
8719
8720
8721
8722
8723
8724
8725
8726
8727
8728
8729
8730
8731
8732
8733
8734
8735
8736
8737
8738
8739
8740
8741
8742
8743
8744
# File 'lib/cyberweb/web_object/web_object.rb', line 8705

def li(
    content             = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = '',
    &block
  )
  # ======================================================================= #
  # === Handle Hashes first
  # ======================================================================= #
  if content.is_a? Hash
    if content.has_key? :css_class
      optional_css_class = content.delete(:css_class)
    end
    if content.empty? and !content.is_a?(String)
      content = ''
    end
  end
  # ======================================================================= #
  # First, always add the <li> tag, whenever li() is called.
  # ======================================================================= #
  append_onto_the_body_tag_nl(
    '<li'+
    css_class_or_no_class(optional_css_class.dup)+
    id_or_no_id(optional_the_id.to_s.dup)+
    css_style_or_no_style(optional_css_style.dup)+
    '>'
  )
  append_onto_the_body_tag_nl(content.dup) if content and !content.empty?
  # ======================================================================= #
  # === Handle blocks given to this method next
  #
  # We'll simply append the content there.
  # ======================================================================= #
  if block_given?
    append_onto_the_body_tag_nl(yield)
    cli
  end
end
#

Use this method to describe an in-page link, ie a link towards ‘HARDWARE.cgi#foobar’ (an “intralink”).

Usage examples:

link_in_page(:where_to, 'internal_pointer', 'Zu meinem Netgar WLAN Stick')
link_in_page(:where_to, 'internal_pointer', 'Zu meinem Netgar WLAN Stick',0,'css_class')
link_in_page(:hware,    'USB_Netgear_108_WG111T', 'Zu meinem Netgar WLAN Stick')
#


6808
6809
6810
6811
6812
6813
6814
6815
6816
6817
6818
6819
6820
6821
6822
6823
6824
6825
6826
6827
6828
6829
6830
6831
6832
6833
6834
6835
6836
6837
6838
6839
6840
6841
# File 'lib/cyberweb/web_object/web_object.rb', line 6808

def link_in_page(
    link_hyperref     = '',
    pointer           = '', 
    link_description  = '',
    default_linebreak = '',
    css_class         = '',
    the_id            = '',
    css_style         = '',
    use_js            = ''
  )
  link_hyperref = 'SELF' if link_hyperref.to_s.empty? # safeguard
  if link_description.to_s.empty? and !pointer.to_s.empty?
    link_description = pointer.dup
  end
  # ======================================================================= #
  # === Pass through BeautifulUrl next but not or /Users link
  # ======================================================================= #
  if link_hyperref.is_a?(String) and !link_hyperref.include?('SELF')
    unless link_hyperref.start_with? '/home'
      _ = sanitize_url(link_hyperref, true)
      link_hyperref = _
    end
  end
  this_target = "#{link_hyperref}#{pointer}" 
  a(
    this_target,
    content:   link_description,
    linebreak: default_linebreak,
    css_class: css_class,
    the_id:    the_id,
    css_style: css_style,
    use_js:    use_js
  )
end
#
#


6787
6788
6789
6790
6791
6792
6793
# File 'lib/cyberweb/web_object/web_object.rb', line 6787

def link_to_local_games(
    optional_css_class = 'mars1em steelblue BOLD'
  )
  abr :local_games,
      content: :self,
      css_class: optional_css_class
end

#linkbr(i = '', option_hash = {}) ⇒ Object Also known as: abr

#

linkbr (abr tag)

This method will mostly delegate onto HtmlTags.a(), by calling a() internally first.

#


7227
7228
7229
7230
7231
7232
7233
7234
7235
7236
7237
7238
7239
7240
7241
7242
7243
7244
7245
7246
7247
7248
7249
7250
7251
7252
7253
7254
7255
7256
7257
7258
7259
7260
7261
7262
7263
7264
7265
7266
7267
7268
7269
7270
7271
7272
7273
7274
7275
7276
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
# File 'lib/cyberweb/web_object/web_object.rb', line 7227

def linkbr(
    i           = '',
    option_hash = {}
  )
  if i.is_a?(Symbol)
    # ===================================================================== #
    # Next is a bit hack-ish. If we are using sinatra, and if the link
    # is registered as a local link, then we will use a much shorter
    # URL that just re-directs to the / root directory of the sinatra
    # application at hand.
    #
    # This will only be the case for Symbols.
    # ===================================================================== #
    if are_we_using_sinatra? and 
       Object.const_defined?(:BeautifulUrl) and
       BeautifulUrl.is_a_local_link?(i)
       i = i.to_s
       option_hash[:content] = i.to_s
    else
      i = beautiful_url(i)
    end
  end
  case i
  when /^SELF$/
    i = request_uri?
  else
    # ===================================================================== #
    # Improve on the option-hash next.
    # ===================================================================== #
    if option_hash.is_a?(Hash)
      if @internal_hash[:css_classes_to_be_used_by_default_for_abr_links]
        if option_hash.has_key?(:css_class)
          option_hash[:css_class] = option_hash[:css_class].dup # Always unfreeze.
          option_hash[:css_class] << @internal_hash[:css_classes_to_be_used_by_default_for_abr_links]
        else
          option_hash[:css_class] = @internal_hash[:css_classes_to_be_used_by_default_for_abr_links]
        end
      end
      # =================================================================== #
      # === :content
      # =================================================================== #
      if option_hash.respond_to?(:content) and
         option_hash.has_key?(:content)
        _ = option_hash[:content]
        case _
        # ================================================================= #
        # === Example: dot101 SELF
        # ================================================================= #
        when /^dot(\d{1,3}) SELF/
          _ = ''.dup
          _ << sg(('dot'+$1.to_s).to_sym, 'marr8px')
          _ << " #{i}"
        end
        option_hash[:content] = _
      end
    end
  end
  a(i, option_hash)
  br
end

#listing_counter=(i) ⇒ Object

#

listing_counter=

#


9481
9482
9483
# File 'lib/cyberweb/web_object/web_object.rb', line 9481

def listing_counter=(i)
  @internal_hash[:listing_counter] = i
end

#listing_counter?Boolean Also known as: listing_counter

#

listing_counter?

#

Returns:

  • (Boolean)


9474
9475
9476
# File 'lib/cyberweb/web_object/web_object.rb', line 9474

def listing_counter?
  @internal_hash[:listing_counter]
end

#listing_css(i) ⇒ Object

#

listing_css

#


9444
9445
9446
# File 'lib/cyberweb/web_object/web_object.rb', line 9444

def listing_css(i)
  Cyberweb.listing_css_object = i
end

#listing_css_objectObject

#

listing_css_object

#


3396
3397
3398
# File 'lib/cyberweb/web_object/web_object.rb', line 3396

def listing_css_object
  Cyberweb.listing_css_object
end

#load_debug_file(i = "#{Cyberweb.config_directory?}debug.yml") ⇒ Object

#

load_debug_file

This will load the content of the ‘debug.yml’ file.

#


8676
8677
8678
8679
8680
8681
8682
8683
8684
# File 'lib/cyberweb/web_object/web_object.rb', line 8676

def load_debug_file(
    i = "#{Cyberweb.config_directory?}debug.yml"
  )
  if File.exist? i
    return YAML.load_file(i)
  else
    return SHALL_WE_DEBUG
  end
end

#load_yaml_configurationObject Also known as: sync_yaml_configuration

#

load_yaml_configuration (yaml tag)

This method will load the yaml configuration dataset. This will also set the @config variable.

In order to query this variable, you can use it like a regular hash.

Example for this:

@config['use_webimages']
#


895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
# File 'lib/cyberweb/web_object/web_object.rb', line 895

def load_yaml_configuration
  @config = nil # This is probably not needed.
  if debug?
    e 'Debugging: The path to our configuration '\
      'is at: '+sfile(_)
  end
  # ======================================================================= #
  # Next, assign to the toplevel @config value.
  # ======================================================================= #
  @config = Cyberweb.configuration_object?
  # ======================================================================= #
  # === :use_jquery
  #
  # Whether to use jquery or whether we don't.
  # ======================================================================= #
  @internal_hash[:use_jquery] = @config['use_jquery']
  # ======================================================================= #
  # Whether to drag all images or whether we won't.
  # ======================================================================= #
  @config['drag_all_images'] = false
end

#local_image_or_remote_image(local_image = '', remote_image_substitute = '', optional_css_class = '', optional_the_id = '', optional_css_style = '', alt_text = '', &block) ⇒ Object

#

local_image_or_remote_image

This method can be used to add a substitute image in the event that a local image could not be found. Otherwise it behaves exactly like image() does.

This method will respond to various block-parameters, such as { :drag }.

#


8863
8864
8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
8890
8891
8892
8893
8894
8895
8896
8897
8898
8899
8900
8901
8902
8903
8904
8905
8906
# File 'lib/cyberweb/web_object/web_object.rb', line 8863

def local_image_or_remote_image(
    local_image             = '',
    remote_image_substitute = '', # This one should be the remote URL.
    optional_css_class      = '',
    optional_the_id         = '',
    optional_css_style      = '',
    alt_text                = '',
    &block
  )
  # ======================================================================= #
  # We first have to decide whether the image exists or whether it does
  # not exist, at the specified location. If it exists then we can use
  # the regular img() call; otherwise we have to use the second argument
  # to this method.
  # ======================================================================= #
  assumed_path = rds(
    path_to_the_image_directory?+
    local_image
  )
  if File.exist?(assumed_path) and !local_image.empty?
    img(
      local_image,
      optional_css_class,
      optional_the_id,
      optional_css_style,
      alt_text,
      &block
    )
  else
    # ===================================================================== #
    # else we use a remote URL or a rescue URL anyway.
    # ===================================================================== #
    remote_img(
      remote_image_substitute,
      {
        css_class: optional_css_class,
        id:        optional_the_id,
        css_style: optional_css_style
      },
      &block
      # alt_text is currently not handled here.
    )
  end
end

#log(what, use_this_as_the_log_directory = log_dir? ) ⇒ Object

#

log (log tag)

This is the general log-related method. For now it simply saves into a default file.

#


2069
2070
2071
2072
2073
2074
2075
# File 'lib/cyberweb/web_object/web_object.rb', line 2069

def log(
    what,
    use_this_as_the_log_directory = log_dir?
  )
  into = "#{use_this_as_the_log_directory}default.log"
  save(what, :default, into)
end

#logical_build_up(array = [ :html_start_tag, :head_start_tag, :add_the_meta_tags, :close_body_head_and_html_tag ]) ⇒ Object

#

logical_build_up

This method can be used to “build up” a webpage from scratch.

Furthermore it can be used to also “build from the middle”, that is start at a later point in time if necessary.

This is experimental right now in October 2021 - perhaps one day we will make it to handle all logical “small steps”.

#


7398
7399
7400
7401
7402
7403
7404
7405
7406
7407
7408
7409
7410
# File 'lib/cyberweb/web_object/web_object.rb', line 7398

def logical_build_up(
    array =
      [
        :html_start_tag,
        :head_start_tag,
        :add_the_meta_tags,
        :close_body_head_and_html_tag
      ]
  )
  array.each {|entry|
    send(entry)
  }
end

#maddonsObject

#

maddons

#


3479
3480
3481
# File 'lib/cyberweb/web_object/web_object.rb', line 3479

def maddons
  Cyberweb.maddons
end

#mail=(i) ⇒ Object

#

mail=

This method expects a Mail object.

#


5694
5695
5696
# File 'lib/cyberweb/web_object/web_object.rb', line 5694

def mail=(i)
  @internal_hash[:mail] = i
end

#mail?Boolean Also known as: mail

#

mail?

Query the mail-object.

#

Returns:

  • (Boolean)


3903
3904
3905
# File 'lib/cyberweb/web_object/web_object.rb', line 3903

def mail?
  @internal_hash[:mail]
end

#marl1em(i = '', optional_css_class = '', optional_the_id = '') ⇒ Object

#

marl1em

#


7948
7949
7950
7951
7952
7953
7954
7955
7956
# File 'lib/cyberweb/web_object/web_object.rb', line 7948

def marl1em(
    i                  = '',
    optional_css_class = '',
    optional_the_id    = ''
  )
  optional_css_class = optional_css_class.dup
  optional_css_class << ' marl1em'
  s2(i, optional_css_class.strip)
end

#marl2em(i = '', optional_css_class = '', optional_the_id = '') ⇒ Object

#

marl2em

#


7961
7962
7963
7964
7965
7966
7967
7968
7969
# File 'lib/cyberweb/web_object/web_object.rb', line 7961

def marl2em(
    i                  = '',
    optional_css_class = '',
    optional_the_id    = ''
  )
  optional_css_class = optional_css_class.dup
  optional_css_class << ' marl2em'
  s2(i, optional_css_class.strip)
end

#marl3em(i = '', optional_css_class = '', optional_the_id = '') ⇒ Object

#

marl3em

#


7974
7975
7976
7977
7978
7979
7980
7981
7982
# File 'lib/cyberweb/web_object/web_object.rb', line 7974

def marl3em(
    i                  = '',
    optional_css_class = '',
    optional_the_id    = ''
  )
  optional_css_class = optional_css_class.dup
  optional_css_class << ' marl3em'
  s2(i, optional_css_class.strip, optional_the_id)
end

#marl4em(i = '', optional_css_class = '', optional_the_id = '') ⇒ Object

#

marl4em

#


7415
7416
7417
7418
7419
7420
7421
7422
7423
# File 'lib/cyberweb/web_object/web_object.rb', line 7415

def marl4em(
    i                  = '',
    optional_css_class = '',
    optional_the_id    = ''
  )
  optional_css_class = optional_css_class.dup
  optional_css_class << ' marl4em'
  s2(i, optional_css_class.strip)
end

#marl5em(i = '', optional_css_class = '', optional_the_id = '') ⇒ Object

#

marl5em

#


7428
7429
7430
7431
7432
7433
7434
7435
7436
# File 'lib/cyberweb/web_object/web_object.rb', line 7428

def marl5em(
    i                  = '',
    optional_css_class = '',
    optional_the_id    = ''
  )
  optional_css_class = optional_css_class.dup
  optional_css_class << ' marl5em'
  s2(i, optional_css_class.strip)
end

#message_box(content = '', css_class = '', the_id = 'success_box', css_style = '') ⇒ Object

#

message_box

We have registered four different message boxes so far.

The ID should never be changed.

You can enable drag and drop if you pass the symbol :enable_drag_and_drop when invoking this method.

An alternative to this would be to pass the identifier __drag__ to the second method, as in this example:

info_box  'Hi there how do you do','__drag__','','width:30%'
error_box 'Hi there how do you do','__drag__','','width:30%'
#


3793
3794
3795
3796
3797
3798
3799
3800
3801
3802
3803
3804
3805
3806
3807
3808
3809
3810
3811
3812
3813
3814
3815
3816
3817
3818
3819
3820
3821
3822
3823
3824
3825
3826
3827
3828
3829
3830
3831
3832
3833
3834
3835
3836
3837
3838
3839
3840
3841
3842
3843
3844
3845
3846
3847
3848
# File 'lib/cyberweb/web_object/web_object.rb', line 3793

def message_box(
    content   = '',
    css_class = '',
    the_id    = 'success_box',
    css_style = ''
  )
  extra_actions = nil
  # ======================================================================= #
  # extra_actions include specific extra instructions to this method.
  # ======================================================================= #
  extra_actions = yield if block_given?
  css_class = '__drag__' if css_class == :drag
  if css_class.to_s.include? '__drag__' # Enable drag and drop support.
    css_class = css_class.to_s.dup
    extra_actions = :enable_drag_and_drop
    css_class.gsub!(/__drag__/,'')
  end
  _ = the_id.split('_').first
  the_id << '_'+::Cyberweb.n_message_boxes_were_created?.to_s
  css_class = _+' '+css_class.to_s # .to_s because it might be a Symbol.
  # ======================================================================= #
  # Designate a default image for the message_box next.
  # ======================================================================= #
  image = full_path_to_image_directory?+WebImages['message_box_'+_] # image should now be, e. g., "STD/MESSAGE_BOX_ERROR.png"
  case extra_actions
  # ======================================================================= #
  # === :enable_drag_and_drop
  # ======================================================================= #
  when :enable_drag_and_drop
    drag the_id.to_sym # Enable drag and drop support here.
  else
    if extra_actions.is_a? Hash
      if extra_actions.has_key? :use_this_as_image
        image = extra_actions.delete :use_this_as_image
        extra_actions = ''
      end
    end
  end
  Cyberweb.increment_n_message_boxes # Increase the amount of used message boxes here.
  # ======================================================================= #
  # Next comes a short hack: if we pass in something that has a src="" entry,
  # then we assume that this is not 100% what the user wanted to do here. Thus,
  # we will extract the src="" component and use that instead.
  # ======================================================================= #
  if image.include? 'src="'
    regex = /src="(.+?)"/ # This is non-greedy, see: http://rubular.com/r/rrc91XBJcI
    image =~ regex
    image = $1.to_s.dup
  end
  css_style = "background-image: url('"+
    image+
  "'); "+css_style
  div(css_class.strip, the_id, css_style.strip) {
    e content
  }
end

#meta_description(i = '20.08.2021') ⇒ Object

#

meta_description

Usage example for this method:

meta_description 'This is a sitemap.'
#


3717
3718
3719
3720
3721
3722
# File 'lib/cyberweb/web_object/web_object.rb', line 3717

def meta_description(
    i = '20.08.2021'
  )
  @internal_hash[:meta_content] <<
    '<meta name="description"           content="'+i.to_s+'"/>'+"\n" 
end

#molecular_oxygenObject

#

molecular_oxygen

#


423
424
425
# File 'lib/cyberweb/web_object/web_object.rb', line 423

def molecular_oxygen
  'O₂'
end

#no_jqueryObject

#

no_jquery

Do not use jquery. This is the default.

#


5639
5640
5641
# File 'lib/cyberweb/web_object/web_object.rb', line 5639

def no_jquery
  @config['use_jquery'] = false
end

#no_params_were_given?Boolean

#

no_params_were_given?

#

Returns:

  • (Boolean)


4432
4433
4434
# File 'lib/cyberweb/web_object/web_object.rb', line 4432

def no_params_were_given?
  !param_first_key?
end

#obtain_the_parameters_passedObject Also known as: return_params_hash, web_params?, web_params, web_param?, params?, params

#

obtain_the_parameters_passed

This query-method will return which params have been passed into, for example, a .cgi page.parameters_as_string?

Typical invocation may go like this:

w.obtain_the_parameters_passed
#


7186
7187
7188
# File 'lib/cyberweb/web_object/web_object.rb', line 7186

def obtain_the_parameters_passed
  Cyberweb.params? # This is part of params.rb actually.
end

#obtain_this_param_as_string(i) ⇒ Object

#

obtain_this_param_as_string

This method must guarantee to return a String.

#


4441
4442
4443
4444
4445
# File 'lib/cyberweb/web_object/web_object.rb', line 4441

def obtain_this_param_as_string(i)
  _ = params?[i]
  _ = _.first if _.is_a? Array
  return _.to_s # e. g. {"view"=>["/tmp"]}
end

#on_this_id(use_this_id = :div_browser_in_use) ⇒ Object

#

on_this_id

#


9259
9260
9261
9262
9263
9264
9265
# File 'lib/cyberweb/web_object/web_object.rb', line 9259

def on_this_id(
    use_this_id = :div_browser_in_use
  )
  javascript_helper = Cyberweb::JavascriptHelper.new
  javascript_helper.work_on_this_id = use_this_id
  return javascript_helper
end

#oop_abbr(a, b = nil) ⇒ Object

#

oop_abbr

This method makes use of the OOP variant for the abbr-html-tag.

#


2801
2802
2803
2804
2805
# File 'lib/cyberweb/web_object/web_object.rb', line 2801

def oop_abbr(a, b = nil)
  append_onto_the_body_tag_nl(
    Cyberweb::Objectified::HtmlTags::Abbr.new(a, b).to_s
  )
end

#oop_div(a, b = nil, &block) ⇒ Object

#

oop_div

#


7889
7890
7891
7892
7893
7894
7895
# File 'lib/cyberweb/web_object/web_object.rb', line 7889

def oop_div(
    a, b = nil, &block
  )
  append_onto_the_body_tag_nl(
    Cyberweb::Objectified::HtmlTags::Div.new(a, b, &block).to_s
  )
end

#oop_progress(n_percent, &block) ⇒ Object Also known as: progress

#

oop_progress

The progress element represents the completion progress of a task. The method here will simply delegate towards the corresponding objectified HTML tag.

Usage example:

progress(35)
#


3353
3354
3355
3356
3357
3358
3359
3360
# File 'lib/cyberweb/web_object/web_object.rb', line 3353

def oop_progress(
    n_percent,
    &block
  )
  append_onto_the_body_tag_nl(
    return_progress(n_percent, &block).to_s
  )
end

#opal_evaluate(i) ⇒ Object

#

opal_evaluate

This is just a wrapper towards Opal. Eventually we may offer support for opal, via the cyberweb project.

#


1098
1099
1100
# File 'lib/cyberweb/web_object/web_object.rb', line 1098

def opal_evaluate(i)
  Opal.compile(i)
end

#output_this_javascript(i) ⇒ Object

#

output_this_javascript

#


3486
3487
3488
# File 'lib/cyberweb/web_object/web_object.rb', line 3486

def output_this_javascript(i)
  Cyberweb.output_this_javascript(i)
end

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

#

p_default

This is similar to p(), but the implicit CSS class ‘default’ will be used.

#


2924
2925
2926
2927
2928
2929
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
2954
2955
# File 'lib/cyberweb/web_object/web_object.rb', line 2924

def p_default(
    optional_css_class = '',
    the_id             = '',
    optional_css_style = '',
    &block
  )
  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
    # ===================================================================== #
    if optional_css_class.has_key? :css_style
      optional_css_style = optional_css_class.delete(:css_style)
    end
    if optional_css_class.is_a?(Hash) and optional_css_class.empty?
      optional_css_class = ''
    end
  end
  optional_css_class = optional_css_class.to_s.dup
  optional_css_class.prepend('default ') # Make it the first argument.
  p(
    optional_css_class.strip,
    the_id,
    optional_css_style,
    &block
  )
end

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

#

p_default_english

This method is specifically to keep track of IDs that are written in the english language. At a later time in point this may become more relevant.

#


5327
5328
5329
5330
5331
5332
5333
5334
5335
5336
5337
5338
5339
# File 'lib/cyberweb/web_object/web_object.rb', line 5327

def p_default_english(
    optional_css_class = '',
    the_id             = '',
    optional_css_style = '',
    &block
  )
  if the_id.empty?
    the_id = "english"
  else
    the_id = "english_{the_id}" unless the_id.start_with?('english_')
  end
  p_default(optional_css_class, the_id, optional_css_style, &block)
end

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

#

p_default_le

This method is basically like p_default(), but it makes all output within that method make use of le() rather than e(). The idea here is that you can get padded (indented) output “for free” for a given paragraph.

Example input:

p_default_le('mart2em', id: 'the_idea_behind_the_chaos_cell') {}
#


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
6237
6238
6239
6240
# File 'lib/cyberweb/web_object/web_object.rb', line 6191

def p_default_le(
    optional_css_class = '',
    the_id             = '',
    optional_css_style = '',
    &block
  )
  # ======================================================================= #
  # === Handle Hashes
  #
  # Next handle Hashes given to this method
  # ======================================================================= #
  if optional_css_class.is_a? Hash
    # ===================================================================== #
    # === :id
    # ===================================================================== #
    if optional_css_class.has_key? :id
      the_id = optional_css_class.delete(:id)
    # ===================================================================== #
    # === :the_id
    # ===================================================================== #
    elsif optional_css_class.has_key? :the_id
      the_id = optional_css_class.delete(:the_id)
    end
    # ===================================================================== #
    # === :css_style
    # ===================================================================== #
    if optional_css_class.has_key? :css_style
      optional_css_style = optional_css_class.delete(:css_style)
    end
    if optional_css_class.is_a?(Hash) and optional_css_class.empty?
      optional_css_class = ''
    end
  end
  if the_id.is_a? Hash
    # ===================================================================== #
    # === :id
    # ===================================================================== #
    if the_id.has_key? :id
      the_id = the_id.delete(:id)
    end
  end
  optional_css_class = optional_css_class.to_s.dup
  optional_css_class.prepend('default ') # Make it the first argument always.
  p(
    optional_css_class.strip,
    the_id,
    optional_css_style,
    &block
  )
end

#param_first_key?Boolean

#

param_first_key?

#

Returns:

  • (Boolean)


7198
7199
7200
# File 'lib/cyberweb/web_object/web_object.rb', line 7198

def param_first_key?
  params?.keys.first
end

#params_as_string?Boolean

#

params_as_string?

#

Returns:

  • (Boolean)


5023
5024
5025
5026
5027
5028
5029
# File 'lib/cyberweb/web_object/web_object.rb', line 5023

def params_as_string?
  _ = Cyberweb.params?
  if _.is_a? Hash
    _ = _.keys.join
  end
  return _
end

#parse_a(i = 'FileUtils.copyDirectory(): http://commons.apache.org/proper/commons-io/apidocs/org/apache/commons/io/FileUtils.html#copyDirectory%28java.io.File,%20java.io.File%29') ⇒ Object

#

parse_a

#


7655
7656
7657
7658
7659
7660
7661
7662
7663
7664
7665
7666
7667
# File 'lib/cyberweb/web_object/web_object.rb', line 7655

def parse_a(
    i = 'FileUtils.copyDirectory(): http://commons.apache.org/proper/commons-io/apidocs/org/apache/commons/io/FileUtils.html#copyDirectory%28java.io.File,%20java.io.File%29'
  )
  if i.include? ':'
    splitted    = i.split(':')
    content     = splitted.first
    link_target = splitted.last
    a(
      link_target,
      content: content
    )
  end
end

#parse_from_this_html_file(i = '/home/x/programming/ruby/src/cyberweb/test/simple_tests/simple_html_test_page/simple_html_test_page.html', be_verbose = true) ⇒ Object Also known as: parse_from_this_html_file=, parse_html_file=

#

parse_from_this_html_file

#


1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
# File 'lib/cyberweb/web_object/web_object.rb', line 1396

def parse_from_this_html_file(
    i          = 
      '/home/x/programming/ruby/src/cyberweb/test/simple_tests/simple_html_test_page/simple_html_test_page.html',
    be_verbose = true
  )
  do_not_use_the_internal_CSS_files # The new .html file must be simple.
  if i.is_a? Array
    i = i.first
  end
  if File.exist? i
    if be_verbose
      puts 'Now parsing the file '+i+'.'
    end
    dataset = File.read(i)
    regex_for_the_title = /<title>([a-zA-Z0-9 \n]+)<\/title>/ # See: https://rubular.com/r/atTe48o6iPG1TU
    if dataset.include?('<title')
      dataset =~ regex_for_the_title
      set_title($1)
    end
    regex_for_the_body = /<body>([\s\S]+)<\/body>/ # See: https://rubular.com/r/MhMR6p3eylZVZo
    if dataset.include?('<body')
      dataset =~ regex_for_the_body
      set_body_content($1)
    end
  end
  @internal_hash[:save_into_this_html_page] = return_pwd+
                                              'new_file_'+
                                              File.basename(i).delete_suffix('.html')+
                                              '.html'
  build_up_the_html_string
end
#
#


6265
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276
6277
6278
6279
6280
6281
# File 'lib/cyberweb/web_object/web_object.rb', line 6265

def parse_html_link(
    i                  = 'https://www.youtube.com/watch?v=WPvGqX-TXP0 Java Programming, 03.05.2014',
    optional_css_class = 'marl2em'
  )
  [i].flatten.compact.each {|this_link|
    if this_link.include? ' '
      index = i.index(' ')
      first = this_link[0 .. index]
      last  = this_link[index+1 .. -1].dup
      last << ':' unless last.end_with? ':'
      s2(last,'bold')
      a(
        first, css_class: optional_css_class
      )
    end
  }
end

#path_to_data?Boolean Also known as: path_to_data_dir?

#

path_to_data?

This is similar to path?, except that it will return the path to the data/ directory. On my home system this may be “/home/x/data/”.

#

Returns:

  • (Boolean)


8646
8647
8648
# File 'lib/cyberweb/web_object/web_object.rb', line 8646

def path_to_data?
  Cyberweb.converted_path_to_data
end

#path_to_jquery_dir?Boolean

#

path_to_jquery_dir?

#

Returns:

  • (Boolean)


17
18
19
# File 'lib/cyberweb/web_object/javascript_and_jquery.rb', line 17

def path_to_jquery_dir?
  Cyberweb.path_to_jquery_dir?
end

#pfeil_rechts(use_this_css_class = 'marr4px') ⇒ Object

#

pfeil_rechts

#


8592
8593
8594
8595
8596
# File 'lib/cyberweb/web_object/web_object.rb', line 8592

def pfeil_rechts(
    use_this_css_class = 'marr4px'
  ) 
  sg(:pfeil_rechts, use_this_css_class)
end

#polaroid_card(optional_content = nil, &block) ⇒ Object

#

polaroid_card

#


1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
# File 'lib/cyberweb/web_object/web_object.rb', line 1445

def polaroid_card(
    optional_content = nil,
    &block
  )
  div(
      id: :drag_polaroid_card,
      css_class: 'polaroid_card',
      css_style: 'margin-left:80%') {
    if block_given?
      yielded = yield
      if yielded.is_a? Hash
        if yielded.has_key? :use_this_image
          optional_content = '<img src="'+yielded[:use_this_image].to_s+'">'
        end
      end
    end
    if optional_content
      p('mar0px') {
        e optional_content
      }
    end
  }
end

#pre(i = '', optional_css_class = 'FS1_5em', optional_the_id = '', optional_css_style = '', optional_commands = nil, &block) ⇒ Object Also known as: numbered_table

#

pre (pre tag)

This method will ultimately generate a <pre> tag.

The alias called “numbered_table” may be subject to change. One day it may be a new method that can then be used to number a list of entries passed as String or Array. For now, though, as of October 2022 it is just an alias.

#


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

def pre(
    i                  = '',
    optional_css_class = 'FS1_5em',
    optional_the_id    = '',
    optional_css_style = '',
    optional_commands  = nil,
    &block
  )
  if optional_commands
    case optional_commands
    # ===================================================================== #
    # === :remove_html
    # ===================================================================== #
    when :remove_html
      i = Cyberweb.remove_html(i)
    end
  end
  # ======================================================================= #
  # === Check for Hashes as second argument to this method next:
  # ======================================================================= #
  if optional_css_class.is_a?(Hash)
    # ===================================================================== #
    # Usage example:
    #
    #   display_this_file 'SLOGANS.md', css_style: 'font-size: 1.2em'
    #
    # ===================================================================== #
    # === :css_style
    # ===================================================================== #
    if optional_css_class.has_key? :css_style
      optional_css_style = optional_css_class.delete(:css_style)
    end
    if optional_css_class.is_a?(Hash) and optional_css_class.empty?
      optional_css_class = 'FS1_5em' # This is the default.
    end
  end
  # ======================================================================= #
  # === Handle blocks next
  # ======================================================================= #
  if block_given?
    yielded = yield.to_s
    if yielded and !yielded.empty?
      i = i.to_s.dup
      i << yielded
    end
  end
  append_onto_the_body_tag_nl(
    '<pre'+
    css_class_or_no_class(optional_css_class)+
    id_or_no_id(optional_the_id)+
    css_style_or_no_style(optional_css_style)+
    '>'+
    i.to_s+
    '</pre>'
  )
end

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

#

pre_htmlentities

#


2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
# File 'lib/cyberweb/web_object/web_object.rb', line 2080

def pre_htmlentities(
    text      = '',
    css_class = '',
    the_id    = '',
    css_style = ''
  )
  pre(
    text,
    css_class,
    the_id,
    css_style,
    :remove_html
  ) # :remove_html means that we strip HTML entries in the text.
end

#predefine_squares(use_these_css_rules_here = 'mars6px VAB') ⇒ Object Also known as: use_predefine_squares, do_predefine_squares

#

predefine_squares

This method will predefine some squares to use, using common CSS rules.

The rules for the constant is to be ALL UPCASED. No exception to this.

You have to call this method manually if you wish to be able to use all those various constants. Alternatively it may be called through a config variable.

#


3413
3414
3415
3416
3417
3418
3419
3420
3421
3422
3423
3424
3425
# File 'lib/cyberweb/web_object/web_object.rb', line 3413

def predefine_squares(
    use_these_css_rules_here = 'mars6px VAB'
  )
  set_web_const 'SQUARE_BLUE',          :square_blue,          use_these_css_rules_here
  set_web_const 'SQUARE_CADETBLUE',     :square_cadetblue,     use_these_css_rules_here
  set_web_const 'SQUARE_GREEN',         :square_green,         use_these_css_rules_here
  set_web_const 'SQUARE_GREY',          :square_grey,          use_these_css_rules_here
  set_web_const 'SQUARE_RED',           :square_red,           use_these_css_rules_here
  set_web_const 'SQUARE_VIOLET',        :square_violet,        use_these_css_rules_here
  set_web_const 'SQUARE_YELLOW',        :square_yellow,        use_these_css_rules_here
  set_web_const 'SQUARE_DARKGOLDENROD', :square_darkgoldenrod, use_these_css_rules_here
  set_web_const 'SQUARE_CHAOS',         :square_chaos,         use_these_css_rules_here
end
#

This method will first pass the input into BeautifulUrl, and then use the result given from BeautifulUrl as the remote URL.

The key idea here is that we can build up links towards remote URLs, all handled by the BeautifulUrl namespace.

One advantage of this approach is that we have to change a remote URL only once, if it ever changes, so we do not have to change all local links that may have outdated entries as such.

Invocation example:

pretty_link('Jules Bordet')
#


7499
7500
7501
7502
7503
7504
7505
7506
7507
7508
7509
# File 'lib/cyberweb/web_object/web_object.rb', line 7499

def pretty_link(
    i,
    optional_css_class = ''
  )
  remote_URL = beautiful_URL(i)
  return string_a(
    remote_URL,
    content: i,
    css_class: optional_css_class
  )
end

#pull_in_these_css_classes(i = 'posab') ⇒ Object

#

pull_in_these_css_classes

This method will try to look for a CSS class such as “.posab absolute”.

#


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

def pull_in_these_css_classes(
    i = 'posab'
  )
  # ======================================================================= #
  # === Handle CSS classes separated via ' ' in a String next
  # ======================================================================= #
  if i.is_a?(String) and i.include?(' ')
    i = i.split(' ') # This is for entries such as "posab white".
  end
  result = ''.dup # This is the String that will be added.
  # ======================================================================= #
  # The next variable is a helper-variable - we will gather all CSS
  # rules into that helper-variable.
  # ======================================================================= #
  complete_dataset_of_all_local_CSS_files = ''.dup
  # ======================================================================= #
  # === Iterate over all local .css files next:
  # ======================================================================= #
  ARRAY_LOCAL_CSS_FILES.each {|this_css_file|
    this_css_file = this_css_file.dup if this_css_file.frozen?
    this_css_file << '.css' unless this_css_file.end_with? '.css'
    target_file = "#{project_base_dir?}cascading_style_sheets/#{this_css_file}"
    if File.exist? target_file
      # =================================================================== #
      # Read in the local .css file next - we ensured it exists before:
      # =================================================================== #
      content_of_this_css_file = File.read(target_file, encoding: use_which_encoding?)
      complete_dataset_of_all_local_CSS_files << content_of_this_css_file # Append it here.
      complete_dataset_of_all_local_CSS_files << "\n"
    end
  }
  # ======================================================================= #
  # Alright - we pulled in all local .css files and dumped them into
  # one String, stored in the variable called
  # `complete_dataset_of_all_local_CSS_files`.
  #
  # Next we will compare our findings to the original dataset.
  # ======================================================================= #
  [i].flatten.compact.each {|entry|
    # ===================================================================== #
    # For the following regex see:
    #
    #   https://rubular.com/r/pHwaAMhcpZqbWI
    #
    # ===================================================================== #
    use_this_regex = /^(\.#{entry}\s+\{[A-Za-z0-9-:;# }]+)/
    complete_dataset_of_all_local_CSS_files =~ /#{use_this_regex}/ # Match it here.
    if $1
      result << $1.to_s.dup+"\n" # And if we found a match, append it into the main result.
    end
  }
  # ======================================================================= #
  # Finally we can put it onto the local CSS rules.
  # ======================================================================= #
  append_onto_the_main_CSS_rules(result)
end

#query_string?(i = cgi?) ) ⇒ Boolean Also known as: env?, parameters_as_string?

#

query_string?

This method will return the query-string that was passed via the URL. This refers to the part after the ‘?’.

#

Returns:

  • (Boolean)


4814
4815
4816
# File 'lib/cyberweb/web_object/web_object.rb', line 4814

def query_string?(i = cgi?)
  i.query_string
end

#rack_path?Boolean

#

rack_path?

#

Returns:

  • (Boolean)


1601
1602
1603
# File 'lib/cyberweb/web_object/web_object.rb', line 1601

def rack_path?
  Cyberweb.rack_path_info?
end

#random_colourObject

#

random_colour

This method will return a random HTML colour, such as ‘steelblue’ or ‘darkgreen’.

#


8604
8605
8606
# File 'lib/cyberweb/web_object/web_object.rb', line 8604

def random_colour
  Cyberweb.all_html_colours.sample
end

#random_linear_gradient_backgroundObject

#

random_linear_gradient_background

This method generates gradients via linear-gradient().

The first argument to linear-gradient() is the “degree”.

#


7904
7905
7906
7907
# File 'lib/cyberweb/web_object/web_object.rb', line 7904

def random_linear_gradient_background
  degree = (0 .. 180).to_a.sample.to_s+'deg' 
  return 'background: linear-gradient('+degree+', '+random_colour+', '+random_colour+', '+random_colour+');'
end

#raw_image(i = '', optional_css_class = '', optional_the_id = '', optional_css_style = '', alt_text = '', optional_width = nil, optional_height = nil) ⇒ Object

#

raw_image

The first argument to this method should be the path to the file at hand. This can also be a remote image.

Note that this method deliberately does NOT check whether the ID is unique or not. You have to solve this prior to calling this method if you wish to avoid duplicate IDs.

#


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
409
410
411
412
413
414
415
416
417
418
# File 'lib/cyberweb/web_object/web_object.rb', line 373

def raw_image(
    i                  = '',
    optional_css_class = '',
    optional_the_id    = '',
    optional_css_style = '',
    alt_text           = '',
    optional_width     = nil,
    optional_height    = nil
  )
  result = ''.dup
  # ======================================================================= #
  # === Honour the base64-encoding for all local images next:
  # ======================================================================= #
  if use_base64_encoding_for_all_local_images?
    i = i.dup if i.frozen?
    if i.start_with?('../')
      i.gsub!(
        Regexp.new('../' * i.scan(/\.\.\//).flatten.size),
        '/home/x/'
      )
    end
    if File.exist? i
      image_type_to_use = File.extname(i)
      dataset = return_image_dataset_via_base64_from_this_file(i)
      result << '<img src="data:image/'+
                 image_type_to_use.to_s.delete('.')+
                ';base64,'+dataset+'"'.dup
    else
      e 'No file exists at '+i+'.'
    end
  else # This here is the default entry point.
    result << '<img src="'+i+'"'
  end
  result << css_class_or_no_class(optional_css_class)+
            id_or_no_id(optional_the_id, i)+
            css_style_or_no_style(optional_css_style)+
            alt_text_or_no_alt_text(alt_text).dup
  if optional_width # Add the width here.
    result << ' width="'+optional_width.to_s+'"'
  end
  if optional_height # Add the height here.
    result << ' height="'+optional_height.to_s+'"'
  end
  result << '>'
  return result
end

#README(i = 'README.md') ⇒ Object

#

README

#


3167
3168
3169
3170
3171
3172
3173
3174
# File 'lib/cyberweb/web_object/web_object.rb', line 3167

def README(
    i = 'README.md'
  )
  # require 'kramdown'
  # doc = Kramdown::Document.new(File.read(i))
  # i = doc.to_html
  display_this_file(i)
end

#register_constantsObject Also known as: do_define_convenience_constants

#

register_constants (constants tag, const tag)

This is a convenience method. It will register some constants which can then be used in your web-app.

This will set constants such as Cyberweb::ALERT or Cyberweb::HANGMAN.

#


3117
3118
3119
3120
3121
3122
3123
3124
3125
3126
3127
3128
3129
3130
3131
3132
3133
3134
3135
3136
3137
3138
3139
3140
3141
3142
3143
3144
3145
3146
3147
3148
3149
3150
3151
3152
3153
3154
3155
3156
3157
3158
3159
3160
3161
3162
# File 'lib/cyberweb/web_object/web_object.rb', line 3117

def register_constants
  set_web_const 'ALERT',         :ausrufungszeichen
  set_web_const 'AUSRUFUNG',     :ausrufungszeichen
  set_web_const 'ANMERKUNG',     :ausrufungszeichen
  set_web_const 'ANM',           :ausrufungszeichen
  set_web_const 'WICHTIG',       :ausrufungszeichen
  set_web_const 'HANGMAN',       :hangman
  set_web_const 'HALLOWEEN',     :halloween
  set_web_const 'EXTERNAL',      :external
  set_web_const 'EXTERN',        :external
  set_web_const 'DONE_IMAGE',    :checkbox_on     
  set_web_const 'DONE',          :checkbox_on
  set_web_const 'DOT1',          :dot1
  set_web_const 'DOT2',          :dot2
  set_web_const 'DOT3',          :dot3
  set_web_const 'DOT4',          :dot4
  set_web_const 'DOT5',          :dot5
  set_web_const 'DOT6',          :dot6
  set_web_const 'DOT7',          :dot7
  set_web_const 'DOT8',          :dot8
  set_web_const 'DOT9',          :dot9
  set_web_const 'DOT10',         :dot10
  set_web_const 'DOT11',         :dot11
  set_web_const 'DOT12',         :dot12
  set_web_const 'LENS',          :lens
  set_web_const 'LEAF',          :leaf
  set_web_const 'LEAF2',         :leaf2
  set_web_const 'MONEY',         :money
  set_web_const 'NEW',           :new
  set_web_const 'NEWS',          :new
  set_web_const 'RUBY',          :ruby
  set_web_const 'PFEIL1',        :pfeil1
  set_web_const 'PFEIL2',        :pfeil2
  set_web_const 'PFEIL3',        :pfeil3
  set_web_const 'HTML_LINK_IMG', :pfeil3
  set_web_const 'PFEIL4',        :pfeil4
  set_web_const 'PFEIL5',        :pfeil5
  set_web_const 'PFEIL6',        :pfeil6
  set_web_const 'PFEIL7',        :pfeil7
  set_web_const 'PFEIL8',        :pfeil8
  set_web_const 'PFEIL9',        :pfeil9
  set_web_const 'PFEIL10',       :pfeil10
  set_web_const 'PFEIL11',       :pfeil11
  set_web_const 'PFEIL12',       :pfeil12
  set_web_const 'PFEIL_RECHTS',  :pfeil_rechts
end

#register_ids?Boolean Also known as: registered_ids?

#

register_ids?

#

Returns:

  • (Boolean)


3105
3106
3107
# File 'lib/cyberweb/web_object/web_object.rb', line 3105

def register_ids?
  @internal_hash[:register_ids]
end

#register_sitemap(i, modify_input = false) ⇒ Object Also known as: add_to_sitemap, sitemap

#

register_sitemap

Use only this method to register an id to a sitemap. This is done automatically when we invoke the method sitemap().

This method will delegate towards the toplevel-method, on the Cyberweb namespace.

If the second argument called ‘modify_input` is set to true, we will replace all occurrences of ’_’ with ‘ ’. The reason for this is that HTML ids should not contain ‘ ’ characters.

#


2836
2837
2838
2839
2840
2841
2842
2843
2844
2845
2846
2847
2848
2849
2850
# File 'lib/cyberweb/web_object/web_object.rb', line 2836

def register_sitemap(
    i, modify_input = false
  )
  if i.is_a? Array
    i.each {|entry|
      register_sitemap(entry, modify_input)
    }
  else
    # ===================================================================== #
    # Next simply delegate onto the toplevel method called
    # Cyberweb.register_sitemap().
    # ===================================================================== #
    Cyberweb.register_sitemap(i, modify_input)
  end
end

#register_the_constants?Boolean

#

register_the_constants?

#

Returns:

  • (Boolean)


3098
3099
3100
# File 'lib/cyberweb/web_object/web_object.rb', line 3098

def register_the_constants?
  @internal_hash[:register_the_constants]
end

#register_this_id(the_id = '') ⇒ Object Also known as: register_id

#

register_this_id

This method will register the ID that is used into the corresponding Array.

#


9461
9462
9463
9464
9465
9466
9467
9468
9469
# File 'lib/cyberweb/web_object/web_object.rb', line 9461

def register_this_id(
    the_id = ''
  )
  if the_id and the_id.to_s.start_with?('drag')
    drag_and_drop(the_id)
  end
  @internal_hash[:register_ids] << the_id
  return the_id # Always return it here.
end

#registered_sitemap?Boolean

#

registered_sitemap?

#

Returns:

  • (Boolean)


8225
8226
8227
# File 'lib/cyberweb/web_object/web_object.rb', line 8225

def registered_sitemap?
  Cyberweb.array_registered_sitemaps?
end

#relative_background_image(this_image) ⇒ Object

#

relative_background_image

We have to build the proper path, e. g.:

url(data/images/wallpapers/TheCalling_AnimeWallpaper.jpg);
#


8963
8964
8965
8966
8967
8968
8969
8970
8971
8972
8973
8974
8975
8976
8977
8978
8979
8980
8981
# File 'lib/cyberweb/web_object/web_object.rb', line 8963

def relative_background_image(this_image)
  _ = ('../' * n_steps_to_the_base_directory?) + 
      "#{name_of_img_dir?}".dup
  _ << this_image
  background_image = "background-image: url(#{_});" # The string to append.
  # ======================================================================= #
  # Next, add some default assumptions here. No repeat is ok to
  # use, centered background position - not sure.
  #   background-position: center;
  # ======================================================================= #
  result = <<-EOF

body {
#{background_image}
background-repeat: no-repeat;
}
EOF
  add_this_css_style(result)
end

#relative_path?Boolean

#

relative_path?

This method attempts to return the correct, relative path to assets.

We need to keep in mind that the .cgi file at hand may reside in another subdirectory, such as /home/x/studium/, rather than /home/x/data/.

#

Returns:

  • (Boolean)


1973
1974
1975
# File 'lib/cyberweb/web_object/web_object.rb', line 1973

def relative_path?
  @internal_hash[:relative_path]
end

#remote_img(i = 'https://mikesrpgcenter.com/krondor/maps/timirianya.html', optional_hash = {}, optional_id = nil, &block) ⇒ Object Also known as: embed_remote_image, embed_remote_img, remote_image

#

remote_img

This method can be used to “embed” a remote image in a given web-application.

Usage example:

embed_remote_image('https://i.imgur.com/jYBEnjr.png', css_class: 'bblack2 mar4px', id: 'drag_ferkellampe')
remote_img 'https://i.imgur.com/caKh9FI.png', 'mars2em bblack1', 'drag_grunge_text'
#


8107
8108
8109
8110
8111
8112
8113
8114
8115
8116
8117
8118
8119
8120
8121
8122
8123
8124
8125
8126
8127
8128
8129
8130
8131
8132
8133
8134
8135
8136
8137
8138
8139
8140
8141
8142
8143
8144
8145
8146
# File 'lib/cyberweb/web_object/web_object.rb', line 8107

def remote_img(
    i             = 'https://mikesrpgcenter.com/krondor/maps/timirianya.html',
    optional_hash = {},
    optional_id   = nil,
    &block
  )
  # ======================================================================= #
  # === Handle Strings rather than Hashes next:
  # ======================================================================= #
  if optional_hash.is_a? String
    # ===================================================================== #
    # In this case we assume the user tries to pass a CSS class into it.
    # ===================================================================== #
    optional_hash = {
      css_class: optional_hash
    }
  end
  # ======================================================================= #
  # === Handle blocks first
  # ======================================================================= #
  if block_given?
    yielded = yield
    # ===================================================================== #
    # === Handle Hashes next
    # ===================================================================== #
    if yielded.is_a? Hash
      optional_hash.merge!(yielded) # And push them onto the main Hash here.
    end
  end
  if optional_id
    optional_hash[:the_id] = optional_id
  end
  append_onto_the_body_tag_nl(
    HtmlTags.img(i) { optional_hash }
  )
  if (optional_id and optional_id.to_s.start_with?('drag_')) or 
      drag_all_images?
    enable_drag_for(optional_id)
  end
end

#remove_newlines?Boolean

#

remove_newlines?

#

Returns:

  • (Boolean)


7912
7913
7914
# File 'lib/cyberweb/web_object/web_object.rb', line 7912

def remove_newlines?
  @internal_hash[:remove_newlines]
end

#report_the_jquery_version_in_useObject

#

report_the_jquery_version_in_use

#


5242
5243
5244
5245
# File 'lib/cyberweb/web_object/web_object.rb', line 5242

def report_the_jquery_version_in_use
  e 'The jquery version in use is '\
    '<b>'+this_jquery_version.to_s+'</b>.'
end

#report_where_the_server_base_directory_isObject

#

report_where_the_server_base_directory_is

#


3853
3854
3855
3856
3857
3858
3859
# File 'lib/cyberweb/web_object/web_object.rb', line 3853

def report_where_the_server_base_directory_is
  append_onto_the_body_tag_nl(
    'The server base directory is at <b>'+
    server_base_directory?+
    '</b>.<br>'
  )
end

#resetObject

#

reset (reset tag)

#


152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
# File 'lib/cyberweb/web_object/web_object.rb', line 152

def reset
  super()
  infer_the_namespace
  # ======================================================================= #
  # === The configuration dataset
  #
  # Load up the main configuration next. This should come before
  # we call use_commandline_mode() and before we invoke
  # reset_the_internal_state().
  # ======================================================================= #
  load_yaml_configuration
  reset_the_internal_state # This should come before we load the yaml-configuration.
  do_use_utf_charset # This is the default.
  do_use_local_CSS_files
  add_the_content_from_the_default_js_files
  do_use_jquery if use_jquery?
end

#reset_the_internal_stateObject

#

reset_the_internal_state (internal reset tag, internal tag)

Note that HtmlTemplate already has a @internal_hash that this class will ultimately inherit from. The primary use case for @internal_hash is to describe the current state the given web-object at hand is in.

#


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
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
# File 'lib/cyberweb/web_object/web_object.rb', line 931

def reset_the_internal_state
  # ======================================================================= #
  # === :debug
  # ======================================================================= #
  @internal_hash[:debug] = Cyberweb.debug? # ← Must come before load_yaml_configuration().
  # ======================================================================= #
  # === :global_CSS_rules_for_all_images
  #
  # This variable must be nil initially.
  #
  # If it is not nil then all images defined via the WebObject will
  # have the same CSS rules. That way the user can specify a global
  # CSS rule all images adhere to, enforcing a uniform style.
  # ======================================================================= #
  @internal_hash[:global_CSS_rules_for_all_images] = nil
  # ======================================================================= #
  # === :use_base64_encoding_for_all_images
  #
  # If the following variable is set to true, then, for all local
  # images, we will use base64-encoding. This is useful for
  # sinatra and rack-based applications; for normal .cgi files
  # this is not necessary.
  # ======================================================================= #
  @internal_hash[:use_base64_encoding_for_all_local_images] = false
  # ======================================================================= #
  # === :save_into_this_html_page
  # ======================================================================= #
  @internal_hash[:save_into_this_html_page] = '/Depot/j/foobar.html'
  # ======================================================================= #
  # === :register_ids
  # ======================================================================= #
  @internal_hash[:register_ids] = []
  # ======================================================================= #
  # === :register_the_constants
  #
  # If the following variable is set to true then the method
  # .register_constants() will be invoked, which in turn will
  # register various constants.
  # ======================================================================= #
  @internal_hash[:register_the_constants] = true
  # ======================================================================= #
  # === :show_source
  #
  # If true then we will show the source of a page.
  # ======================================================================= #
  @internal_hash[:show_source] = false
  # ======================================================================= #
  # === :database
  #
  # If we may wish to use a database. This must initially be nil,
  # to designate that we have no interest in using a database.
  # ======================================================================= #
  @internal_hash[:database] = nil
  # ======================================================================= #
  # === :remove_newlines
  #
  # By default, we will keep newlines in the main String, so this
  # variable defaults to false. If set to true, however had, then
  # the result-string will lose all newlines.
  # ======================================================================= #
  @internal_hash[:remove_newlines] = false
  # ======================================================================= #
  # === :enable_title_for_reading_files
  #
  # Empty Array by default.
  # ======================================================================= #
  @internal_hash[:enable_title_for_reading_files] = []
  # ======================================================================= #
  # === :do_not_display_empty_files
  # ======================================================================= #
  @internal_hash[:do_not_display_empty_files] = false
  # ======================================================================= #
  # === :encoding_to_use
  # ======================================================================= #
  @internal_hash[:encoding_to_use] = :default
  # ======================================================================= #
  # === :mail
  #
  # This variable keeps track as to whether we wish to use email or
  # not.
  # ======================================================================= #
  @internal_hash[:mail] = nil
  # ======================================================================= #
  # === :css_classes_to_be_used_by_default_for_abr_links
  # ======================================================================= #
  @internal_hash[:css_classes_to_be_used_by_default_for_abr_links] = nil
  # ======================================================================= #
  # === :clickable_image
  #
  # This variable keeps track as to which clickable image is to be used.
  #
  # In this context, a "clickable image" means that an image will be
  # shown that the user can click onto.
  # ======================================================================= #
  @internal_hash[:clickable_image] = :dot109
  use_utf_encoding # Use ISO or UTF encoding. Current default is UTF.
  # add_http_response_header
  # ======================================================================= #
  # === :listing_counter
  #
  # Keep track of the listing counter. This will have an initial value
  # of 0.
  # ======================================================================= #
  reset_the_listing_counter
  use_commandline_mode
  # ======================================================================= #
  # === set_proper_base_directory()
  #
  # Now we have finished the initial loadup and description of the
  # @internal_hash. We can now continue to describe the remaining web
  # object. We do this by calling the proper base directory next.
  #
  # This should come after @internal_hash has already been populated
  # with the correct dataset.
  # ======================================================================= #
  set_proper_base_directory # Initial setup.
  # ======================================================================= #
  # Next we must determine the relative path. This should come very
  # late in this reset-method.
  # ======================================================================= #
  determine_the_relative_path
  # ======================================================================= #
  # Some entries must come after the configuration has been loaded.
  # One such method-call is the call to no-jquery. However had, since
  # as of May 2021, we will simply let the configure file, the yaml
  # file, determine whether jquery is used or whether it is not used.
  # ======================================================================= #
  # no_jquery # No jquery by default.
  # ======================================================================= #
  # But we overrule it if the user decided this in the configuration file.
  # ======================================================================= #
  if enable_jquery_for_every_page?
    do_use_jquery
  end
end

#reset_the_listing_counterObject Also known as: reset_counter, reset_the_counter, reset_the_main_counter

#

reset_the_listing_counter

#


1675
1676
1677
# File 'lib/cyberweb/web_object/web_object.rb', line 1675

def reset_the_listing_counter
  @internal_hash[:listing_counter] = 0
end

#return_absolute_image(remote_url, css_class = '', the_id = '', css_style = '') ⇒ Object

#

return_absolute_image

#


7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
# File 'lib/cyberweb/web_object/web_object.rb', line 7322

def return_absolute_image(
    remote_url,
    css_class = '',
    the_id    = '',
    css_style = ''
  )
  register_this_id(the_id)
  return string_absolute_img(
             remote_url,
             css_class,
             the_id,
             css_style
           )
end

#return_base64_image(i, image_type_to_use = :infer, optional_css_class = '', optional_the_id = '', optional_css_style = '') ⇒ Object

#

return_base64_image

The first argument to this method should be the binary data representing the image at hand.

#


3056
3057
3058
3059
3060
3061
3062
3063
3064
3065
3066
3067
3068
3069
3070
3071
3072
3073
3074
3075
3076
3077
3078
3079
3080
3081
3082
3083
3084
3085
3086
3087
3088
3089
3090
3091
3092
3093
# File 'lib/cyberweb/web_object/web_object.rb', line 3056

def return_base64_image(
    i,
    image_type_to_use  = :infer,
    optional_css_class = '',
    optional_the_id    = '',
    optional_css_style = ''
  )
  case image_type_to_use
  # ======================================================================= #
  # === :infer
  # ======================================================================= #
  when :infer
    image_type_to_use = File.extname(i)
    if image_type_to_use.empty?
      image_type_to_use = 'png' # Rescue in this case. We assume it'll be a .png file.
    end
  end
  # ======================================================================= #
  # We need to build up a String such as:
  #
  #   <img src="data:image/jpeg;base64,..." />
  #
  # ======================================================================= #
  _ = '<img src="data:image/'+
      image_type_to_use.to_s.delete('.')+
      ';base64,'+i+'"'.dup
  if optional_css_class
    _ << css_class_or_no_class(optional_css_class)
  end
  if optional_the_id
    _ << id_or_no_id(optional_the_id)
  end
  if optional_css_style
    _ << css_style_or_no_style(optional_css_style)
  end
  _ << '>'
  return _
end

#return_css_rules_for_the_coffee_animationObject

#

return_css_rules_for_the_coffee_animation

#


7700
7701
7702
# File 'lib/cyberweb/web_object/web_object.rb', line 7700

def return_css_rules_for_the_coffee_animation
  return Cyberweb.css_rules_for_the_coffee_animation
end

#return_css_style_for_the_triangle_isosceles_bubble(additional_css_rules = '') ⇒ Object

#

return_css_style_for_the_triangle_isosceles_bubble

This method will return two CSS classes, which can be used if you want to make use of CSS bubbles. Currently only the downwards-facing triangle is available.

The original source has been adapted from here:

http://nicolasgallagher.com/pure-css-speech-bubbles/demo/
#


3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
3965
3966
3967
3968
3969
3970
3971
3972
3973
3974
3975
3976
3977
3978
3979
3980
# File 'lib/cyberweb/web_object/web_object.rb', line 3949

def return_css_style_for_the_triangle_isosceles_bubble(
    additional_css_rules = ''
  )
  if additional_css_rules and additional_css_rules.empty?
    additional_css_rules = 'margin: 1em 0 3em;'
  end
  return '.triangle_isosceles_bubble {
position:relative;
padding:15px;
'+additional_css_rules.to_s+';
width:500px;
color:#000;
background:#f3961c; /* default background for browsers without gradient support */
/* css3 */
background:linear-gradient(#f9d835, #f3961c);
border-radius:10px;
border: 1px solid black;
}

/* This class creates the triangle that faces downwards */
.triangle_isosceles_bubble:after {
content:"";
position:absolute;
bottom:-13px; /* value = - border-top-width - border-bottom-width */
left:30px;    /* controls the horizontal position */
border-width: 15px 15px 0; /* vary these values to change the angle of the vertex */
border-style: solid;
border-color: #f3961c transparent;
display:block;
width:0;
}'
end

#return_dataset_without_any_comments(i) ⇒ Object

#

return_dataset_without_any_comments

Simply delegate towards Cyberweb.return_dataset_without_any_comments() here.

#


5674
5675
5676
# File 'lib/cyberweb/web_object/web_object.rb', line 5674

def return_dataset_without_any_comments(i)
  Cyberweb.return_dataset_without_any_comments(i)
end

#return_default_css_files(array_local_css_files = ARRAY_LOCAL_CSS_FILES) ⇒ Object

#

return_default_css_files

#


2485
2486
2487
2488
2489
2490
2491
2492
2493
2494
2495
2496
2497
# File 'lib/cyberweb/web_object/web_object.rb', line 2485

def return_default_css_files(
    array_local_css_files = ARRAY_LOCAL_CSS_FILES
  )
  _ = ''.dup
  if use_the_internal_CSS_files?
    array_local_css_files.each {|this_css_file|
      _ << '<link rel="stylesheet" type="text/css" '\
           'href="'+relative_path?+'cascading_style_sheet/'+
           this_css_file+'" />'+"\n"
    }
  end
  return _
end

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

#

return_details

This will return a <details> tag.

#


4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
# File 'lib/cyberweb/web_object/web_object.rb', line 4029

def return_details(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = '',
    &block
  )
  result = HtmlTags.details(
    i,
    optional_css_class,
    optional_the_id,
    optional_css_style,
    &block
  )
  return result
end

#return_doc_write(i = '') ⇒ Object

#

return_doc_write

This captures the javascript command to doc-write.

#


9086
9087
9088
# File 'lib/cyberweb/web_object/web_object.rb', line 9086

def return_doc_write(i = '')
  Cyberweb.doc_write(i)
end

#return_dot_dot_slash_to_the_data_directory(n_times = :infer_automatically) ⇒ Object Also known as: dot_dot_slash_to_the_data_directory, dot_dot_slash_to_data_directory, dot_dot_slash_to_data, clever_to_data

#

return_dot_dot_slash_to_the_data_directory

This method will return the correct amount of “../” towards our global images-directory.

This is, however had, at the least for the time being, only useful on my home setup.

#


4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
# File 'lib/cyberweb/web_object/web_object.rb', line 4133

def return_dot_dot_slash_to_the_data_directory(
    n_times = :infer_automatically
  )
  case n_times
  # ======================================================================= #
  # === :infer_automatically
  # ======================================================================= #
  when :infer_automatically
    pwd = return_pwd
    n_times = pwd.sub(%r(/home/x/data/),'').count('/')
  end
  _ = '../' * n_times.to_i
  return _
end

#return_fotos_in_total(target = Cyberweb.home_x_dir?+'data/images/fotos/**/**') ⇒ Object

#

return_fotos_in_total

#


706
707
708
709
710
711
712
713
714
715
# File 'lib/cyberweb/web_object/web_object.rb', line 706

def return_fotos_in_total(
    target = Cyberweb.home_x_dir?+'data/images/fotos/**/**'
  )
  begin
    require 'image_paradise/toplevel_methods/is_an_image_file.rb'
  rescue LoadError; end
  Dir[target].select {|entry|
    ImageParadise.is_an_image?(entry)
  }
end

#return_google_search_fieldObject

#

return_google_search_field

#


5497
5498
5499
5500
5501
5502
5503
5504
5505
5506
5507
5508
5509
5510
5511
# File 'lib/cyberweb/web_object/web_object.rb', line 5497

def return_google_search_field
  div('s5px padtb3px wid44 martb2px posab bordorange1px',
      'PC_CENTER',
      'left: 16em;') {
    ee '<form name="dict" method="GET" action="https://www.google.com/search" class="spads5px">
    <p class="mar0">
    <input type="text" name="q" value="" size="20" onFocus="(this.select())" class="LBlue BG_Black1 borddorange1px" accesskey="e"/>
    <input type="image"  name="btnG" src="../IMG/STD/GOOGLE.png" alt="Google" accesskey="R" class="bordblack1px VAM"/>
    <input type="hidden" name="ie" value="UTF-8"/>
    <input type="hidden" name="oe" value="UTF-8"/>
    <input type="hidden" name="hl" value="de"/>
    </p>
    </form>'
  }
end

#return_head_start_tagObject

#

return_head_start_tag

#


7719
7720
7721
# File 'lib/cyberweb/web_object/web_object.rb', line 7719

def return_head_start_tag
  '<head>'
end

#return_image_dataset_via_base64_from_this_file(this_file) ⇒ Object

#

return_image_dataset_via_base64_from_this_file

This method will return the dataset from a locally existing file containing an image - typically a .jpg or a .png file.

The image must exist - this method will not check whether it does, so it would fail if the image does not exist.

The method will automatically require base64 if the constant Base64 is not defined/known.

#


8063
8064
8065
8066
8067
8068
8069
8070
8071
# File 'lib/cyberweb/web_object/web_object.rb', line 8063

def return_image_dataset_via_base64_from_this_file(
    this_file
  )
  require 'base64' unless Object.const_defined?(:Base64)
  image_dataset = File.open(this_file, 'rb') { |this_image_file|
    Base64.strict_encode64(this_image_file.read)
  }
  return image_dataset
end

#return_jquery_string(jquery_ui_version = Cyberweb.jquery_ui_version?) ⇒ Object Also known as: build_jquery_string

#

return_jquery_string

Since as of 21.09.2014 this method will return two .js files here.

The version of jquery-ui is currently hardcoded.

The latest version of jquery-ui can be viewed here:

https://code.jquery.com/ui/
#


9352
9353
9354
9355
9356
# File 'lib/cyberweb/web_object/web_object.rb', line 9352

def return_jquery_string(
    jquery_ui_version = Cyberweb.jquery_ui_version?
  )
  return Cyberweb.return_jquery_string(jquery_ui_version)
end

#return_meta_collection(encoding_to_use = encoding_to_use?, , meta_collection = meta_collection? ) ⇒ Object

#

return_meta_collection

The meta-collection will be returned by this method.

#


8662
8663
8664
8665
8666
8667
8668
8669
# File 'lib/cyberweb/web_object/web_object.rb', line 8662

def return_meta_collection(
    encoding_to_use = encoding_to_use?,
    meta_collection = meta_collection?
  )
  result = Cyberweb.return_meta_collection(encoding_to_use).dup+"\n"
  result << meta_collection.to_s
  return result
end

#return_n_fotos_in(this_directory = :zwetschki) ⇒ Object

#

return_n_fotos_in

Wrapper over ImageParadise.

#


9025
9026
9027
9028
9029
9030
# File 'lib/cyberweb/web_object/web_object.rb', line 9025

def return_n_fotos_in(
    this_directory = :zwetschki
  )
  require 'image_paradise/toplevel_methods/roebe.rb'
  ImageParadise.return_n_fotos_in(this_directory)  
end

#return_n_fotos_in_total(target = Cyberweb.home_x_dir?+'data/images/fotos/**/**') ⇒ Object

#

return_n_fotos_in_total

This method depends on the external method ImageParadise.is_an_image?().

#


697
698
699
700
701
# File 'lib/cyberweb/web_object/web_object.rb', line 697

def return_n_fotos_in_total(
    target = Cyberweb.home_x_dir?+'data/images/fotos/**/**'
  )
  return_fotos_in_total(target).size
end

#return_name_of_the_images_directoryObject

#

return_name_of_the_images_directory

This method must always return the name of the default images directory, without any trailing ‘/’.

#


1624
1625
1626
1627
1628
# File 'lib/cyberweb/web_object/web_object.rb', line 1624

def return_name_of_the_images_directory
  File.basename(
    use_this_relative_directory_for_custom_images?
  )
end

#return_only_duplicates(array) ⇒ Object

#

return_only_duplicates

This method will return only duplicates. The input should be an array.

#


1386
1387
1388
1389
1390
1391
# File 'lib/cyberweb/web_object/web_object.rb', line 1386

def return_only_duplicates(array)
  duplicates = []
  array.each {|member| duplicates << member if array.count(member) > 1}
  duplicates.reject! {|entry| entry.empty? }
  duplicates.uniq
end

#return_path_to_the_images_directory(path_to_use = relative_path? ) ⇒ Object Also known as: path_to_the_images_directory?

#

return_path_to_the_images_directory

#


6887
6888
6889
6890
6891
# File 'lib/cyberweb/web_object/web_object.rb', line 6887

def return_path_to_the_images_directory(
    path_to_use = relative_path?
  )
  return "#{path_to_use}#{use_this_relative_directory_for_custom_images?}"
end

#return_progress(n_percent, &block) ⇒ Object

#

return_progress

#


3334
3335
3336
3337
3338
3339
# File 'lib/cyberweb/web_object/web_object.rb', line 3334

def return_progress(
    n_percent,
    &block
  )
  return Cyberweb::Objectified::HtmlTags::Progress.new(n_percent, &block)
end

#return_screen_resolution_from_the_file_screen_resolution_htmlObject

#

return_screen_resolution_from_the_file_screen_resolution_html

This method unfortunately does not really work so far.

#


6913
6914
6915
6916
6917
6918
6919
6920
6921
6922
6923
# File 'lib/cyberweb/web_object/web_object.rb', line 6913

def return_screen_resolution_from_the_file_screen_resolution_html
  # ======================================================================= #
  # See: https://rubular.com/r/zVSPI4aQ8dirbp
  # ======================================================================= #
  regex_to_use = /(Your screen resolution is: )(\d{2,4})x(\d{2,4})/
  require 'open-uri'
  _ = '/home/x/programming/ruby/src/cyberweb/examples/javascript_and_jquery/screen_resolution/screen_resolution.html'
  dataset = URI.open(_).read.to_s
  dataset =~ regex_to_use
  return [$2.to_s.dup, $3.to_s.dup]
end

#return_the_content_of_this_default_javascript_file(i) ⇒ Object

#

return_the_content_of_this_default_javascript_file

#


9236
9237
9238
9239
9240
9241
9242
9243
# File 'lib/cyberweb/web_object/web_object.rb', line 9236

def return_the_content_of_this_default_javascript_file(i)
  target_file = return_this_default_javascript_file(i)
  if File.exist? target_file
    return File.read(target_file)
  else
    return 'Could not find path: '+target_file.to_s
  end
end

#return_the_name(i = '') ⇒ Object

#

return_the_name

#


8636
8637
8638
# File 'lib/cyberweb/web_object/web_object.rb', line 8636

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

#return_the_registered_base64_imagesObject

#

return_the_registered_base64_images

#


8091
8092
8093
# File 'lib/cyberweb/web_object/web_object.rb', line 8091

def return_the_registered_base64_images
  Cyberweb.base64_images
end

#return_this_base64_image(i, optional_css_class = '', optional_css_id = '') ⇒ Object

#

return_this_base64_image

#


8076
8077
8078
8079
8080
8081
8082
8083
8084
8085
8086
# File 'lib/cyberweb/web_object/web_object.rb', line 8076

def return_this_base64_image(
    i,
    optional_css_class = '',
    optional_css_id    = ''
  )
  return Cyberweb.return_this_base64_image(
    i,
    optional_css_class,
    optional_css_id
  )
end

#return_this_file_without_comments(i) ⇒ Object

#

return_this_file_without_comments

#


1930
1931
1932
1933
1934
1935
1936
1937
1938
# File 'lib/cyberweb/web_object/web_object.rb', line 1930

def return_this_file_without_comments(i)
  if File.exist? i
    dataset = File.read(i)
    dataset = ensure_main_encoding(dataset)
    return return_dataset_without_any_comments(i)
  else
    nil
  end
end

#return_wikipedia_search_fieldObject

#

return_wikipedia_search_field

#


4176
4177
4178
4179
4180
4181
4182
4183
4184
4185
4186
# File 'lib/cyberweb/web_object/web_object.rb', line 4176

def return_wikipedia_search_field
  append_onto_the_body_tag_nl(
    '<form name="searchform" action="https://en.wikipedia.org/wiki/Special:Search" id="searchform" class="disin pads5px">
 <p class="">
<input type="text" id="searchinput" name="search" class="LBlue BG_Black1 borddorange1px" accesskey=""/>
<input type="submit" value="Go" name="go" class="LBlue BG_Black1 borddorange1px" accesskey=""/>
<input type="submit" value="Search" name="fulltext" class="LBlue BG_Black1 borddorange1px" accesskey=""/>
 </p>
</form>'
  )
end

#return_youtube_video(src = 'gexazLr6pSY', width = '640', height = '385') ⇒ Object

#

return_youtube_video

#


5978
5979
5980
5981
5982
5983
5984
5985
5986
5987
5988
# File 'lib/cyberweb/web_object/web_object.rb', line 5978

def return_youtube_video(
    src    = 'gexazLr6pSY',
    width  = '640',
    height = '385'
  )
  return Cyberweb.embed_youtube_video(
      src,
      width,
      height
    )
end

#roebe_hardware(optional_css_class = 'mars1em steelblue BOLD') ⇒ Object

#

roebe_hardware

#


8419
8420
8421
8422
8423
8424
# File 'lib/cyberweb/web_object/web_object.rb', line 8419

def roebe_hardware(
    optional_css_class = 'mars1em steelblue BOLD'
  )
  abr_self :local_hardware,
           css_class: optional_css_class
end
#

This is the method that, since as of June 2021, should be used for any “roebe-internal” link. This refers primarily to my home system, which is now spread out into different projects.

Note that since as of June 2021, all roebe-internal links MUST start with a :local_ prefix. This may change at a later time, but for now we will keep this very strict.

#


2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366
2367
2368
2369
2370
2371
2372
2373
2374
2375
# File 'lib/cyberweb/web_object/web_object.rb', line 2356

def roebe_internal_link(
    i, hash
  )
  if i.is_a? Symbol
    if i.start_with? 'local'
      i = BeautifulUrl.local_link(i)
      # =================================================================== #
      # For sinatra, we will simplify this a bit. This is fairly hackish
      # but it should suffice for now.
      # =================================================================== #
      if uses_sinatra?
        i = i.to_s
        i = File.basename(
              i.delete_suffix(File.extname(i))
            )
      end
    end
  end
  abr(i, hash)
end

#runObject

#

run (run tag)

#


9599
9600
9601
9602
9603
9604
9605
9606
9607
9608
9609
9610
9611
9612
9613
9614
9615
9616
9617
9618
9619
9620
9621
9622
9623
# File 'lib/cyberweb/web_object/web_object.rb', line 9599

def run
  try_to_create_the_log_directory_unless_it_already_exists
  try_to_populate_the_log_directory_with_javascript_files
  # add_html_and_head_start_tag # ← This will add the <html> and <head> tag.
  # ======================================================================= #
  # (1) Register all constants.
  # ======================================================================= #
  register_constants if register_the_constants?
  # ======================================================================= #
  # (2) This will load require-files that the user may want to
  #     load up optionally, such as prawn.
  # ======================================================================= #
  consider_loading_addons_based_on_the_config_file
  # ======================================================================= #
  # (3) check whether we have to show the source code. This has to be
  #     handled with care, as a user may not always want to show the
  #     source code. Thus, we require a config variable for this to
  #     work.
  # ======================================================================= #
  check_whether_to_show_the_source_code
  # ======================================================================= #
  # (4) check on params given through the webpage in question.
  # ======================================================================= #
  check_on_params
end

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

#

s2_quote

#


1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
# File 'lib/cyberweb/web_object/web_object.rb', line 1332

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

#sanitize_javascript(i) ⇒ Object

#

sanitize_javascript

#


5235
5236
5237
# File 'lib/cyberweb/web_object/web_object.rb', line 5235

def sanitize_javascript(i)
  Cyberweb.sanitize_javascript(i)
end

#save(what = html_string?, , use_this_as_filename = title?.to_s, into = :default, be_verbose = true) ⇒ Object Also known as: do_save

#

save (save tag)

This method will store the “HTML” stored inside the main string at the variable :html_string into a local file.

The first argument denotes the name of the file at hand, stored as a .html file always.

#


8325
8326
8327
8328
8329
8330
8331
8332
8333
8334
8335
8336
8337
8338
8339
8340
8341
8342
8343
8344
8345
8346
8347
8348
8349
8350
8351
8352
8353
8354
8355
8356
8357
8358
8359
8360
# File 'lib/cyberweb/web_object/web_object.rb', line 8325

def save(
    what                 = html_string?,
    use_this_as_filename = title?.to_s,
    into                 = :default,
    be_verbose           = true
  )
  log_dir = log_dir?
  case use_this_as_filename
  # ======================================================================= #
  # === :default
  # ======================================================================= #
  when :default
    use_this_as_filename = title?.to_s.tr(' ','_')
  end
  case into
  # ======================================================================= #
  # === :save_into_this_html_page
  # ======================================================================= #
  when :save_into_this_html_page
    into = save_into_this_html_page?
  # ======================================================================= #
  # === :default
  #
  # Build the filename here.
  # ======================================================================= #
  when :default
    into = log_dir+
           use_this_as_filename.to_s+'.html'
  end
  mkdir(log_dir) unless File.directory? log_dir
  message = "Storing into the file #{into}."
  puts message if be_verbose
  e message
  write_what_into(what, into)
  return into
end

#save_as_webobject(into = @internal_hash[:save_into_this_html_page]. delete_suffix('.html')+ '.cgi') ⇒ Object

#

save_as_webobject

This method will save as a WebObject variant, as a .cgi file.

#


2197
2198
2199
2200
2201
2202
2203
2204
2205
2206
2207
2208
2209
2210
2211
2212
2213
2214
2215
2216
2217
2218
2219
2220
2221
2222
2223
2224
# File 'lib/cyberweb/web_object/web_object.rb', line 2197

def save_as_webobject(
    into = @internal_hash[:save_into_this_html_page].
           delete_suffix('.html')+
           '.cgi'
  )
  puts 'Storing into `'+into+'`.'
  what = ''.dup # string?
  what.prepend(ruby_header?+"\n")
  append_this = <<-EOF
# =========================================================================== #
#
# =========================================================================== #
require 'cyberweb/autoinclude'

english('#{use_this_title?}') {
created_on '#{dd_mm_yyyy}' # Wednesday.
default_template
body_css_class :default
body_css_style ''
default_font_size

doc_preferred_width {
ee '#{body_string?.tr("'","\'")}'
}}
EOF
  what << append_this
  SaveFile.write_what_into(what, into)
end

#save_into_the_default_html_page(into = ) ⇒ Object

#

save_into_the_default_html_page

#


2724
2725
2726
2727
2728
2729
2730
2731
2732
# File 'lib/cyberweb/web_object/web_object.rb', line 2724

def save_into_the_default_html_page(
    into = @internal_hash[:save_into_this_html_page]
  )
  puts 'Storing into `'+into+'`.'
  append_body_string
  append_cbody_and_chtml_tags
  what = string?
  SaveFile.write_what_into(what, into)
end

#save_into_this_html_page?Boolean

#

save_into_this_html_page?

#

Returns:

  • (Boolean)


2772
2773
2774
# File 'lib/cyberweb/web_object/web_object.rb', line 2772

def save_into_this_html_page?
  @internal_hash[:save_into_this_html_page]
end
#

This method will add some of my default hyperlinks for local files, in regards to science-related links/content.

The first argument to this method can be additional entries that the user may want to display.

Different usage examples follow next:

science_hyperlinks
science_hyperlinks { :use_unicode_right_arrows }
science_links {{ use_this_image: LINK_IMAGE }}
#


7557
7558
7559
7560
7561
7562
7563
7564
7565
7566
7567
7568
7569
7570
7571
7572
7573
7574
7575
7576
7577
7578
7579
7580
7581
7582
7583
7584
7585
7586
7587
7588
7589
7590
7591
7592
7593
7594
7595
7596
7597
7598
7599
7600
7601
7602
7603
7604
7605
7606
7607
7608
7609
7610
7611
7612
7613
7614
# File 'lib/cyberweb/web_object/web_object.rb', line 7557

def science_hyperlinks(
    additional_entries              = nil,
    use_only_the_additional_entries = false,
    &block
  )
  array_science_entries = %w(
    local_cellbiology
    local_biochemistry
    local_chemistry
    local_genetics
    local_gene_expression
    local_microbiology
    local_biotechnology
    local_evolution
  )
  if use_only_the_additional_entries
    array_science_entries.clear
  end
  if additional_entries
    array_science_entries << [additional_entries]
    array_science_entries.flatten!
    array_science_entries.compact! 
  end
  yielded = nil
  yielded = yield if block_given?
  array_science_entries.each {|this_local_link|
    this_local_link = BeautifulUrl.local_menu(this_local_link)
    short_name = File.basename(this_local_link.to_s).delete_suffix('.cgi').dup.
                 tr('_',' ').
                 sub(/local/,'')
    if yielded.is_a? Hash
      # =================================================================== #
      # === :use_this_image
      # =================================================================== #
      if yielded.has_key?(:use_this_image)
        use_this_image = yielded[:use_this_image]
        short_name = "#{use_this_image}#{short_name.strip}"
      end
    else
      case yielded
      # =================================================================== #
      # === pretty_image
      # =================================================================== #
      when :pretty_image
        short_name.prepend(dot109?)
      # =================================================================== #
      # === :use_unicode_right_arrows
      # =================================================================== #
      when :use_unicode_right_arrows
        short_name.prepend('')
      end
    end
    abr_self(
      this_local_link,
      content: short_name
    )
  }
end
#
#


4012
4013
4014
4015
4016
4017
4018
4019
4020
4021
4022
# File 'lib/cyberweb/web_object/web_object.rb', line 4012

def science_links_to(
    i = [
      :chemistry,
      :organic_chemistry
    ]
  )
  science_hyperlinks(
    i,
    true
  ) { :use_unicode_right_arrows }
end

#script_type_ruby(i) ⇒ Object

#

script_type_ruby

#


188
189
190
191
192
193
194
# File 'lib/cyberweb/web_object/web_object.rb', line 188

def script_type_ruby(i)
  append_onto_the_body_tag_nl(
    '<script type="text/ruby">'+"\n"+
    i+
    '</script>'
  ) 
end

#scrolling(enable_or_disable = '+') ⇒ Object

#

scrolling

#


3924
3925
3926
# File 'lib/cyberweb/web_object/web_object.rb', line 3924

def scrolling(enable_or_disable = '+')
  enable_scrolling if enable_or_disable == '+'
end

#sdimg(url = '', css_class = :empty_string_or_global_css_rules_for_images, the_id = '', css_style = '', alt_text = '', &block) ⇒ Object

#

sdimg

This will return the string representation for a draggable image (as a string).

#


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

def sdimg(
    url       = '',
    css_class = :empty_string_or_global_css_rules_for_images, 
    the_id    = '',
    css_style = '',
    alt_text  = '',
    &block
  )
  if the_id and the_id.empty?
    the_id = (
              'drag_'+
               File.basename(url.to_s).
               downcase.
               delete_suffix(
                 File.extname(url.to_s)
               )
             ).tr('.','_')
  end
  if the_id and !the_id.empty? and !the_id.start_with?('drag_')
    the_id = the_id.dup
    the_id.prepend('drag_')
  end
  return simg(
    url,
    css_class,
    the_id,
    css_style,
    alt_text
  )
end

#select(css_class = '', the_id = '', css_style = '', javascript = '') ⇒ Object Also known as: selection

#

select (selection tag)

This method makes a <select> tag.

In raw HTML, this may look like so:

<select>
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="opel">Opel</option>
  <option value="audi">Audi</option>
</select>

It is recommended to use a name=“” label for the <select> tag, such as in:

For documentation, see this link:

https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_select
#


6653
6654
6655
6656
6657
6658
6659
6660
6661
6662
6663
6664
6665
6666
6667
6668
6669
6670
6671
6672
6673
6674
6675
6676
6677
6678
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
# File 'lib/cyberweb/web_object/web_object.rb', line 6653

def select(
    css_class  = '',
    the_id     = '',
    css_style  = '',
    javascript = ''
  )
  add_newline
  the_tag = string_tag(
    :select,
    css_class,
    the_id,
    css_style,
    javascript
  )
  add_newline
  string_that_is_to_be_displayed = ''.dup
  # ======================================================================= #
  # === Handle blocks next
  # ======================================================================= #
  if block_given?
    yielded = yield
    # ===================================================================== #
    # === And now, we will handle Hashes:
    # ===================================================================== #
    if yielded.is_a? Hash
      # =================================================================== #
      # === :dataset_to_use
      # =================================================================== #
      if yielded.has_key? :dataset_to_use
        yielded[:dataset_to_use].each {|content|
          # =============================================================== #
          # Append this onto the content-string next:
          # =============================================================== #
          string_that_is_to_be_displayed <<
            "<option value=\"#{content.downcase}\">#{content}</option>\n"
        }
      end
      # =================================================================== #
      # === :css_class
      # =================================================================== #
      if yielded.has_key? :css_class
        the_tag[-2,0] = ' class="'+yielded.delete(:css_class)+'"'
      end
      # =================================================================== #
      # === :name
      # =================================================================== #
      if yielded.has_key? :name
        the_tag[-2,0] = ' name="'+yielded.delete(:name)+'"'
      end
    end
  end
  # ======================================================================= #
  # Next display our <select> tag:
  # ======================================================================= #
  append_onto_the_body_tag_nl the_tag
  append_onto_the_body_tag_nl string_that_is_to_be_displayed
  append_onto_the_body_tag_nl sclose(:select)
end

#self_abr(remote_url, optional_hash = {}) ⇒ Object Also known as: abr_self, selfy

#

self_abr

This method is similar to abr(), but it will automatically use content: :self as-is.

Invocation example:

selfy 'https://forums.beamdog.com/discussion/87645/mod-the-dreadful-tales-juniper-and-the-stone-leech',
      css_class: 'BOLD marl2_5em'
#


1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
# File 'lib/cyberweb/web_object/web_object.rb', line 1526

def self_abr(
    remote_url,
    optional_hash = {}
  )
  if optional_hash.is_a? String
    optional_hash = {
      content: optional_hash # This here is the equivalent.
    }
  end
  abr(remote_url, optional_hash)
end

#selfy_newtab(remote_url, optional_hash = {}) ⇒ Object

#

selfy_newtab

This variant passes in this option:

new_tab: true
#


1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
# File 'lib/cyberweb/web_object/web_object.rb', line 1547

def selfy_newtab(
    remote_url,
    optional_hash = {}
  )
  if optional_hash.is_a? String
    optional_hash = {
      content: optional_hash # This here is the equivalent.
    }
  end
  optional_hash.update(new_tab: true)
  self_abr(remote_url, optional_hash)
end

#sentence(i, optional_css_class = '') ⇒ Object Also known as: string_quote, squote, squotes, sq

#

sentence

This method can be used to “simulate” a quote, a sentence - something a person may say or have said.

It will return a string that is assumed to be a “full sentence”.

#


4068
4069
4070
4071
4072
4073
4074
4075
4076
4077
4078
4079
4080
4081
4082
4083
# File 'lib/cyberweb/web_object/web_object.rb', line 4068

def sentence(
    i,
    optional_css_class = ''
  )
  # ======================================================================= #
  # === :css_class
  # ======================================================================= #
  if optional_css_class.is_a?(Hash) and optional_css_class.has_key?(:css_class)
    optional_css_class = optional_css_class.delete(:css_class)
  end
  if optional_css_class and !optional_css_class.empty?
    "„<i class=\"#{optional_css_class}\">#{i}</i>“"
  else
    "„<i>#{i}</i>“"
  end
end

#set_clickable_image(i) ⇒ Object

#

set_clickable_image

#


6855
6856
6857
# File 'lib/cyberweb/web_object/web_object.rb', line 6855

def set_clickable_image(i)
  @internal_hash[:clickable_image] = i
end

#set_fixed_path(i = '') ⇒ Object Also known as: path=

#

set_fixed_path

Consistently use this method when setting or modifying @fixed_path.

It must be a String, which this method will ensure, before passing its argument to “Cyberweb.set_path_to_images()”.

#


2742
2743
2744
2745
# File 'lib/cyberweb/web_object/web_object.rb', line 2742

def set_fixed_path(i = '') # Here we simply set the @fixed_path variable.
  i = i.to_s
  Cyberweb.set_path_to_images(i) # Must return a String.
end

#set_proper_base_directoryObject Also known as: absolute_position=

#

set_proper_base_directory

#


2762
2763
2764
2765
2766
2767
# File 'lib/cyberweb/web_object/web_object.rb', line 2762

def set_proper_base_directory
  set_fixed_path(
    "#{Cyberweb.converted_path}"\
    "#{Cyberweb.name_of_img_dir?}"
  )
end

#set_relative_path(i) ⇒ Object

#

set_relative_path

#


4120
4121
4122
# File 'lib/cyberweb/web_object/web_object.rb', line 4120

def set_relative_path(i)
  @internal_hash[:relative_path] = i
end

#set_web_const(name_of_the_constant, symbol, css_class_to_use = 'marr4px') ⇒ Object

#

set_web_const

Easier, internal wrapper towards setting a constant.

All constants will be registered inside the variable @array_predefined_constants, and the method here will ensure that.

Currently the css class which we will use is hardset. I am not sure if we should be able to change this, and if so, how to alter it. For now it will stay as it is.

Notice that this method requires the string_img() method to exist, aliased to sg(), which is defined as part of the module Cyberweb.

The constant ARRAY_PREDEFINED_CONSTANTS is defined in the file bl $CYBER/constants/constants.rb

#


3508
3509
3510
3511
3512
3513
3514
3515
3516
3517
3518
3519
3520
3521
3522
3523
3524
3525
3526
3527
3528
3529
3530
3531
3532
3533
3534
3535
3536
3537
3538
3539
3540
3541
3542
3543
3544
3545
3546
3547
# File 'lib/cyberweb/web_object/web_object.rb', line 3508

def set_web_const(
    name_of_the_constant,
    symbol,
    css_class_to_use = 'marr4px'
  )
  array_predefined_constants = Cyberweb.array_predefined_constants?
  unless array_predefined_constants.include? name_of_the_constant
    # ===================================================================== #
    # The next line will store the constant in a top-level variable, the
    # one referenced by Cyberweb.array_predefined_constants?
    # We will set on the Cyberweb namespace.
    # ===================================================================== #
    array_predefined_constants << name_of_the_constant
    # ===================================================================== #
    # The following code was disabled as of 07.08.2018. We do not want to
    # pollute the main Object namespace, so the constants now reside
    # within the Cyberweb "namespace" instead.
    # ===================================================================== #
    #   Object.const_set(
    #     name_of_the_constant, Cyberweb.sg(symbol, css_class_to_use)
    #   )
    # ===================================================================== #
    # The constants will typically be like:
    #   Cyberweb::PFEIL_RECHTS
    # ===================================================================== #
    # In October 2021 the following "if use_jquery?" line was removed.
    # You now have to specifically enable 'drag_' for the image ID
    # if you need draggable images here.
    # ===================================================================== #
    # if use_jquery?
    #   use_this_as_the_image = sg(symbol, css_class_to_use) { :drag }
    # else
      use_this_as_the_image = sg(symbol, css_class_to_use)
    # end
    Cyberweb.const_set(
      name_of_the_constant,
      use_this_as_the_image
    )
  end
end

#show_admin_iconsObject

#

show_admin_icons

#


2705
2706
2707
# File 'lib/cyberweb/web_object/web_object.rb', line 2705

def show_admin_icons
  Cyberweb.show_admin_icons
end

#show_all_registered_idsObject

#

show_all_registered_ids

#


5344
5345
5346
5347
5348
5349
5350
5351
5352
5353
5354
# File 'lib/cyberweb/web_object/web_object.rb', line 5344

def show_all_registered_ids
  h2 "Now showing all registered IDs of this page ("\
     "#{name_of_served_page?}):"
  all_ids?.each { |entry|
    marl2em sg(:pfeil_rechts,'marr4px')+'`'+entry+'`', 'red'
    if entry.include? ' '
      anm('^^^ Please note that the entry above '+
      '('+entry.to_s+') is invalid!','large red')
    end
  }
end

#show_cheerleader(path_to_cheerleader_file = "#{Cyberweb.path_to_data?}javascript/cheerleader.js") ⇒ Object

#

show_cheerleader

Shows an ASCII cheerleader.

#


5648
5649
5650
5651
5652
5653
5654
5655
# File 'lib/cyberweb/web_object/web_object.rb', line 5648

def show_cheerleader(
    path_to_cheerleader_file = "#{Cyberweb.path_to_data?}javascript/cheerleader.js"
  )
  filename = 'cheerleader.js'
  _ = path_to_cheerleader_file
  _ << filename unless _[-filename.size, filename.size] == filename
  load_javascript(_)
end

#show_config(use_this_css_class_for_the_pre_tag = 'mars2em') ⇒ Object Also known as: show_cyberweb_configuration

#

show_config (config tag)

Show the available configuration settings for the Cyberweb project via this method.

#


5915
5916
5917
5918
5919
# File 'lib/cyberweb/web_object/web_object.rb', line 5915

def show_config(
    use_this_css_class_for_the_pre_tag = 'mars2em'
  )
  ee Cyberweb.return_configuration_settings
end

#show_debug_informationObject Also known as: debug

#

show_debug_information (debug tag)

Various debug methods are bundled here into this methodtogether. To debug your application, make use of code like the following:

w.debug

Remember that w defaults to the method call web_object?.

#


8802
8803
8804
8805
8806
8807
8808
8809
8810
8811
8812
8813
8814
8815
8816
8817
8818
8819
8820
8821
8822
8823
8824
8825
# File 'lib/cyberweb/web_object/web_object.rb', line 8802

def show_debug_information
  div('mar2em pad1em bblack1') {
    h2 'All known predefined constants:',
       'BG_Black pad8px yel'
    Cyberweb.array_predefined_constants?.each_with_index { |_, index|
      index = (index+1).to_s
      e index+') '+_ 
    }
  }
  div { view_source } # <-- Also display a view button.
  # ======================================================================= #
  # Show where the missing images are stored.
  # ======================================================================= #
  div {
    anm 'Please note that all Missing Images are stored '\
        'in this file: '+BR+
        MISSING_IMAGES_ARE_STORED_HERE+BR+'
         which we will display now:'
    read_and_display MISSING_IMAGES_ARE_STORED_HERE,'mars2em pad1em'
  }
  # debug_method('initialize')
  show_duplicated_ids # <-- And show duplicated ids as well.
  spacer { show_missing_css_classes }
end

#show_duplicated_idsObject

#

show_duplicated_ids

This method will show duplicate IDs. Currently only called from the method debug().

#


5145
5146
5147
5148
5149
5150
5151
5152
5153
5154
5155
5156
5157
5158
5159
# File 'lib/cyberweb/web_object/web_object.rb', line 5145

def show_duplicated_ids
  @internal_hash[:id_duplicates] = return_only_duplicates(all_ids?)
  unless @internal_hash[:id_duplicates].empty?
    div('mart1em mars2em pad1em','','RAND_BORD_2PX') {
      show_all_registered_ids
      # =================================================================== #
      # Now we must find duplicated IDs.
      # =================================================================== #
      h2 'The following <b>duplicate ID</b> entries were found:'
      @internal_hash[:id_duplicates].each { |id|
        lem("`#{id}`", 'FI red')
      }
    }
  end
end
#
#


302
303
304
305
306
307
308
309
310
311
# File 'lib/cyberweb/web_object/web_object.rb', line 302

def show_how_to_solve_printer_related_issues_under_windows
  h3 'Probleme mit dem Drucker'
  p('marl2em') {
    e '1) Warteschlange bei Druckaufträgen entfernen'
    e '2) Sollten sich <b>danach</b> einzelne Einträge nicht
    entfernen lassen, so muss der Computer 1x neugestartet
    werden (<b>links unten</b>, statt "<b>Herunterfahren</b>"
    auf "<b>Neustarten</b>" drücken)'
  }
end

#show_information_about_georgeObject

#

show_information_about_george

This method has to work primarily for a smaller screen size, say, about 1024 px or so.

#


319
320
321
322
323
324
325
326
327
# File 'lib/cyberweb/web_object/web_object.rb', line 319

def show_information_about_george
  h3 's-identity-app am smartphone (login für George)'
  p('marl2em') {
    e sg('misc/s_identity_app.png','marr10px','drag_s_identity_app_image')+
      'Am <b>smartphone</b> (handy) mit dem<br>Finger einmal '\
      'nach <b>→ rechts</b> schieben<br>'\
      'um zur <b>s-identity app</b> zu gelangen.'; drag_for(:drag_s_identity_app_image)
  }
end

#show_known_params(use_this_css = 'red larger marl5em') ⇒ Object

#

show_known_params

This method outputs the given params, which may be helpful when you want to debug.

#


4420
4421
4422
4423
4424
4425
4426
4427
# File 'lib/cyberweb/web_object/web_object.rb', line 4420

def show_known_params(
    use_this_css = 'red larger marl5em'
  )
  div {
    h2 'These Parameters are known:'
    cyberweb_params?
  }
end

#show_missing_css_classesObject

#

show_missing_css_classes

This method will show missing CSS classes.

In order for this to work, we depend on class AllCssClasses.

#


3868
3869
3870
3871
3872
3873
3874
3875
3876
3877
3878
3879
3880
3881
3882
3883
3884
3885
# File 'lib/cyberweb/web_object/web_object.rb', line 3868

def show_missing_css_classes
  _ = Cyberweb::AllCssClasses.new(:default, false)
  _.test(Cyberweb.found_these_css_classes)
  _.run
  result = _.result
  spacer
  h2 'Result'
  pre result.to_s
  pre Cyberweb.found_these_css_classes.to_s
  spacer
  div('mart1em mars2em pad1em','','RAND_BORD_2PX') {
    h2 'Now showing all missing <b class="orange">'\
       'CSS classes</b> for this page:'
    result.each { |entry|
      marl2em sg(:pfeil_rechts,'marr4px')+entry, 'red'
    }
  }
end

#show_roebe_email_addresses(use_this_width = '600px') ⇒ Object Also known as: roebe_email, roebe_email?

#

show_roebe_email_addresses

This method is only useful on my home system. It will fetch all my email addresses and then simply display them, via a div-element.

#


4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
4398
4399
4400
# File 'lib/cyberweb/web_object/web_object.rb', line 4373

def show_roebe_email_addresses(
    use_this_width = '600px'
  )
  div('mar2px pad0_5em marl1em',
      'roebe_email',
      'border: 3px dotted darkblue;
       border-radius: 10px;
       width:  '+use_this_width+';') {
    # ===================================================================== #
    # === Roebe-Email addresses
    # ===================================================================== #
    h3 'Roebe-Email addresses',
       'mart5px'
    dataset = YAML.load_file(beautiful_url(:my_email)) 
    p_default_le {
      dataset.each {|this_email|
        css_classes_to_use = 'BOLD marl1em'.dup
        modified_this_email = this_email.sub(//,'')
        if this_email.include? 'unet.' # Exemption for now.
          css_classes_to_use << ' darkgreen'
        end
        e '<a href="mailto: '+modified_this_email+'">'\
          '<b class="'+css_classes_to_use+'">✉ '+
          this_email+'</b></a>'
      }
    }
  }
end

#show_source?Boolean

#

show_source?

#

Returns:

  • (Boolean)


9286
9287
9288
# File 'lib/cyberweb/web_object/web_object.rb', line 9286

def show_source?
  @internal_hash[:show_source]
end

#show_the_cat_short_stories(css_style_to_use = 'margin-top: 2em;') ⇒ Object

#

show_the_cat_short_stories

This is an ad-hoc method mostly, for custom cat stories. I added this mostly to quickly test local features, including displaying different short stories about cats.

#


7155
7156
7157
7158
7159
7160
7161
7162
7163
7164
7165
7166
7167
7168
7169
7170
7171
7172
7173
# File 'lib/cyberweb/web_object/web_object.rb', line 7155

def show_the_cat_short_stories(
    css_style_to_use = 'margin-top: 2em;'
  )
  the_arrow = rarrow?
  p(css_style: css_style_to_use) {
    abr :local_ginger_html,
        content: "#{the_arrow} Ginger der Bandit",
        css_class: 'BOLD marl1em'
    abr :local_ariolante_and_the_kitten_html,
        content: "#{the_arrow} Ariolante und das Kätzchen",
        css_class: 'BOLD marl1em'
    abr :local_die_herrenlose_katze_html,
        content: "#{the_arrow} Die herrenlose Katze",
        css_class: 'BOLD marl1em'
    abr :local_die_katze_im_schnee_html,
        content: "#{the_arrow} Die Katze im Schnee",
        css_class: 'BOLD marl1em'
  }
end

#show_the_keyboard(optional_css_class = '') ⇒ Object

#

show_the_keyboard

This method will show a fancy CSS-styled keyboard.

#


5045
5046
5047
5048
5049
5050
5051
5052
5053
5054
5055
5056
5057
5058
5059
5060
5061
5062
5063
5064
5065
5066
5067
5068
5069
5070
5071
5072
5073
5074
5075
5076
5077
5078
5079
5080
5081
5082
5083
5084
5085
5086
5087
5088
5089
5090
5091
5092
5093
5094
5095
5096
5097
5098
5099
5100
5101
5102
5103
5104
5105
5106
5107
5108
5109
5110
5111
5112
5113
5114
5115
5116
5117
5118
5119
5120
5121
5122
5123
5124
5125
5126
5127
5128
5129
5130
5131
5132
5133
5134
5135
5136
5137
# File 'lib/cyberweb/web_object/web_object.rb', line 5045

def show_the_keyboard(
    optional_css_class = ''
  )
  estyle '.container_for_the_keyboard {
margin: 100px 0 0 200px;
}

.row_for_the_keyboard {
width: 100%;
height: 60px;
}

.row_one,
.row_two,
.row_three,
.row_four,
.row_five {
margin: 10px 0 0 0;
}

button.for_the_keyboard {
color: black;
font-weight: 500;
width: 55px;
height: 55px;
border: none;
background: rgb(214, 214, 214);
box-shadow: 0 0 10px #9521f3, 0 0 40px #c600ee, 0 0 80px #f704f7;

font-size: 15px;
margin-left: 5px;
outline: none;
font-family: Arial, Helvetica, sans-serif;
border-radius: 20%;
}

button.for_the_keyboard:active {
box-shadow: 1px 1px 2px #fd0c99,
            1px 1px 2px #ff00dd;
}

.print_key {
width: 85px !important;
border-radius: 10px !important;
}

.backspace_key {
width: 148px !important;
border-radius: 10px !important;
}

.tab_key {
width: 115px !important;
border-radius: 10px !important;
}

.slace_key {
width: 90px !important;
border: 10px !important;
}

.caps_lock_key {
width: 96px !important;
border-radius: 10px !important;
}

.enter_button {
width: 109px !important;
border-radius: 10px !important;
}

.shift_key {
width: 135px !important;
border-radius: 10px !important;
}

.space_key {
width: 398px !important;
border-radius: 10px !important;
}

.last_row {
width: 56px !important;
border-radius: 10px !important;
}
'
div(optional_css_class) {
   e File.read(
       project_base_directory?+'skeleton/html_keyboard.md',
       encoding: use_which_encoding?
   )
 }
end

#show_the_titleObject

#

show_the_title

This is mostly a debugging-method, hence why it uses puts.

#


1487
1488
1489
# File 'lib/cyberweb/web_object/web_object.rb', line 1487

def show_the_title
  puts "<title>#{Cyberweb.title?}</title>"
end

#show_this_local_directory(from = return_pwd, shall_we_include_the_subdirectories = :do_include_the_subdirectories, optional_filter_for = nil, report_if_no_file_was_found = true) ⇒ Object

#

show_this_local_directory

This method can be used to show the content of a local directory as well as its subdirectories.

Usage example:

show_this_local_directory('C:\ingrid')
#


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
5297
5298
5299
5300
# File 'lib/cyberweb/web_object/web_object.rb', line 5258

def show_this_local_directory(
    from                                = return_pwd,
    shall_we_include_the_subdirectories = :do_include_the_subdirectories,
    optional_filter_for                 = nil, # can be filter_for: '.pdf'
    report_if_no_file_was_found         = true
  )
  if File.directory? from
    # ===================================================================== #
    # Obtain all files next:
    # ===================================================================== #
    files = files_from(
      from,
      shall_we_include_the_subdirectories
    )
    if optional_filter_for and optional_filter_for.is_a?(Hash)
      # =================================================================== #
      # === :filter_for
      # =================================================================== #
      if optional_filter_for.has_key? :filter_for
        files.select! {|entry|
          entry.end_with?(optional_filter_for[:filter_for])
        }
      end
    end
    if report_if_no_file_was_found and files.empty?
      p_default_le {
        e 'No file could be found at <b>'+
          from.to_s.delete('*').squeeze('/')+'</b>.'
      }
    else
      files.each {|this_file|
        abr(
          this_file,
          css_class: 'mars2em BOLD'
        )
      }
    end
  else
    p_default_le {
      e "No directory called #{from} could be found."
    }
  end
end
#

A simplified wrapper around link().

This is simpler since we only have to provide one URL; and optionally a second argument denoting the css-class in use.

Usage example:

simple_link 'https://gamefaqs.gamespot.com/pc/565051-alone-in-the-dark-3/faqs/8459','mars2em'
#


7524
7525
7526
7527
7528
7529
7530
7531
7532
7533
7534
7535
7536
7537
7538
# File 'lib/cyberweb/web_object/web_object.rb', line 7524

def simple_link(
    link_hyperref,
    optional_css_class = '',
    make_newline       = 1
  )
  link(
    link_hyperref,
    desc:      link_hyperref,
    css_class: optional_css_class
  )
  case make_newline
  when 1, true
    br
  end
end

#simpler_string_image(i = :random, optional_css_class = :empty_string_or_global_css_rules_for_images, optional_the_id = '', optional_css_style = '', alt_text = '', make_linebreak = 0, something1 = '', something2 = '', hmmmmmmmmm = '', javascript = '', &block) ⇒ Object Also known as: string_img, simg, sg

#

simpler_string_image (sg tag)

This method has been added in September 2020 to specifically work around the problem that the older sg() method had.

The return-value of this method MUST always be a String; it may never call addnl() directly. The whole idea is to build up a <img> tag through it.

Note that sg stands short for string_image().

#


439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
# File 'lib/cyberweb/web_object/web_object.rb', line 439

def simpler_string_image(
    i                  = :random, # This is the path - or a Symbol denoting that a path should be used.
    optional_css_class = :empty_string_or_global_css_rules_for_images,
    optional_the_id    = '',
    optional_css_style = '',
    alt_text           = '',
    make_linebreak     =  0,
    something1         = '',
    something2         = '',
    hmmmmmmmmm         = '',
    javascript         = '', # Javascript-related functions.
    &block
  )
  if optional_css_class and optional_css_class.is_a?(String) and
     images_css_rules? and !images_css_rules?.empty?
    optional_css_class << " #{images_css_rules?}"
  end
  case optional_css_class
  # ======================================================================= #
  # === :empty_string_or_global_css_rules_for_images
  #
  # Make use of the global image CSS rules here.
  # ======================================================================= #
  when :empty_string_or_global_css_rules_for_images
    if images_css_rules?.nil?
      optional_css_class = ''
    else
      optional_css_class = images_css_rules?
    end
  end
  yielded = nil # Dummy variable for later re-use.
  # ======================================================================= #
  # === Handle Symbols as primary input next; it will be assumed it is
  #     an image_url, such as :cheering_person becoming
  #     "#{IMG_DIR}CHEERING_PERSON.png"
  #
  # There is one caveat here, though - Cyberweb.image_url() uses
  # hardcoded paths, so many images will NOT be found. So, as of
  # May 2023, we will additionally try to tap into find_image()
  # if no match was found.
  # ======================================================================= #
  if i.is_a? Symbol
    i = Cyberweb.image_url(i) # This has the path.
    if i.start_with? RUBY_SITE_DIR
      # =================================================================== #
      # Work on e. g.:
      #
      #  /usr/lib/ruby/site_ruby/3.2.0/cyberweb/images/standard_images/AUSRUFUNGSZEICHEN.png
      #
      # =================================================================== #
      i.sub!(
        /#{RUBY_SITE_DIR}/,
        rds(
          relative_path?+
          '/programming/ruby/src/cyberweb/lib/'
        )
      )
    else
      i.prepend(
        Cyberweb.convert_n_relative_slashes_to_relative_directory+
        image_directory?.to_s
      )
    end
  else # Handle non-symbols here.
    i = i.dup if i.frozen?
    unless i.start_with?('./') and File.exist?(i)
      i.prepend(
        Cyberweb.convert_n_relative_slashes_to_relative_directory+
        image_directory?.to_s
      ) unless i.start_with?('http')
    end
  end
  optional_width  = nil
  optional_height = nil
  # ======================================================================= #
  # === Handle Hashes next
  #
  # We must be careful here, depending on which symbol is passed to the
  # method.
  # ======================================================================= #
  if optional_css_class.is_a? Hash
    # ===================================================================== #
    # === :id
    # ===================================================================== #
    if optional_css_class.has_key? :id
      optional_the_id = optional_css_class.delete(:id)
    # ===================================================================== #
    # === :the_id
    # ===================================================================== #
    elsif optional_css_class.has_key? :the_id
      optional_the_id = optional_css_class.delete(:the_id)
    end
    # ===================================================================== #
    # === :loading
    # ===================================================================== #
    if optional_css_class.has_key? :loading
      yielded = :lazy_loading if (optional_css_class[:loading] == true)
    end
    # ===================================================================== #
    # === :alt
    # ===================================================================== #
    if optional_css_class.has_key? :alt
      alt_text = optional_css_class.delete(:alt)
    end
    # ===================================================================== #
    # === :css_style
    # ===================================================================== #
    if optional_css_class.has_key? :css_style
      optional_css_style = optional_css_class.delete(:css_style)
    end
    # ===================================================================== #
    # === :width
    # ===================================================================== #
    if optional_css_class.has_key? :width
      optional_width = optional_css_class.delete(:width).to_s
    end
    # ===================================================================== #
    # === :height
    # ===================================================================== #
    if optional_css_class.has_key? :height
      optional_height = optional_css_class.delete(:height).to_s
    end
    # ===================================================================== #
    # === :content
    # ===================================================================== #
    if optional_css_class.has_key? :content
      i = optional_css_class.delete(:content)
    end
    # ===================================================================== #
    # === :css_class
    #
    # This should come last.
    # ===================================================================== #
    if optional_css_class.has_key? :css_class
      optional_css_class = optional_css_class.delete(:css_class)
    # ===================================================================== #
    # === :css
    # ===================================================================== #
    elsif optional_css_class.has_key? :css
      optional_css_class = optional_css_class.delete(:css)
    end
    if optional_css_class.is_a?(Hash) and optional_css_class.empty?
      optional_css_class = ''
    end
  end
  i = i.to_s
  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
  may_we_prepend_the_path = true
  case optional_the_id
  # ======================================================================= #
  # === :drag
  #
  # "Rescue" a specific symbol here, called :drag.
  # ======================================================================= #
  when :drag
    optional_the_id = 'drag_'+File.basename(i).downcase.delete_suffix(
      File.extname(i)
    ).tr('.','_')
  end
  # ======================================================================= #
  # === Handle blocks next
  # ======================================================================= #
  if block_given?
    yielded = yield
    # ===================================================================== #
    # First, handle Symbols given via a block here:
    # ===================================================================== #
    case yielded
    # ===================================================================== #
    # === :drag
    # ===================================================================== #
    when :drag
      optional_the_id = 'drag_'+File.basename(i).downcase.
                         delete_suffix(
                           File.extname(i)
                         ).tr('.','_')
    # ===================================================================== #
    # === :lazy_loading
    #
    # This entry point allows for the lazy loading of an image.
    #
    # The use case for this may look like so:
    #
    #    img 'foobar.jpg', loading: lazy
    #    img('foobar.jpg') { :lazy }
    #
    # ===================================================================== #
    when :lazy_loading
      i = i.dup
      i[-1,0] = ' loading="lazy"'
    # ===================================================================== #
    # === :prepend_only_to_the_images_real_directory
    # ===================================================================== #
    when :prepend_only_to_the_images_real_directory
      i.prepend(relative_path?.dup)
      may_we_prepend_the_path = false
    # ===================================================================== #
    # === :draggable_attribute
    # ===================================================================== #
    when :draggable_attribute
      i = i.dup
      i[-1,0] = ' draggable="true"'
    # ===================================================================== #
    # === :do_not_prepend_anything
    # ===================================================================== #
    when :do_not_prepend_anything
      may_we_prepend_the_path = false
    end
  end
  # ======================================================================= #
  # Next we prepend the path to the local directory. This is, however
  # had, NOT the case if i begins with the substring 'http'.
  # ======================================================================= #
  if may_we_prepend_the_path and !i.start_with?('http') and
    !i.start_with?('../') and # This line was added in January 2023.
    !i.start_with?('/programming/ruby/src/')
    if i.start_with?('./') and File.exist?(i)
      # In this case it exists, so do nothing about it.
    else # This is the default entry point of this clause here.
      i = "#{return_path_to_the_images_directory}"\
          "#{i}"
    end
  end
  # ======================================================================= #
  # Last but not least, we need to ensure that the ID is unique. If
  # not then we will append some characters here.
  # ======================================================================= #
  if optional_the_id and !optional_the_id.empty? and is_a_duplicate_id?(optional_the_id)
    optional_the_id = optional_the_id.dup if optional_the_id.frozen?
    optional_the_id << '_'+random_alphabet_characters(10)
  end
  # ======================================================================= #
  # Next delegate onto raw_image():
  # ======================================================================= #
  return raw_image(
    i,
    optional_css_class,
    optional_the_id,
    optional_css_style,
    alt_text,
    optional_width,
    optional_height
  )
end

#sitemap_array(*array) ⇒ Object

#

sitemap_array

#


4191
4192
4193
4194
4195
4196
4197
4198
4199
4200
4201
4202
4203
# File 'lib/cyberweb/web_object/web_object.rb', line 4191

def sitemap_array(
    *array
  )
  array = [array].flatten.compact
  register_sitemap(array)
  div('mars1em') {
    h2 'Sitemap','gold BG_Black pad8px'
    registered_sitemap?.each {|entry|
      abr_self('#'+entry.downcase)
    }
  }
  # autogenerated_sitemap # And call the autogenerated sitemap method at once.
end

#slogans(use_this_fancy_heading = :fancy2) ⇒ Object

#

slogans

#


4920
4921
4922
4923
4924
# File 'lib/cyberweb/web_object/web_object.rb', line 4920

def slogans(
    use_this_fancy_heading = :fancy2
  )
  send(use_this_fancy_heading.to_sym, 'Slogans')
end

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

#

stars

#


2712
2713
2714
2715
2716
2717
2718
2719
# File 'lib/cyberweb/web_object/web_object.rb', line 2712

def stars(
    n_stars            = 1,
    optional_css_class = ''
  )
  append_onto_the_body_tag_nl(
    return_stars(n_stars, optional_css_class)
  )
end

#string_absolute_img(remote_url, css_class = '', the_id = '', css_style = '') ⇒ Object

#

string_absolute_img

#


7340
7341
7342
7343
7344
7345
7346
7347
7348
7349
7350
7351
7352
# File 'lib/cyberweb/web_object/web_object.rb', line 7340

def string_absolute_img(
    remote_url,
    css_class = '',
    the_id    = '',
    css_style = ''
  )
  return Cyberweb.string_absolute_img(
             remote_url,
             css_class,
             the_id,
             css_style
           )
end

#string_dot(i = 108, optional_css_class = '', optional_the_id = '', optional_css_style = '') ⇒ Object Also known as: dot

#

string_dot

This variant will return a String. The regular dot() method on the other hand will append that String onto the resulting webpage content, as-is.

#


3378
3379
3380
3381
3382
3383
3384
3385
3386
3387
3388
3389
3390
3391
# File 'lib/cyberweb/web_object/web_object.rb', line 3378

def string_dot(
    i                  = 108,
    optional_css_class = '',
    optional_the_id    = '',
    optional_css_style = ''
  )
  _ = sg(
    "dot#{i}".to_sym,
    optional_css_class,
    optional_the_id,
    optional_css_style
  )
  return _
end

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

#

string_h1

This will wrap over HtmlTags.h1().

#


5559
5560
5561
5562
5563
5564
5565
5566
5567
5568
5569
5570
5571
5572
# File 'lib/cyberweb/web_object/web_object.rb', line 5559

def string_h1(
    i                   = '',
    optional_css_class  = '',
    optional_the_id     = '',
    optional_css_style  = '',
    optional_javascript = ''
  )
  return HtmlTags.h1(
    i,
    optional_css_class,
    optional_the_id,
    optional_css_style
  )
end

#string_table12_with_heading(css_class = '', id = '', css_style = '', *content) ⇒ Object

#

string_table12_with_heading

#


8519
8520
8521
8522
8523
8524
8525
8526
8527
8528
8529
# File 'lib/cyberweb/web_object/web_object.rb', line 8519

def string_table12_with_heading(
    css_class = '',
    id        = '',
    css_style = '',
    *content
  )
  Cyberweb.string_table12_with_heading(
    css_class, id, css_style,
    content
  )
end

#tastaturkürzel_windowsObject Also known as: show_tastaturkürzel_for_windows, show_tastaturkürzel_windows

#

tastaturkürzel_windows

This is in german.

#


8405
8406
8407
8408
8409
8410
8411
8412
8413
# File 'lib/cyberweb/web_object/web_object.rb', line 8405

def tastaturkürzel_windows
  h3 'Tastaturkürzel für Windows'
  p('marl2em') {
    e sg(:windows_key, 'marr8px')+
      '<b>WIN</b>+<b class="darkblue">E</b>: startet den <b>explorer</b>'
    e '<b>Drücken</b> der <b>rechten</b> Maustaste: dies öffnet <br>
    das <b>Kontextmenü</b>'
  }
end

#test_the_html_coloursObject

#

test_the_html_colours

#


2380
2381
2382
2383
2384
# File 'lib/cyberweb/web_object/web_object.rb', line 2380

def test_the_html_colours
  all_html_colours.each {|this_html_colour|
    e 'Hello world!', this_html_colour
  }
end

#text(i) ⇒ Object Also known as: label_text

#

text

#


3741
3742
3743
# File 'lib/cyberweb/web_object/web_object.rb', line 3741

def text(i)
  Cyberweb::Objectified::HtmlTags::Span.new(i)
end

#title?Boolean Also known as: use_this_title?, title

#

title?

Query method for the title of our webpage.

Note that the method .title() is an alias for .title?(); in the past, before April 2022, it was an alias for .set_title() instead.

Also note that this is different to web_title?. The latter will always query the title stored in the WebObject at hand, whereas the former will always call the toplevel method Cyberweb.title?.

#

Returns:

  • (Boolean)


5549
5550
5551
# File 'lib/cyberweb/web_object/web_object.rb', line 5549

def title?
  Cyberweb.title?
end

#try_to_create_the_log_directory_unless_it_already_exists(i = Cyberweb.log_dir?) ⇒ Object

#

try_to_create_the_log_directory_unless_it_already_exists

#


9361
9362
9363
9364
9365
9366
9367
# File 'lib/cyberweb/web_object/web_object.rb', line 9361

def try_to_create_the_log_directory_unless_it_already_exists(
    i = Cyberweb.log_dir?
  )
  unless File.directory?(i)
    mkdir(i)
  end
end

#try_to_generate_pdf_fileObject

#

try_to_generate_pdf_file

Use this method to generate a dump from a .cgi page.

Invocation example from the commandline:

rf biotut ?pdf
#


5366
5367
5368
5369
5370
5371
5372
5373
5374
5375
5376
5377
5378
5379
5380
5381
5382
5383
5384
5385
5386
5387
5388
5389
5390
5391
5392
5393
5394
5395
5396
5397
5398
5399
5400
5401
5402
5403
5404
5405
5406
5407
5408
5409
5410
5411
5412
5413
5414
5415
5416
5417
5418
5419
5420
5421
5422
5423
5424
5425
5426
5427
5428
5429
5430
5431
5432
5433
5434
5435
5436
5437
5438
5439
5440
5441
5442
5443
# File 'lib/cyberweb/web_object/web_object.rb', line 5366

def try_to_generate_pdf_file
  # ======================================================================= #
  # The directory where to generate our .pdf file into.
  # ======================================================================= #
  base_dir = '/home/x/Temp/lighty/'
  h2 'We will next generate a .pdf document of this webpage.'
  which_file = base_dir+'hello_world.pdf'
  which_file = base_dir+::Cyberweb.name_of_served_page?
  this_pdf_file = which_file.gsub(/\.cgi/,'')+'.pdf'
  target = ::Cyberweb.localhost?.to_s+ENV['SCRIPT_NAME']
  begin
    require 'serve_local_page'
  rescue LoadError; end
  if Object.const_defined? :ServeLocalPage
    # ===================================================================== #
    # Next, we will delegate towards class ServeLocalPage.
    # ===================================================================== #
    dataset = ServeLocalPage.new(target, :dont_save).dataset?
    # ===================================================================== #
    # This dataset contains all the HTML tags, which is not nice.
    # So we will get rid of them. But this may be a problem
    # lateron, so for now we won't do so.
    # ===================================================================== #
    # dataset = ::Cyberweb.remove_html(dataset)
    delete_file(this_pdf_file) if File.exist? this_pdf_file
    what = dataset
    into = which_file.gsub(/\.pdf/,'').gsub(/\.cgi/,'')+'.html'
    h3 'Storing into the .html file, by using wkhtmltopdf:
    <b class="darkblue BG_White s5px">'+into+'</b>.'
    a into, 'SELF',1,'marl3em'
    # ===================================================================== #
    # Next, create /Depot/Temp/lighty unless it already exists.
    # ===================================================================== #
    unless File.directory? File.dirname(this_pdf_file)
      mkdir(File.dirname(this_pdf_file))
    end
    # ===================================================================== #
    # Store into the .html page next.
    # ===================================================================== #
    write_what_into(what, into)
    h3 'Storing into .pdf file: <b class="darkblue BG_White s5px">'+this_pdf_file+'</b>.'
    a(
      this_pdf_file,
      content: 'SELF',
      css_class: 'marl3em'
    )
    br
    # ===================================================================== #
    # We essentially have two ways to generate a .pdf file:
    #
    #   (1) by using wkhtmltopdf
    #   (2) by using prawn
    #
    # (1) is more robust.
    # ===================================================================== #
    use_wkhtmltopdf = true # Hack. :D
    if use_wkhtmltopdf
      _ = 'wkhtmltopdf '+into+' '+this_pdf_file
      system _ # We are silent here.
      # =================================================================== #
      # Next, keep a reference to the generated .pdf file.
      # =================================================================== #
      ::Cyberweb.set_path_to_last_generated_pdf_document(
        this_pdf_file
      )
    else # else use prawn.
      Prawn::Document.generate(this_pdf_file, :page_size => 'A4') {
        font 'Times-Roman'
        text 'Hello Prawn!'
        text(dataset)
      }
    end
    spacer
    e 'It is now available at `<b>'+which_file.gsub(/\.cgi/,'.html')+'</b>`.'
    # spacer
  end
  spacer
end

#try_to_honour_database_file(use_this_name_for_the_table = 'webpage') ⇒ Object

#

try_to_honour_database_file

#


2665
2666
2667
2668
2669
2670
2671
2672
2673
2674
2675
2676
2677
2678
2679
2680
2681
# File 'lib/cyberweb/web_object/web_object.rb', line 2665

def try_to_honour_database_file(
    use_this_name_for_the_table = 'webpage'
  )
  _ = 'database.sql'
  if File.exist? _
    # require 'sequel'
    # Sequel.connect(_){|database|
    #   content = database[:content]
    #   e content
    # }
    p_default_le {
      cmd = "sqlite3 database.sql 'SELECT content from #{use_this_name_for_the_table} where id=1;'"
      result = `#{cmd}`
      e result
    }
  end
end

#try_to_populate_the_log_directory_with_javascript_files(_ = log_dir? ) ⇒ Object

#

try_to_populate_the_log_directory_with_javascript_files

This method will try to populate the main log directory with the default javascript files.

#


9555
9556
9557
9558
9559
9560
9561
9562
9563
9564
9565
9566
9567
9568
9569
9570
9571
9572
9573
9574
9575
# File 'lib/cyberweb/web_object/web_object.rb', line 9555

def try_to_populate_the_log_directory_with_javascript_files(
    _ = log_dir?
  )
  if File.directory? _
    # ===================================================================== #
    # If the log-directory exists, try to create the javascript_code/
    # directory, then cd into it. Since as of 20.10.2022 we will return
    # to the original directory afterwards.
    # ===================================================================== #
    full_target = "#{_}javascript_code"
    unless File.directory? full_target
      mkdir(full_target)
    end
    original_directory = return_pwd
    if File.directory?(full_target)
      cd(full_target)
      do_copy_the_javascript_code_files_into_current_working_directory
    end
    cd original_directory # Return to the original directory again.
  end
end

#try_to_require_the_mail_gemObject

#

try_to_require_the_mail_gem

#


6159
6160
6161
6162
6163
6164
6165
6166
# File 'lib/cyberweb/web_object/web_object.rb', line 6159

def try_to_require_the_mail_gem
  begin
    require 'mail'
  rescue LoadError => error
    e 'No gem called mail is available.'
    pre error
  end
end

#try_to_use_per_project_settings?Boolean

#

try_to_use_per_project_settings

This is currently not really in use - I forgot why I really need to have it in the first place.

I’ll keep it for now until at a later point, when I will decide what to do with this.

h3 'YEAH WE USE PER PROJECT SETTING'
e File.exist? Dir.pwd+'/yaml/base_dir.yml'
e File.exist? Dir.pwd+'/YAML/base_dir.yml'
e File.exist? 'yaml/base_dir.yml'
e File.exist? 'YAML/base_dir.yml'
#

Returns:

  • (Boolean)


2281
2282
2283
2284
2285
2286
2287
# File 'lib/cyberweb/web_object/web_object.rb', line 2281

def try_to_use_per_project_settings?
  if @config.has_key? 'try_to_use_per_project_settings'
    @config['try_to_use_per_project_settings']
  else
    false # Default if we don't have this setting defined.
  end
end

#ul(optional_css_class = 'marl1em', optional_the_id = '', &block) ⇒ Object

#

ul (ul tag)

ul stands for “unsorted list”.

#


7835
7836
7837
7838
7839
7840
7841
7842
7843
7844
7845
7846
7847
7848
7849
7850
7851
7852
7853
7854
7855
7856
7857
7858
7859
7860
7861
7862
7863
7864
7865
7866
7867
7868
7869
7870
# File 'lib/cyberweb/web_object/web_object.rb', line 7835

def ul(
    optional_css_class = 'marl1em', # This is the default.
    optional_the_id    = '',
    &block
  )
  # ======================================================================= #
  # === First we will handle Hashes
  # ======================================================================= #
  if optional_css_class.is_a? Hash
    # ===================================================================== #
    # === :id
    # ===================================================================== #
    if optional_css_class.has_key? :id
      optional_the_id = optional_css_class.delete(:id)
      optional_css_class = 'marl1em' if optional_css_class.empty?
    end
    # ===================================================================== #
    # === :css_class
    #
    # This must come last.
    # ===================================================================== #
    if optional_css_class.respond_to?(:css_class) and
       optional_css_class.has_key?(:css_class)
      optional_css_class = optional_css_class.delete(:css_class)
    end
  end
  append_onto_the_body_nl(
    '<ul class="'+optional_css_class.to_s+'"'+
    id_or_no_id(optional_the_id)+
    '>'
  )
  if block_given?
    yield
    cul
  end
end

#update_the_body(with_this_content) ⇒ Object

#

update_the_body

This method will update the content of the <body> tag, via javascript.

#


9250
9251
9252
9253
9254
# File 'lib/cyberweb/web_object/web_object.rb', line 9250

def update_the_body(with_this_content)
  ejavascript'
document.body.innerHTML = "'+with_this_content+'"
 '
end

#use(i) ⇒ Object

#

use (use tag)

General wrapper to call other use-related methods for a given web_object instance.

Examples:

use :utf8
use :frames
#


4311
4312
4313
4314
4315
4316
4317
4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
4336
4337
4338
4339
4340
4341
4342
4343
4344
4345
4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
4358
4359
4360
4361
4362
4363
4364
4365
# File 'lib/cyberweb/web_object/web_object.rb', line 4311

def use(i)
  if i.to_s.include?(',') # Treat "," as separator.
    i.to_s.split(',').each {|entry| use(entry) }
  elsif i.to_s.include?('|') # Treat "|" as separator too.
    i.to_s.split('|').map(&:strip).each {|entry| use(entry) }
  else
    case i.to_s # case tag
    # ===================================================================== #
    # === jquery
    # ===================================================================== #
    when 'jquery'
      do_use_jquery
    # ===================================================================== #
    # === predefine_squares
    # ===================================================================== #
    when 'predefine_squares',
         'squares',
         'square',
         'sq'
      use_predefine_squares
    # ===================================================================== #
    # === utf
    # ===================================================================== #
    when 'utf',
         'utf8'
      use_utf8
    # ===================================================================== #
    # === iso
    # ===================================================================== #
    when 'iso'
      use_iso_encoding
    # ===================================================================== #
    # === scrolling
    # ===================================================================== #
    when 'scrolling'
      use_scrolling
    # ===================================================================== #
    # === frames
    # ===================================================================== #
    when 'frames'
      use_frames
    # ===================================================================== #
    # === exceptions
    # ===================================================================== #
    when 'exceptions',
         'exception'
      do_use_exceptions
    # ===================================================================== #
    # === monospace_font
    # ===================================================================== #
    when /^monospace(_|-)?font/
      use_monospace_font
    end
  end
end

#use_base64_encoding_for_all_local_images?Boolean

#

use_base64_encoding_for_all_local_images?

#

Returns:

  • (Boolean)


920
921
922
# File 'lib/cyberweb/web_object/web_object.rb', line 920

def use_base64_encoding_for_all_local_images?
  @internal_hash[:use_base64_encoding_for_all_local_images]
end

#use_dragula?Boolean

#

use_dragula?

Whether we will use dragula or whether we will not.

#

Returns:

  • (Boolean)


1956
1957
1958
1959
1960
1961
1962
# File 'lib/cyberweb/web_object/web_object.rb', line 1956

def use_dragula?
  if @config.has_key? 'use_dragula'
    @config['use_dragula']
  else
    false # Default if we don't have this setting defined.
  end
end

#use_frames(optional_hash = {}) ⇒ Object

#

use_frames

Use this to denote that frames will be used. Not sure if this is still the case.

There is an optional argument, a hash. If you pass a hash, we will call frame_left and frame_right.

Usage example:

w.use_frames( :left => 'foo.cgi', :right => 'bla.cgi')
#


2136
2137
2138
2139
2140
2141
2142
# File 'lib/cyberweb/web_object/web_object.rb', line 2136

def use_frames(
    optional_hash = {}
  )
  frame_left(optional_hash[:left])   if optional_hash.has_key[:left]
  frame_right(optional_hash[:right]) if optional_hash.has_key[:right]
  @internal_hash[:frame_string] << '</frameset>'+N unless @frame_string.include? '</frameset>'
end

#use_jquery?Boolean Also known as: jquery?

#

use_jquery?

This allows us to use jquery specifically.

#

Returns:

  • (Boolean)


5166
5167
5168
# File 'lib/cyberweb/web_object/web_object.rb', line 5166

def use_jquery?
  @config['use_jquery']
end

#use_prawn?Boolean

#

use_prawn?

Whether to use prawn in order to generate .pdf files.

#

Returns:

  • (Boolean)


4291
4292
4293
4294
4295
4296
4297
# File 'lib/cyberweb/web_object/web_object.rb', line 4291

def use_prawn?
  if @config.has_key? 'use_prawn'
    @config['use_prawn']
  else
    false # Default if the method is not set.
  end
end

#use_title_automatically?Boolean

#

use_title_automatically?

Whether to automatically set a title or not, depending on the configuration option.

#

Returns:

  • (Boolean)


1084
1085
1086
1087
1088
1089
1090
# File 'lib/cyberweb/web_object/web_object.rb', line 1084

def use_title_automatically?
  if @config.has_key? 'set_title_automatically'
    @config['set_title_automatically']
  else
    false # Default if the method is not set.
  end
end

#use_unicode?Boolean

#

use_unicode?

#

Returns:

  • (Boolean)


2600
2601
2602
# File 'lib/cyberweb/web_object/web_object.rb', line 2600

def use_unicode?
  @internal_hash[:use_unicode]
end

#use_utfObject Also known as: use_utf8, use_utf_encoding

#

use_utf

#


1643
1644
1645
# File 'lib/cyberweb/web_object/web_object.rb', line 1643

def use_utf
  set_encoding_to_use :utf # ← Better to pass it through a method.
end

#use_verbose_warnings?Boolean

#

use_verbose_warnings?

#

Returns:

  • (Boolean)


5681
5682
5683
5684
5685
5686
5687
# File 'lib/cyberweb/web_object/web_object.rb', line 5681

def use_verbose_warnings?
  if @config.has_key? 'warnings'
    @config['warnings'] = 'verbose'
  else
    false
  end
end

#video(*i) ⇒ Object

#

video

#


2591
2592
2593
2594
2595
# File 'lib/cyberweb/web_object/web_object.rb', line 2591

def video(*i)
  i.flatten.compact.each {|entry|
    youtube_link(entry)
  }
end

#view_file?Boolean

#

view_file?

#

Returns:

  • (Boolean)


1684
1685
1686
# File 'lib/cyberweb/web_object/web_object.rb', line 1684

def view_file?
  @config['view_file']
end

#view_source(css_class = 'wid25', optional_id = 'view_source', optional_css_style = '') ⇒ Object

#

view_source

#


2779
2780
2781
2782
2783
2784
2785
2786
2787
2788
2789
2790
2791
2792
2793
2794
# File 'lib/cyberweb/web_object/web_object.rb', line 2779

def view_source(
    css_class          = 'wid25',
    optional_id        = 'view_source',
    optional_css_style = ''
  )
  button_css = 'view_source BG_White Black pad2px'
  if css_class.is_a? Hash
    css_class = css_class.delete :css_class
  end
  form '', '', '', optional_id, optional_css_style
    ee '<input class="'+button_css+' '+css_class+'" type="button" value="View Source" '
    # ee 'onClick=\'window.location = "view-source:"+window.location.href\'
    ee "onClick='window.location=\"view-source:\"+window.location.href'"
    ee '>'+"\n"
  cform
end

#window(title = '', width = 1024, height = 800, hash = {}) ⇒ Object

#

window

Simply delegate towards Cyberweb.window() here.

#


9326
9327
9328
9329
9330
9331
9332
9333
9334
9335
9336
9337
9338
# File 'lib/cyberweb/web_object/web_object.rb', line 9326

def window(
    title  = '',
    width  = 1024,
    height =  800,
    hash   = {}
  )
  return Cyberweb.window(
    title,
    width,
    height,
    hash
  )
end

#write_the_last_tag_used(last_tag_used = last_tag_used? ) ⇒ Object

#

write_the_last_tag_used

#


1919
1920
1921
1922
1923
1924
1925
# File 'lib/cyberweb/web_object/web_object.rb', line 1919

def write_the_last_tag_used(
    last_tag_used = last_tag_used?
  )
  append_onto_the_body_tag_nl(
    last_tag_used.first.to_s
  )
end