Skip to content

Instantly share code, notes, and snippets.

import {mount} from 'react-mounter';
//////////////////////////////////////////////////////
// Collection & Schema //
//////////////////////////////////////////////////////
Movies = new Mongo.Collection("movies");
const isLoggedIn = user => !!user;
const isOwner = (user, document) => user._id === document.userId;
import NoSSR from 'react-no-ssr';
import Core from 'meteor/nova:core';
import SmartContainers from "meteor/utilities:react-list-container";
import FormContainers from "meteor/utilities:react-form-containers";
FlashContainer = Core.FlashContainer;
ModalButton = Core.ModalButton;
NewDocContainer = FormContainers.NewDocContainer;
EditDocContainer = FormContainers.EditDocContainer;
@SachaG
SachaG / SbPage.jsx
Created May 22, 2016 09:48
A markdown page component for Nova
/*
This component fetches a .md file and renders it as an HTML page.
Dependencies: react, react-markdown
Note: a package file can only access assets in the same package. This means
this component needs to be live in the same package as your assets,
which means it can't be distributed as a separate package.
@SachaG
SachaG / counts_collection.js
Last active June 8, 2017 15:15
Publishing Counts
if (Meteor.isClient) {
NovaCounts = new Mongo.Collection("novacounts");
}
if (Meteor.isServer) {
NovaCounts = {
subscription: {},
counts: [],
push(listId, count, sessionId) {
this.subscription.added("novacounts", listId, {count: count});
<!DOCTYPE html>
<html>
<head>
<script type="text/inject-data">%7B%22fast-render-data%22%3A%7B%22collectionData%22%3A%7B%22kadira_settings%22%3A%5B%5B%7B%22appId%22%3A%22L4HLjQ44fdnGprzy9%22%2C%22endpoint%22%3A%22https%3A%2F%2Fenginex.kadira.io%22%2C%22clientEngineSyncDelay%22%3A10000%2C%22enableErrorTracking%22%3Atrue%2C%22_id%22%3A%22sNfoRga9SaZuXncBo%22%7D%5D%5D%7D%2C%22subscriptions%22%3A%7B%7D%7D%7D</script>
<script id='serverTimezoneOffset' type='application/ejson'>{"offset":0}</script>
<title data-react-helmet="true">Sidebar</title><meta data-react-helmet="true" charset="utf-8"/><meta data-react-helmet="true" name="description" content="The 5 Best Design Links, Every Day."/><meta data-react-helmet="true" name="viewport" content="width=device-width, initial-scale=1"/><meta data-react-helmet="true" property="og:type" content="article"/><meta data-react-helmet="true" property="og:url" content="http://sidebar.io/"/><meta data-react-helmet="true" property="og:image" content="http://sidebar.io/img/logo.png

Groups

User groups let you give your users permission to perform specific actions.

Creating A Group

Users.createGroup("mods"); // let's create a new "mods" group
@SachaG
SachaG / apollo.md
Last active June 8, 2017 15:15
Telescope Nova + Apollo

Telescope Nova is the new, React-based version of Telescope, a Meteor open-source app.

Now that Telescope's front-end layer has been ported to React, the next step is porting the data layer to Apollo.

Codebase

You can find Telescope's code on GitHub. I recommend you use this branch to get the latest version of the codebase:

https://github.com/TelescopeJS/Telescope/tree/apollo

@SachaG
SachaG / nova-users-apollo-migration.js
Last active June 8, 2017 15:12 — forked from xavxyz/nova-users-apollo-migration.js
Migration script for Nova Users to run server-side: from user.telescope.settingX to user.__settingX (without removing user.telescope.settingX for backward compatibility)
// Explanation:
// This is a migration script for your users to be compatible with the Apollo version of Nova
// We do not support anymore users properties on the `telescope` namespace. They will be duplicated onto __setting:
// Example: `user.telescope.karma` becomes `user.__karma`
// Note: we do not remove the `user.telescope` object, you'll still be able to go back to your previous full Meteor build if you feel that Apollo doesn't fit your needs
// How to use:
// Create a new /server directory at the root of your project then paste the script below in /server/migration.js
import Users from 'meteor/nova:users';
@SachaG
SachaG / MyComponents.jsx
Last active March 4, 2018 17:43
Quick Apollo Mutations
// define component1, component2, etc. here
// will pass mutation as this.props.myMutation
export default withMutation({
name: 'myMutation',
args: {foo: 'String', bar: 'String'},
})(component1);
// will pass mutation as this.props.myOtherMutation
// this time, we don't have any arguments
@SachaG
SachaG / withList.jsx
Last active June 8, 2017 15:15
Nova Gists
import {withList} from 'meteor/nova:core';
import gql from 'graphql-tag';
import Movies from 'movies.js';
const MyComponent = ({loading, results}) => <div>
{ loading ? <p>Loading…</p> : results.map(movie => <p>{movie.title} ({movie.year})</p>) }
</div>
const options = {
collection: Movies,