<commit_before>var validator = require('validator');
var moment = require('moment');
moment.locale('de');

var updateBrowser = function (req, res, next, force) {
  return ThemeService.view(req, 'views/fallback/browser.jade', res, {force: force, host: req.host, url: req.path, useragent: req.useragent, title: 'Ihr Browser wird nicht unterstützt' });
}

var fallbackHome = function (req, res, next, force, showLegacyToast) {
  sails.log.debug("fallbackHome");
  var about = null, goals = null;
  Content.find({name:'about'}).exec(function found(err, results) {
    if(UtilityService.isDefined(results) && UtilityService.isDefined(results[0]) && UtilityService.isDefined(results[0].content)) about = results[0].content;
    Content.find({name:'goals'}).exec(function found(err, results) {
      if(UtilityService.isDefined(results) && UtilityService.isDefined(results[0]) && UtilityService.isDefined(results[0].content)) goals = results[0].content;
      return ThemeService.view(req, 'views/fallback/home/content.jade', res, {showLegacyToast: showLegacyToast, force: force, host: req.host, url: req.path, about: about, goals: goals, useragent: req.useragent, title: 'Nautischer Verein Cuxhaven e.V. - Startseite', config: {paths: sails.config.paths} });
    });
  });
}

var fallbackMembers = function (req, res, next, force, showLegacyToast) {
  var members;
  Member.find().exec(function found(err, results) {
    members = MemberService.sort(results);
    return ThemeService.view(req, 'views/fallback/members/content.jade', res, {showLegacyToast: showLegacyToast, force: force, host: req.host, url: req.path, members: members, useragent: req.useragent, title: 'Nautischer Verein Cuxhaven e.V. - Vorstand / Beirat', config: {paths: sails.config.paths} });
  });
}

var fallbackEvents = function (req, res, next, force, showLegacyToast) {
  var events;
  Timeline.find().exec(function found(err, results) {
    // sails.log.debug(results);
    // events = EventService.sort(results);
    // events = EventService.momentise(events);
    // events = EventService.split(events);
    // sails.log.debug(events);
    events = EventService.transform(results);
    return ThemeService.view(req, 'views/fallback/events/timeline.jade', res,  {showLegacyToast: showLegacyToast, force: force, host: req.host, url: req.path, events: events, useragent: req.useragent, title: 'Nautischer Verein Cuxhaven e.V. - Veranstaltungen', config: {paths: sails.config.paths} });
  });
}

var fallbackGallery = function (req, res, next, force, showLegacyToast) {
  var about, goals;
  Gallery.find().exec(function found(err, results) {
    images = results;
    return ThemeService.view(req, 'views/fallback/gallery/content.jade', res, {showLegacyToast: showLegacyToast, force: force, host: req.host, url: req.path, images: images, useragent: req.useragent, title: 'Nautischer Verein Cuxhaven e.V. - Galerie', config: {paths: sails.config.paths}});
  });
}

var fallbackApplication = function (req, res, next, force, showLegacyToast) {
  var application = null;

  var member = {
    datum: moment().format("dddd Do MMMM YYYY, HH:mm")
    , vorname: null
    , geburtstag: null
    , geburtsort: null
    , email: null
    , telefon: null
    , beruf: null
    , strasse: null
    , plz: null
    , ort: null
    , bank: {
      name: null
      , iban: null
      , bic: null
    }
  }

  Content.find({name:'application'}).exec(function found(err, results) {
    if(UtilityService.isDefined(results) && UtilityService.isDefined(results[0]) && UtilityService.isDefined(results[0].content)) {
      application = results[0].content;
    }
    return ThemeService.view(req, 'views/fallback/application/content.jade', res, {showLegacyToast: showLegacyToast, force: force, host: req.host, url: req.path, application: application, member: member, useragent: req.useragent, title: 'Nautischer Verein Cuxhaven e.V. - Aufnahmeantrag', config: {paths: sails.config.paths} });
  });
}

var fallbackLinks = function (req, res, next, force, showLegacyToast) {
  var links = null;
  Content.find({name:'links'}).exec(function found(err, results) {
    if(UtilityService.isDefined(results) && UtilityService.isDefined(results[0]) && UtilityService.isDefined(results[0].content)) links = results[0].content;
    return ThemeService.view(req, 'views/fallback/links/content.jade', res, {showLegacyToast: showLegacyToast, force: force, host: req.host, url: req.path, links: links, useragent: req.useragent, title: 'Nautischer Verein Cuxhaven e.V. - Links', config: {paths: sails.config.paths} });
  });
}

