Created
March 25, 2014 06:53
-
-
Save tuxdna/9756406 to your computer and use it in GitHub Desktop.
Generate static html for all images in sub-folders
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# 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