class RBT::Cookbooks::GenerateHomepage
Constants
- BR
#¶ ↑
BR
¶ ↑#¶ ↑
- LJUST
#¶ ↑
LJUST
¶ ↑#¶ ↑
- USE_THIS_DIRECTORY
#¶ ↑
USE_THIS_DIRECTORY
¶ ↑The individual webpages are stored in a subdirectory within the log-directory.
#¶ ↑
Public Class Methods
[](i = '')
click to toggle source
Public Instance Methods
_(i)
click to toggle source
a( i, optional_arguments = nil )
click to toggle source
#¶ ↑
a¶ ↑
This method essentially creates a <a> href tag.
#¶ ↑
# File lib/rbt/cookbooks/generate_homepage/generate_homepage.rb, line 455 def a( i, optional_arguments = nil ) if optional_arguments result = HtmlTags.a(i, optional_arguments) else result = HtmlTags.a(i) end if result.nil? opne "The result for #{i} is nil." end return result end
br()
click to toggle source
cdiv()
click to toggle source
cookbooks_include_this_program?(i)
click to toggle source
current_time()
click to toggle source
dataset?()
click to toggle source
#¶ ↑
dataset?¶ ↑
#¶ ↑
# File lib/rbt/cookbooks/generate_homepage/generate_homepage.rb, line 216 def dataset? @dataset end
Also aliased as: data?
feedback_where_to_store()
click to toggle source
file_location?()
click to toggle source
generate_a_webpage_for_this_program( program, index )
click to toggle source
#¶ ↑
generate_a_webpage_for_this_program
¶ ↑
#¶ ↑
# File lib/rbt/cookbooks/generate_homepage/generate_homepage.rb, line 230 def generate_a_webpage_for_this_program( program, index ) obtain_dataset_for(program) # ======================================================================= # # Ok now we have the dataset. Start to build up the html page, by # using the data stored in the cookbook-object. # ======================================================================= # program_name = dataset?.program_name? program_version = dataset?.program_version? short_name = dataset?.short_name?.to_s url1 = dataset?.url1? url2 = dataset?.url2? size = dataset?.size? md5sum = dataset?.md5sum? deps = dataset?.deps? extra_information = dataset?.extra_information?.to_s.strip blfs_entry = dataset?.blfs? if extra_information.start_with? '"' extra_information[0,1] = '' end if extra_information.end_with? '"' extra_information.chop! extra_information.strip! end binaries = dataset?.binaries?.join(', ').strip.chop libraries = dataset?.libraries?.join(', ').strip.chop the_program_before = @array_available_programs[index-1] the_next_program_is = @array_available_programs[index+1] opne royalblue( ((index+1).to_s+')').to_s.ljust(6) )+ rev+'Working on the program `'+ slateblue(program.to_s.ljust(LJUST))+ rev+'` next (Version: '+ royalblue(program_version.to_s.rjust(10))+ rev+').' _ '<html>' _ HtmlTags.title(program_name) # ======================================================================= # # Next, define some basic CSS style # ======================================================================= # _ '<style> div.top_navigation { background: #ecedef; margin: 0; padding: 0.3em .5em; border: 1px solid black; } pre { font-size: larger; } </style>' _ '<body style="font-size: 1.2em">' # ======================================================================= # # === The top header # ======================================================================= # _ '<div class="top_navigation">' _ h1(short_name) _ cdiv use_this_name = short_name.to_s.dup if use_this_name.empty? use_this_name = program_name.to_s end _ '<h2>Introduction to '+use_this_name.capitalize+'</h2>' what = @string # ======================================================================= # # We need to save the file somewhere, so determine the name. # ======================================================================= # into = use_this_directory+use_this_name.downcase+'.html' set_file_location(into) # ======================================================================= # # Next add the program description: # ======================================================================= # dataset_as_pre_tag = HtmlTags.pre(dataset?.raw_description?) _ HtmlTags.p(dataset_as_pre_tag,'','','margin-left:2em; width: 70%;') # ======================================================================= # # Show the extra information next. (extra information tag) # ======================================================================= # unless extra_information.empty? _ '<h3>Extra information</h3>' formatted_extra_information = extra_information.gsub(/#{N}/,'<br>') _ HtmlTags.p(formatted_extra_information, '','','margin-left:2.5em' ) end # ======================================================================= # # Next, the "Package Information" subsection follows: # ======================================================================= # _ HtmlTags.h3('Package Information') _ "This program is available at the following URL:#{br}#{br}" _ '<p>' _ a(url1, css_style: 'margin-left:2em; margin-top:1em; padding: 1.5em; border: 2px solid darkblue; border-radius: 15px; font-weight:800; background-color: #f0fff0;')+br+br if url2 _ BR _ 'Additionally, this is most likely another good URL resource:'+br+br _ a(url2, css_style: 'margin-left:2em; font-weight:800;') end _ '</p>' _ '<ul>' _ '<li><p><b>MD5-sum:</b> '+md5sum.to_s+' </p></li>' use_this_size = (size.to_f / 1024 / 1024).round(5).to_s _ '<li><p><b>Download size:</b> '+use_this_size+' MB </p></li>' _ '</ul>' # ======================================================================= # # === Dependencies # # We will next provide a link to the other dependencies. # ======================================================================= # if deps unless deps.empty? _ '<h4>Dependencies for the project <b>'+program_name.to_s+':</h4>' _ p # Paragraph. deps.each {|dependency| _ HtmlTags.span(dependency, style: 'margin-left: 3em') _ ' → ' _ HtmlTags.a(dependency+'.html') _ br } _ '</p>' end end # ======================================================================= # # === BLFS subsection # # We add a link to the remote LFS/BLFS entry, should it exist. # ======================================================================= # unless blfs_entry.empty? first_entry = blfs_entry.first _ '<div style="margin-bottom:2px">' _ '<h4>the LFS/BLFS entry can be seen here:</h4>' _ HtmlTags.a( content: first_entry.to_s, css_style: 'margin-left:3em' ) _ '</div>' end # ======================================================================= # # === Contents # # Add the contents subsection next. # ======================================================================= # _ '<div style="margin-bottom:1em">' _ ' <h3>Content</h3>' unless binaries.to_s.empty? _ ' <b style="margin-left:2em">Installed Programs:</b> '+binaries.to_s+'<br>' end unless libraries.to_s.empty? _ ' <b style="margin-left:2em">Installed Libraries:</b> '+libraries.to_s+'<br>' end # ======================================================================= # # We don't track installed directories as of yet. # ======================================================================= # _ ' <b style="margin-left:2em">Installed Directories: (Not yet implemented)</b><br>' _ '</div>' # ======================================================================= # # Add the next and previous program to the chain. These are links # that the user can click on. # ======================================================================= # begin if the_program_before _ a(the_program_before+'.html') _ ' | ' # Add a separator. end _ a(the_next_program_is+'.html') rescue NoMethodError; end # Do a silent rescue though. _ br+br+'<i>This file was autogenerated at <b>'+current_time+'</b></i>' _ '</body></html>' write_what_into(what, into) reset_string end
generate_all_webpages()
click to toggle source
#¶ ↑
generate_all_webpages
¶ ↑
This method will generate all the various .html webpages.
#¶ ↑
# File lib/rbt/cookbooks/generate_homepage/generate_homepage.rb, line 474 def generate_all_webpages notify_the_user_how_we_will_start # ======================================================================= # # We must create the directory if it does not yet exist. # ======================================================================= # unless File.directory? use_this_directory mkdir(use_this_directory) end # ======================================================================= # # cd into that directory. # ======================================================================= # cd use_this_directory # ======================================================================= # # Ok, next we iterate over all programs: # ======================================================================= # @array_available_programs = available_programs? @array_available_programs.each_with_index {|program, index| generate_a_webpage_for_this_program(program, index) } report_where_there_file_is end
h1(i)
click to toggle source
input?()
click to toggle source
notify_the_user_how_we_will_start()
click to toggle source
#¶ ↑
notify_the_user_how_we_will_start
¶ ↑
#¶ ↑
# File lib/rbt/cookbooks/generate_homepage/generate_homepage.rb, line 154 def notify_the_user_how_we_will_start opne 'Now generating a '+slateblue('LFS-like homepage')+'.' opne 'We will use this directory as our base directory:' opne ' '+sdir(use_this_directory) end
obtain_dataset_for(i)
click to toggle source
#¶ ↑
obtain_dataset_for
¶ ↑
#¶ ↑
# File lib/rbt/cookbooks/generate_homepage/generate_homepage.rb, line 408 def obtain_dataset_for(i) sanitize_cookbook = action(:SanitizeCookbook, i) { :fast } opne "Obtaining information from the file "+ "#{sfile(sanitize_cookbook.file)}#{rev}." #sanitize_cookbook.initialize_raw_cookbook(i) #sanitize_cookbook.sync_everything @dataset = sanitize_cookbook end
p()
click to toggle source
report_where_there_file_is(i = @file_location)
click to toggle source
reset()
click to toggle source
reset_string()
click to toggle source
return_day_month_year()
click to toggle source
return_hours_minutes_seconds()
click to toggle source
run()
click to toggle source
#¶ ↑
run (run tag)¶ ↑
#¶ ↑
# File lib/rbt/cookbooks/generate_homepage/generate_homepage.rb, line 499 def run # ======================================================================= # # The next if-clause is valid for when the user did input a program # name such as 'ruby'. In that case we will NOT generate all # webpages. # ======================================================================= # if input? and cookbooks_include_this_program?(input?.sub(/\.yml$/,'')) _ = "#{File.dirname(file_location?)}/#{input?}.html" set_xorg_buffer(_) opne "#{rev}Next opening `#{simp(_)}#{rev}` in a browser tab." open_in_browser(_) # We open it in the browser as well. else generate_all_webpages # This will generate all the various individual .html files. end end
set_file_location(i = use_this_directory+'ruby.html')
click to toggle source
set_input(i = '')
click to toggle source
#¶ ↑
set_input
¶ ↑
#¶ ↑
# File lib/rbt/cookbooks/generate_homepage/generate_homepage.rb, line 104 def set_input(i = '') i = i.first if i.is_a? Array i = i.to_s.dup if i case i # case tag # ======================================================================= # # === genhomepage --l? # ======================================================================= # when '--location?', '--location', '--l?', 'LOCATION', 'WHERE' feedback_where_to_store exit # ======================================================================= # # === genhomepage --help # ======================================================================= # when /^-?-?help$/i show_help exit end @input = i end
show_help()
click to toggle source
#¶ ↑
show_help
¶ ↑
#¶ ↑
# File lib/rbt/cookbooks/generate_homepage/generate_homepage.rb, line 89 def show_help e e 'Currently this class responds to these instructions:' e ecomment ' ['+sfancy('name')+'] # Give the name of the program '\ 'you wish to open in a browser tab.' e ecomment ' # No argument - this is the default way to invoke it.' ecomment ' # In this case, we will generate a lot of .html files.' e end
use_this_directory?()
click to toggle source
#¶ ↑
use_this_directory
?¶ ↑
#¶ ↑
# File lib/rbt/cookbooks/generate_homepage/generate_homepage.rb, line 146 def use_this_directory? USE_THIS_DIRECTORY end
Also aliased as: use_this_directory, store_where?