diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..376f694 --- /dev/null +++ b/.babelrc @@ -0,0 +1,15 @@ +{ + "presets": [ + ["@babel/preset-env", { "modules": "cjs" }], + "@babel/preset-react"], + "plugins": [ + "@babel/plugin-proposal-class-properties", + "@babel/plugin-transform-runtime", + "@babel/plugin-syntax-export-default-from", + "@babel/plugin-transform-strict-mode", + "@babel/plugin-transform-react-jsx", + "babel-plugin-styled-components", + "./babel/moment_no_i18n" + ], + "comments": false +} diff --git a/.eslintrc.yaml b/.eslintrc.yaml index 962ffa1..85485de 100644 --- a/.eslintrc.yaml +++ b/.eslintrc.yaml @@ -48,6 +48,7 @@ rules: - error - single no-ternary: off + prefer-template: error parserOptions: ecmaVersion: 2017 sourceType: module diff --git a/.gitignore b/.gitignore index ebae525..e5389d2 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ build /**/.DS_Store dump/ wp-content/ +.idea/ \ No newline at end of file diff --git a/.meteor/packages b/.meteor/packages index b7f3940..5d38ab9 100644 --- a/.meteor/packages +++ b/.meteor/packages @@ -6,7 +6,7 @@ meteor-base@1.4.0 # Packages every Meteor app needs to have mobile-experience@1.0.5 # Packages for a great mobile UX -mongo@1.6.0 # The database Meteor supports right now +mongo@1.6.2 # The database Meteor supports right now blaze-html-templates # Compile .html files into Meteor Blaze views session@1.2.0 # Client-side reactive dictionary for your app jquery@1.11.10 # Helpful client-side library @@ -23,9 +23,8 @@ todda00:friendly-slugs email@1.2.3 meteorhacks:picker themeteorchef:bert -momentjs:moment -standard-minifier-css@1.5.2 -standard-minifier-js@2.4.0 +standard-minifier-css@1.5.3 +standard-minifier-js@2.4.1 summernote:standalone@=0.6.16 aldeed:autoform tsega:bootstrap3-datetimepicker @@ -50,18 +49,18 @@ scorpiusjs:materialize blaze templating templating-runtime -kadira:blaze-layout -kadira:flow-router scorpiusjs:s3 useraccounts:flow-routing useraccounts:materialize -dynamic-import@0.5.0 -meteor@1.9.2 +dynamic-import@0.5.1 +meteor@1.9.3 okgrow:analytics aldeed:simple-schema clinical:csv raix:rssfeed meteorhacks:ssr react-meteor-data -kadira:react-layout gadicc:blaze-react-component +kadira:flow-router +kadira:blaze-layout +kadira:react-layout diff --git a/.meteor/release b/.meteor/release index 91e05fc..97064e1 100644 --- a/.meteor/release +++ b/.meteor/release @@ -1 +1 @@ -METEOR@1.8.0.2 +METEOR@1.8.1 diff --git a/.meteor/versions b/.meteor/versions index bf7966c..69f3582 100644 --- a/.meteor/versions +++ b/.meteor/versions @@ -1,4 +1,4 @@ -accounts-base@1.4.3 +accounts-base@1.4.4 accounts-facebook@1.3.2 accounts-google@1.3.2 accounts-oauth@1.1.16 @@ -11,8 +11,8 @@ aldeed:schema-index@1.1.1 aldeed:simple-schema@1.5.4 allow-deny@1.1.0 anti:i18n@0.4.3 -autoupdate@1.5.0 -babel-compiler@7.2.4 +autoupdate@1.6.0 +babel-compiler@7.3.4 babel-runtime@1.3.0 base64@1.0.11 binary-heap@1.0.11 @@ -32,11 +32,11 @@ ddp@1.4.0 ddp-client@2.3.3 ddp-common@1.4.0 ddp-rate-limiter@1.0.7 -ddp-server@2.2.0 +ddp-server@2.3.0 deps@1.0.12 diff-sequence@1.1.1 dynamic-import@0.5.1 -ecmascript@0.12.4 +ecmascript@0.12.7 ecmascript-runtime@0.7.0 ecmascript-runtime-client@0.8.0 ecmascript-runtime-server@0.7.1 @@ -44,12 +44,12 @@ ejson@1.1.0 email@1.2.3 es5-shim@4.8.0 evaisse:csv@0.1.4 -facebook-oauth@1.5.0 +facebook-oauth@1.6.0 fastclick@1.0.13 -fetch@0.1.0 +fetch@0.1.1 fortawesome:fontawesome@4.7.0 -fourseven:scss@4.5.4 -gadicc:blaze-react-component@1.4.1 +fourseven:scss@4.10.0 +gadicc:blaze-react-component@1.4.2 geojson-utils@1.0.10 gildaspk:autoform-materialize@0.0.26 google-oauth@1.2.6 @@ -73,34 +73,34 @@ localstorage@1.2.0 logging@1.1.20 matb33:collection-hooks@0.8.4 mdg:validation-error@0.5.1 -meteor@1.9.2 +meteor@1.9.3 meteor-base@1.4.0 meteor-platform@1.2.6 meteorhacks:inject-initial@1.0.4 meteorhacks:picker@1.0.3 meteorhacks:ssr@2.2.0 -minifier-css@1.4.1 -minifier-js@2.4.0 +minifier-css@1.4.2 +minifier-js@2.4.1 minimongo@1.4.5 mobile-experience@1.0.5 mobile-status-bar@1.0.14 -modern-browsers@0.1.3 +modern-browsers@0.1.4 modules@0.13.0 modules-runtime@0.10.3 -momentjs:moment@2.22.2 -mongo@1.6.0 -mongo-decimal@0.1.0 +momentjs:moment@2.17.1 +mongo@1.6.2 +mongo-decimal@0.1.1 mongo-dev-server@1.1.0 mongo-id@1.0.7 mpowaga:autoform-summernote@0.4.2 nicolaslopezj:options@1.0.1 nicolaslopezj:reactive-templates@1.2.1 nicolaslopezj:roles@2.6.6 -nicolaslopezj:router-layer@0.1.0 +nicolaslopezj:router-layer@0.0.11 nicolaslopezj:tabular-materialize@1.4.1_4 npm-bcrypt@0.9.3 -npm-mongo@3.1.1 -oauth@1.2.7 +npm-mongo@3.1.2 +oauth@1.2.8 oauth2@1.2.1 observe-sequence@1.0.16 okgrow:analytics@3.0.5 @@ -114,9 +114,9 @@ rate-limit@1.0.9 react@16.0.0 react-meteor-data@0.2.16 react-runtime@16.0.0 -reactive-dict@1.2.1 +reactive-dict@1.3.0 reactive-var@1.0.11 -reload@1.2.0 +reload@1.3.0 retry@1.1.0 routepolicy@1.1.0 sacha:spin@2.3.1 @@ -130,7 +130,7 @@ scorpiusjs:dictionary@0.3.1 scorpiusjs:filesystem@0.3.1 scorpiusjs:image-attribute@0.3.1 scorpiusjs:lang-en@0.3.1 -scorpiusjs:materialize@0.3.0 +scorpiusjs:materialize@0.3.4 scorpiusjs:s3@0.3.1 scorpiusjs:summernote@0.3.0 service-configuration@1.0.11 @@ -141,15 +141,15 @@ softwarerero:accounts-t9n@1.3.11 spacebars@1.0.15 spacebars-compiler@1.1.3 srp@1.0.12 -standard-minifier-css@1.5.2 -standard-minifier-js@2.4.0 +standard-minifier-css@1.5.3 +standard-minifier-js@2.4.1 standard-minifiers@1.1.0 summernote:standalone@0.6.16 templating@1.3.2 templating-compiler@1.3.3 templating-runtime@1.3.2 templating-tools@1.1.2 -themeteorchef:bert@2.1.3 +themeteorchef:bert@2.2.0 tmeasday:check-npm-versions@0.3.2 todda00:friendly-slugs@0.6.0 tracker@1.2.0 @@ -159,7 +159,7 @@ ui@1.0.13 underscore@1.0.10 url@1.2.0 useraccounts:core@1.14.2 -useraccounts:flow-routing@1.12.4 -useraccounts:materialize@1.13.1 -webapp@1.7.2 +useraccounts:flow-routing@1.15.0 +useraccounts:materialize@1.14.2 +webapp@1.7.4 webapp-hashing@1.0.9 diff --git a/babel/moment_no_i18n/index.js b/babel/moment_no_i18n/index.js new file mode 100644 index 0000000..a75557c --- /dev/null +++ b/babel/moment_no_i18n/index.js @@ -0,0 +1,13 @@ +module.exports = function () { + return { + visitor: { + CallExpression(path) { + if (path.node.callee.property + && path.node.callee.property.name === 'defineLocale' + && !path.node.arguments[0].value !== 'en') { + path.parentPath.parentPath.remove(); + } + } + } + }; +}; diff --git a/client/helpers/errors.js b/client/helpers/errors.js index dee8d4c..f1909cb 100644 --- a/client/helpers/errors.js +++ b/client/helpers/errors.js @@ -2,7 +2,9 @@ import { Mongo } from 'meteor/mongo'; import { Bert } from 'meteor/themeteorchef:bert'; -export default Errors = new Mongo.Collection(null); +var Errors = new Mongo.Collection(null); + +export default Errors; export function throwError(message, type) { var type = type || 'default'; diff --git a/client/main.html b/client/main.html index 6b9a9f0..0f444f0 100644 --- a/client/main.html +++ b/client/main.html @@ -16,6 +16,8 @@ + + diff --git a/client/main.js b/client/main.js index 0c2a31c..53c934e 100644 --- a/client/main.js +++ b/client/main.js @@ -15,7 +15,7 @@ Session.setDefault(IGNORE_CONNECTION_ISSUE_KEY, true); // Global audio player because it causes stack overflow when wrapped into a // session variable. -player = null; +global.player = null; Session.set('hashesOpen', false); Session.set('isSearching', false); @@ -38,7 +38,7 @@ Meteor.startup(function () { AutoForm.addHooks(['partyForm'],{ onSuccess: function() { - FlowRouter.go('/event' + this.docId); + FlowRouter.go(`/events/${this.docId}`); } }); diff --git a/imports/api/charts/charts_collection.js b/imports/api/charts/charts_collection.js index 1255b74..903c4e3 100644 --- a/imports/api/charts/charts_collection.js +++ b/imports/api/charts/charts_collection.js @@ -1,6 +1,6 @@ import ChartsSchema from './charts_schema.js'; import { scorpius } from 'meteor/scorpiusjs:core'; -import { moment } from 'meteor/momentjs:moment'; +import { default as moment } from 'moment'; var Charts = new scorpius.collection('charts', { singularName: 'chart', @@ -37,4 +37,4 @@ Charts.friendlySlugs({ Charts.attachSchema(ChartsSchema); -export default Charts +export default Charts diff --git a/imports/api/comments/comments_methods.js b/imports/api/comments/comments_methods.js index 4d30e47..f00d7f4 100644 --- a/imports/api/comments/comments_methods.js +++ b/imports/api/comments/comments_methods.js @@ -43,17 +43,17 @@ Meteor.methods({ switch(commentAttributes.type) { case 'partyPage': var party = Parties.findOne({ _id: commentAttributes.postId }); - url += 'events/' + post.slug; + url += `events/${post.slug}`; recipient = Meteor.users.findOne({ _id: party.userId }); to = recipient.emails && recipient.emails[0].address; // So we don't email if the party page's author is commenting. if (party.userId === comment.userId) break; - subject = 'New Comment on Your Event "' + party.title + '"'; + subject = `New Comment on Your Event "${party.title}"`; body = 'Hello,

