class Cookbooks::GenerateHomepage
Constants
- BR
#¶ ↑
BR¶ ↑
#¶ ↑
- LJUST
#¶ ↑
LJUST¶ ↑
#¶ ↑
- USE_THIS_DIRECTORY
#¶ ↑
USE_THIS_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¶ ↑
#¶ ↑
# File lib/cookbooks/utility_scripts/generate_homepage/generate_homepage.rb, line 215 def a(i, optional_arguments = nil) if optional_arguments result = HtmlTags.a(i, optional_arguments) else result = HtmlTags.a(i) end if result.nil? opnn; e 'The result for '+i.to_s+' 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/cookbooks/utility_scripts/generate_homepage/generate_homepage.rb, line 230 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/cookbooks/utility_scripts/generate_homepage/generate_homepage.rb, line 251 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. # ======================================================================= # program_name = dataset?.program_name? program_version = dataset?.program_version? short_name = dataset?.real_short_name? url1 = dataset?.url1? url2 = dataset?.url2? size = dataset?.size? md5sum = dataset?.md5sum deps = dataset?.deps? extra_information = dataset?.extra_information?.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] opnn; e 'Working on the program `'+simp(program.to_s.ljust(LJUST))+ '` next (Version: '+simp(program_version.to_s.rjust(10))+').' _ '<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>' # ======================================================================= # # === The top header # ======================================================================= # _ '<div class="top_navigation">' _ HtmlTags.h1(short_name) _ cdiv _ '<h2>Introduction to '+short_name.capitalize+'</h2>' what = @string into = use_this_directory+short_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') # ======================================================================= # # 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: 1px solid darkblue; 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>' _ '<li><p><b>Download size:</b> '+(size.to_f / 1024 / 1024).to_s+' MB </p></li>' _ '</ul>' # ======================================================================= # # === Dependencies # # We will next provide a link to the other dependencies. # ======================================================================= # unless deps.empty? _ '<h4>Dependencies for the project <b>'+program_name+':</h4>' _ p # Paragraph. deps.each {|dependency| _ HtmlTags.span(dependency, style: 'margin-left: 3em') _ ' -> ' _ HtmlTags.a(dependency+'.html') _ br } _ '</p>' end # ======================================================================= # # === BLFS subsection # ======================================================================= # unless blfs_entry.empty? _ '<div style="margin-bottom:2px">' _ '<h4>A LFS/BLFS entry can be seen here:</h4>' _ HtmlTags.a(blfs_entry.first, 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/cookbooks/utility_scripts/generate_homepage/generate_homepage.rb, line 404 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. # ======================================================================= # opnn; cd use_this_directory # ======================================================================= # # Ok, next we iterate over all programs: # ======================================================================= # @array_available_programs = Cookbooks.available_programs @array_available_programs.each_with_index {|program, index| generate_a_webpage_for_this_program(program, index) } report_where_there_file_is end
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/cookbooks/utility_scripts/generate_homepage/generate_homepage.rb, line 144 def notify_the_user_how_we_will_start opnn; e 'Now generating a '+slateblue('LFS-like homepage')+'.' opnn; e 'We will use this directory as our base directory:' opnn; e ' '+sdir(use_this_directory) end
obtain_dataset_for(i)
click to toggle source
opnn()
click to toggle source
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/cookbooks/utility_scripts/generate_homepage/run.rb, line 14 def run # ======================================================================= # # The next if-clause is valid for when the user did input a program # name such as 'ruby'. # ======================================================================= # if input? and cookbooks_include_this_program?(input?.sub(/\.yml$/,'')) _ = "#{File.dirname(file_location?)}/#{input?}.html" XorgBuffer[_] if Object.const_defined? :XorgBuffer if Object.const_defined? :OpenInBrowser opnn; e "Next opening `#{simp(_)}` in a browser tab." OpenInBrowser[_] # We open it in the browser as well. end 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/cookbooks/utility_scripts/generate_homepage/generate_homepage.rb, line 89 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','HELP' show_help exit end @input = i end
show_help()
click to toggle source
#¶ ↑
#show_help¶ ↑
#¶ ↑
# File lib/cookbooks/utility_scripts/generate_homepage/generate_homepage.rb, line 74 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/cookbooks/utility_scripts/generate_homepage/generate_homepage.rb, line 136 def use_this_directory? USE_THIS_DIRECTORY end
Also aliased as: use_this_directory, store_where?