25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

49 lines
904 B

  1. #!/usr/bin/node
  2. const fs = require('fs');
  3. var DIR = process.argv[2];
  4. if(!DIR) {
  5. console.log(`### ERROR! No directory provided!`);
  6. console.log(`Usage: node gallery.js {directory REQUIRED}`);
  7. process.exit(1);
  8. }
  9. outHtml = `
  10. <head><title>Gallery</title></head>
  11. <style>
  12. body {
  13. font-family: 'Segoe UI', Arial;
  14. font-size: 15px;
  15. background-color: #eee;
  16. }
  17. img {
  18. display: block;
  19. width: 100%;
  20. height: auto;
  21. }
  22. .imgbox {
  23. display: inline-block;
  24. margin: 0.5rem;
  25. padding: 0.5rem;
  26. text-align: center;
  27. width: 12rem;
  28. word-wrap: break-word;
  29. background-color: #fff;
  30. }
  31. </style>
  32. <body>
  33. `
  34. var files = fs.readdirSync(DIR);
  35. for(let f of files) {
  36. if(!f.endsWith(".svg")) continue;
  37. //console.log(f);
  38. //<br/><span>${f}<span><br/>
  39. outHtml += `<div class="imgbox"><img src="${f}"/><span>${f}</span></div>\n`
  40. }
  41. outHtml += "</body></html>"
  42. fs.writeFileSync(DIR + '/index.html', outHtml);