You have a new comment on your event, ' + - party.title + '. User ' + comment.author + ' said:

"' + - comment.body + '".


Click here to view this comment in context.'; Meteor.call('sendEmailNotification', to, subject, body, false); break; @@ -62,7 +62,7 @@ Meteor.methods({ // TODO: Sort out the issue with using FlowRouter.url() to generate the // path dynamically. It was failing to substitute the route and params // when given a route name. For now, we've hard-coded in the url. - url += 'playlist/' + playlist.spinPlaylistId; + url += `playlists/${playlist.spinPlaylistId}`; var show = Shows.findOne({ showId: playlist.showId }); recipient = Meteor.users.findOne({ _id: show.userId }); @@ -71,22 +71,22 @@ Meteor.methods({ break; subject = 'New Comment on Your Playlist'; body = 'Hello,

You have a new comment on a playlist for ' + - show.showName + '. User ' + comment.author + ' said:

"' + - comment.body + '".


Click here to view this comment in context.'; Meteor.call('sendEmailNotification', to, subject, body, false); break; case 'newsPage': var post = Posts.findOne({ _id: commentAttributes.postId }); - url += 'radioblog/' + post.slug; + url += `radioblog/${post.slug}`; recipient = Meteor.users.findOne({ _id: post.userId }); to = recipient.emails && recipient.emails[0].address; if (post.userId === comment.userId) break; - subject = 'New Comment on Your Post, "' + post.title + '"'; + subject = `New Comment on Your Post, "${post.title}"`; body = 'Hello,

You have a new comment on your post, ' + - post.title + '. User ' + comment.author + ' said:

"' + - comment.body + '".


Click here to view this comment in context.'; Meteor.call('sendEmailNotification', to, subject, body, false); break; diff --git a/imports/api/parties/parties_collection.js b/imports/api/parties/parties_collection.js index eda5892..40fc4a0 100644 --- a/imports/api/parties/parties_collection.js +++ b/imports/api/parties/parties_collection.js @@ -10,8 +10,8 @@ var Parties = new scorpius.collection('parties', { { data: 'flyerFront', title: 'Flyer', - render: function (val) { - return ''; + render: function ({ url }) { + return ``; } }, { data: 'title', diff --git a/imports/startup/client/routes.js b/imports/startup/client/routes.js index 3cd9d16..73d44af 100644 --- a/imports/startup/client/routes.js +++ b/imports/startup/client/routes.js @@ -1,19 +1,9 @@ import React from 'react'; import { FlowRouter } from 'meteor/kadira:flow-router'; -import { ReactLayout } from 'meteor/kadira:react-layout'; +import { mount } from 'react-mounter'; import Layout from '../../ui/components/application/Layout.jsx'; import { $ } from 'meteor/jquery'; -FlowRouter.notFound = { - action: async function() { - await import('../../ui/components/application/NotFound.jsx').then( - function(NotFound) { - ReactLayout.render(Layout, { content: }); - } - ); - } -}; - FlowRouter.triggers.enter( [ function() { @@ -28,7 +18,7 @@ FlowRouter.route('/', { action: async function () { await import('../../ui/components/home/Home.jsx').then( function(Home) { - ReactLayout.render(Layout, { content: }); + mount(Layout, { content: }); } ); } @@ -39,7 +29,7 @@ FlowRouter.route('/radioblog/:slug', { action: async function () { await import('../../ui/components/news/NewsPage.jsx').then( function(NewsPage) { - ReactLayout.render(Layout, { content: }); + mount(Layout, { content: }); }); } }); @@ -49,7 +39,7 @@ FlowRouter.route('/radioblog', { action: async function () { await import('../../ui/components/news/NewsList.jsx').then( function(NewsList) { - ReactLayout.render(Layout, { content: }); + mount(Layout, { content: }); }); } }); @@ -59,7 +49,7 @@ FlowRouter.route('/events/:slug', { action: async function () { await import('../../ui/components/parties/PartyPage.jsx').then( function(PartyPage) { - ReactLayout.render(Layout, { content: }); + mount(Layout, { content: }); }); } }); @@ -69,7 +59,7 @@ FlowRouter.route('/events', { action: async function () { await import('../../ui/components/parties/PartyList.jsx').then( function(PartyList) { - ReactLayout.render(Layout, { content: }); + mount(Layout, { content: }); }); } }); @@ -79,7 +69,7 @@ FlowRouter.route('/playlists/:id', { action: async function () { await import('../../ui/components/playlists/PlaylistPage.jsx').then( function(PlaylistPage) { - ReactLayout.render(Layout, { content: }); + mount(Layout, { content: }); } ); } @@ -90,7 +80,7 @@ FlowRouter.route('/playlists', { action: async function () { await import('../../ui/components/playlists/PlaylistList.jsx').then( function(PlaylistList) { - ReactLayout.render(Layout, { content: }); + mount(Layout, { content: }); } ); } @@ -101,7 +91,7 @@ FlowRouter.route('/reviews/:slug', { action: async function() { await import('../../ui/components/reviews/ReviewPage.jsx').then( function(ReviewPage) { - ReactLayout.render(Layout, { content: }); + mount(Layout, { content: }); } ); } @@ -112,7 +102,7 @@ FlowRouter.route('/reviews/', { action: async function() { await import('../../ui/components/reviews/ReviewList.jsx').then( function(ReviewList) { - ReactLayout.render(Layout, { content: }); + mount(Layout, { content: }); }); } }); @@ -122,7 +112,7 @@ FlowRouter.route('/shows/:slug', { action: async function() { await import('../../ui/components/shows/ShowPage.jsx').then( (ShowPage) => { - ReactLayout.render(Layout, { content: }); + mount(Layout, { content: }); } ); } @@ -133,7 +123,7 @@ FlowRouter.route('/shows', { action: async function() { await import('../../ui/components/shows/ShowList.jsx').then( (ShowList) => { - ReactLayout.render(Layout, { content: }); + mount(Layout, { content: }); } ); } @@ -144,7 +134,7 @@ FlowRouter.route('/charts/:slug', { action: async function () { await import('../../ui/components/charts/ChartsPage.jsx').then( function(ChartsPage) { - ReactLayout.render(Layout, { content: }); + mount(Layout, { content: }); }); } }); @@ -154,7 +144,7 @@ FlowRouter.route('/charts', { action: async function () { await import('../../ui/components/charts/ChartsList.jsx').then( function(ChartsList) { - ReactLayout.render(Layout, { content: }); + mount(Layout, { content: }); }); } }); @@ -164,7 +154,7 @@ FlowRouter.route('/music', { action: async function() { await import('../../ui/components/music/Music.jsx').then( function(Music) { - ReactLayout.render(Layout, { content: }); + mount(Layout, { content: }); } ); } @@ -175,7 +165,7 @@ FlowRouter.route('/profile/:username', { action: async function () { await import('../../ui/components/profile/ProfilePage.jsx').then( (ProfilePage) => { - ReactLayout.render(Layout, { content: }); + mount(Layout, { content: }); } ); } @@ -186,7 +176,7 @@ FlowRouter.route('/profile', { action: async function () { await import('../../ui/components/profile/ProfileEdit.jsx').then( function(ProfileEdit) { - ReactLayout.render(Layout, { content: }); + mount(Layout, { content: }); } ); } @@ -197,7 +187,7 @@ FlowRouter.route('/alumni', { action: async function() { await import('../../ui/components/static_pages/Alumni.jsx').then( function(Alumni) { - ReactLayout.render(Layout, { content: }); + mount(Layout, { content: }); }); } }); @@ -207,7 +197,7 @@ FlowRouter.route('/about-us', { action: async function() { await import('../../ui/components/static_pages/About.jsx').then( function(About) { - ReactLayout.render(Layout, { content: }); + mount(Layout, { content: }); }); } }); @@ -217,7 +207,7 @@ FlowRouter.route('/join-ktuh', { action: async function() { await import('../../ui/components/static_pages/Join.jsx').then( function(Join) { - ReactLayout.render(Layout, { content: }); + mount(Layout, { content: }); }); } }); @@ -227,7 +217,7 @@ FlowRouter.route('/faq', { action: async function() { await import('../../ui/components/static_pages/FAQ.jsx').then( function(FAQ) { - ReactLayout.render(Layout, { content: }); + mount(Layout, { content: }); }); } }); @@ -237,7 +227,7 @@ FlowRouter.route('/contact-us', { action: async function() { await import('../../ui/components/static_pages/Contact.jsx').then( function(Contact) { - ReactLayout.render(Layout, { content: }); + mount(Layout, { content: }); } ); } @@ -248,7 +238,7 @@ FlowRouter.route('/staff', { action: async function() { await import('../../ui/components/static_pages/Staff.jsx').then( function(Staff) { - ReactLayout.render(Layout, { content: }); + mount(Layout, { content: }); }); } }); @@ -258,7 +248,7 @@ FlowRouter.route('/timeline', { action: async function() { await import('../../ui/components/static_pages/Timeline.jsx').then( function(Timeline) { - ReactLayout.render(Layout, { content: }); + mount(Layout, { content: }); } ); } @@ -269,7 +259,7 @@ FlowRouter.route('/underwriting', { action: async function() { await import('../../ui/components/static_pages/Underwriting.jsx').then( function(Underwriting) { - ReactLayout.render(Layout, { content: }); + mount(Layout, { content: }); } ); } @@ -280,7 +270,7 @@ FlowRouter.route('/resend', { action: async function() { await import('../../ui/components/static_pages/Resend.jsx').then( function(Resend) { - ReactLayout.render(Layout, { content: }); + mount(Layout, { content: }); }); } }); @@ -290,7 +280,7 @@ FlowRouter.route('/not-found', { action: async function() { await import('../../ui/components/application/NotFound.jsx').then( function(NotFound) { - ReactLayout.render(Layout, { content: }); + mount(Layout, { content: }); } ); } @@ -301,7 +291,17 @@ FlowRouter.route('/:slug', { action: async function() { await import('../../ui/components/pages/PagesItem.jsx').then( function(PagesItem) { - ReactLayout.render(Layout, { content: }); + mount(Layout, { content: }); }); } }); + +FlowRouter.notFound = { + action: async function() { + await import('../../ui/components/application/NotFound.jsx').then( + function(NotFound) { + mount(Layout, { content: }); + } + ); + } +} diff --git a/imports/startup/lib/helpers.js b/imports/startup/lib/helpers.js index 07c0986..1652fe3 100644 --- a/imports/startup/lib/helpers.js +++ b/imports/startup/lib/helpers.js @@ -2,7 +2,7 @@ import Playlists from '../../api/playlists/playlists_collection.js'; import Shows from '../../api/shows/shows_collection.js'; import Profiles from '../../api/users/profiles_collection.js'; import moment from 'moment-timezone'; -import { moment as momentUtil } from 'meteor/momentjs:moment'; +import { default as momentUtil } from 'moment'; import { Meteor } from 'meteor/meteor'; import { FlowRouter } from 'meteor/kadira:flow-router'; import { $ } from 'meteor/jquery'; @@ -91,9 +91,8 @@ export const thumbnailUrl = function(url, maxW) { Meteor.call('requestFrom', url, maxW, (err, data) => { if (!err) return data; }); - return 'https://s3-' + Meteor.settings.awsRegion + - '.amazonaws.com/' + Meteor.settings.bucket + '/thumbs/' + - url.split('/').slice(-1)[0] + '.jpg'; + return `https://s3-${Meteor.settings.awsRegion}.amazonaws.com/${ + Meteor.settings.bucket}/thumbs/${url.split('/').slice(-1)[0]}.jpg`; } export const displayNameById = (userId) => { @@ -129,9 +128,9 @@ export const renderSummary = function(summary, numWords) { if (summary.indexOf('<') > -1) { summary = $.parseHTML(summary).map(node => node.innerText).join(' '); } - var regex = new RegExp('(([^\\s]+\\s\\s*){' + numWords + '})(.*)'); + var regex = new RegExp(`(([^\\s]+\\s\\s*){${numWords}})(.*)`); var match = regex.exec(summary); - return (match && match[1] || summary) + '…'; + return `${match && match[1] || summary}…`; } export const getPathBySlug = function(template, slug) { diff --git a/imports/startup/server/routes.js b/imports/startup/server/routes.js index ebc94ad..d8b55d8 100644 --- a/imports/startup/server/routes.js +++ b/imports/startup/server/routes.js @@ -9,19 +9,20 @@ import Profiles from '../../api/users/profiles_collection.js'; import Playlists from '../../api/playlists/playlists_collection.js'; import Parties from '../../api/parties/parties_collection.js'; import NowPlaying from '../../api/playlists/now_playing.js'; +import Pages from '../../api/pages/pages_collection.js'; import bodyParser from 'body-parser'; import { getLocalTime } from '../lib/helpers.js'; -import { moment as momentUtil } from 'meteor/momentjs:moment'; +import { default as momentUtil } from 'moment'; import moment from 'moment-timezone'; import React from 'react'; import { Helmet } from 'react-helmet'; -import { renderToStaticMarkup } from 'react-dom/server'; -import SSRLayout from '../../ui/components/application/SSRLayout.jsx' +import { renderToString } from 'react-dom/server'; +import SSRLayout from '../../ui/components/application/SSRLayout.jsx'; Picker.middleware(bodyParser.json()); Picker.middleware(bodyParser.urlencoded({ extended: false })); -Picker.route('/spinitron/latest', function(params, req, res, next) { +Picker.route('/spinitron/latest', function(params, req, res) { check(params.query, { playlistId: Match.Where(function(str) { check(str, String); return /[0-9]+/.test(str); @@ -34,7 +35,7 @@ Picker.route('/spinitron/latest', function(params, req, res, next) { var showItself = Shows.findOne({ showId: showId }); if (!showItself) showId = -1; var playlistId = parseInt(params.query.playlistId); - var html = params.query.artist + ' - ' + params.query.song; + var html = `${params.query.artist} - ${params.query.song}`; if (!Playlists.findOne({ spinPlaylistId: playlistId })) { if (playlistId <= 1000000) { @@ -118,21 +119,22 @@ const SeoRouter = Picker.filter(function(request) { }); var renderOut = (component) => { - var html = renderToStaticMarkup(), + var html = renderToString(), helmet = Helmet.renderStatic(); - return ` - - - ${helmet.title.toString()} - ${helmet.meta.toString()} - ${helmet.link.toString()} - - - - - ${html} - - + return ` + +${helmet.title.toString()} +${helmet.meta.toString()} +${helmet.link.toString()} + + + + + + ${html} + `; }; @@ -150,20 +152,32 @@ SeoRouter.route('/radioblog/:slug', async function(params, request, response) { var post = Posts.findOne({ slug: params.slug }); await import('../../ui/components/news/SSRNewsPage.jsx').then( function(SSRNewsPage) { - var html = renderOut(SSRNewsPage.default(post)); - response.setHeader('Content-Type', 'text/html;charset=utf-8'); - response.end(html); + if (post) { + var html = renderOut(SSRNewsPage.default(post)); + response.setHeader('Content-Type', 'text/html;charset=utf-8'); + response.end(html); + } + else { + response.statusCode = 404; + response.end(); + } } ); }); SeoRouter.route('/events/:slug', async function(params, request, response) { + var party = Parties.findOne({ slug: params.slug }); await import('../../ui/components/parties/SSRPartyPage.jsx').then( function(SSRPartyPage) { - var party = Parties.findOne({ slug: params.slug }); - var html = renderOut(SSRPartyPage.default(party)); - response.setHeader('Content-Type', 'text/html;charset=utf-8'); - response.end(html); + if (party) { + var html = renderOut(SSRPartyPage.default(party)); + response.setHeader('Content-Type', 'text/html;charset=utf-8'); + response.end(html); + } + else { + response.statusCode = 404; + response.end(); + } }); }); @@ -291,8 +305,38 @@ SeoRouter.route('/contact-us', async function(params, request, response) { SeoRouter.route('/:slug', async function(params, request, response) { await import('../../ui/components/pages/SSRPagesItem.jsx').then( function(SSRPagesItem) { - var html = renderOut(SSRPagesItem.default(params.slug)); - response.setHeader('Content-Type', 'text/html;charset=utf-8'); - response.end(html); + var page = Pages.findOne({ slug: params.slug }); + if (page) { + var html = renderOut(SSRPagesItem.default(params.slug)); + response.setHeader('Content-Type', 'text/html;charset=utf-8'); + response.end(html); + } + else { + response.statusCode = 404; + response.end('Not Found'); + } }); }); + +SeoRouter.route('*', function(params, request, response) { + response.statusCode = 404; + response.end(); +}); + +const BrowserFilter = Picker.filter(function(request) { + var agent = request.headers['user-agent']; + return /^mozilla/i.test(agent); +}); + +BrowserFilter.route('/:slug', async function(params, request, response, next) { + var static_routes = [ + 'alumni', 'about-us', 'join-ktuh', 'faq', 'resend', 'staff', 'timeline', + 'underwriting', 'contact-us', 'radioblog', 'shows', 'playlists', 'events', + 'reviews', 'profile', + ]; + if (!params.slug.match(/\.[a-z0-9]+$/i) && + !static_routes.includes[params.slug]) { + response.statusCode = 404; + } + return next(); +}); diff --git a/imports/ui/components/application/Layout.jsx b/imports/ui/components/application/Layout.jsx index 35fa6e0..6fd1ca3 100644 --- a/imports/ui/components/application/Layout.jsx +++ b/imports/ui/components/application/Layout.jsx @@ -1,46 +1,37 @@ -import React, { Component } from 'react'; -import PropTypes from 'prop-types'; +import React, { useEffect } from 'react'; +import { oneOfType, object, func } from 'prop-types'; import Landing from '../home/Landing.jsx'; import Header from '../includes/Header.jsx'; import Footer from '../includes/Footer.jsx'; import { FlowRouter } from 'meteor/kadira:flow-router'; import Banner from '../includes/Banner.jsx'; -import { Blaze } from 'meteor/gadicc:blaze-react-component'; -import './blaze_layout.js'; -export default class Layout extends Component { - static propTypes = { - content: PropTypes.object - } - - constructor(props) { - super(props); - } - - home() { +export default function Layout({ content }) { + function home() { return FlowRouter.getRouteName() === 'home'; } - componentDidMount() { - player.setSrc('http://stream.ktuh.org:8000/stream-mp3'); - } + useEffect(function() { + if (global.player) + global.player.setSrc('http://stream.ktuh.org:8000/stream-mp3'); + }, []); - render() { - return [ - this.home() ? : null, -
- {this.home() && [, -
] || -
} -
- -
- {this.props.content} -
-
, -