aboutsummaryrefslogtreecommitdiffhomepage
path: root/controllers/views.js
blob: 82d3d00abcd9568566cca71ddd33940205a3873c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
;(function () {
  'use strict'

  var express = require('express')

  var cacheMiddleware = require('../middlewares').cache

  var router = express.Router()

  router.get(/^\/(index)?$/, cacheMiddleware.cache(), getIndex)
  router.get('/partials/:directory/:name', cacheMiddleware.cache(), getPartial)

  // ---------------------------------------------------------------------------

  module.exports = router

  // ---------------------------------------------------------------------------

  function getIndex (req, res) {
    res.render('index')
  }

  function getPartial (req, res) {
    var directory = req.params.directory
    var name = req.params.name

    res.render('partials/' + directory + '/' + name)
  }
})()