From cac2ad9c41d4a5ae326937d6c56fa5c5d195d4a6 Mon Sep 17 00:00:00 2001 From: Wynne Crisman Date: Mon, 7 Jan 2019 16:53:54 -0800 Subject: [PATCH] Changed Appreciation to Jr High Summer; Fixed sorting of internships such that changes get properly sorted; Added a proper date on news & notices on the home page using the page's update timestamp. --- client/main.styl | 2 +- imports/api/User.js | 2 +- imports/startup/both/accounts.js | 7 ++- imports/startup/client/routes.js | 12 ++-- imports/startup/server/email.js | 30 +++++++++- imports/ui/Admin/InternshipEditor.js | 8 ++- imports/ui/Admin/PageEditor.js | 2 +- imports/ui/Admin/UserManagement.js | 3 +- imports/ui/Appreciation.html | 5 -- imports/ui/Appreciation.import.styl | 21 ------- imports/ui/Appreciation.js | 14 ----- imports/ui/EditablePage.js | 2 +- imports/ui/Home.html | 8 +-- imports/ui/Home.import.styl | 2 +- imports/ui/Home.js | 12 ++++ imports/ui/InternshipJobs.js | 5 +- imports/ui/JrHighSummer.html | 5 ++ imports/ui/JrHighSummer.import.styl | 21 +++++++ imports/ui/JrHighSummer.js | 14 +++++ imports/ui/layouts/Admin.html | 6 +- server/server.js | 88 ++++++++++++++-------------- 21 files changed, 160 insertions(+), 109 deletions(-) delete mode 100644 imports/ui/Appreciation.html delete mode 100644 imports/ui/Appreciation.import.styl delete mode 100644 imports/ui/Appreciation.js create mode 100644 imports/ui/JrHighSummer.html create mode 100644 imports/ui/JrHighSummer.import.styl create mode 100644 imports/ui/JrHighSummer.js diff --git a/client/main.styl b/client/main.styl index c1a19de..4aa6b9e 100644 --- a/client/main.styl +++ b/client/main.styl @@ -204,7 +204,7 @@ h3 @import "../imports/ui/Fellowships.import.styl" @import "../imports/ui/News&Notices.import.styl" @import "../imports/ui/PhotoGallery.import.styl" -@import "../imports/ui/Appreciation.import.styl" +@import "../imports/ui/JrHighSummer.import.styl" @import "../imports/ui/Support.import.styl" @import "../imports/ui/CurrentBoard.import.styl" diff --git a/imports/api/User.js b/imports/api/User.js index a405878..73b6f2d 100644 --- a/imports/api/User.js +++ b/imports/api/User.js @@ -46,7 +46,7 @@ if(Meteor.isServer) { //Verify the currently logged in user has authority to manage users. if(Roles.userIsInRole(this.userId, [Meteor.UserRoles.ROLE_MANAGE])) { //Verify the user name isn't already used with a different ID. - if(Meteor.collections.Users.findOne({username: user.username, _id: {$ne: user._id}}) == undefined) { + if(Meteor.collections.Users.findOne({username: user.username, _id: {$ne: user._id}}) === undefined) { //Update the user. Note: I am using direct mongo modification, versus attempting to go through the Accounts and Roles objects. This could cause problems in the future if these packages change their data structures. Meteor.collections.Users.update(user._id, {$set: {username: user.username, emails: user.emails, roles: user.roles}}); } diff --git a/imports/startup/both/accounts.js b/imports/startup/both/accounts.js index 49f82c9..f2627ee 100644 --- a/imports/startup/both/accounts.js +++ b/imports/startup/both/accounts.js @@ -1,6 +1,7 @@ import { AccountsTemplates } from 'meteor/useraccounts:core'; AccountsTemplates.configure({ + enablePasswordChange: true, //Allow the user to change their password via the login UI. forbidClientAccountCreation: true, //Turn off client side account creation. The app is expected to have a feature that will do this. showForgotPasswordLink: true, defaultTemplate: 'OverrideAtForm', @@ -11,7 +12,11 @@ AccountsTemplates.configure({ // defaultLayout: 'Body', // defaultContentRegion: 'content', // defaultLayoutRegions: {} - homeRoutePath: '/Admin/InternshipJobs', //The path where the user is taken after logging in successfully. + homeRoutePath: '/Admin/Internships', //The path where the user is taken after logging in successfully. Unfortunately this is also used for the path when logging out, so we must override that function with an onLogoutHook. + onLogoutHook: function() { + FlowRouter.go("/"); + }, + texts: { title: { signIn: "" diff --git a/imports/startup/client/routes.js b/imports/startup/client/routes.js index 557dc73..2842ec2 100644 --- a/imports/startup/client/routes.js +++ b/imports/startup/client/routes.js @@ -27,6 +27,10 @@ AccountsTemplates.configureRoute('forgotPwd', { name: 'ForgotPwd', path: '/ForgotPwd' }); +AccountsTemplates.configureRoute('changePwd', { + name: 'ChangePwd', + path: '/ChangePwd' +}); pri.route("/Admin/Internships", { name: "InternshipsEditor", @@ -56,8 +60,8 @@ pri.route("/Admin/UserManagement", { BlazeLayout.render("Admin", {content: "UserManagement"}); } }); -pri.route("/Admin/Appreciation", { - name: "AppreciationEditor", +pri.route("/Admin/JrHighSummer", { + name: "JrHighSummerEditor", action: function(params, queryParams) { require("/imports/ui/Admin/PageEditor.js"); BlazeLayout.render("Admin", {content: "PageEditor"}); @@ -187,8 +191,8 @@ pub.route("/PhotoGallery", { BlazeLayout.render("Public", {content: "PhotoGallery"}); } }); -pub.route("/Appreciation", { - name: 'Appreciation', +pub.route("/JrHighSummer", { + name: 'JrHighSummer', action: function(params, queryParams) { require("/imports/ui/EditablePage.js"); BlazeLayout.render("Public", {content: "EditablePage"}); diff --git a/imports/startup/server/email.js b/imports/startup/server/email.js index b8ab653..72b124b 100644 --- a/imports/startup/server/email.js +++ b/imports/startup/server/email.js @@ -1,6 +1,32 @@ -Accounts.emailTemplates.from = "Do Not Reply "; -Accounts.emailTemplates.siteName = "Petit Teton App"; +Accounts.emailTemplates.from = "Do Not Reply "; +Accounts.emailTemplates.siteName = "Anderson Valley Education Foundation"; + +Accounts.emailTemplates.resetPassword.txt = function(user, url) { + let result; + + result = "Hello,\n\ + \n\ + To reset your password, simply click the link below\n\ + \n\ + " + url.replace("#/reset-password","ResetPwd") + "\n\ + \n\ + Thank you,\n\ + \tAnderson Valley Education Foundation"; + + return result; +}; +Accounts.emailTemplates.resetPassword.html = function(user, url) { + let result; + + result = "

Hello,

\ +

To reset your password, simply click the link below

\ + Reset Link\ +

Thank you,
\ + Anderson Valley Education Foundation

"; + + return result; +}; // Accounts.emailTemplates.verifyEmail.subject = function (user) { // return "Welcome to My Site! Please verify your email"; // }; diff --git a/imports/ui/Admin/InternshipEditor.js b/imports/ui/Admin/InternshipEditor.js index da96f5e..8f843a6 100644 --- a/imports/ui/Admin/InternshipEditor.js +++ b/imports/ui/Admin/InternshipEditor.js @@ -10,12 +10,13 @@ Tracker.autorun(function() { }); Template.InternshipEditor.onCreated(function() { - this.internships = Meteor.collections.Internship.find({}, {sort: {name: 1}}); + //this.internships = Meteor.collections.Internship.find({}, {sort: {name: 1}}); Session.set(PREFIX + 'selectedInternship', null); }); Template.InternshipEditor.helpers({ internships: function() { - return Template.instance().internships; + //return Template.instance().internships; + return Meteor.collections.Internship.find({}, {sort: {name: 1}}); }, selectedInternship: function() { return Session.get(PREFIX + "selectedInternship"); @@ -107,7 +108,8 @@ Template.InternshipHtmlEditor.onCreated(function() { let template = this; //Only ask the user if they want to update their changes if they actually have changes that have not yet been saved. - if(data !== template.currentHtml) { + //Note: This is only useful if the user was editing an internship. If the user was looking at the list then template.currentHtml will be undefined. + if(template.currentHtml && data !== template.currentHtml) { const changedData = data; //Ensure this does not get run twice. diff --git a/imports/ui/Admin/PageEditor.js b/imports/ui/Admin/PageEditor.js index 8099551..34e2312 100644 --- a/imports/ui/Admin/PageEditor.js +++ b/imports/ui/Admin/PageEditor.js @@ -6,7 +6,7 @@ let currentHtml = ""; let currentPath = ""; let routeData = { - AppreciationEditor: {title: "Appreciation", name: "Appreciation"}, + JrHighSummerEditor: {title: "Jr High Summer", name: "JrHighSummer"}, NewsEditor: {title: "News", name: "News"}, DatesEditor: {title: "Dates", name: "Dates"}, BoardEditor: {title: "Current Board", name: "Board"}, diff --git a/imports/ui/Admin/UserManagement.js b/imports/ui/Admin/UserManagement.js index f0b53e9..c04c120 100644 --- a/imports/ui/Admin/UserManagement.js +++ b/imports/ui/Admin/UserManagement.js @@ -144,7 +144,6 @@ Template.UserEditor.events({ let roles = []; user.username = template.$('input[name="username"]').val(); - user.email = template.$('input[name="email"]').val(); let roleSpans = template.$('.role.selected'); for(let i = 0; i < roleSpans.length; i++) { @@ -154,6 +153,7 @@ Template.UserEditor.events({ user.roles = roles; if(Session.get(PREFIX + 'displayNewUser')) { + user.email = template.$('input[name="email"]').val(); Meteor.call('insertUser', user, function(error, result) { if(error) { sAlert.error(error); @@ -166,6 +166,7 @@ Template.UserEditor.events({ }); } else { + user.emails = [{address: template.$('input[name="email"]').val(), verified: true}]; //Since this is through the admin console we will assume the address is verified. user._id = this._id; Meteor.call("updateUser", user, function(error, result) { if(error) sAlert.error(error); diff --git a/imports/ui/Appreciation.html b/imports/ui/Appreciation.html deleted file mode 100644 index b6ae04d..0000000 --- a/imports/ui/Appreciation.html +++ /dev/null @@ -1,5 +0,0 @@ - \ No newline at end of file diff --git a/imports/ui/Appreciation.import.styl b/imports/ui/Appreciation.import.styl deleted file mode 100644 index c9afe7b..0000000 --- a/imports/ui/Appreciation.import.styl +++ /dev/null @@ -1,21 +0,0 @@ -#appreciationView - display: block - -#appreciation p, #appreciationEditor p - font-family: Palatino, "Palatino Linotype", "Palatino LT STD", "Book Antiqua", Georgia, serif - font-size: 16px - margin: 16px 0 - -#appreciation h2, #appreciationEditor h2 - font-family: "Arial Black", "Arial Bold", Gadget, sans-serif - font-size: 19px - text-transform: uppercase - background-color: #EEE - font-weight: bold - padding-left: 40px - -#appreciation h4, #appreciationEditor h4 - font-family: "Century Gothic", CenturyGothic, AppleGothic, sans-serif - font-size: 16px - font-weight: 800 - clear: left \ No newline at end of file diff --git a/imports/ui/Appreciation.js b/imports/ui/Appreciation.js deleted file mode 100644 index 7fec60a..0000000 --- a/imports/ui/Appreciation.js +++ /dev/null @@ -1,14 +0,0 @@ -import './Appreciation.html'; - -Tracker.autorun(function() { - Meteor.subscribe("pages"); -}); - - -Template.Appreciation.helpers({ - appreciationHTML: function() { - let doc = Meteor.collections.Pages.findOne({name: 'Appreciation'}); - - return doc === undefined ? "" : doc.html; - } -}); \ No newline at end of file diff --git a/imports/ui/EditablePage.js b/imports/ui/EditablePage.js index ef917f6..c30e5e5 100644 --- a/imports/ui/EditablePage.js +++ b/imports/ui/EditablePage.js @@ -1,7 +1,7 @@ import './EditablePage.html'; let routeData = { - Appreciation: {name: "Appreciation"}, + JrHighSummer: {name: "JrHighSummer"}, News: {name: "News"}, ImportantDates: {name: "Dates"}, CurrentBoard: {name: "Board"} diff --git a/imports/ui/Home.html b/imports/ui/Home.html index 38adcca..7ad15c6 100644 --- a/imports/ui/Home.html +++ b/imports/ui/Home.html @@ -24,7 +24,7 @@ - + @@ -32,11 +32,9 @@ - + - - - + diff --git a/imports/ui/Home.import.styl b/imports/ui/Home.import.styl index dbbdc4b..ca75bd7 100644 --- a/imports/ui/Home.import.styl +++ b/imports/ui/Home.import.styl @@ -90,7 +90,7 @@ left: 245px top: 160px background-image: url('./images/buckeye_seed_v2.jpg') - .appreciationMenu + .jrHighSummerMenu left: 490px top: 160px background-image: url('./images/bay_seed_v2.jpg') diff --git a/imports/ui/Home.js b/imports/ui/Home.js index ddddd18..733ec8a 100644 --- a/imports/ui/Home.js +++ b/imports/ui/Home.js @@ -1,6 +1,10 @@ import './Home.html'; +Tracker.autorun(function() { + Meteor.subscribe("pages"); +}); + Template.Home.events({ 'mouseenter .menuTile': function (event, template) { event.preventDefault(); @@ -11,3 +15,11 @@ Template.Home.events({ $(event.target).find(".menuHeaderBackground").hide(); } }); +Template.Home.helpers({ + newsDate: function() { + let news = Meteor.collections.Pages.findOne({name: "News"}); + let date = news ? news.updatedAt : undefined; + + return date ? moment(date).format("MM / DD / YY") : ""; + } +}); diff --git a/imports/ui/InternshipJobs.js b/imports/ui/InternshipJobs.js index 0ad7453..65e820a 100644 --- a/imports/ui/InternshipJobs.js +++ b/imports/ui/InternshipJobs.js @@ -7,11 +7,12 @@ Tracker.autorun(function() { }); Template.InternshipJobs.onCreated(function() { - this.internships = Meteor.collections.Internship.find({}, {sort: {name: 1}}); + //this.internships = Meteor.collections.Internship.find({}, {sort: {name: 1}}); }); Template.InternshipJobs.helpers({ internships: function() { - return Template.instance().internships; + //return Template.instance().internships; + return Meteor.collections.Internship.find({}, {sort: {name: 1}}); } }); Template.InternshipJobs.events({ diff --git a/imports/ui/JrHighSummer.html b/imports/ui/JrHighSummer.html new file mode 100644 index 0000000..9001580 --- /dev/null +++ b/imports/ui/JrHighSummer.html @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/imports/ui/JrHighSummer.import.styl b/imports/ui/JrHighSummer.import.styl new file mode 100644 index 0000000..b5ba4c5 --- /dev/null +++ b/imports/ui/JrHighSummer.import.styl @@ -0,0 +1,21 @@ +#jrHighSummer + display: block + + p + font-family: Palatino, "Palatino Linotype", "Palatino LT STD", "Book Antiqua", Georgia, serif + font-size: 16px + margin: 16px 0 + + h2 + font-family: "Arial Black", "Arial Bold", Gadget, sans-serif + font-size: 19px + text-transform: uppercase + background-color: #EEE + font-weight: bold + padding-left: 40px + + h4 + font-family: "Century Gothic", CenturyGothic, AppleGothic, sans-serif + font-size: 16px + font-weight: 800 + clear: left \ No newline at end of file diff --git a/imports/ui/JrHighSummer.js b/imports/ui/JrHighSummer.js new file mode 100644 index 0000000..ece7d6f --- /dev/null +++ b/imports/ui/JrHighSummer.js @@ -0,0 +1,14 @@ +import './JrHighSummer.html'; + +Tracker.autorun(function() { + Meteor.subscribe("pages"); +}); + + +Template.JrHighSummer.helpers({ + html: function() { + let doc = Meteor.collections.Pages.findOne({name: 'JrHighSummer'}); + + return doc === undefined ? "" : doc.html; + } +}); \ No newline at end of file diff --git a/imports/ui/layouts/Admin.html b/imports/ui/layouts/Admin.html index 96b0a18..d8e2c57 100644 --- a/imports/ui/layouts/Admin.html +++ b/imports/ui/layouts/Admin.html @@ -30,9 +30,9 @@ Important Dates -
  • - - Appreciation +
  • + + Jr High Summer
  • diff --git a/server/server.js b/server/server.js index b01f883..faec0da 100644 --- a/server/server.js +++ b/server/server.js @@ -4,7 +4,8 @@ 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"; +//import {SSR, Template} from "meteor/meteorhacks:ssr"; + // let PropertiesReader = require('properties-reader'); // let props = PropertiesReader('release.properties'); @@ -14,6 +15,7 @@ import {SSR, Template} from "meteor/meteorhacks:ssr"; // // 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; } @@ -30,30 +32,30 @@ if(process.env.MONGO_URL) { 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 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'); +//const path = require('path'); +//const fs = require('fs'); -let templateMap = JSON.parse(Assets.getText('template-index')); -let templateNames = Object.keys(templateMap); +//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]); -}); +//templateNames.forEach(function(key) { +// //console.log(key); +// //console.log(templateMap[key]); +// //console.log("------------------------------------------------------------------------------------------------"); +// SSR.compileTemplate(key, templateMap[key]); +//}); //console.log(Meteor.rootPath); @@ -91,25 +93,25 @@ templateNames.forEach(function(key) { //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); -}); \ No newline at end of file +//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); +//}); \ No newline at end of file