Skip to content

Commit

Permalink
Add layout and error components to core so we always have something t…
Browse files Browse the repository at this point in the history
…o display even without themes; small clean-ups
  • Loading branch information
SachaG committed Feb 17, 2017
1 parent f82e458 commit 8b82172
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 40 deletions.
17 changes: 17 additions & 0 deletions packages/nova-core/lib/modules/components/Error404.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { registerComponent } from 'meteor/nova:lib';
import React from 'react';
import { FormattedMessage } from 'react-intl';

const Error404 = () => {
return (
<div className="error404">
<h3><FormattedMessage id="app.404"/></h3>
</div>
)
}

Error404.displayName = "Error404";

registerComponent('Error404', Error404);

export default Error404;
11 changes: 11 additions & 0 deletions packages/nova-core/lib/modules/components/Layout.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Components, registerComponent } from 'meteor/nova:core';
import React, { PropTypes, Component } from 'react';

const Layout = ({children}) =>
<div className="wrapper" id="wrapper">{children}</div>

Layout.displayName = "Layout";

registerComponent('Layout', Layout);

export default Layout;
2 changes: 2 additions & 0 deletions packages/nova-core/lib/modules/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ export {
bindEnvironment, webAppConnectHandlersUse
} from 'meteor/nova:lib';

export { default as Layout } from "./components/Layout.jsx";
export { default as App } from "./components/App.jsx";
export { default as Icon } from "./components/Icon.jsx";
export { default as Loading } from "./components/Loading.jsx";
export { default as ShowIf } from "./components/ShowIf.jsx";
export { default as ModalTrigger } from './components/ModalTrigger.jsx';
export { default as Error404 } from './components/Error404.jsx';

export { default as withMessages } from "./containers/withMessages.js";
export { default as withList } from './containers/withList.js';
Expand Down
5 changes: 4 additions & 1 deletion packages/nova-lib/lib/modules/fragments.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ export const getFragmentName = fragment => fragment && fragment.definitions[0] &
// get fragment
// note: parentFragmentName is used for debugging purposes only
export const getFragment = (fragmentName, parentFragmentName) => {

const fragment = Fragments[fragmentName];

if (!fragment) {
throw new Error(`Fragment "${fragmentName}" not registered.`)
}

// pad the literals array with line returns for each subFragments
const literals = [fragment.fragmentText, ...fragment.subFragments.map(x => '\n')];

Expand Down
5 changes: 1 addition & 4 deletions packages/nova-posts/lib/callbacks/callbacks_posts_edit.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import marked from 'marked';
import Posts from '../collection.js'
import Users from 'meteor/nova:users';
import { runCallbacks, runCallbacksAsync, addCallback, getSetting, Utils } from 'meteor/nova:core';
import { runCallbacksAsync, addCallback, getSetting, Utils } from 'meteor/nova:core';

//////////////////////////////////////////////////////
// posts.edit.sync //
Expand Down Expand Up @@ -60,7 +59,6 @@ const PostsEditSlugify = (modifier, post) => {
if (modifier.$set && modifier.$set.title) {
modifier.$set.slug = Utils.slugify(modifier.$set.title);
}

return modifier;
}

Expand Down Expand Up @@ -97,7 +95,6 @@ addCallback("posts.edit.sync", PostsEditHTMLContent);
// posts.edit.async //
//////////////////////////////////////////////////////


function PostsEditRunPostApprovedAsyncCallbacks (post, oldPost) {
if (Posts.isApproved(post) && !Posts.isApproved(oldPost)) {
runCallbacksAsync("posts.approve.async", post);
Expand Down
35 changes: 2 additions & 33 deletions packages/nova-posts/lib/callbacks/callbacks_posts_new.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ function PostsNewRateLimit (post, user) {
maxPostsPer24Hours = Math.abs(parseInt(getSetting('maxPostsPerDay', 5)));

// check that user waits more than X seconds between posts
// if(timeSinceLastPost < postInterval)
// throw new Error(Utils.encodeIntlError({id: "posts.rate_limit_error", value: postInterval-timeSinceLastPost}));

console.log(numberOfPostsInPast24Hours)
if(timeSinceLastPost < postInterval)
throw new Error(Utils.encodeIntlError({id: "posts.rate_limit_error", value: postInterval-timeSinceLastPost}));

// check that the user doesn't post more than Y posts per day
if(numberOfPostsInPast24Hours >= maxPostsPer24Hours)
Expand Down Expand Up @@ -52,33 +50,6 @@ function PostsNewDuplicateLinksCheck (post, user) {
}
addCallback("posts.new.sync", PostsNewDuplicateLinksCheck);

/**
* @summary Check for necessary properties
*/
// function PostsNewRequiredPropertiesCheck (post, user) {

// // initialize default properties
// const defaultProperties = {
// createdAt: new Date(),
// author: Users.getDisplayNameById(post.userId),
// status: Posts.getDefaultStatus(user)
// };

// post = _.extend(defaultProperties, post);

// // generate slug
// post.slug = Utils.slugify(post.title);

// // if post is approved but doesn't have a postedAt date, give it a default date
// // note: pending posts get their postedAt date only once theyre approved
// if (Posts.isApproved(post) && !post.postedAt) {
// post.postedAt = new Date();
// }

// return post;
// }
// addCallback("posts.new.sync", PostsNewRequiredPropertiesCheck);

/**
* @summary Set the post's postedAt if it's going to be approved
*/
Expand All @@ -102,10 +73,8 @@ addCallback("posts.new.sync", PostsNewSetFuture);
*/
const PostsNewSlugify = post => {
post.slug = Utils.slugify(post.title);

return post;
}

addCallback("posts.new.sync", PostsNewSlugify);

/**
Expand Down
5 changes: 4 additions & 1 deletion packages/nova-routing/lib/client/routing.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ Meteor.startup(() => {

const indexRoute = _.filter(Routes, route => route.path === '/')[0];
const childRoutes = _.reject(Routes, route => route.path === '/');
delete indexRoute.path; // delete the '/' path to avoid warning

if (indexRoute) {
delete indexRoute.path; // delete the '/' path to avoid warning
}

const AppRoutes = {
path: '/',
Expand Down
5 changes: 4 additions & 1 deletion packages/nova-routing/lib/server/routing.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ Meteor.startup(() => {

const indexRoute = _.filter(Routes, route => route.path === '/')[0];
const childRoutes = _.reject(Routes, route => route.path === '/');
delete indexRoute.path; // delete the '/' path to avoid warning

if (indexRoute) {
delete indexRoute.path; // delete the '/' path to avoid warning
}

const AppRoutes = {
path: '/',
Expand Down

0 comments on commit 8b82172

Please sign in to comment.