Ruby Source Code: common.rb
#!/usr/bin/ruby
#----------------------------------------------------------
# The Web Language Project
# Mark Brautigam
# May-June 2015
# http://www.mixed-up.com/markb/
#----------------------------------------------------------
#----------------------------------------------------
def headers1()
#----------------------------------------------------
print %q(<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<link rel="icon" href="../images/puzzle2.png" />
<link href='http://fonts.googleapis.com/css?family=Share+Tech+Mono' rel='stylesheet' type='text/css'>
<title>Web Programming Languages</title>
<style type='text/css'>
@import "../common.css";
)
end
#----------------------------------------------------
def headers2()
#----------------------------------------------------
print %q(<!DOCTYPE html>
</style>
</head>
<body>
<h1 class='brown'>Web Programming Languages</h1>
<div id="container">
)
end
#----------------------------------------------------
def sidebar()
#----------------------------------------------------
f = File.new("sidebar.html", "r")
contents = f.read
f.close
print contents
end
#----------------------------------------------------
def footers()
#----------------------------------------------------
print %q(
</div>
<div id="footer" class='brown'>
© 2015 · Mark Brautigam
</div>
<script type='text/javascript' src='../scripts/icons.js'></script>
<script type='text/javascript' src='../scripts/whereami.js'></script>
<!-- !3 -->
</body>
</html>
)
end
#----------------------------------------------------
def formHasData (formData)
#----------------------------------------------------
nData = formData.count
for i in (0..nData-1)
if (formData[i].strip() != '')
return true;
end
end
return false;
end
#---------------------------------------------
def sidebarX (language, activity, ext)
#---------------------------------------------
f = File.new("../sidebar/sidebar.html", "r")
sidebar = f.read()
f.close()
hash = "{#" + language + "}";
sidebar = sidebar.sub(hash, " <b>★</b>");
hash = "{#" + activity + "}";
sidebar = sidebar.gsub(hash, " <b>★</b>");
sidebar = sidebar.gsub("{ext}", ext);
sidebar = sidebar.gsub(/\{.*\}/, "");
return sidebar;
end