31 lines
624 B
Nim
31 lines
624 B
Nim
import emerald, os, streams
|
|
|
|
proc getItems(): seq[string] =
|
|
result = newSeq[string]()
|
|
|
|
for kind, path in walkDir("."):
|
|
result.add(path)
|
|
|
|
proc indexTemplate(files: seq[string]) {.html_templ.} =
|
|
html(lang = "en"):
|
|
head:
|
|
title: "Image Archive"
|
|
|
|
body:
|
|
h1: "Image Archive"
|
|
|
|
for path in files.items():
|
|
a(href=path):
|
|
img(src="thumbs/" & path & ".thumb.png")
|
|
|
|
when isMainModule:
|
|
setCurrentDir "/home/xena/pictures/derpi"
|
|
|
|
var
|
|
files = getItems()
|
|
fs = newFileStream("index.html", fmWrite)
|
|
myTempl = newIndexTemplate()
|
|
|
|
myTempl.files = files
|
|
myTempl.render(fs)
|