117 lines
3.9 KiB
JavaScript
117 lines
3.9 KiB
JavaScript
import '/imports/util/polyfills/regex.js';
|
|
import '/imports/startup/server';
|
|
import '/imports/startup/both';
|
|
import '/imports/api';
|
|
import '/imports/startup/server/postStartup/version.js'; //Run this right after the api - relies on the API to upgrade the app database & data to the current version.
|
|
import { Picker } from 'meteor/meteorhacks:picker';
|
|
//import {SSR, Template} from "meteor/meteorhacks:ssr";
|
|
|
|
|
|
// let PropertiesReader = require('properties-reader');
|
|
// let props = PropertiesReader('release.properties');
|
|
//
|
|
// if(props.get('email-settings')) {
|
|
// process.env.MAIL_URL = props.get('email-settings');
|
|
// // console.log("Loaded email settings from properties file.");
|
|
// }
|
|
|
|
//Note: This is set in a development environment, or at runtime via the Nginx config file for the app (if using phusion passenger, it would be: `passenger_env_var MAIL_URL smtp://no-reply%40my-domain.com:my_password@secure.emailsrvr.com`).
|
|
if (!process.env.MAIL_URL) {
|
|
process.env.MAIL_URL = Meteor.settings.MAIL_URL;
|
|
}
|
|
|
|
// console.log("Mail settings: " + process.env.MAIL_URL);
|
|
|
|
if(Meteor.log) Meteor.log.info("Server Started");
|
|
else console.log("Server Started");
|
|
|
|
if(process.env.MONGO_URL) {
|
|
let msg = "You can find the mongo database at: " + process.env.MONGO_URL;
|
|
|
|
if(Meteor.log) Meteor.log.info(msg);
|
|
else console.log(msg);
|
|
}
|
|
|
|
//const SeoRouter = Picker.filter((request, response) => {
|
|
// let botAgents = [
|
|
// /^facebookexternalhit/i, // Facebook
|
|
// /^linkedinbot/i, // LinkedIn
|
|
// /^twitterbot/i, // Twitter
|
|
// /^slackbot-linkexpanding/i // Slack
|
|
// ];
|
|
//
|
|
// return /_escaped_fragment_/.test(request.url) || botAgents.some(i => i.test(request.headers['user-agent']));
|
|
//});
|
|
|
|
|
|
//const path = require('path');
|
|
//const fs = require('fs');
|
|
|
|
//let templateMap = JSON.parse(Assets.getText('template-index'));
|
|
//let templateNames = Object.keys(templateMap);
|
|
|
|
//templateNames.forEach(function(key) {
|
|
// //console.log(key);
|
|
// //console.log(templateMap[key]);
|
|
// //console.log("------------------------------------------------------------------------------------------------");
|
|
// SSR.compileTemplate(key, templateMap[key]);
|
|
//});
|
|
|
|
|
|
//console.log(Meteor.rootPath);
|
|
////joining path of directory
|
|
//const directoryPath = path.join(Meteor.rootPath, 'imports/ui');
|
|
////passing directoryPath and callback function
|
|
//fs.readdir(directoryPath, function (err, files) {
|
|
// //handling error
|
|
// if(err) return console.log('Unable to scan directory: ' + err);
|
|
// //listing all files using forEach
|
|
////<template name="Public">
|
|
// let templateRegex = /<template\s+name="([^"]*)>/igm;
|
|
//
|
|
// files.forEach(function (file) {
|
|
// let extension = file.name.split('.').pop();
|
|
//
|
|
// if(extension === 'html') {
|
|
// let html = fs.readFileSync(file, {encoding: "UTF8"});
|
|
// let matches = html.match(templateRegex);
|
|
// console.log(matches);
|
|
// }
|
|
// });
|
|
// files.forEach(function (file) {
|
|
// let extension = file.name.split('.').pop();
|
|
//
|
|
// if(extension === 'js') {
|
|
// require(path.join(directoryPath, file.name));
|
|
// }
|
|
// });
|
|
//});
|
|
|
|
//Prepare the server side rendering templates.
|
|
//SSR.compileTemplate('public', Assets.getText('/imports/ui/layouts/Public.html'));
|
|
//
|
|
//SSR.compileTemplate('home', Assets.getText('/imports/ui/Home.html'));
|
|
//
|
|
//SSR.compileTemplate('currentBoard', Assets.getText('/imports/ui/CurrentBoard.html'));
|
|
//Template.CurrentBoard.helpers({
|
|
// currentBoardHTML: () => {
|
|
// //Template.instance().data
|
|
// let doc = Meteor.collections.Pages.findOne({name: 'Board'});
|
|
//
|
|
// return doc === undefined ? "" : doc.html;
|
|
// }
|
|
//});
|
|
//
|
|
//SeoRouter.route('/', (params, request, response) => {
|
|
// let html = SSR.render('public', {content: 'home'});
|
|
//
|
|
// response.setHeader('Content-Type', 'text/html;charset=utf-8');
|
|
// response.end(html);
|
|
//});
|
|
//
|
|
//SeoRouter.route('/CurrentBoard', (params, request, response) => {
|
|
// let html = SSR.render('public', {content: 'currentBoard'});
|
|
//
|
|
// response.setHeader('Content-Type', 'text/html;charset=utf-8');
|
|
// response.end(html);
|
|
//});
|