tabref.rb
· 1.0 KiB · Ruby
Raw
#!/usr/bin/env ruby
require "cgi"
cgi = CGI.new
puts "Content-Type: text/html"
puts ""
# HTML structure
divider = "<hr>\n\n"
html_head = <<-EOF
<!DOCTYPE html>
<html lang="en">
<head>
<title>guitar tab quick ref</title>
<meta name="author" content="kat, girl on the moon">
<meta name="description" content="why do you look so blue?">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="../assets/main.css">
</head>
EOF
html_header = <<-EOF
<header id="title-block-header">
<h1 id="title p-name">guitar tab quick ref :D</h1>
</header>
EOF
# display HTML content
puts "<main class=\"h-entry\">"
puts "#{html_head}"
puts "#{html_header}"
files = Dir["/home/kat/Documents/Git/-mine/tabref/tabs/*.txt"].each do |tab|
fname = "#{File.basename(tab)}"
fcontent = "#{File.read(tab)}"
html_body = <<-EOF
<h2 id="#{fname}">"#{fname}" (<a href=\"##{fname}\">link</a>)</h2>
<pre>"#{fcontent}"</pre>
<hr>
EOF
puts "#{html_body}"
end
puts "</main>"
| 1 | #!/usr/bin/env ruby |
| 2 | |
| 3 | require "cgi" |
| 4 | cgi = CGI.new |
| 5 | |
| 6 | puts "Content-Type: text/html" |
| 7 | puts "" |
| 8 | |
| 9 | # HTML structure |
| 10 | |
| 11 | divider = "<hr>\n\n" |
| 12 | |
| 13 | html_head = <<-EOF |
| 14 | <!DOCTYPE html> |
| 15 | <html lang="en"> |
| 16 | <head> |
| 17 | <title>guitar tab quick ref</title> |
| 18 | |
| 19 | <meta name="author" content="kat, girl on the moon"> |
| 20 | <meta name="description" content="why do you look so blue?"> |
| 21 | |
| 22 | <meta charset="UTF-8"> |
| 23 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 24 | |
| 25 | <link rel="stylesheet" href="../assets/main.css"> |
| 26 | </head> |
| 27 | EOF |
| 28 | |
| 29 | html_header = <<-EOF |
| 30 | <header id="title-block-header"> |
| 31 | <h1 id="title p-name">guitar tab quick ref :D</h1> |
| 32 | </header> |
| 33 | EOF |
| 34 | |
| 35 | # display HTML content |
| 36 | |
| 37 | puts "<main class=\"h-entry\">" |
| 38 | puts "#{html_head}" |
| 39 | puts "#{html_header}" |
| 40 | |
| 41 | files = Dir["/home/kat/Documents/Git/-mine/tabref/tabs/*.txt"].each do |tab| |
| 42 | fname = "#{File.basename(tab)}" |
| 43 | fcontent = "#{File.read(tab)}" |
| 44 | |
| 45 | html_body = <<-EOF |
| 46 | <h2 id="#{fname}">"#{fname}" (<a href=\"##{fname}\">link</a>)</h2> |
| 47 | |
| 48 | <pre>"#{fcontent}"</pre> |
| 49 | |
| 50 | <hr> |
| 51 | EOF |
| 52 | puts "#{html_body}" |
| 53 | end |
| 54 | |
| 55 | puts "</main>" |