Commit | Line | Data |
---|---|---|
1d184b4c BA |
1 | var express = require('express'); |
2 | var router = express.Router(); | |
15c1295a | 3 | var createError = require('http-errors'); |
1d184b4c BA |
4 | |
5 | const Variants = require("../variants"); | |
6 | ||
7 | // Home | |
8 | router.get('/', function(req, res, next) { | |
9 | res.render('index', { | |
982d5b66 | 10 | title: 'club', |
1d184b4c BA |
11 | variantArray: Variants, //JSON.stringify(Variants) |
12 | }); | |
13 | }); | |
14 | ||
15 | // Variant | |
15c1295a | 16 | router.get("/:vname([a-zA-Z0-9]+)", (req,res,next) => { |
1d184b4c | 17 | const vname = req.params["vname"]; |
15c1295a BA |
18 | if (!Variants.some(v => { return (v.name == vname); })) |
19 | return next(createError(404)); | |
1d184b4c BA |
20 | res.render('variant', { |
21 | title: vname + ' Variant', | |
22 | variant: vname, | |
23 | }); | |
24 | }); | |
25 | ||
26 | // Load a rules page (AJAX) | |
27 | router.get("/rules/:variant([a-zA-Z0-9]+)", (req,res) => { | |
28 | res.render("rules/" + req.params["variant"]); | |
29 | }); | |
30 | ||
31 | module.exports = router; |