);
}
}
+TabBar.propTypes = {
+
+ // className to be added to the root element.
+ className: PropTypes.string,
+
+ // classNames allows full design customization of the component.
+ classNames: PropTypes.shape({
+ root: PropTypes.string,
+ rootSub: PropTypes.string,
+ }),
+
+ // classNames to be passed to the children.
+ tabClassNames: Tab.propTypes.classNames,
+
+ // activeTab should be set to the currently active tabId.
+ activeTab: PropTypes.string,
+
+ // onTabClick is fired whenever the tab was clicked. The tabId is passed as
+ // the first argument.
+ onTabClick: PropTypes.func,
+
+ // Sub indicates that this is a sub-tab-panel.
+ sub: PropTypes.bool,
+
+ // `aria-controls` should be set to the `id` of the `TabContent` for accessibility.
+ 'aria-controls': PropTypes.string,
+};
+
export default TabBar;
diff --git a/client/coral-ui/components/TabContent.css b/client/coral-ui/components/TabContent.css
new file mode 100644
index 000000000..debafa97c
--- /dev/null
+++ b/client/coral-ui/components/TabContent.css
@@ -0,0 +1,3 @@
+.root {
+ padding-top: 10px;
+}
diff --git a/client/coral-ui/components/TabContent.js b/client/coral-ui/components/TabContent.js
index 737c9a5e6..99676f7cc 100644
--- a/client/coral-ui/components/TabContent.js
+++ b/client/coral-ui/components/TabContent.js
@@ -1,6 +1,43 @@
import React from 'react';
+import cn from 'classnames';
+import PropTypes from 'prop-types';
+import styles from './TabContent.css';
-export default ({children, show = true}) => (
- show ?
{children}
: null
+function getRootClassName(className) {
+ return cn('talk-tab-content', className, styles.root);
+}
+
+/**
+ * The `TabContent` component accepts `TabPane` components to render
+ * the content of a `Tab`.
+ */
+const TabContent = ({children, className, activeTab, sub, ...rest}) => (
+
);
+TabContent.propTypes = {
+
+ // className to be added to the root element.
+ className: PropTypes.string,
+
+ // activeTab should be set to the currently active tabId.
+ activeTab: PropTypes.string,
+
+ // Sub indicates that this component belongs to a sub-tab-panel.
+ sub: PropTypes.bool,
+};
+
+export default TabContent;
diff --git a/client/coral-ui/components/TabCount.css b/client/coral-ui/components/TabCount.css
new file mode 100644
index 000000000..f95792a0b
--- /dev/null
+++ b/client/coral-ui/components/TabCount.css
@@ -0,0 +1,18 @@
+
+.root, .rootSub {
+ display: inline-block;
+ position: relative;
+ top: -2px;
+ background: #616161;
+ color: white;
+ font-weight: normal;
+ font-size: 10px;
+ padding: 2px;
+ margin-left: 2px;
+ margin-top: -2px;
+ min-width: 20px;
+}
+
+.rootSubActive {
+ background: #10589b;
+}
diff --git a/client/coral-ui/components/TabCount.js b/client/coral-ui/components/TabCount.js
new file mode 100644
index 000000000..01a3840a9
--- /dev/null
+++ b/client/coral-ui/components/TabCount.js
@@ -0,0 +1,47 @@
+import React from 'react';
+import cn from 'classnames';
+import styles from './TabCount.css';
+import PropTypes from 'prop-types';
+
+function getNumber(no) {
+ let result = Number.parseInt(no);
+ if (no >= 1000) {
+ result = `${Math.round(result / 100) / 10}k`;
+ }
+ return result;
+}
+
+function getRootClassName({className, active, sub}) {
+ return cn(
+ 'talk-tab-count',
+ className,
+ {
+ [styles.root]: !sub,
+ [styles.rootSub]: sub,
+ [styles.rootActive]: active && !sub,
+ [styles.rootSubActive]: active && sub,
+ 'talk-tab-active': active,
+ }
+ );
+}
+
+/**
+ * The `TabCount` renders a count number next to a tab name.
+ */
+const TabCount = ({children, active, sub, className}) => (
+ {getNumber(children)}
+);
+
+TabCount.propTypes = {
+
+ // className to be added to the root element.
+ className: PropTypes.string,
+
+ // active indicates that the related tab is currently active.
+ active: PropTypes.bool,
+
+ // Sub indicates that this component belongs to a sub-tab-panel.
+ sub: PropTypes.bool,
+};
+
+export default TabCount;
diff --git a/client/coral-ui/components/TabPane.js b/client/coral-ui/components/TabPane.js
new file mode 100644
index 000000000..16750b335
--- /dev/null
+++ b/client/coral-ui/components/TabPane.js
@@ -0,0 +1,34 @@
+import React from 'react';
+import cn from 'classnames';
+import PropTypes from 'prop-types';
+
+function getRootClassName(className) {
+ return cn('talk-pane', className);
+}
+
+/**
+ * The `TabPane` component is used inside the `TabContent` component to render
+ * the content of a `Tab`.
+ */
+const TabPane = ({children, className, tabId: _a, sub: _b, ...rest}) => (
+
+ {children}
+
+);
+
+TabPane.propTypes = {
+
+ // className to be added to the root element.
+ className: PropTypes.string,
+
+ tabId: PropTypes.string,
+
+ // Sub indicates that this component belongs to a sub-tab-panel.
+ // This is injected by the `TabContent` component.
+ sub: PropTypes.bool,
+};
+
+export default TabPane;
diff --git a/client/coral-ui/index.js b/client/coral-ui/index.js
index 3e9456727..8a538d120 100644
--- a/client/coral-ui/index.js
+++ b/client/coral-ui/index.js
@@ -4,7 +4,9 @@ export {default as CoralLogo} from './components/CoralLogo';
export {default as FabButton} from './components/FabButton';
export {default as TabBar} from './components/TabBar';
export {default as Tab} from './components/Tab';
+export {default as TabCount} from './components/TabCount';
export {default as TabContent} from './components/TabContent';
+export {default as TabPane} from './components/TabPane';
export {default as Button} from './components/Button';
export {default as Spinner} from './components/Spinner';
export {default as Tooltip} from './components/Tooltip';
diff --git a/docs/_data/sidebars/talk_sidebar.yml b/docs/_data/sidebars/talk_sidebar.yml
index b44c9648f..62660783c 100644
--- a/docs/_data/sidebars/talk_sidebar.yml
+++ b/docs/_data/sidebars/talk_sidebar.yml
@@ -37,6 +37,20 @@ entries:
url: /install-setup.html
output: web
+ - title: Architecture
+ output: web
+ folderitems:
+ - title: Overview
+ url: /architecture.html
+ output: web
+ - title: Tags
+ url: /architecture-tags.html
+ output: web
+ - title: cli
+ url: /architecture-cli.html
+ output: web
+
+
- title: Plugins
output: web
folderitems:
diff --git a/docs/architecture-cli.md b/docs/architecture-cli.md
new file mode 100644
index 000000000..3079890d4
--- /dev/null
+++ b/docs/architecture-cli.md
@@ -0,0 +1,139 @@
+---
+title: The Talk cli
+keywords: architecture
+sidebar: talk_sidebar
+permalink: architecture-cli.html
+summary:
+---
+
+Talk ships with a cli tool that allows access to a wide variety of functionality.
+
+It is designed to provide a convenient way for engineers to perform key tasks without the need to muck about in the UI. It also opens the door for scripts to perform operations programmatically.
+
+Note: the cli tool requires [the Talk environment to be configured](configuration.html) either via env vars or by using a `.cli` file via `bin/cli -c .env [command] ....`
+
+## Using the cli
+
+In a terminal, try:
+
+```
+/path/to/talk/bin cli [options] [commands] [arguments]
+```
+
+Commonly, you'll be in the `talk/` folder, in which case you can:
+
+```
+bin/cli [options] [commands] [arguments]
+```
+
+If you're a heavy cli user, consider adding the `bin` folder to your PATH so you can run `cli` from anywhere!
+
+If you are using [our Docker environment](install-docker.html), the bin folder will already be in the PATH.
+
+## What can I do with the cli?
+
+The Talk cli ships with 'unix style' help. To access the docs, simply run the cli with insufficient arguments.
+
+Let's say I wanted to figure out how to change a user's password. I'd start be seeing what the cli has for me.
+
+(Note: the following output may change, please reference at the `--help` output for your version as you use the cli.)
+
+```
+talk :) ]$ bin/cli --help
+
+ Usage: cli [options] [command]
+
+
+ Commands:
+
+ serve serve the application
+ settings interact with the application settings
+ assets interact with assets
+ setup setup the application
+ jobs work with the job queues
+ token work with the access tokens
+ users work with the application auth
+ migration provides utilities for migrating the database
+ plugins provides utilities for interacting with the plugin system
+ help [cmd] display help for [cmd]
+
+ Options:
+
+ -h, --help output usage information
+ -V, --version output the version number
+ -c, --config [path] Specify the configuration file to load
+ --pid [path] Specify a path to output the current PID to
+```
+
+Most commands contain sub-commands. Running with cli with such a command generates the docs for the sub-commands and options therein.
+
+Change user password is likely to be in the `users` command group.
+
+```
+talk :) ]$ bin/cli users
+
+ Usage: cli-users [options] [command]
+
+
+ Commands:
+
+ create [options] create a new user
+ delete delete a user
+ passwd change a password for a user
+ update [options] update a user
+ list list all the users in the database
+ merge merge srcUser into the dstUser
+ addrole adds a role to a given user
+ removerole removes a role from a given user
+ ban ban a given user
+ uban unban a given user
+ disable disable a given user from logging in
+ enable enable a given user from logging in
+
+ Options:
+
+ -h, --help output usage information
+ -V, --version output the version number
+ -c, --config [path] Specify the configuration file to load
+ --pid [path] Specify a path to output the current PID to
+```
+
+I now see that I can change a password like so:
+
+```
+bin/cli users passwd [userID]
+```
+
+You can also read these help prompts by [exploring the source code](https://github.com/coralproject/talk/blob/master/bin/cli).
+
+### Usage Notes
+
+If you haven't used a cli enabled system before, think of it like this: generally, you'd make a rest call, rpc, etc... to perform an action. The cli's api is designed in the same way, just for the audience of command line wielding engineers and scripts.
+
+The best way to understand what the cli does is to explore the help commands. Uses of cli are also scattered through this documentation in context of their topics.
+
+For some real world uses of the cli, see the scripts in the [package.json file](https://github.com/coralproject/talk/blob/d688f70c19d8dee48371784009fd07322dae4eb5/package.json#L8).
+
+## What's really going on when I run the cli?
+
+The cli tool is a standalone application. Running it starts up the internals of a talk process, executes the given command, then shuts it down. No server functionality is enabled by cli commands unless specifically noted.
+
+The cli tool _does not require a talk server to be running._ This means that you can execute commands, for example, during and installation process before starting the server. The also means that you can execute commands using varying configurations (via the `-c [.env file]` flag).
+
+### Accessing existing Talk installs with the cli
+
+You may use the cli tool to 'remotely' control existing talk installs.
+
+This is accomplished by running the cli tool on any box using the mongo/redis/etc... credentials for the environment that you would like to act on. For example, if you want something to happen periodically on your production Talk install, you could set up a utility box with a cron job that triggers the cli with the same db/cache credentials. If you want to do something quick on a staging server, you could run the cli locally with staging credentials.
+
+The cli tool will connect directly with the install's db and redis instance(s) so ensure that your box can reach those servers on the appropriate ports.
+
+Also, _please ensure your cli and the server(s) in an environment are using the same version of Talk._
+
+Please secure your environments and credentials or the cli tool becomes a convenient way for someone to own your system.
+
+## Extending the cli
+
+The Talk cli is based on the excellent [commander](https://github.com/tj/commander.js/) library.
+
+At the time of writing, there are no plugin hooks for the cli tool. If you would like to change this, whether by writing code yourself or recommending a need, please [write and issue](https://github.com/coralproject/talk/blob/053b687959d45bcd682a1a2a4b604ebfab7441bb/CONTRIBUTING.md#writing-code).
diff --git a/docs/architecture-tags.md b/docs/architecture-tags.md
new file mode 100644
index 000000000..06c5d3498
--- /dev/null
+++ b/docs/architecture-tags.md
@@ -0,0 +1,71 @@
+---
+title: Tags
+keywords: architecture
+sidebar: talk_sidebar
+permalink: architecture-tags.html
+summary:
+---
+
+Tags are essentially strings that can be added to models. Currently, tags can be added to [Users, Comments and Assets](https://github.com/coralproject/talk/blob/ced449a1489d47c25d604020fa2e0b3b7a741353/graph/typeDefs.graphql#L144). If you would like to add tags to other models, you can extend this schema using [GraphQL hooks](plugins-server.html#graphql-hooks).
+
+## Tag Definitions
+
+When handling tags, the Talk Server references a set of definitions that describe how tags are handled. These definitions are keyed off the tag `name`, the simple string that is stored on items.
+
+The schema for Tag definitions [can be found here](https://github.com/coralproject/talk/blob/3545bf01cd91044fdb738d337a0ac94d9f71fbc3/models/schema/tag.js).
+
+Note that along with the `name`, tag definitions contains:
+
+* `permissions` information about who can see and set the tag,
+* `models` which `ITEM_TYPES` this tag can be applied to, and
+
+Whenever a tag is 'handled' by the server, it references this definition to determine that tag's behavior.
+
+See [Plugin API Documentation](plugins-server.html#field-tags) for more information.
+
+### Creating a Tag Definition
+
+Tag Definitions must be created in order for the system to determine what tags are permitted on the server side.
+
+Tag Definitions do not contain any logic themselves but provide information that other parts of the system can use to specify which models a tag can be applied to (models) and perform authorization logic (permissions).
+
+Take the tag created by `coral-plugin-offtopic` as an example.
+
+```
+// coral-plugin-offtopic/index.js
+module.exports = {
+ tags: [
+ {
+ name: 'OFF_TOPIC',
+ permissions: {
+ public: true,
+ self: true,
+ roles: []
+ },
+ models: ['COMMENTS'],
+ created_at: new Date()
+ }
+ ]
+};
+```
+
+This plugin allows users to self-report that their comment is "off topic" at the time of creation, then display a badge on those comments.
+
+To accomplish this, the plugin creates the tag `OFF_TOPIC` with:
+
+* `permissions.public: true` - will be sent over the wire to the client side
+* `permissions.self: true` - can be added by the active user to themselves or assets they own
+* `permissions.roles: []` - cannot be added by anyone based on their roles
+* `models: ['COMMENTS']` - can only be added to COMMENTS (not to users/assets/etc...)
+
+And [viola](https://youtu.be/Q0O9gFf-tiI?t=23s)! This tag is something that can only be created by the logged in user on their own comments and is sent over the wire to the client so it can display the badge.
+
+## Tag Links
+
+When tags are stored on objects in the database, they are represented by [TagLinks](https://github.com/coralproject/talk/blob/master/models/schema/tag_link.js).
+
+A TagLinks says that `tag` was `assigned_by` a specific user at a specific time (`created_at`).
+
+Note that the `tag` field in the TagLinkSchema is the full TagSchema itself. This allows for another level of flexibility. Server code may generate Tags on the fly, complete with programmatically generated permissions and item behaviors.
+
+If a Tag definitions exists in the global/asset context then that definition will be used regardless of what is stored here. This allows high level controls on the behavior of tags, ensuring that plugins cannot produce unexpected definitions for already defined tags.
diff --git a/docs/architecture.md b/docs/architecture.md
new file mode 100644
index 000000000..180e172ac
--- /dev/null
+++ b/docs/architecture.md
@@ -0,0 +1,80 @@
+---
+title: Architecture Overview
+keywords: architecture
+sidebar: talk_sidebar
+permalink: architecture.html
+summary:
+---
+
+## Talk's Architecture
+
+Talk consists of four distinct layers of code:
+
+* Plugins
+* Plugin API
+* Core
+* cli
+
+### Plugins
+
+Talk plugins deliver the features and functionality that can be changed or removed. Much of the default functionality is delivered by plugins allowing developers to change behavior along product lines that we've found to be important.
+
+### Plugin API
+
+Talk plugins interact exclusively with the Plugin API. Maintaining this layer of separation between plugins and core allows us to consciously design the api that we want it publish to plugin authors. We can then expose just the elements of core that make sense and maintain that contract as core changes.
+
+### Core
+
+Talk core consists of architecture and functionality that deliver stability, security, scalability, extendability, etc... In addition, the Core contains features and functionality that is essential to the operation of Talk as a product.
+
+Our goal is to continually extend our plugin infrastructure making the Core as pluggable as possible. Ultimately, a day may come where the Core of Talk is simply a framework for delivering a certain flavor of web applications.
+
+### cli
+
+Talk ships with [a cli tool](architecture-cli.html) that exposes functionality to the command line. We seek to provide cli functionality for all features that could need to be accomplished programmatically or prior to the server's startup.
+
+## Thinking about Plugins, the Plugin API and Core?
+
+The following is a template for a thought process that may help clarify your ideas against the backdrop of Talk's architecture.
+
+Think of a feature or capability. It could be something that's already in Talk or not. It could be something you want to build, or something you'd think would be a terrible idea. The important part here is to have something to interrogate.
+
+```
+wait(60000);
+```
+
+Now, ask these questions:
+
+### Is it a Plugin?
+
+Most work for Talk happens in the Plugin space. If the answers to any of these questions is Yes, then you're thinking of a Plugin.
+
+* Does Talk's existing Plugin APIs support the thing you want to build?
+* Is this something that only some users will want/need?
+* Is this something that we want devs to iterate on widely?
+
+You should [build it as a plugin](plugins-quickstart.html). Feel free to explore here on your own or reach out to us. We love to advise on plugins, so please feel free to [file an issue](https://github.com/coralproject/talk/blob/master/CONTRIBUTING.md) and we will start a conversation. We will help you conceptualize, architect and promote your plugin if it is in line with our values.
+
+### Does it need updates to the Plugin API?
+
+If you answered yes above:
+
+* Do I need to extend the Plugin API to support my plugin?
+
+Often times all the functionality a plugin needs is in the Core, but the Plugin API doesn't expose it. In these cases, we seek to iteratively extend the Talk Plugin API. All Plugin API contributions from the community must begin by [filing an Issue](https://github.com/coralproject/talk/blob/master/CONTRIBUTING.md).
+
+Note: we are stabilizing the process by which new Plugin API bindings are created, agreed upon and ultimately made part of our Plugins Contract. If you are interested in this process, please reach out to us.
+
+### Does it require updates to the Plugin API _and_ Core?
+
+What, if any, changes need to be made to Core so that the API can be extended?
+
+Quite often the only things missing from Core are things like _events_, _slots_, _CSS classes_, etc... Adding these is a great way to become a Core Contributor and break new ground as a Plugin Developer.
+
+We seek to keep Core as lean as possible.
+
+### Is my idea really just Core?
+
+Amazing! We are always looking to extend the capabilities of Talk. We look forward to discussing what you've got to bring!
+
+Please see our [contributing guide](](https://github.com/coralproject/talk/blob/master/CONTRIBUTING.md)) for more information.
diff --git a/docs/plugins-quickstart.md b/docs/plugins-quickstart.md
index 77de5e8a0..b69c14d72 100644
--- a/docs/plugins-quickstart.md
+++ b/docs/plugins-quickstart.md
@@ -215,7 +215,7 @@ It is important to realize that when you're writing a Talk plugin you are writin
### Publish to npm
-In order to [register](http://localhost:4000/plugins.html#plugin-registration) your _published_ plugin, you will need to [publish it to npm](https://docs.npmjs.com/getting-started/publishing-npm-packages).
+In order to [register](plugins.html#plugin-registration) your _published_ plugin, you will need to [publish it to npm](https://docs.npmjs.com/getting-started/publishing-npm-packages).
Once the package is published, update `plugins.json` to use the published plugin:
diff --git a/locales/en.yml b/locales/en.yml
index 44db5e1b8..e3bf42e5e 100644
--- a/locales/en.yml
+++ b/locales/en.yml
@@ -2,6 +2,7 @@ en:
your_account_has_been_suspended: Your account has been temporarily suspended.
your_account_has_been_banned: Your account has been banned.
your_username_has_been_rejected: Your account has been suspended because your username has been deemed inappropriate. To restore your account please enter a new username.
+ embed_comments_tab: Comments
bandialog:
are_you_sure: "Are you sure you would like to ban {0}?"
ban_user: "Ban User?"
diff --git a/locales/es.yml b/locales/es.yml
index a6b1bc4cd..fe6030b74 100644
--- a/locales/es.yml
+++ b/locales/es.yml
@@ -2,6 +2,7 @@ es:
your_account_has_been_suspended: Su cuenta ha sido temporalmente suspendida.
your_account_has_been_banned: Su cuenta ha sido suspendida.
your_username_has_been_rejected: Su cuenta ha sido suspendida porque tu nombre de usuario ha sido considerado no apropiado para el espacio. Para recuperar la cuenta, por favor ingresar un nuevo nombre de usuario.
+ embed_comments_tab: Comentarios
bandialog:
are_you_sure: "¿Estás segura que quieres suspender a {0}?"
ban_user: "¿Quieres suspender el Usuario?"
diff --git a/package.json b/package.json
index 0eeeabd2e..21e597c4b 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "talk",
- "version": "2.3.0",
+ "version": "2.4.0",
"description": "A better commenting experience from Mozilla, The New York Times, and the Washington Post. https://coralproject.net",
"main": "app.js",
"scripts": {
diff --git a/plugins/coral-plugin-auth/client/components/styles.css b/plugins/coral-plugin-auth/client/components/styles.css
index c8fbf9a30..735f34d31 100644
--- a/plugins/coral-plugin-auth/client/components/styles.css
+++ b/plugins/coral-plugin-auth/client/components/styles.css
@@ -66,7 +66,7 @@ input.error{
}
.userBox {
- padding: 10px 0 20px;
+ margin: 10px 0 20px;
letter-spacing: 0.1px;
}
diff --git a/plugins/coral-plugin-like/client/LikeButton.js b/plugins/coral-plugin-like/client/LikeButton.js
index 7d17ef056..dfbf88d1c 100644
--- a/plugins/coral-plugin-like/client/LikeButton.js
+++ b/plugins/coral-plugin-like/client/LikeButton.js
@@ -45,8 +45,10 @@ class LikeButton extends React.Component {
className={cn(styles.button, {[styles.liked]: alreadyReacted}, `${plugin}-button`)}
onClick={this.handleClick}
>
- {t(alreadyReacted ? 'coral-plugin-like.liked' : 'coral-plugin-like.like')}
-
+
+ {t(alreadyReacted ? 'coral-plugin-like.liked' : 'coral-plugin-like.like')}
+
+ {count > 0 && count}