var fallbackImprint = function (req, res, next, force, showLegacyToast) {
  var imprint = null, emailIsSend = null;

  var view = function (req, host, url, form, useragent, emailIsSend) {
    Content.find({name:'imprint'}).exec(function found(err, results) {
      if(UtilityService.isDefined(results) && UtilityService.isDefined(results[0]) && UtilityService.isDefined(results[0].content))  imprint = results[0].content;
      return ThemeService.view(req, 'views/fallback/imprint/content.jade', res, {showLegacyToast: showLegacyToast, force: force, emailIsSend: emailIsSend, host: host, url: url, imprint: imprint, form: form, useragent: useragent, title: 'Nautischer Vere<NAME> e.V. - Impressum', config: {paths: sails.config.paths} });
    });
  }

  var form = {
    name: {
      value: null,
      $invalid: null,
      $valid: null,
      $error: {
        required: false,
        email: false
      }
    },
    from:  {
      value: null,
      $invalid: null,
      $valid: null,
      $error: {
        required: false,
      }
    },
    subject: {
      value: null,
      $invalid: null,
      $valid: null,
      $error: {<commit_msg>image sort and multisite support for fallback<commit_after>var validator = require('validator');
var moment = require('moment');
moment.locale('de');

var updateBrowser = function (req, res, next, force) {
  return ThemeService.view(req, 'views/fallback/browser.jade', res, {force: force, host: req.host, url: req.path, useragent: req.useragent, title: 'Ihr Browser wird nicht unterstützt' });
}

var fallbackHome = function (req, res, next, force, showLegacyToast) {
  sails.log.debug("fallbackHome");
  var about = null, goals = null;
  MultisiteService.getCurrentSiteConfig(req.session.uri.host, function (err, config) {
    if(err) { return res.serverError(err); }
    Content.find({name:'about', site:config.name}).exec(function found(err, results) {
      if(UtilityService.isDefined(results) && UtilityService.isDefined(results[0]) && UtilityService.isDefined(results[0].content)) about = results[0].content;
      Content.find({name:'goals', site:config.name}).exec(function found(err, results) {
        if(UtilityService.isDefined(results) && UtilityService.isDefined(results[0]) && UtilityService.isDefined(results[0].content)) goals = results[0].content;
        return ThemeService.view(req, 'views/fallback/home/content.jade', res, {showLegacyToast: showLegacyToast, force: force, host: req.host, url: req.path, about: about, goals: goals, useragent: req.useragent, title: 'Nautischer Verein Cuxhaven e.V. - Startseite', config: {paths: sails.config.paths} });
      });
    });
  });
}

var fallbackMembers = function (req, res, next, force, showLegacyToast) {
  var members;
  MultisiteService.getCurrentSiteConfig(req.session.uri.host, function (err, config) {
    if(err) { return res.serverError(err); }
    Member.find({site:config.name}).exec(function found(err, results) {
      members = MemberService.sort(results);
      return ThemeService.view(req, 'views/fallback/members/content.jade', res, {showLegacyToast: showLegacyToast, force: force, host: req.host, url: req.path, members: members, useragent: req.useragent, title: 'Nautischer Verein Cuxhaven e.V. - Vorstand / Beirat', config: {paths: sails.config.paths} });
    });
  }); 
}

var fallbackEvents = function (req, res, next, force, showLegacyToast) {
  var events;
  MultisiteService.getCurrentSiteConfig(req.session.uri.host, function (err, config) {
    if(err) { return res.serverError(err); }
    Timeline.find({site:config.name}).exec(function found(err, results) {
      // sails.log.debug(results);
      // events = EventService.sort(results);
      // events = EventService.momentise(events);
      // events = EventService.split(events);
      // sails.log.debug(events);
      events = EventService.transform(results);
      return ThemeService.view(req, 'views/fallback/events/timeline.jade', res,  {showLegacyToast: showLegacyToast, force: force, host: req.host, url: req.path, events: events, useragent: req.useragent, title: 'Nautischer Verein Cuxhaven e.V. - Veranstaltungen', config: {paths: sails.config.paths} });
    });
  }); 
}

var fallbackGallery = function (req, res, next, force, showLegacyToast) {
  MultisiteService.getCurrentSiteConfig(req.session.uri.host, function (err, config) {
    if(err) { return res.serverError(err); }
    var query = {
      where: {
        site: config.name
      },
      sort: 'position'
    };
    Gallery.find(query).exec(function found(err, results) {
      images = results;
      return ThemeService.view(req, 'views/fallback/gallery/content.jade', res, {showLegacyToast: showLegacyToast, force: force, host: req.host, url: req.path, images: images, useragent: req.useragent, title: 'Nautischer Verein Cuxhaven e.V. - Galerie', config: {paths: sails.config.paths}});
    });
  });
}

var fallbackApplication = function (req, res, next, force, showLegacyToast) {
  var application = null;

  var member = {
    datum: moment().format("dddd Do MMMM YYYY, HH:mm")
    , vorname: null
    , geburtstag: null
    , geburtsort: null
    , email: null
    , telefon: null
    , beruf: null
    , strasse: null
    , plz: null
    , ort: null
    , bank: {
      name: null
      , iban: null
      , bic: null
    }
  }
  MultisiteService.getCurrentSiteConfig(req.session.uri.host, function (err, config) {
    if(err) { return res.serverError(err); }
    Content.find({name:'application', site:config.name}).exec(function found(err, results) {
      if(UtilityService.isDefined(results) && UtilityService.isDefined(results[0]) && UtilityService.isDefined(results[0].content)) {
        application = results[0].content;
      }
      return ThemeService.view(req, 'views/fallback/application/content.jade', res, {showLegacyToast: showLegacyToast, force: force, host: req.host, url: req.path, application: application, member: member, useragent: req.useragent, title: 'Nautischer Verein Cuxhaven e.V. - Aufnahmeantrag', config: {paths: sails.config.paths} });
    });
  });
}

var fallbackLinks = function (req, res, next, force, showLegacyToast) {
  var links = null;
  MultisiteService.getCurrentSiteConfig(req.session.uri.host, function (err, config) {
    if(err) { return res.serverError(err); }
    Content.find({name:'links', site:config.name}).exec(function found(err, results) {
      if(UtilityService.isDefined(results) && UtilityService.isDefined(results[0]) && UtilityService.isDefined(results[0].content)) links = results[0].content;
      return ThemeService.view(req, 'views/fallback/links/content.jade', res, {showLegacyToast: showLegacyToast, force: force, host: req.host, url: req.path, links: links, useragent: req.useragent, title: 'Nautischer Verein Cuxhaven e.V. - Links', config: {paths: sails.config.paths} });
    });
  });
}

var fallbackImprint = function (req, res, next, force, showLegacyToast) {
  var imprint = null, emailIsSend = null;

  var view = function (req, host, url, form, useragent, emailIsSend) {
    MultisiteService.getCurrentSiteConfig(req.session.uri.host, function (err, config) {
      if(err) { return res.serverError(err); }
      Content.find({name:'imprint', site:config.name}).exec(function found(err, results) {
        if(UtilityService.isDefined(results) && UtilityService.isDefined(results[0]) && UtilityService.isDefined(results[0].content))  imprint = results[0].content;
        return ThemeService.view(req, 'views/fallback/imprint/content.jade', res, {showLegacyToast: showLegacyToast, force: force, emailIsSend: emailIsSend, host: host, url: url, imprint: imprint, form: form, useragent: useragent, title: '<NAME>.V. - Impressum', config: {paths: sails.config.paths} });
      });
    });
  }

  var form = {
    name: {
      value: null,
      $invalid: null,
      $valid: null,
      $error: {
        required: false,
        email: false
      }
    },
    from:  {
      value: null,
      $invalid: null,
      $valid: null,
      $error: {
        required: false,
      }
    },
    subject: {
      value: null,
      $invalid: null,
      $valid: null,
      $error: {
{'fraction_non_alphanumeric': 0.147737111373475, 'fraction_numerical': 0.0023612750885478157, 'mean_word_length': 4.11102172164119, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '2748272', 'n_tokens_mistral': 4154, 'n_tokens_neox': 4126, 'n_words': 926}