2016-02-17 17:22:32 +09:00
# Telescope Nova
**Nova** is a top-secret, highly unstable experimental branch of Telescope with a really cool name.
2016-03-30 10:55:11 +09:00
## Install
2016-02-22 13:23:46 +09:00
2016-03-30 10:55:11 +09:00
1. Clone this branch to your local machine
2. Run `npm install`
3. Run `meteor`
2016-02-22 13:23:46 +09:00
2016-03-30 10:55:11 +09:00
Note: the `nova:*` packages are *not* currently published to Atmosphere.
2016-02-24 14:47:44 +09:00
2016-03-30 10:55:11 +09:00
## Resources
2016-02-24 14:47:44 +09:00
2016-03-30 10:55:11 +09:00
The best way to get support is the #nova channel in the [Telescope Slack Chatroom ](http://slack.telescopeapp.org ).
2016-02-17 17:22:32 +09:00
2016-03-30 10:55:11 +09:00
You can also check out the [Nova roadmap on Trello ](https://trello.com/b/dwPR0LTz/nova-roadmap ) to see what needs to be done.
2016-02-17 17:22:32 +09:00
2016-03-30 10:55:11 +09:00
## Settings
2016-02-17 17:22:32 +09:00
2016-03-30 10:55:11 +09:00
Settings can be configured in your `settings.json` file (although any settings published to the `Telescope.settings.collection` collection will also be taken into account).
2016-02-17 17:22:32 +09:00
2016-03-30 10:55:11 +09:00
Settings can be public (meaning they will be published to the client) or private (they will be kept on the server). Public settings should be set on the `public` object. You can find a full example in `sample_settings.json` .
2016-02-17 17:22:32 +09:00
2016-03-30 10:55:11 +09:00
To use your `settings.json` file:
2016-02-17 17:22:32 +09:00
2016-03-30 10:55:11 +09:00
- Development: `meteor --settings settings.json`
- Production: specify the path to `settings.json` in `mup.json`
2016-02-17 17:22:32 +09:00
2016-03-30 10:55:11 +09:00
## Packages
2016-02-17 17:22:32 +09:00
#### Core Packages
2016-03-30 10:55:11 +09:00
These packages are necessary for Nova to run.
2016-02-17 17:22:32 +09:00
- `lib` : utility functions used by the app; also handles all external packages.
- `events` : event tracking.
2016-03-30 10:55:11 +09:00
- `i18n` : internationalization.
- `core` : import previous core packages.
2016-02-17 17:22:32 +09:00
#### Optional Packages
2016-02-17 21:57:07 +09:00
These packages are optional, although they might depend on each other. Note that dependencies on non-core packages should be `weak` whenever possible.
2016-02-17 17:22:32 +09:00
2016-03-30 10:55:11 +09:00
- `settings` : publish the `Settings` collection (for backwards compatibility)
2016-02-17 17:22:32 +09:00
- `posts`
- `comments`
- `users`
- `search`
- `tags`
- `vote`
- `scoring`
#### Theme Packages
- `base-components`
2016-02-24 14:47:44 +09:00
- `base-styles`
2016-02-17 17:22:32 +09:00
2016-03-30 10:55:11 +09:00
## Files
2016-02-17 17:22:32 +09:00
Nova tries to maintain a consistent file structure for its main packages:
- `config.js` : the package's main namespace and set basic config options.
- `collection.js` : the package's collection schema.
- `callbacks.js` : callbacks used by the package.
- `helpers.js` : collection helpers.
- `methods.js` : collectiom methods.
- `published_fields.js` : specifies which collection fields should be published in which context.
- `custom_fields.js` : sets custom fields on *other* collections.
- `routes.jsx` : routes.
- `views.js` : views used for [query constructors ](https://www.discovermeteor.com/blog/query-constructors/ ).
- `parameters.js` : the collection's query constructor.
- `server/publications.js` : publications.
2016-03-30 10:55:11 +09:00
## Customizing Components
2016-02-17 17:22:32 +09:00
2016-03-30 10:55:11 +09:00
Apart from a couple exceptions, almost all React components in Nova live inside the `nova:base-components` package. There are two main ways of customizing them.
2016-02-17 17:22:32 +09:00
2016-03-30 10:55:11 +09:00
### Override
2016-02-17 17:22:32 +09:00
2016-03-30 10:55:11 +09:00
If you only need to modify a single component, you can simply override it with a new one without having to touch the `nova:base-components` package.
2016-02-17 17:22:32 +09:00
2016-03-30 10:55:11 +09:00
For example, if you wanted to use your own `CustomLogo` component you would do:
2016-02-17 17:22:32 +09:00
2016-03-30 10:55:11 +09:00
```js
class CustomLogo extends Telescope.components.Logo{
render() {
return (
< div > /* custom component code */< / div > ;
)
}
}
Telescope.components.Logo = CustomLogo;
```
2016-02-23 13:10:08 +09:00
2016-03-30 10:55:11 +09:00
Nova components are resolved at render. So you just need to make the override anytime before the `<Logo/>` component is called from a parent component.
2016-02-23 13:10:08 +09:00
2016-03-30 10:55:11 +09:00
### Clone & Modify
2016-02-23 13:10:08 +09:00
2016-03-30 10:55:11 +09:00
For more in-depth customizations, you can also just clone the entire `nova:base-components` package and then make your modification directly there.
Of course, keeping your own new `components` package up to date with any future `nova:base-components` modifications will then be up to you.
## Callbacks
Nova uses a system of hooks and callbacks for many of its operations.
For example, here's how you would add a callback to `posts.edit.sync` to give posts an `editedAt` date every time they are modified:
```js
function setEditedAt (post, user) {
post.editedAt = new Date();
return post;
2016-02-23 13:10:08 +09:00
}
2016-03-30 10:55:11 +09:00
Telescope.callbacks.add("posts.edit.sync", setEditedAt);
2016-02-23 13:10:08 +09:00
```
2016-03-30 10:55:11 +09:00
If the callback function is named (i.e. declared using the `function foo () {}` syntax), you can also remove it from the callback using:
```js
Telescope.callbacks.remove("posts.edit.sync", "setEditedAt");
```
Methods support four distinct types of callbacks, each with their own hook:
2016-02-24 18:23:21 +09:00
- `client` callbacks are only called on the client, before the actual method is called.
- `method` callbacks are called within the body of the method, and they run both on the client and server.
- `sync` callbacks are called in the mutator, and can run either on both client and server, *or* on the server only if the mutator is called directly.
- `async` callbacks are called in the mutator, and only run on the server in an async non-blocking way.
2016-03-30 10:55:11 +09:00
## Cheatsheet
You can access a dynamically generated cheatsheet of Nova's main functions at [http://localhost:3000/cheatsheet ](/cheatsheet ) (replace with your own development URL).