Permalink
Browse files

Code of Conduct support [fixes #69, thanks @limulus]

  • Loading branch information...
1 parent c2430a2 commit bbc8e8dfc1ab72cc402b71250bc9ec07483b4bc3 @rauchg committed Nov 19, 2015
Showing with 93 additions and 6 deletions.
  1. +1 −1 Procfile
  2. +4 −0 app.json
  3. +1 −0 bin/slackin
  4. +11 −0 lib/assets/checkbox-checked.svg
  5. BIN lib/assets/checkbox.png
  6. +12 −0 lib/assets/checkbox.svg
  7. +4 −2 lib/assets/client.js
  8. +9 −2 lib/index.js
  9. +51 −1 lib/splash.js
View
@@ -1 +1 @@
-web: bin/slackin --channels "$SLACK_CHANNELS" --port $PORT $SLACK_SUBDOMAIN $SLACK_API_TOKEN
+web: bin/slackin --coc "$SLACK_COC" --channels "$SLACK_CHANNELS" --port $PORT $SLACK_SUBDOMAIN $SLACK_API_TOKEN
View
@@ -13,6 +13,10 @@
"description": "A Slack API token (find it on https://api.slack.com/web)",
"required": true
},
+ "SLACK_COC": {
+ "description": "A URL to a Code of Conduct people must agree on before joining.",
+ "required": false
+ },
"SLACK_CHANNELS": {
"description": "Comma-separated list of single guest channels to invite them to (leave blank for a normal, all-channel invite). In order to make this work, you have to have a paid account. You'll only be able to invite as many people as your number of paying members times 5.",
"required": false
View
@@ -14,6 +14,7 @@ program
.option('-i, --interval <int>', 'How frequently (ms) to poll Slack [$SLACK_INTERVAL or 5000]', process.env.SLACK_INTERVAL || 5000)
.option('-P, --path', 'Path to serve slackin under', '/')
.option('-s, --silent', 'Do not print out warns or errors')
+.option('-C, --coc <coc>', 'Full URL to a CoC that needs to be agreed to')
.option('-c, --css <file>', 'Full URL to a custom CSS file to use on the main page')
.parse(process.argv);
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg width="15px" height="15px" viewBox="0 0 15 15" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
+ <!-- Generator: Sketch 3.4 (15575) - http://www.bohemiancoding.com/sketch -->
+ <title>Untitled</title>
+ <desc>Created with Sketch.</desc>
+ <defs></defs>
+ <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
+ <rect id="Rectangle-2" stroke="#000000" sketch:type="MSShapeGroup" x="0" y="0" width="15" height="15"></rect>
+ <path d="M7.15531926,10.7858006 C7.13881898,10.809301 7.12906882,10.8363014 7.10781846,10.8573018 C7.00906682,10.9560534 6.87956466,11.0013042 6.75031251,10.9978041 C6.62106035,11.0015542 6.49155819,10.9560534 6.39305655,10.8573018 C6.3718062,10.8363014 6.36205603,10.809801 6.34580576,10.7858006 L3.16350273,7.88125219 C2.94549909,7.67949882 2.94549909,7.35274338 3.16350273,7.15124002 C3.38100635,6.94973666 3.73451224,6.94973666 3.95251588,7.15124002 L6.75031251,9.80953433 L11.097635,4.14793997 C11.3041384,3.95068668 11.639144,3.95068668 11.8456474,4.14793997 C12.0521509,4.34569326 12.0521509,4.66694862 11.8456474,4.86495192 L7.15531926,10.7858006 L7.15531926,10.7858006 Z" id="Path" fill="#000000" sketch:type="MSShapeGroup"></path>
+ </g>
+</svg>
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg width="30px" height="15px" viewBox="0 0 30 15" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">
+ <!-- Generator: Sketch 3.4 (15575) - http://www.bohemiancoding.com/sketch -->
+ <title>Untitled</title>
+ <desc>Created with Sketch.</desc>
+ <defs></defs>
+ <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">
+ <rect id="Rectangle-2" stroke="#000000" sketch:type="MSShapeGroup" x="15" y="0" width="15" height="15"></rect>
+ <path d="M22.1553193,10.7858006 C22.138819,10.809301 22.1290688,10.8363014 22.1078185,10.8573018 C22.0090668,10.9560534 21.8795647,11.0013042 21.7503125,10.9978041 C21.6210604,11.0015542 21.4915582,10.9560534 21.3930566,10.8573018 C21.3718062,10.8363014 21.362056,10.809801 21.3458058,10.7858006 L18.1635027,7.88125219 C17.9454991,7.67949882 17.9454991,7.35274338 18.1635027,7.15124002 C18.3810064,6.94973666 18.7345122,6.94973666 18.9525159,7.15124002 L21.7503125,9.80953433 L26.097635,4.14793997 C26.3041384,3.95068668 26.639144,3.95068668 26.8456474,4.14793997 C27.0521509,4.34569326 27.0521509,4.66694862 26.8456474,4.86495192 L22.1553193,10.7858006 L22.1553193,10.7858006 Z" id="Path" fill="#000000" sketch:type="MSShapeGroup"></path>
+ <rect id="Rectangle-2" stroke="#000000" sketch:type="MSShapeGroup" x="0" y="0" width="15" height="15"></rect>
+ </g>
+</svg>
View
@@ -6,6 +6,7 @@ var request = superagent;
// elements
var select = body.querySelector('select');
var input = body.querySelector('input');
+var coc = body.querySelector('input[name=coc]');
var button = body.querySelector('button');
// remove loading state
@@ -18,7 +19,7 @@ body.addEventListener('submit', function(ev){
button.className = '';
button.innerHTML = 'Please Wait';
var channel = select ? select.value : null;
- invite(channel, input.value, function(err){
+ invite(channel, coc && coc.checked ? 1 : 0, input.value, function(err){
if (err) {
button.removeAttribute('disabled');
button.className = 'error';
@@ -31,10 +32,11 @@ body.addEventListener('submit', function(ev){
});
-function invite(channel, email, fn){
+function invite(channel, coc, email, fn){
request
.post(data.path + 'invite')
.send({
+ coc: coc,
channel: channel,
email: email
})
View
@@ -23,6 +23,7 @@ export default function slackin({
interval = 5000, // jshint ignore:line
org,
css,
+ coc,
path='/',
channels,
silent = false // jshint ignore:line
@@ -71,7 +72,7 @@ export default function slackin({
dom('link rel="shortcut icon" href=https://slack.global.ssl.fastly.net/272a/img/icons/favicon-32.png'),
css && dom('link rel=stylesheet', { href: css })
),
- splash({ path, css, name, org, logo, channels, active, total })
+ splash({ coc, path, css, name, org, logo, channels, active, total })
);
res.type('html');
res.send(page.toHTML());
@@ -112,6 +113,12 @@ export default function slackin({
.json({ msg: 'Invalid email' });
}
+ if (coc && '1' != req.body.coc) {
+ return res
+ .status(400)
+ .json({ msg: 'Agreement to CoC is mandatory' });
+ }
+
invite({ token, org, email, channel: chanId }, err => {
if (err) {
return res
@@ -137,7 +144,7 @@ export default function slackin({
let { name } = slack.org;
let { active, total } = slack.users;
if (!name) return res.send(404);
- let dom = splash({ path, name, channels, active, total, iframe: true });
+ let dom = splash({ coc, path, name, channels, active, total, iframe: true });
res.type('html');
res.send(dom.toHTML());
});
View
@@ -1,7 +1,7 @@
import dom from 'vd';
-export default function splash({ path, name, org, logo, active, total, channels, iframe }){
+export default function splash({ path, name, org, coc, logo, active, total, channels, iframe }){
let div = dom('.splash',
!iframe && dom('.logos',
logo && dom('.logo.org'),
@@ -30,6 +30,14 @@ export default function splash({ path, name, org, logo, active, total, channels,
),
dom('input.form-item type=email placeholder=you@yourdomain.com '
+ (!iframe ? 'autofocus' : '')),
+ coc && dom('.coc',
+ dom('label',
+ dom('input type=checkbox name=coc value=1'),
+ 'I agree to the ',
+ dom('a', { href: coc, target: '_blank', }, 'Code of Conduct'),
+ '.'
+ )
+ ),
dom('button.loading', 'Get my Invite')
),
!iframe && dom('p.signin',
@@ -132,6 +140,48 @@ function style({ logo, active, iframe } = {}){
}
}
+ css.add('.coc', {
+ 'font-size': '12px',
+ padding: '15px 0 5px',
+ color: '#666'
+ });
+
+ css.add('.coc label', {
+ cursor: 'pointer'
+ });
+
+ css.add('.coc input', {
+ 'appearance': 'none',
+ '-webkit-appearance': 'none',
+ border: 'none',
+ 'vertical-align': 'middle',
+ margin: '0 5px 0 0',
+ });
+
+ css.add('.coc input::after', {
+ content: '""',
+ display: 'inline-block',
+ width: '15px',
+ height: '15px',
+ 'vertical-align': 'middle',
+ background: 'url(/assets/checkbox.svg)',
+ cursor: 'pointer'
+ });
+
+ css.add('.coc input:checked::after', {
+ 'background-position': 'right'
+ });
+
+ css.add('.coc a', {
+ color: '#666'
+ });
+
+ css.add('.coc a:hover', {
+ 'background-color': '#666',
+ 'text-decoration': 'none',
+ color: '#fff'
+ });
+
css.add('p', {
'font-size': iframe ? '12px' : '15px',
'margin': iframe ? '0 0 5px' : '5px 0'

0 comments on commit bbc8e8d

Please sign in to comment.