Skip to content

Instantly share code, notes, and snippets.

@tuxdna
Created March 25, 2014 06:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tuxdna/9756406 to your computer and use it in GitHub Desktop.
Save tuxdna/9756406 to your computer and use it in GitHub Desktop.
Generate static html for all images in sub-folders
#
# Generate static html for all images in sub-folders
# Author Saleem Ansari<tuxdna@gmail.com>
#
folder = "bootconf-2014-pics"
filetypes = ["jpg", "png"]
rows = (filetypes.map{ |filetype|
(Dir.glob("#{folder}/*/*.#{filetype}").map { | img |
"<tr><td><a name='#{img}' href='#{img}'><img src='#{img}' /></a></td></tr>"
}).sort.join("\n")
}).join("")
HTML = <<EOF
<html>
<head>
<meta http-equiv="Content-Type" content="text/html">
<title>Show images in folder</title>
<style type="text/css">
body {
margin: 0 auto 20px;
padding: 0;
background: #acacac;
text-align: center;
}
td {
padding: 0 0 50px;
text-align: center;
font: 9px sans-serif;
}
table {
width: 100%;
}
img {
display: block;
margin: 20px auto 10px;
max-width: 900px;
outline: none;
}
img:active {
max-width: 100%;
}
a:focus {
outline: none;
}
</style>
</head>
<body>
<table>
#{rows}
</table>
</body>
</html>
EOF
puts HTML
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment