Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
28 changed files
with
3,153 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# OS X | ||
.DS_Store | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM octohost/nodejs | ||
|
||
ENV PORT 3000 | ||
|
||
ADD . /srv/www | ||
|
||
WORKDIR /srv/www | ||
|
||
RUN npm install | ||
|
||
RUN make | ||
|
||
EXPOSE 3000 | ||
|
||
CMD ./bin/slackin --channels $SLACK_CHANNELS --port $PORT $SLACK_SUBDOMAIN $SLACK_API_TOKEN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
|
||
0.5.0 / 2015-05-07 | ||
================== | ||
|
||
* allow for multiple guest channels [afeld] | ||
* add important notes to README | ||
* better error handling and tests [afeld] | ||
* add Slack favicon and better title [frabrunelle] | ||
* error when the token account is not an admin [martypenner] | ||
* added Dockerfile [darron] | ||
|
||
0.4.0 / 2015-04-10 | ||
================== | ||
|
||
* use SVG Heroku button | ||
* fixed svg dimensions issues | ||
* exclude bots (and slackbot) from users count | ||
* improve mobile zoom | ||
* use `<input type="email">` | ||
* fix for single-channel guests invitation parameter name | ||
|
||
0.3.1 / 2015-03-16 | ||
================== | ||
|
||
* fix meta tags for mobile support | ||
|
||
0.3.0 / 2015-03-06 | ||
================== | ||
|
||
* update `babel`, fix all scenarios | ||
|
||
0.2.9 / 2015-03-03 | ||
================== | ||
|
||
* package: bump `socket.io` | ||
|
||
0.2.8 / 2015-02-03 | ||
================== | ||
|
||
* bump socket.io | ||
|
||
0.2.7 / 2015-02-02 | ||
================== | ||
|
||
* support for custom css | ||
|
||
0.2.6 / 2015-02-01 | ||
================== | ||
|
||
* fix issue with 6to5 and `-g install` | ||
|
||
0.2.5 / 2015-02-01 | ||
================== | ||
|
||
* fix single channel invites to be ultra restricted | ||
|
||
0.2.4 / 2015-02-01 | ||
================== | ||
|
||
* bump 6to5 | ||
|
||
0.2.3 / 2015-02-01 | ||
================== | ||
|
||
* fixed heroku button | ||
|
||
0.2.2 / 2015-01-30 | ||
================== | ||
|
||
* fixed ability to `require('slackin')` | ||
|
||
0.2.1 / 2015-01-30 | ||
================== | ||
|
||
* improved startup speed by leveraging pre-compilation | ||
|
||
0.2.0 / 2015-01-30 | ||
================== | ||
|
||
* improved CLI interface [buildkite] | ||
* support for ENV vars [buildkite] | ||
* deploy to heroku button [buildkite] | ||
|
||
0.1.2 / 2015-01-28 | ||
================== | ||
|
||
* fix bin name [brianloweswords] | ||
|
||
0.1.1 / 2015-01-26 | ||
================== | ||
|
||
* fix typo | ||
|
||
0.1.0 / 2015-01-26 | ||
================== | ||
|
||
* initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
BABEL = ./node_modules/.bin/babel | ||
|
||
all: node | ||
|
||
node: lib | ||
@mkdir -p node/assets/ | ||
@rm -rf node/assets/* | ||
@cp -r lib/assets node/ | ||
@for path in lib/*.js; do \ | ||
file=`basename $$path`; \ | ||
$(BABEL) "lib/$$file" > "node/$$file"; \ | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
web: make && bin/slackin --channels "$SLACK_CHANNELS" --port $PORT $SLACK_SUBDOMAIN $SLACK_API_TOKEN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,116 @@ | ||
<!-- | ||
# | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you 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. | ||
# | ||
--> | ||
|
||
# Cordova Labs | ||
# slackin | ||
|
||
> Caution: Safety Goggles are Recommended! | ||
A little server that enables public access | ||
to a Slack server. Like Freenode, but on Slack. | ||
|
||
## Purpose | ||
It provides | ||
|
||
The purpose of this repo is for experimental code. Examples include demo apps, | ||
native api explorations, or anything really that does not fit in an existing Cordova platform. | ||
- A landing page you can point users to fill in their | ||
emails and receive an invite (`http://slack.yourdomain.com`) | ||
- An `<iframe>` badge to embed on any website | ||
that shows connected users in *realtime* with socket.io. | ||
- A SVG badge that works well from static mediums | ||
(like GitHub README pages) | ||
|
||
## Project Organization | ||
Read more about the [motivations and history](http://rauchg.com/slackin) behind Slackin. | ||
|
||
> Everyone works on a branch | ||
## How to use | ||
|
||
`master` branch should *never* have content. | ||
### Server | ||
|
||
Each project should create a separate branch to work on. There are major benefits | ||
to this practice: | ||
[](https://heroku.com/deploy?template=https://github.com/rauchg/slackin/tree/0.5.0) | ||
|
||
- Each project has an isolate git history, which allows for easy migration to | ||
a new git repository; | ||
- Working directory is not polluted with the files of other projects. | ||
- Projects will not step on each others toes. | ||
Or install it and launch it on your server: | ||
|
||
## Migrating Repositories | ||
```bash | ||
$ npm install -g slackin | ||
$ slackin "your-slack-subdomain" "your-slack-token" | ||
``` | ||
|
||
One day, you labs project may grow up and need it's own repository. | ||
You can easily move all of your Git history to your new repository with the | ||
following steps: | ||
You can find your API token at [api.slack.com/web](https://api.slack.com/web) – note that the user you use to generate the token must be an admin. You may want to create a dedicated `@slackin-inviter` user (or similar) for this. | ||
|
||
# cd to labs and checkout your project's branch | ||
git checkout my-branch | ||
The available options are: | ||
|
||
# add your new repository as a remote | ||
git add remote my-remote <url> | ||
``` | ||
Usage: slackin [options] <slack-subdomain> <api-token> | ||
# currently, my-remote should be empty (no commits) | ||
Options: | ||
# push my-branch to my-remote's master branch | ||
git push my-remote my-branch:master | ||
-h, --help output usage information | ||
-V, --version output the version number | ||
-p, --port <port> Port to listen on [$PORT or 3000] | ||
-c, --channels [<chan>] One or more comma-separated channel names to allow single-channel guests [$SLACK_CHANNELS] | ||
-i, --interval <int> How frequently (ms) to poll Slack [$SLACK_INTERVAL or 1000] | ||
-s, --silent Do not print out warns or errors | ||
``` | ||
|
||
# now clone your new project (my-remote) | ||
git clone <url> | ||
**Important: if you use Slackin in single-channel mode, you'll only be | ||
able to invite as many external accounts as paying members you have | ||
times 5. If you are not getting invite emails, this might be the reason. | ||
Workaround: sign up for a free org, and set up Slackin to point to it | ||
(all channels will be visible).** | ||
|
||
### Realtime Badge | ||
|
||
[](http://slack.socket.io) | ||
|
||
```html | ||
<script async defer src="http://slackin.yourhost.com/slackin.js"></script> | ||
``` | ||
|
||
or for the large version, append `?large`: | ||
|
||
```html | ||
<script async defer src="http://slackin.yourhost.com/slackin.js?large"></script> | ||
``` | ||
|
||
### SVG | ||
|
||
[](http://slack.socket.io) | ||
|
||
```html | ||
<img src="http://slackin.yourhost.com/badge.svg"> | ||
``` | ||
|
||
### Landing page | ||
|
||
[](http://slack.socket.io) | ||
|
||
Point to `http://slackin.yourhost.com`. | ||
|
||
**Note:** the image for the logo of the landing page | ||
is retrieved from the Slack API. If your organization | ||
doesn't have one configured, it won't be shown. | ||
|
||
## API | ||
|
||
Requiring `slackin` as a module will return | ||
a `Function` that creates a `HTTP.Server` instance | ||
that you can manipulate. | ||
|
||
```js | ||
require('slackin')({ | ||
token: 'yourtoken', // required | ||
interval: 1000, | ||
org: 'your-slack-subdomain', // required | ||
channels: 'channel,channel,...' // for single channel mode | ||
silent: false // suppresses warnings | ||
}).listen(3000); | ||
``` | ||
|
||
This will show response times from Slack and how many | ||
online users you have on the console. | ||
|
||
By default logging is enabled. | ||
|
||
## Credits | ||
|
||
- The SVG badge generation was taken from the | ||
excellent [shields](https://github.com/badges/shields) project. | ||
- The button CSS is based on | ||
[github-buttons](https://github.com/mdo/github-buttons). | ||
|
||
## License | ||
|
||
MIT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"name": "Slackin", | ||
"description": "Let people invite themselves to your Slack", | ||
"logo": "https://i.imgur.com/odDO1Fx.png", | ||
"repository": "https://github.com/rauchg/slackin", | ||
"keywords": ["node", "slack"], | ||
"env": { | ||
"SLACK_SUBDOMAIN": { | ||
"description": "Your Slack's subdomain (**this**.slack.com)", | ||
"required": true | ||
}, | ||
"SLACK_API_TOKEN": { | ||
"description": "A Slack API token (find it on https://api.slack.com/web)", | ||
"required": true | ||
}, | ||
"SLACK_CHANNEL": { | ||
"description": "Name of a single guest channel 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 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/env node | ||
|
||
var pkg = require('../package'); | ||
var program = require('commander'); | ||
var slackin = require('../node'); | ||
|
||
program | ||
.version(pkg.version) | ||
.usage('[options] <slack-subdomain> <api-token>') | ||
.option('-p, --port <port>', 'Port to listen on [$PORT or 3000]', process.env.PORT || 3000) | ||
.option('-c, --channels [<chan>]', 'One or more comma-separated channel names to allow single-channel guests [$SLACK_CHANNELS]', process.env.SLACK_CHANNELS) | ||
.option('-c, --channel <chan>', 'Single channel guest invite (deprecated) [$SLACK_CHANNEL]', process.env.SLACK_CHANNEL) | ||
.option('-i, --interval <int>', 'How frequently (ms) to poll Slack [$SLACK_INTERVAL or 1000]', process.env.SLACK_INTERVAL || 1000) | ||
.option('-s, --silent', 'Do not print out warns or errors') | ||
.option('-c, --css <file>', 'Full URL to a custom CSS file to use on the main page') | ||
.parse(process.argv); | ||
|
||
if (program.args.length != 2) { | ||
program.help(); | ||
} else { | ||
program.org = program.args[0]; | ||
program.token = program.args[1]; | ||
} | ||
|
||
// support deprecated option | ||
if (!program.channels && program.channel) { | ||
program.channels = program.channel; | ||
} | ||
|
||
var port = program.port; | ||
slackin(program).listen(port, function(err){ | ||
if (err) throw err; | ||
if (!program.silent) console.log('%s – listening on *:%d', new Date, port); | ||
}); |
Oops, something went wrong.