1 // (any) variant page (with room, games, problems ...)
3 let router
= require("express").Router();
4 const createError
= require('http-errors');
5 const VariantModel
= require("../models/Variant");
6 const selectLanguage
= require("../utils/language.js");
7 const access
= require("../utils/access");
9 router
.get("/:vname([a-zA-Z0-9]+)", (req
,res
,next
) => {
10 const vname
= req
.params
["vname"];
11 VariantModel
.getByName(vname
, (err
,variant
) => {
15 return next(createError(404));
16 res
.render('variant', {
17 title: vname
+ ' Variant',
18 variant: variant
, //the variant ID might also be useful
19 lang: selectLanguage(req
, res
),
24 // Load a rules page (AJAX)
25 router
.get("/rules/:vname([a-zA-Z0-9]+)", access
.ajax
, (req
,res
) => {
26 const lang
= selectLanguage(req
, res
);
27 res
.render("rules/" + req
.params
["vname"] + "/" + lang
);
30 module
.exports
= router
;