Class: Cyberweb::Base
Overview
Direct Known Subclasses
AutogenerateDropShadowRules, Booklet, Calculator, Controller, CopyAllImagesFromThisWebpageToTheCurrentWorkingDirectory, CorrectImageEntriesInHtmlFile, CreateColouredTags, CreateStandaloneHtmlPage, CssManager, Cybersprawl::SimpleForum, DownloadAllImagesFromThisWebsite, DownloadBalloonCss, FixIncorrectLinksToLocallyExistingImagesInThisFile, FotoGallery, Generator::Generator, HtmlTemplate, HtmlToCyberwebConverter, HyperlinkAllImagesFrom, Objectified::HtmlTags::WebObject, ObtainCssRules, ObtainFilesAndDirectoriesFromThisPath, RemoveThisImageFromThatWebpage, SimpleIndex, TryToMapThisInputToThatLocalImage, Vue, WebrickWrapper
Constant Summary
collapse
- NAMESPACE =
#
NAMESPACE
NAMESPACE is a legacy constant - it is not deprecated, but downstream classes should ideally use the method called .infer_the_namespace() instead.
#
inspect
- HOME_DIRECTORY_OF_THE_USER_X =
#
HOME_DIRECTORY_OF_THE_USER_X
The method used here is defined at cyberweb/constants/user_x.rb.
#
Cyberweb.home_x_dir?
Instance Method Summary
collapse
#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, #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, #string_remote_image, #today?, #try_to_require_rack, #try_to_require_the_open_gem, #write_what_into
#content_type_is_html, #content_type_is_jpeg, #content_type_is_json, #content_type_is_plain_text
#append_to_the_commandline_arguments, #commandline_arguments?, #first_argument?, #parse_these_commandline_arguments, #second_argument?, #set_commandline_arguments
#all_html_colours, #lightgreen, #rev, #sdir, #sfancy, #sfile, #simp, #steelblue, #tomato
Constructor Details
#initialize(commandline_arguments = ARGV) ⇒ Base
52
53
54
55
56
57
58
59
|
# File 'lib/cyberweb/base/base.rb', line 52
def initialize(
commandline_arguments = ARGV
)
reset
set_commandline_arguments(
commandline_arguments
)
end
|
Instance Method Details
#be_verbose ⇒ Object
Also known as:
set_be_verbose
#
be_verbose
Whether we will be verbose or not.
#
157
158
159
|
# File 'lib/cyberweb/base/base.rb', line 157
def be_verbose
@internal_hash[:be_verbose] = true
end
|
#be_verbose? ⇒ Boolean
164
165
166
|
# File 'lib/cyberweb/base/base.rb', line 164
def be_verbose?
@internal_hash[:be_verbose]
end
|
#cascading_style_sheets_directory? ⇒ Boolean
#
cascading_style_sheets_directory?
#
439
440
441
|
# File 'lib/cyberweb/base/base.rb', line 439
def cascading_style_sheets_directory?
"#{project_base_directory?}cascading_style_sheets/"
end
|
103
104
105
|
# File 'lib/cyberweb/base/base.rb', line 103
def cd(i)
Dir.chdir(i) if File.directory?(i)
end
|
#commandline_mode? ⇒ Boolean
Also known as:
commandline?
180
181
182
|
# File 'lib/cyberweb/base/base.rb', line 180
def commandline_mode?
@internal_hash[:mode] == :commandline
end
|
#copyright? ⇒ Boolean
Also known as:
copyright
#
copyright?
To display a copyright symbol + text you can use this method.
#
79
80
81
|
# File 'lib/cyberweb/base/base.rb', line 79
def copyright?
COPYRIGHT_SYMBOL
end
|
325
326
327
|
# File 'lib/cyberweb/base/base.rb', line 325
def (i = '')
return Cyberweb.(i)
end
|
#delete_directory(i) ⇒ Object
Also known as:
remove_directory
#
delete_directory
Consistently use this method if you wish to remove a directory.
#
132
133
134
135
136
|
# File 'lib/cyberweb/base/base.rb', line 132
def delete_directory(i)
if File.directory? i FileUtils.rm_rf(i) unless i.start_with? '/'
end
end
|
#do_toggle ⇒ Object
Also known as:
toggle
#
do_toggle
This method can be used to quickly change between the two main modi.
#
313
314
315
316
317
318
319
320
|
# File 'lib/cyberweb/base/base.rb', line 313
def do_toggle
case @internal_hash[:mode]
when :www
@internal_hash[:mode] = :commandline
else
@internal_hash[:mode] = :www
end
end
|
#
e (e tag)
This is the method e, short for “echo”, aka output. There are two basic means for output, depending on the main “modus operandi”.
(1) the normal e() is just a wrapper for “puts”, which is to be used
on the commandline.
(2) the modified use for the www (such as in .cgi scripts), where
e is a wrapper over sbr, combining a <span> tag and then a
newline (via <br>).
#
267
268
269
270
271
272
273
|
# File 'lib/cyberweb/base/base.rb', line 267
def e(*args)
if commandline_mode?
puts args.first else
ee Cyberweb.string_sbr(args) end
end
|
#echo_raw(i = '') ⇒ Object
Also known as:
er, re
#
echo_raw
This is a simplified echo-method, in case e() does not work.
#
494
495
496
|
# File 'lib/cyberweb/base/base.rb', line 494
def echo_raw(i = '')
puts i
end
|
#full_path_to_image_directory? ⇒ Boolean
Also known as:
path_to_the_main_image_directory?, path_to_the_image_directory?, prepend_path_to_the_images?
#
full_path_to_image_directory?
Convenience method towards the images.
#
247
248
249
|
# File 'lib/cyberweb/base/base.rb', line 247
def full_path_to_image_directory?
Cyberweb.path_to_images?
end
|
#html_image(i) ⇒ Object
Also known as:
html_img
#
html_image
Wrapper method towards the objectified <img> HTML tag.
#
#htmlentities(i) ⇒ Object
Also known as:
html_ent
195
196
197
|
# File 'lib/cyberweb/base/base.rb', line 195
def htmlentities(i)
return Cyberweb.htmlentities(i)
end
|
#img_dir? ⇒ Boolean
#
img_dir?
This method refers to a local directory where images are kept.
This is hardcoded for my home system, so it is fairly useless for other people.
#
#infer_the_namespace ⇒ Object
#
infer_the_namespace
This will assume the true namespace from the inspectable name.
#
204
205
206
207
208
209
210
211
212
213
214
215
216
217
|
# File 'lib/cyberweb/base/base.rb', line 204
def infer_the_namespace
_ = inspect
if _.include?(':0x')
_ = _.split(':0x').first.to_s.strip
end
_ = _.to_s.delete('<')
if _.include? ' '
_ = _.split(' ').first.delete('#')
if _.include? ':'
_ = _.split(':')[0 .. -2].reject {|entry| entry.empty? }.join('::')
end
end
@internal_hash[:namespace] = _.delete('#') end
|
#initialize_the_configuration ⇒ Object
Also known as:
load_the_configuration
#
initialize_the_configuration
#
#is_a_file?(i) ⇒ Boolean
502
503
504
|
# File 'lib/cyberweb/base/base.rb', line 502
def is_a_file?(i)
File.file?(i)
end
|
#is_a_video_file?(i) ⇒ Boolean
#is_an_image_file?(i) ⇒ Boolean
Also known as:
is_an_image?, is_image?
#
is_an_image_file?
This method will return true if the input is an image, otherwise it will yield false.
#
#is_on_roebe? ⇒ Boolean
Also known as:
on_roebe?, roebe_system?
#last_tag_used? ⇒ Boolean
#last_tag_used_first_element? ⇒ Boolean
#
last_tag_used_first_element?
#
378
379
380
|
# File 'lib/cyberweb/base/base.rb', line 378
def last_tag_used_first_element?
last_tag_used?.first.to_s
end
|
#last_tag_used_id? ⇒ Boolean
385
386
387
388
|
# File 'lib/cyberweb/base/base.rb', line 385
def last_tag_used_id?
_ = last_tag_used?
return _.last
end
|
#mkdir(i) ⇒ Object
Also known as:
create_directory
#
mkdir (mkdir tag)
This method can be used to create a directory.
#
112
113
114
115
116
117
118
|
# File 'lib/cyberweb/base/base.rb', line 112
def mkdir(i)
begin
FileUtils.mkdir_p(i)
rescue Errno::EACCES e "Permission denied for the directory `#{i}`."
end
end
|
#mode? ⇒ Boolean
297
298
299
|
# File 'lib/cyberweb/base/base.rb', line 297
def mode?
@internal_hash[:mode]
end
|
#namespace? ⇒ Boolean
222
223
224
|
# File 'lib/cyberweb/base/base.rb', line 222
def namespace?
@internal_hash[:namespace]
end
|
#open_in_browser(i) ⇒ Object
472
473
474
475
476
477
478
479
480
|
# File 'lib/cyberweb/base/base.rb', line 472
def open_in_browser(i)
begin
require 'open'
if i.include? ' '
i = '"'+i+'"'
end
Open.in_browser(i)
rescue LoadError; end
end
|
141
142
143
|
# File 'lib/cyberweb/base/base.rb', line 141
def opne(i)
opnn; puts i
end
|
#opnn(namespace = namespace? # NAMESPACE
) ⇒ Object
#
opnn
This method can be used to display which class is responsible for commandline-output.
#
232
233
234
235
236
237
238
239
|
# File 'lib/cyberweb/base/base.rb', line 232
def opnn(
namespace = namespace? )
if namespace.is_a? String namespace = { namespace: namespace }
end
Opn.opn(namespace)
end
|
#
This method is similar to remove_comments_from_this_string() but it will specifically retain “{}” such as in “#smoke_1 {”.
#
335
336
337
338
|
# File 'lib/cyberweb/base/base.rb', line 335
def (i)
use_this_regex = /^\s*#.+[^{]$/ return i.gsub(use_this_regex,'')
end
|
64
65
66
67
68
69
70
71
72
|
# File 'lib/cyberweb/base/base.rb', line 64
def reset
create_the_internal_hash @internal_hash[:mode] = :www
end
|
#return_all_directories ⇒ Object
#
return_all_directories
#
148
149
150
|
# File 'lib/cyberweb/base/base.rb', line 148
def return_all_directories
return Dir['*'].select {|entry| File.directory?(entry) }
end
|
#return_date ⇒ Object
Also known as:
dd_mm_yyyy
#
return_date
This method will return a String such as “20.10.2023”.
#
88
89
90
|
# File 'lib/cyberweb/base/base.rb', line 88
def return_date
::Time.now.strftime '%d.%m.%Y'
end
|
#return_program_name(i = $PROGRAM_NAME) ⇒ Object
#
return_program_name
This method will return the filename. So if you have an URL such as bla/webforum.cgi then this method will simply return the String “webforum.cgi”.
Since as of August 2023 this method here taps into a toplevel-defined method.
#
123
124
125
|
# File 'lib/cyberweb/base/base.rb', line 123
def
RUBY_HEADER
end
|
#server_base_directory? ⇒ Boolean
#
server_base_directory?
#
#set_commandline_mode ⇒ Object
Also known as:
use_commandline_mode
187
188
189
|
# File 'lib/cyberweb/base/base.rb', line 187
def set_commandline_mode
@internal_hash[:mode] = :commandline
end
|
#set_last_tag_used(a, id = '') ⇒ Object
#update_the_image_directory ⇒ Object
#
update_the_image_directory
#
#use_this_relative_directory_for_custom_images? ⇒ Boolean
Also known as:
name_of_img_dir?, default_image_directory?, image_directory?
#
use_this_relative_directory_for_custom_images?
This method will return a string such as “data/images/”.
#
#www_mode? ⇒ Boolean
304
305
306
|
# File 'lib/cyberweb/base/base.rb', line 304
def www_mode?
@internal_hash[:mode] == :www
end
|