diff --git a/README.md b/README.md index 0b77e95b7..3b258736f 100644 --- a/README.md +++ b/README.md @@ -1,62 +1,49 @@ # Talk [![CircleCI](https://circleci.com/gh/coralproject/talk.svg?style=svg)](https://circleci.com/gh/coralproject/talk) -A commenting platform from The Coral Project. [https://coralproject.net](https://coralproject.net) + +A commenting platform from [The Coral Project](https://coralproject.net). ## Contributing to Talk ### Product Roadmap -You can view what the Coral Team is working on next here: https://www.pivotaltracker.com/n/projects/1863625 -You can view product ideas and our longer term roadmap here: https://trello.com/b/ILND751a/talk +You can view what the Coral Team is working on next here https://www.pivotaltracker.com/n/projects/1863625. -### Local Dependencies -Node +You can view product ideas and our longer term roadmap here https://trello.com/b/ILND751a/talk. -Mongo - -### Getting Started -`npm install` -Run it once to install the dependencies. - -`npm start` -Runs Talk. +## Usage ### Configuration The Talk application requires specific configuration options to be available inside the environment in order to run, those variables are listed here: -- `TALK_SESSION_SECRET` (*required*) - a random string which will be used to +- `TALK_MONGO_URL` (*required*) - the database connection string for the MongoDB database. +- `TALK_REDIS_URL` (*required*) - the database connection string for the Redis database. +- `TALK_SESSION_SECRET` (*required*) - a random string which will be used to secure cookies. - `TALK_FACEBOOK_APP_ID` (*required*) - the Facebook app id for your Facebook Login enabled app. - `TALK_FACEBOOK_APP_SECRET` (*required*) - the Facebook app secret for your Facebook Login enabled app. -- `TALK_ROOT_URL` (*required*) - root url of the installed application externally +- `TALK_ROOT_URL` (*required*) - root url of the installed application externally available in the format: `://` without the path. -- `TALK_SMTP_PROVIDER` (*required*) - SMTP provider name. +- `TALK_SMTP_EMAIL` (*required*) - the address to send emails from using the + SMTP provider. - `TALK_SMTP_USERNAME` (*required*) - username of the SMTP provider you are using. - `TALK_SMTP_PASSWORD` (*required*) - password for the SMTP provider you are using. - `TALK_SMTP_HOST` (*required*) - SMTP host url with format `smtp.domain.com`. - `TALK_SMTP_PORT` (*required*) - SMTP port. -### Running with Docker -Make sure you have Docker running first and then run `docker-compose up -d` - -### Testing -`npm test` - -### Lint -`npm run lint` - -### Helpful URLs -Comment stream: http://localhost:3000/ - -Comment stream embedded on sample article: http://localhost:3000/assets/samplearticle.html - -Moderator view: http://localhost:3000/admin - -### Docs -`swagger.yaml` - ### License -**Apache-2.0** + + Copyright 2016 Mozilla Foundation + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + + See the License for the specific language governing permissions and limitations under the License. diff --git a/app.json b/app.json new file mode 100644 index 000000000..ba15f1ce4 --- /dev/null +++ b/app.json @@ -0,0 +1,32 @@ +{ + "name": "The Coral Project: Talk", + "env": { + "TALK_SESSION_SECRET": { + "description": "The session secret", + "generator": "secret" + }, + "TALK_FACEBOOK_APP_ID": { + "value": "", + "required": true + }, + "TALK_FACEBOOK_APP_SECRET": { + "value": "", + "required": true + }, + "NODE_ENV": "production", + "TALK_SMTP_PORT": "2525", + "REWRITE_ENV": "TALK_PORT:PORT,TALK_MONGO_URL:MONGO_URI,TALK_REDIS_URL:REDIS_URL,TALK_SMTP_HOST:POSTMARK_SMTP_SERVER,TALK_SMTP_USERNAME:POSTMARK_API_TOKEN,TALK_SMTP_PASSWORD:POSTMARK_API_TOKEN" + }, + "addons": [{ + "plan": "mongolab:sandbox", + "as": "MONGO" + }, { + "plan": "rediscloud:30", + "as": "REDIS" + }, { + "plan": "postmark:10k", + "as": "POSTMARK" + }], + "image": "heroku/nodejs", + "success_url": "/admin/setup" +} diff --git a/bin/cli b/bin/cli index d8148282f..131614e86 100755 --- a/bin/cli +++ b/bin/cli @@ -1,10 +1,9 @@ #!/usr/bin/env node -/** - * Setup the debug paramater. - */ - -process.env.DEBUG = process.env.TALK_DEBUG; +// Perform rewrites to the runtime environment variables based on the contents +// of the process.env.REWRITE_ENV if it exists. This is done here as it is the +// entrypoint for the entire application. +require('env-rewrite').rewrite(); /** * Module dependencies. diff --git a/bin/cli-assets b/bin/cli-assets index 4b0d65c2a..008460f9e 100755 --- a/bin/cli-assets +++ b/bin/cli-assets @@ -1,11 +1,5 @@ #!/usr/bin/env node -/** - * Setup the debug paramater. - */ - -process.env.DEBUG = process.env.TALK_DEBUG; - /** * Module dependencies. */ diff --git a/bin/cli-jobs b/bin/cli-jobs index 91a0a6e59..60a7b8efb 100755 --- a/bin/cli-jobs +++ b/bin/cli-jobs @@ -1,11 +1,5 @@ #!/usr/bin/env node -/** - * Setup the debug paramater. - */ - -process.env.DEBUG = process.env.TALK_DEBUG; - /** * Module dependencies. */ diff --git a/bin/cli-serve b/bin/cli-serve index 5478b7c1e..05fe6efc7 100755 --- a/bin/cli-serve +++ b/bin/cli-serve @@ -1,11 +1,5 @@ #!/usr/bin/env node -/** - * Setup the debug paramater. - */ - -process.env.DEBUG = process.env.TALK_DEBUG; - const app = require('../app'); const debug = require('debug')('talk:server'); const http = require('http'); diff --git a/bin/cli-settings b/bin/cli-settings index e38249199..5fdfbc38f 100755 --- a/bin/cli-settings +++ b/bin/cli-settings @@ -1,11 +1,5 @@ #!/usr/bin/env node -/** - * Setup the debug paramater. - */ - -process.env.DEBUG = process.env.TALK_DEBUG; - /** * Module dependencies. */ diff --git a/bin/cli-users b/bin/cli-users index e212a477f..ae688e122 100755 --- a/bin/cli-users +++ b/bin/cli-users @@ -1,11 +1,5 @@ #!/usr/bin/env node -/** - * Setup the debug paramater. - */ - -process.env.DEBUG = process.env.TALK_DEBUG; - /** * Module dependencies. */ diff --git a/package.json b/package.json index c61934043..4d4aa01bb 100644 --- a/package.json +++ b/package.json @@ -5,15 +5,16 @@ "main": "app.js", "scripts": { "start": "./bin/cli serve --jobs", - "build": "NODE_ENV=production ./node_modules/.bin/webpack --config webpack.config.js --bail", - "build-watch": "NODE_ENV=development ./node_modules/.bin/webpack --config webpack.config.dev.js --watch", - "lint": "./node_modules/.bin/eslint bin/* .", - "lint-fix": "./node_modules/.bin/eslint bin/* . --fix", - "test": "NODE_ENV=test ./node_modules/.bin/mocha --compilers js:babel-core/register tests/helpers/*.js --require ignore-styles --recursive tests", - "test-watch": "NODE_ENV=test ./node_modules/.bin/mocha --compilers js:babel-core/register --recursive -w tests", + "build": "NODE_ENV=production webpack --config webpack.config.js --bail", + "build-watch": "NODE_ENV=development webpack --config webpack.config.dev.js --watch", + "lint": "eslint bin/* .", + "lint-fix": "eslint bin/* . --fix", + "test": "NODE_ENV=test mocha --compilers js:babel-core/register tests/helpers/*.js --require ignore-styles --recursive tests", + "test-watch": "NODE_ENV=test mocha --compilers js:babel-core/register --recursive -w tests", "pree2e": "NODE_ENV=test scripts/pree2e.sh", "e2e": "NODE_ENV=test nightwatch", - "embed-start": "NODE_ENV=development npm run build && ./bin/cli serve --jobs" + "embed-start": "NODE_ENV=development npm run build && ./bin/cli serve --jobs", + "postinstall": "npm run build" }, "config": { "pre-git": { @@ -53,6 +54,7 @@ "connect-redis": "^3.1.0", "debug": "^2.2.0", "ejs": "^2.5.2", + "env-rewrite": "^1.0.2", "express": "^4.14.0", "express-session": "^1.14.2", "helmet": "^3.1.0",