Class: Cyberweb::Booklet
- Defined in:
- lib/cyberweb/utility_scripts/booklet/booklet.rb
Overview
Cyberweb::Booklet
Constant Summary
Constants inherited from Base
Cyberweb::Base::HOME_DIRECTORY_OF_THE_USER_X, Cyberweb::Base::NAMESPACE
Class Method Summary collapse
-
.[](i = ARGV) ⇒ Object
# === Cyberweb::Booklet[] ========================================================================= #.
Instance Method Summary collapse
-
#create_a_booklet_from_these_image_files(i) ⇒ Object
# === create_a_booklet_from_these_image_files ========================================================================= #.
-
#html_template(i) ⇒ Object
# === html_template ========================================================================= #.
-
#initialize(i = ARGV, run_already = true) ⇒ Booklet
constructor
# === initialize ========================================================================= #.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#run ⇒ Object
# === run (run tag) ========================================================================= #.
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 Cyberweb::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 Cyberweb::BaseModule::ContentType
#content_type_is_html, #content_type_is_jpeg, #content_type_is_json, #content_type_is_plain_text
Methods included from Cyberweb::BaseModule::CommandlineArguments
#append_to_the_commandline_arguments, #commandline_arguments?, #first_argument?, #parse_these_commandline_arguments, #second_argument?, #set_commandline_arguments
Methods included from Cyberweb::BaseModule::Colours
#all_html_colours, #lightgreen, #rev, #sdir, #sfancy, #sfile, #simp, #steelblue, #tomato
Constructor Details
Class Method Details
Instance Method Details
#create_a_booklet_from_these_image_files(i) ⇒ Object
#
create_a_booklet_from_these_image_files
#
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/cyberweb/utility_scripts/booklet/booklet.rb', line 90 def create_a_booklet_from_these_image_files(i) first = i.first first = File.basename(first) _ = ' <div id="this_div_shows_the_image" style="visibility: none; top: 0.25em; left: 40%; float: right;"> </div> <script> var div_target = document.getElementById("this_div_shows_the_image") </script> '.dup i.each_with_index {|entry, index| index += 1 _ << HtmlTags.img( File.basename(entry), css_style: 'width: 1200px; margin-bottom: 4px; '\ 'border: 1px solid black; border-radius: 12px', id: 'image_'+index.to_s ) _ << "<br>\n" } _ = html_template(_) write_what_into(_, 'index.html') end |
#html_template(i) ⇒ Object
#
html_template
#
77 78 79 80 81 82 83 84 85 |
# File 'lib/cyberweb/utility_scripts/booklet/booklet.rb', line 77 def html_template( i ) return Cyberweb.html_template {{ title: File.dirname(Dir.pwd).tr('_',' '), body: i, use_jquery: false }} end |
#reset ⇒ Object
#
reset (reset tag)
#
37 38 39 40 |
# File 'lib/cyberweb/utility_scripts/booklet/booklet.rb', line 37 def reset super() infer_the_namespace end |
#run ⇒ Object
#
run (run tag)
#
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/cyberweb/utility_scripts/booklet/booklet.rb', line 45 def run _ = first_argument?.to_s if _ and !_.empty? and File.directory?(_) e 'Creating a booklet next from this directory:' e e " #{sdir(_)}" e all_image_files = rds( Dir[_+'/*'].select {|entry| is_an_image_file?(entry) } ) # ===================================================================== # # Next we must sort the Array: # ===================================================================== # all_image_files = all_image_files.sort_by {|entry| entry = File.basename(entry) number = entry.scan(/(\d+)/) number = number.flatten.first number.to_i } e 'A total of '+all_image_files.size.to_s+' images were found.' create_a_booklet_from_these_image_files(all_image_files) else e 'Please supply an existing directory, from which all image' e 'files will be taken, to then create a booklet.' end end |