<commit_before>"use strict";

let express = require('express'),
    passport = require('passport'),
    moment = require('moment'),
    queries = require('../server/queries'),
    xml = require('../server/xml'),
    router = express.Router();

router.get('/', function (req, res, next) {
  return res.render('pages/index', {
    username: req.user ? req.user.username : null
  });
});

router.get('/about', function (req, res, next) {
  return res.render('pages/about', {
    username: req.user ? req.user.username : null
  });
});

router.get('/404', function (req, res, next) {
  return res.render('pages/404', {
    username: req.user ? req.user.username : null
  });
});

router.get('/500', function (req, res, next) {
  return res.render('pages/500', {
    username: req.user ? req.user.username : null
  });
});

router.get('/faq', function (req, res, next) {
  return res.render('pages/faq', {
    username: req.user ? req.user.username : null
  });
});

router.get('/news', function (req, res, next) {
  return res.render('pages/news', {
    username: req.user ? req.user.username : null
  });
});

router.get('/contact', function (req, res, next) {
  return res.render('pages/contact', {
    username: req.user ? req.user.username : null
  });
});

router.get('/privacypolicy', function (req, res, next) {
  return res.render('pages/privacypolicy', {
    username: req.user ? req.user.username : null
  });
});

router.get('/tos', function (req, res, next) {
  return res.render('pages/tos', {
    username: req.user ? req.user.username : null
  });
});

router.get('/upload', isLoggedIn, function (req, res, next) {
  return res.render('pages/upload', {
    username: req.user ? req.user.username : null,
    title: res.locals.title,
    author: res.locals.author,
    genre: res.locals.genre,
    lines: res.locals.lines,
    poem_check: res.locals.poem_check
  });
});

router.get('/encodesubmission', isLoggedIn, function (req, res, next) {
  return res.render('pages/encodesubmission', {
    username: req.user ? req.user.username : null
  });
});

router.get('/compare/:poem_id/:type_1/:version_1/:type_2/:version_2', isLoggedIn, queries.getEncodingsForCompare, function (req, res, next) {
  return res.render('pages/compare', {
    username: req.user ? req.user.username : null,
    encodings: res.locals.encodings,
    poem_id: req.params.poem_id
  });
});

router.get('/poem/:id', isLoggedIn, queries.getPoem, queries.getEncodingsByPoem, function (req, res, next) {
  return res.render('pages/poem', {
    moment: moment,
    username: req.user ? req.user.username : null,
    poem: res.locals.poem,
    encodings: res.locals.encodings
  });
});

router.get('/poem/:poem_id/encoding/:encoded_id', isLoggedIn, queries.getEncoding, function (req, res, next) {
  return res.render('pages/userencoding', {
    moment: moment,
    username: req.user ? req.user.username : null,
    encoding: res.locals.poemcoding
  });
});

router.get('/search', isLoggedIn, queries.searchPoems, function (req, res, next) {
  let search = req.query.q || "",
      total = parseInt(res.locals.poems.total),
      page = parseInt(res.locals.poems.page),
      pageSize = parseInt(res.locals.poems.pageSize);
  let totalPages = Math.ceil(total/pageSize);
  let pageBottom = page - 3 > 0 ? page - 3 : 1,
      pageTop = page + 7 > totalPages ? totalPages : page + 7;
  return res.render('pages/search', {
    moment: moment,<commit_msg>Fixed search again<commit_after>"use strict";

let express = require('express'),
    passport = require('passport'),
    moment = require('moment'),
    queries = require('../server/queries'),
    xml = require('../server/xml'),
    router = express.Router();

router.get('/', function (req, res, next) {
  return res.render('pages/index', {
    username: req.user ? req.user.username : null
  });
});

router.get('/about', function (req, res, next) {
  return res.render('pages/about', {
    username: req.user ? req.user.username : null
  });
});

router.get('/404', function (req, res, next) {
  return res.render('pages/404', {
    username: req.user ? req.user.username : null
  });
});

router.get('/500', function (req, res, next) {
  return res.render('pages/500', {
    username: req.user ? req.user.username : null
  });
});

router.get('/faq', function (req, res, next) {
  return res.render('pages/faq', {
    username: req.user ? req.user.username : null
  });
});

router.get('/news', function (req, res, next) {
  return res.render('pages/news', {
    username: req.user ? req.user.username : null
  });
});

router.get('/contact', function (req, res, next) {
  return res.render('pages/contact', {
    username: req.user ? req.user.username : null
  });
});

router.get('/privacypolicy', function (req, res, next) {
  return res.render('pages/privacypolicy', {
    username: req.user ? req.user.username : null
  });
});

router.get('/tos', function (req, res, next) {
  return res.render('pages/tos', {
    username: req.user ? req.user.username : null
  });
});

router.get('/upload', isLoggedIn, function (req, res, next) {
  return res.render('pages/upload', {
    username: req.user ? req.user.username : null,
    title: res.locals.title,
    author: res.locals.author,
    genre: res.locals.genre,
    lines: res.locals.lines,
    poem_check: res.locals.poem_check
  });
});

router.get('/encodesubmission', isLoggedIn, function (req, res, next) {
  return res.render('pages/encodesubmission', {
    username: req.user ? req.user.username : null
  });
});

router.get('/compare/:poem_id/:type_1/:version_1/:type_2/:version_2', isLoggedIn, queries.getEncodingsForCompare, function (req, res, next) {
  return res.render('pages/compare', {
    username: req.user ? req.user.username : null,
    encodings: res.locals.encodings,
    poem_id: req.params.poem_id
  });
});

router.get('/poem/:id', isLoggedIn, queries.getPoem, queries.getEncodingsByPoem, function (req, res, next) {
  return res.render('pages/poem', {
    moment: moment,
    username: req.user ? req.user.username : null,
    poem: res.locals.poem,
    encodings: res.locals.encodings
  });
});

router.get('/poem/:poem_id/encoding/:encoded_id', isLoggedIn, queries.getEncoding, function (req, res, next) {
  return res.render('pages/userencoding', {
    moment: moment,
    username: req.user ? req.user.username : null,
    encoding: res.locals.poemcoding
  });
});

router.get('/search', isLoggedIn, queries.searchPoems, function (req, res, next) {
  let search = req.query.q || "",
      total = parseInt(res.locals.poems.total),
      page = parseInt(res.locals.poems.page),
      pageSize = parseInt(res.locals.poems.pageSize);
  let totalPages = total > 0 ? Math.ceil(total/pageSize) : 1;
  let pageBottom = page - 3 > 0 ? page - 3 : 1,
      pageTop = page + 7 > totalPages ? totalPages : page + 7;
  return res.render('pages/search', {
    moment: moment,
{'fraction_non_alphanumeric': 0.1792411687745312, 'fraction_numerical': 0.006687018461985754, 'mean_word_length': 3.608171466845278, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2525925', 'n_tokens_mistral': 2374, 'n_tokens_neox': 2371, 'n_words': 484}