2016-08-08 11:18:21 +09:00
|
|
|
import Telescope from 'meteor/nova:lib';
|
2016-03-30 09:24:52 +09:00
|
|
|
import React from 'react';
|
2016-06-23 11:40:35 +09:00
|
|
|
import Posts from "meteor/nova:posts";
|
2016-06-23 12:17:39 +09:00
|
|
|
import Comments from "meteor/nova:comments";
|
2016-06-23 15:00:58 +09:00
|
|
|
import Users from 'meteor/nova:users';
|
2016-12-12 11:34:28 +09:00
|
|
|
import { Callbacks, Utils } from 'meteor/nova:core';
|
2016-03-30 09:24:52 +09:00
|
|
|
|
2016-03-21 10:56:14 +09:00
|
|
|
const methodList = Meteor.isServer ? Meteor.server.method_handlers : Meteor.connection._methodHandlers;
|
|
|
|
|
2016-03-19 10:15:36 +09:00
|
|
|
const renderFunction = (func, name) => {
|
|
|
|
const s = func.toString();
|
|
|
|
const openParen = s.indexOf("(");
|
|
|
|
const closeParen = s.indexOf(")");
|
|
|
|
return (
|
|
|
|
<li key={name}>
|
|
|
|
<code>{name}({s.substr(openParen+1, closeParen-openParen-1)})</code>
|
|
|
|
</li>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
const renderCallback = (callbacks, key) => {
|
|
|
|
if (Array.isArray(callbacks)) {
|
|
|
|
return (
|
|
|
|
<div className="callbacks" key={key}>
|
|
|
|
<h4>{key}</h4>
|
|
|
|
<ul>
|
|
|
|
{_.map(callbacks, (item, key) => <li key={key}><code>{item.name}</code></li>)}
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const Cheatsheet = props => {
|
|
|
|
return (
|
|
|
|
<div className="cheatsheet">
|
|
|
|
<h1>Cheatsheet</h1>
|
|
|
|
|
|
|
|
<div className="cheatsheet-wrapper">
|
|
|
|
|
|
|
|
<div className="cheatsheet-block">
|
|
|
|
<h2>Users</h2>
|
|
|
|
<h3>Helpers (<code>Users.*</code>)</h3>
|
|
|
|
<ul>
|
|
|
|
{_.map(Users, (item, key) => (key[0] !== "_" ? renderFunction(item, key) : null) )}
|
|
|
|
</ul>
|
|
|
|
<ul>
|
|
|
|
{_.map(Users.is, renderFunction)}
|
|
|
|
</ul>
|
2016-03-21 10:27:43 +09:00
|
|
|
<h3>Methods</h3>
|
|
|
|
<ul>
|
2016-03-21 10:56:14 +09:00
|
|
|
{_.map(methodList, (item, key) => (key.indexOf("users.") !== -1 ? renderFunction(item, key) : null))}
|
2016-03-21 10:27:43 +09:00
|
|
|
</ul>
|
2016-03-19 10:15:36 +09:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="cheatsheet-block">
|
|
|
|
<h2>Posts</h2>
|
|
|
|
<h3>Helpers (<code>Posts.*</code>)</h3>
|
|
|
|
<ul>
|
|
|
|
{_.map(Posts, (item, key) => (key[0] !== "_" ? renderFunction(item, key) : null) )}
|
|
|
|
</ul>
|
2016-03-21 10:27:43 +09:00
|
|
|
<h3>Methods</h3>
|
|
|
|
<ul>
|
2016-03-21 10:56:14 +09:00
|
|
|
{_.map(methodList, (item, key) => (key.indexOf("posts.") !== -1 ? renderFunction(item, key) : null))}
|
2016-03-21 10:27:43 +09:00
|
|
|
</ul>
|
2016-03-19 10:15:36 +09:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="cheatsheet-block">
|
|
|
|
<h2>Comments</h2>
|
|
|
|
<h3>Helpers (<code>Comments.*</code>)</h3>
|
|
|
|
<ul>
|
|
|
|
{_.map(Comments, (item, key) => (key[0] !== "_" ? renderFunction(item, key) : null) )}
|
|
|
|
</ul>
|
2016-03-21 10:27:43 +09:00
|
|
|
<h3>Methods</h3>
|
|
|
|
<ul>
|
2016-03-21 10:56:14 +09:00
|
|
|
{_.map(methodList, (item, key) => (key.indexOf("comments.") !== -1 ? renderFunction(item, key) : null))}
|
2016-03-21 10:27:43 +09:00
|
|
|
</ul>
|
2016-03-19 10:15:36 +09:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="cheatsheet-block">
|
|
|
|
<h2>Callbacks</h2>
|
|
|
|
<h3>Functions</h3>
|
|
|
|
<ul>
|
|
|
|
<li><code>add()</code></li>
|
|
|
|
<li><code>remove()</code></li>
|
|
|
|
<li><code>run()</code></li>
|
|
|
|
<li><code>runAsync()</code></li>
|
|
|
|
</ul>
|
2016-12-12 10:24:34 +09:00
|
|
|
<h3>Hooks (<code>Callbacks.*</code>)</h3>
|
2016-03-19 10:15:36 +09:00
|
|
|
<ul>
|
2016-12-12 10:24:34 +09:00
|
|
|
{_.map(Callbacks, renderCallback)}
|
2016-03-19 10:15:36 +09:00
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="cheatsheet-block">
|
|
|
|
<h2>Utils</h2>
|
2016-12-12 11:34:28 +09:00
|
|
|
<h3>Helpers (<code>Utils.*</code>)</h3>
|
2016-03-19 10:15:36 +09:00
|
|
|
<ul>
|
|
|
|
{_.map(Telescope.utils, renderFunction)}
|
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Cheatsheet
|
|
|
|
export default Cheatsheet
|