   express = require 'express'
   app = express()
   app.locals.base = base
+  app.locals.templateVars = {base: base}
   app.get '/random', serveRandomImage
   app.get '/id/:id', serveImageByID
   app.get '/image/:filename', serveImageByName

# Request handlers

links = """
<div class="links"><a href="/random">Random</a> - <a href="/date/2015">2015</a> - <a href="/date/2016">2016</a> - <a href="/tag">Tags by freq</a> -
<a href="/tag?sort=alpha">Tags by alpha</a> - <a href="/nonjournal">Nonjournal</a> - <a href="/journal">Journal</a></div>
"""
header = """
<style type="text/css">body { font-family: Arial, sans-serif; }
ul li { margin-bottom: 0.5em }
.links { font-size: large; margin-top: 1em; margin-bottom: 1em; clear: both }</style>

    res.header "Cache-Control", "no-cache, no-store, must-revalidate"
    res.header "Pragma", "no-cache"
    res.header "Expires", 0
    s = header(req.app.locals.templateVars) + formatList(req, list) + footer(req.app.locals.templateVars) + masonry
    res.send s
exports.serveRandomImage = serveRandomImage

showTextList = (req, res, filter) ->
  getSketches(SKETCH_DIR).then (sketches) ->
    list = sketches.filter(filter)
    res.send header(req.app.locals.templateVars) + '<ul>' + list.map((filename) ->
      url = req.app.base + '/image/' + encodeURIComponent(filename)
      return '<li><a href="' + url + '">View</a> - ' + linkTags(filename) + '</li>'
    ).join('') + '</ul>' + footer(req.app.locals.templateVars)
exports.showTextList = showTextList
  
listNonjournalSketches = (req, res) ->
