diff --git a/.env.sample b/.env.sample
new file mode 100644
index 0000000..29ee038
--- /dev/null
+++ b/.env.sample
@@ -0,0 +1,4 @@
+SLACK_CLIENT_ID=
+SLACK_CLIENT_SECRET=
+STRIPE_API_PUBLISHABLE_KEY=
+STRIPE_API_KEY=
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..aea4ab7
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,6 @@
+.DS_Store
+.rvmrc
+.irbrc
+.bundle
+log
+.env
diff --git a/.rspec b/.rspec
new file mode 100644
index 0000000..412e568
--- /dev/null
+++ b/.rspec
@@ -0,0 +1,3 @@
+--color
+--format=documentation
+
diff --git a/.rubocop.yml b/.rubocop.yml
new file mode 100644
index 0000000..6314100
--- /dev/null
+++ b/.rubocop.yml
@@ -0,0 +1,5 @@
+Style/FrozenStringLiteralComment:
+ Enabled: false
+
+inherit_from: .rubocop_todo.yml
+
diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
new file mode 100644
index 0000000..31adea5
--- /dev/null
+++ b/.rubocop_todo.yml
@@ -0,0 +1,57 @@
+# This configuration was generated by
+# `rubocop --auto-gen-config`
+# on 2017-08-16 12:45:08 -0400 using RuboCop version 0.49.1.
+# The point is for the user to remove these configuration records
+# one by one as the offenses are removed from the code base.
+# Note that changes in the inspected code, or installation of new
+# versions of RuboCop, may require this file to be generated again.
+
+# Offense count: 1
+Lint/UselessAssignment:
+ Exclude:
+ - 'slack-sup/commands/subscription.rb'
+
+# Offense count: 6
+Metrics/AbcSize:
+ Max: 36
+
+# Offense count: 29
+# Configuration parameters: CountComments, ExcludedMethods.
+Metrics/BlockLength:
+ Max: 71
+
+# Offense count: 2
+Metrics/CyclomaticComplexity:
+ Max: 11
+
+# Offense count: 115
+# Configuration parameters: AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
+# URISchemes: http, https
+Metrics/LineLength:
+ Max: 242
+
+# Offense count: 5
+# Configuration parameters: CountComments.
+Metrics/MethodLength:
+ Max: 23
+
+# Offense count: 2
+Metrics/PerceivedComplexity:
+ Max: 11
+
+# Offense count: 26
+Style/Documentation:
+ Enabled: false
+
+# Offense count: 1
+# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts, AllowedAcronyms.
+# AllowedAcronyms: CLI, DSL, ACL, API, ASCII, CPU, CSS, DNS, EOF, GUID, HTML, HTTP, HTTPS, ID, IP, JSON, LHS, QPS, RAM, RHS, RPC, SLA, SMTP, SQL, SSH, TCP, TLS, TTL, UDP, UI, UID, UUID, URI, URL, UTF8, VM, XML, XMPP, XSRF, XSS
+Style/FileName:
+ Exclude:
+ - 'slack-sup.rb'
+
+# Offense count: 3
+Style/MultilineBlockChain:
+ Exclude:
+ - 'spec/api/endpoints/credit_cards_endpoint_spec.rb'
+ - 'spec/api/endpoints/subscriptions_endpoint_spec.rb'
diff --git a/.ruby-version b/.ruby-version
new file mode 100644
index 0000000..005119b
--- /dev/null
+++ b/.ruby-version
@@ -0,0 +1 @@
+2.4.1
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..7bf5205
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,20 @@
+rvm:
+ - 2.3.1
+
+language: ruby
+
+cache: bundler
+
+services:
+ - mongodb
+
+addons:
+ firefox: 54.0
+
+before_install:
+ - export DISPLAY=:99.0
+ - sh -e /etc/init.d/xvfb start
+ - wget https://github.com/mozilla/geckodriver/releases/download/v0.18.0/geckodriver-v0.18.0-linux64.tar.gz
+ - mkdir geckodriver
+ - tar -xzf geckodriver-v0.18.0-linux64.tar.gz -C geckodriver
+ - export PATH=$PATH:$PWD/geckodriver
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..7ab059a
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,3 @@
+### Changelog
+
+* 8/16/2017: Initial public release, Artsy hackathon 2017 - [@dblock](https://github.com/dblock).
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000..aa4ed90
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,125 @@
+# Contributing to SlackSup
+
+This project is work of [many contributors](https://github.com/dblock/slack-sup/graphs/contributors).
+
+You're encouraged to submit [pull requests](https://github.com/dblock/slack-sup/pulls), [propose features and discuss issues](https://github.com/dblock/slack-sup/issues).
+
+In the examples below, substitute your Github username for `contributor` in URLs.
+
+## Fork the Project
+
+Fork the [project on Github](https://github.com/dblock/slack-sup) and check out your copy.
+
+```
+git clone https://github.com/contributor/slack-sup.git
+cd slack-sup
+git remote add upstream https://github.com/dblock/slack-sup.git
+```
+
+## Create a Topic Branch
+
+Make sure your fork is up-to-date and create a topic branch for your feature or bug fix.
+
+```
+git checkout master
+git pull upstream master
+git checkout -b my-feature-branch
+```
+
+## Bundle Install and Test
+
+Ensure that you can build the project and run tests.
+
+```
+bundle install
+bundle exec rake
+```
+
+## Write Tests
+
+Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build.
+Add to [spec](spec).
+
+We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
+
+## Write Code
+
+Implement your feature or bug fix.
+
+Ruby style is enforced with [Rubocop](https://github.com/bbatsov/rubocop).
+Run `bundle exec rubocop` and fix any style issues highlighted.
+
+Make sure that `bundle exec rake` completes without errors.
+
+## Write Documentation
+
+Document any external behavior in the [README](README.md).
+
+## Update Changelog
+
+Add a line to [CHANGELOG](CHANGELOG.md) under *Next Release*.
+Make it look like every other line, including your name and link to your Github account.
+
+## Commit Changes
+
+Make sure git knows your name and email address:
+
+```
+git config --global user.name "Your Name"
+git config --global user.email "contributor@example.com"
+```
+
+Writing good commit logs is important. A commit log should describe what changed and why.
+
+```
+git add ...
+git commit
+```
+
+## Push
+
+```
+git push origin my-feature-branch
+```
+
+## Make a Pull Request
+
+Go to https://github.com/contributor/slack-sup and select your feature branch.
+Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
+
+## Rebase
+
+If you've been working on a change for a while, rebase with upstream/master.
+
+```
+git fetch upstream
+git rebase upstream/master
+git push origin my-feature-branch -f
+```
+
+## Update CHANGELOG Again
+
+Update the [CHANGELOG](CHANGELOG.md) with the pull request number. A typical entry looks as follows.
+
+```
+* [#123](https://github.com/dblock/slack-sup/pull/123): Reticulated splines - [@contributor](https://github.com/contributor).
+```
+
+Amend your previous commit and force push the changes.
+
+```
+git commit --amend
+git push origin my-feature-branch -f
+```
+
+## Check on Your Pull Request
+
+Go back to your pull request after a few minutes and see whether it passed muster with Travis-CI. Everything should look green, otherwise fix issues and amend your commit as described above.
+
+## Be Patient
+
+It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang on there!
+
+## Thank You
+
+Please do know that we really appreciate and value your time and work. We love you, really.
diff --git a/DEBUGGING.md b/DEBUGGING.md
new file mode 100644
index 0000000..438304e
--- /dev/null
+++ b/DEBUGGING.md
@@ -0,0 +1,25 @@
+## Debugging
+
+### Locally
+
+You can debug your instance of slack-sup with a built-in `script/console`.
+
+### Silence Mongoid Logger
+
+If Mongoid logging is annoying you.
+
+```ruby
+Mongoid.logger.level = Logger::INFO
+Mongo::Logger.logger.level = Logger::INFO
+```
+
+### Heroku
+
+```
+heroku run script/console --app=...
+
+Running `script/console` attached to terminal... up, run.7593
+
+2.2.1 > Team.count
+=> 3
+```
diff --git a/DEV.md b/DEV.md
new file mode 100644
index 0000000..759d1fd
--- /dev/null
+++ b/DEV.md
@@ -0,0 +1,60 @@
+## Development Environment
+
+You may want to watch [Your First Slack Bot Service video](http://code.dblock.org/2016/03/11/your-first-slack-bot-service-video.html) first.
+
+### Prerequisites
+
+Ensure that you can build the project and run tests. You will need these.
+
+- [MongoDB](https://docs.mongodb.com/manual/installation/)
+- [Firefox](https://www.mozilla.org/firefox/new/)
+- [Geckodriver](https://github.com/mozilla/geckodriver), download, `tar vfxz` and move to `/usr/local/bin`
+- Ruby 2.3.1
+
+```
+bundle install
+bundle exec rake
+```
+
+### Slack Team
+
+Create a Slack team [here](https://slack.com/create).
+
+### Slack App
+
+Create a test app [here](https://api.slack.com/apps). This gives you a client ID and a client secret.
+
+Under _Features/OAuth & Permissions_, configure the redirect URL to `http://localhost:5000`.
+
+Add the following Permission Scope.
+
+* Add a bot user with the username @bot.
+
+### Slack Keys
+
+Create a `.env` file.
+
+```
+SLACK_CLIENT_ID=slack_client_id
+SLACK_CLIENT_SECRET=slack_client_secret
+```
+
+### Stripe Keys
+
+If you want to test paid features or payment-related functions you need a [Stripe](https://www.stripe.com) account and test keys. Add to `.env` file.
+
+```
+STRIPE_API_PUBLISHABLE_KEY=pk_test_key
+STRIPE_API_KEY=sk_test_key
+```
+
+### Start the Bot
+
+```
+$ foreman start
+
+08:54:07 web.1 | started with pid 32503
+08:54:08 web.1 | I, [2017-08-04T08:54:08.138999 #32503] INFO -- : listening on addr=0.0.0.0:5000 fd=11
+```
+
+Navigate to [localhost:5000](http://localhost:5000).
diff --git a/Gemfile b/Gemfile
new file mode 100644
index 0000000..0e969fb
--- /dev/null
+++ b/Gemfile
@@ -0,0 +1,36 @@
+source 'http://rubygems.org'
+
+ruby '2.4.1'
+
+gem 'mongoid'
+gem 'mongoid-scroll'
+gem 'newrelic_rpm'
+gem 'rack-robotz'
+gem 'rack-server-pages'
+gem 'slack-ruby-bot-server'
+gem 'slack-ruby-client'
+gem 'stripe', '~> 1.58.0'
+
+group :development, :test do
+ gem 'foreman'
+ gem 'rake', '~> 10.4'
+ gem 'rubocop', '0.49.1'
+end
+
+group :development do
+ gem 'mongoid-shell'
+end
+
+group :test do
+ gem 'capybara'
+ gem 'database_cleaner'
+ gem 'fabrication'
+ gem 'faker'
+ gem 'hyperclient'
+ gem 'rack-test'
+ gem 'rspec'
+ gem 'selenium-webdriver'
+ gem 'stripe-ruby-mock', '~> 2.4.1', require: 'stripe_mock'
+ gem 'vcr'
+ gem 'webmock'
+end
diff --git a/Gemfile.lock b/Gemfile.lock
new file mode 100644
index 0000000..e49defd
--- /dev/null
+++ b/Gemfile.lock
@@ -0,0 +1,297 @@
+GEM
+ remote: http://rubygems.org/
+ specs:
+ activemodel (5.1.3)
+ activesupport (= 5.1.3)
+ activesupport (5.1.3)
+ concurrent-ruby (~> 1.0, >= 1.0.2)
+ i18n (~> 0.7)
+ minitest (~> 5.1)
+ tzinfo (~> 1.1)
+ addressable (2.5.1)
+ public_suffix (~> 2.0, >= 2.0.2)
+ ast (2.3.0)
+ axiom-types (0.1.1)
+ descendants_tracker (~> 0.0.4)
+ ice_nine (~> 0.11.0)
+ thread_safe (~> 0.3, >= 0.3.1)
+ bson (4.2.2)
+ builder (3.2.3)
+ capybara (2.15.1)
+ addressable
+ mini_mime (>= 0.1.3)
+ nokogiri (>= 1.3.3)
+ rack (>= 1.0.0)
+ rack-test (>= 0.5.4)
+ xpath (~> 2.0)
+ celluloid (0.17.3)
+ celluloid-essentials
+ celluloid-extras
+ celluloid-fsm
+ celluloid-pool
+ celluloid-supervision
+ timers (>= 4.1.1)
+ celluloid-essentials (0.20.5)
+ timers (>= 4.1.1)
+ celluloid-extras (0.20.5)
+ timers (>= 4.1.1)
+ celluloid-fsm (0.20.5)
+ timers (>= 4.1.1)
+ celluloid-io (0.17.3)
+ celluloid (>= 0.17.2)
+ nio4r (>= 1.1)
+ timers (>= 4.1.1)
+ celluloid-pool (0.20.5)
+ timers (>= 4.1.1)
+ celluloid-supervision (0.20.6)
+ timers (>= 4.1.1)
+ childprocess (0.7.1)
+ ffi (~> 1.0, >= 1.0.11)
+ coercible (1.0.0)
+ descendants_tracker (~> 0.0.1)
+ concurrent-ruby (1.0.5)
+ crack (0.4.3)
+ safe_yaml (~> 1.0.0)
+ dante (0.2.0)
+ database_cleaner (1.6.1)
+ declarative (0.0.9)
+ declarative-option (0.1.0)
+ descendants_tracker (0.0.4)
+ thread_safe (~> 0.3, >= 0.3.1)
+ diff-lcs (1.3)
+ domain_name (0.5.20170404)
+ unf (>= 0.0.5, < 1.0.0)
+ equalizer (0.0.11)
+ fabrication (2.16.2)
+ faker (1.8.4)
+ i18n (~> 0.5)
+ faraday (0.9.2)
+ multipart-post (>= 1.2, < 3)
+ faraday-digestauth (0.2.1)
+ faraday (~> 0.7)
+ net-http-digest_auth (~> 1.4)
+ faraday_hal_middleware (0.0.1)
+ faraday_middleware (>= 0.9, < 0.10)
+ faraday_middleware (0.9.2)
+ faraday (>= 0.7.4, < 0.10)
+ ffi (1.9.18)
+ foreman (0.84.0)
+ thor (~> 0.19.1)
+ futuroscope (0.1.11)
+ gli (2.16.1)
+ grape (1.0.0)
+ activesupport
+ builder
+ mustermann-grape (~> 1.0.0)
+ rack (>= 1.3.0)
+ rack-accept
+ virtus (>= 1.0.0)
+ grape-roar (0.4.1)
+ grape
+ multi_json
+ roar (~> 1.1.0)
+ grape-swagger (0.27.3)
+ grape (>= 0.16.2)
+ hashdiff (0.3.5)
+ hashie (3.5.6)
+ hitimes (1.2.6)
+ http-cookie (1.0.3)
+ domain_name (~> 0.5)
+ hyperclient (0.8.5)
+ faraday (>= 0.9.0)
+ faraday-digestauth
+ faraday_hal_middleware
+ faraday_middleware
+ futuroscope
+ net-http-digest_auth
+ uri_template
+ i18n (0.8.6)
+ ice_nine (0.11.2)
+ json (2.1.0)
+ kaminari-core (1.0.1)
+ kaminari-grape (1.0.1)
+ grape
+ kaminari-core (~> 1.0)
+ kgio (2.11.0)
+ mime-types (3.1)
+ mime-types-data (~> 3.2015)
+ mime-types-data (3.2016.0521)
+ mini_mime (0.1.4)
+ mini_portile2 (2.2.0)
+ minitest (5.10.3)
+ mongo (2.4.3)
+ bson (>= 4.2.1, < 5.0.0)
+ mongoid (6.2.1)
+ activemodel (~> 5.1)
+ mongo (>= 2.4.1, < 3.0.0)
+ mongoid-compatibility (0.4.1)
+ activesupport
+ mongoid (>= 2.0)
+ mongoid-scroll (0.3.5)
+ i18n
+ mongoid (>= 3.0)
+ mongoid-compatibility
+ mongoid-shell (0.4.4)
+ i18n
+ mongoid (>= 3.0.0)
+ mongoid-compatibility
+ multi_json (1.12.1)
+ multipart-post (2.0.0)
+ mustermann (1.0.0)
+ mustermann-grape (1.0.0)
+ mustermann (~> 1.0.0)
+ net-http-digest_auth (1.4.1)
+ netrc (0.11.0)
+ newrelic_rpm (4.3.0.335)
+ nio4r (2.1.0)
+ nokogiri (1.8.0)
+ mini_portile2 (~> 2.2.0)
+ parallel (1.12.0)
+ parser (2.4.0.0)
+ ast (~> 2.2)
+ powerpack (0.1.1)
+ public_suffix (2.0.5)
+ rack (2.0.3)
+ rack-accept (0.4.5)
+ rack (>= 0.4)
+ rack-cors (1.0.1)
+ rack-rewrite (1.5.1)
+ rack-robotz (0.0.4)
+ rack
+ rack-server-pages (0.1.0)
+ rack
+ rack-test (0.7.0)
+ rack (>= 1.0, < 3)
+ rainbow (2.2.2)
+ rake
+ raindrops (0.19.0)
+ rake (10.5.0)
+ representable (3.0.4)
+ declarative (< 0.1.0)
+ declarative-option (< 0.2.0)
+ uber (< 0.2.0)
+ rest-client (2.0.2)
+ http-cookie (>= 1.0.2, < 2.0)
+ mime-types (>= 1.16, < 4.0)
+ netrc (~> 0.8)
+ roar (1.1.0)
+ representable (~> 3.0.0)
+ rspec (3.6.0)
+ rspec-core (~> 3.6.0)
+ rspec-expectations (~> 3.6.0)
+ rspec-mocks (~> 3.6.0)
+ rspec-core (3.6.0)
+ rspec-support (~> 3.6.0)
+ rspec-expectations (3.6.0)
+ diff-lcs (>= 1.2.0, < 2.0)
+ rspec-support (~> 3.6.0)
+ rspec-mocks (3.6.0)
+ diff-lcs (>= 1.2.0, < 2.0)
+ rspec-support (~> 3.6.0)
+ rspec-support (3.6.0)
+ rubocop (0.49.1)
+ parallel (~> 1.10)
+ parser (>= 2.3.3.1, < 3.0)
+ powerpack (~> 0.1)
+ rainbow (>= 1.99.1, < 3.0)
+ ruby-progressbar (~> 1.7)
+ unicode-display_width (~> 1.0, >= 1.0.1)
+ ruby-progressbar (1.8.1)
+ rubyzip (1.2.1)
+ safe_yaml (1.0.4)
+ selenium-webdriver (3.5.1)
+ childprocess (~> 0.5)
+ rubyzip (~> 1.0)
+ slack-ruby-bot (0.10.4)
+ hashie
+ slack-ruby-client (>= 0.6.0)
+ slack-ruby-bot-server (0.6.1)
+ celluloid-io
+ foreman
+ grape
+ grape-roar (>= 0.4.0)
+ grape-swagger
+ kaminari-grape
+ rack-cors
+ rack-rewrite
+ rack-server-pages
+ slack-ruby-bot
+ unicorn
+ slack-ruby-client (0.9.0)
+ activesupport
+ faraday (>= 0.9)
+ faraday_middleware
+ gli
+ hashie
+ json
+ websocket-driver
+ stripe (1.58.0)
+ rest-client (>= 1.4, < 4.0)
+ stripe-ruby-mock (2.4.1)
+ dante (>= 0.2.0)
+ multi_json (~> 1.0)
+ stripe (>= 1.31.0, <= 1.58.0)
+ thor (0.19.4)
+ thread_safe (0.3.6)
+ timers (4.1.2)
+ hitimes
+ tzinfo (1.2.3)
+ thread_safe (~> 0.1)
+ uber (0.1.0)
+ unf (0.1.4)
+ unf_ext
+ unf_ext (0.0.7.4)
+ unicode-display_width (1.3.0)
+ unicorn (5.3.0)
+ kgio (~> 2.6)
+ raindrops (~> 0.7)
+ uri_template (0.7.0)
+ vcr (3.0.3)
+ virtus (1.0.5)
+ axiom-types (~> 0.1)
+ coercible (~> 1.0)
+ descendants_tracker (~> 0.0, >= 0.0.3)
+ equalizer (~> 0.0, >= 0.0.9)
+ webmock (3.0.1)
+ addressable (>= 2.3.6)
+ crack (>= 0.3.2)
+ hashdiff
+ websocket-driver (0.6.5)
+ websocket-extensions (>= 0.1.0)
+ websocket-extensions (0.1.2)
+ xpath (2.1.0)
+ nokogiri (~> 1.3)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ capybara
+ database_cleaner
+ fabrication
+ faker
+ foreman
+ hyperclient
+ mongoid
+ mongoid-scroll
+ mongoid-shell
+ newrelic_rpm
+ rack-robotz
+ rack-server-pages
+ rack-test
+ rake (~> 10.4)
+ rspec
+ rubocop (= 0.49.1)
+ selenium-webdriver
+ slack-ruby-bot-server
+ slack-ruby-client
+ stripe (~> 1.58.0)
+ stripe-ruby-mock (~> 2.4.1)
+ vcr
+ webmock
+
+RUBY VERSION
+ ruby 2.4.1p111
+
+BUNDLED WITH
+ 1.15.3
diff --git a/Guardfile b/Guardfile
new file mode 100644
index 0000000..efd406b
--- /dev/null
+++ b/Guardfile
@@ -0,0 +1,8 @@
+guard 'bundler' do
+ watch('Gemfile')
+end
+
+guard 'rack' do
+ watch('Gemfile.lock')
+ watch(%r{^(config|app|api)/.*})
+end
diff --git a/LICENSE.md b/LICENSE.md
new file mode 100644
index 0000000..9e4e55c
--- /dev/null
+++ b/LICENSE.md
@@ -0,0 +1,24 @@
+The MIT License (MIT)
+
+Copyright (c) 2017 Daniel Doubrovkine
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
+
+Icons made by [Vectors Market](https://www.flaticon.com/authors/vectors-market) from [Flaticon](http://www.flaticon.com)
+is licensed by [Creative Commons CC BY 3.0](http://creativecommons.org/licenses/by/3.0).
diff --git a/Procfile b/Procfile
new file mode 100644
index 0000000..5784a17
--- /dev/null
+++ b/Procfile
@@ -0,0 +1 @@
+web: bundle exec unicorn -p $PORT
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..4d52f6c
--- /dev/null
+++ b/README.md
@@ -0,0 +1,14 @@
+Slack Sup
+=========
+
+[![Build Status](https://travis-ci.org/dblock/slack-sup.svg?branch=master)](https://travis-ci.org/dblock/slack-sup)
+[![Dependency Status](https://gemnasium.com/dblock/slack-sup.svg)](https://gemnasium.com/dblock/slack-sup)
+[![Code Climate](https://codeclimate.com/github/dblock/slack-sup.svg)](https://codeclimate.com/github/dblock/slack-sup)
+
+A Sup' bot for Slack.
+
+### Copyright & License
+
+Copyright [Daniel Doubrovkine](http://code.dblock.org), 2017
+
+[MIT License](LICENSE)
diff --git a/Rakefile b/Rakefile
new file mode 100644
index 0000000..04cea0f
--- /dev/null
+++ b/Rakefile
@@ -0,0 +1,6 @@
+require 'rubygems'
+require 'bundler'
+
+Bundler.setup :default, :development
+
+import "tasks/#{ENV['RACK_ENV'] || 'development'}.rake"
diff --git a/app.json b/app.json
new file mode 100644
index 0000000..84f2105
--- /dev/null
+++ b/app.json
@@ -0,0 +1,9 @@
+{
+ "name": "Slack Sup",
+ "description": "A Slack bot for team sup.",
+ "respository": "https://github.com/dblock/slack-sup",
+ "keywords": ["slack", "bots", "sup", "teams"],
+ "addons": [
+ "mongolab"
+ ]
+}
diff --git a/config.ru b/config.ru
new file mode 100644
index 0000000..0d31739
--- /dev/null
+++ b/config.ru
@@ -0,0 +1,26 @@
+$LOAD_PATH.unshift(File.dirname(__FILE__))
+
+ENV['RACK_ENV'] ||= 'development'
+
+require 'bundler/setup'
+Bundler.require :default, ENV['RACK_ENV']
+
+require 'slack-ruby-bot-server'
+require 'slack-sup'
+
+SlackRubyBotServer.configure do |config|
+ config.server_class = SlackSup::Server
+end
+
+NewRelic::Agent.manual_start
+
+SlackSup::App.instance.prepare!
+
+Thread.abort_on_exception = true
+
+Thread.new do
+ SlackSup::Service.instance.start_from_database!
+ SlackSup::App.instance.after_start!
+end
+
+run Api::Middleware.instance
diff --git a/config/initializers/array.rb b/config/initializers/array.rb
new file mode 100644
index 0000000..541de80
--- /dev/null
+++ b/config/initializers/array.rb
@@ -0,0 +1,19 @@
+class Array
+ def and
+ join_with 'and'
+ end
+
+ def or
+ join_with 'or'
+ end
+
+ private
+
+ def join_with(separator)
+ if count > 1
+ "#{self[0..-2].join(', ')} #{separator} #{self[-1]}"
+ else
+ first
+ end
+ end
+end
diff --git a/config/initializers/slack-ruby-bot/hooks/message.rb b/config/initializers/slack-ruby-bot/hooks/message.rb
new file mode 100644
index 0000000..1983cb1
--- /dev/null
+++ b/config/initializers/slack-ruby-bot/hooks/message.rb
@@ -0,0 +1,13 @@
+module SlackRubyBot
+ module Hooks
+ class Message
+ # HACK: order command classes predictably
+ def command_classes
+ [
+ SlackSup::Commands::Help,
+ SlackSup::Commands::Subscription
+ ]
+ end
+ end
+ end
+end
diff --git a/config/initializers/stripe.rb b/config/initializers/stripe.rb
new file mode 100644
index 0000000..3bd9955
--- /dev/null
+++ b/config/initializers/stripe.rb
@@ -0,0 +1 @@
+Stripe.api_key = ENV['STRIPE_API_KEY'] if ENV.key?('STRIPE_API_KEY')
diff --git a/config/mongoid.yml b/config/mongoid.yml
new file mode 100644
index 0000000..150c7b7
--- /dev/null
+++ b/config/mongoid.yml
@@ -0,0 +1,27 @@
+development:
+ clients:
+ default:
+ database: slack_sup_development
+ hosts:
+ - 127.0.0.1:27017
+ options:
+ raise_not_found_error: false
+ use_utc: true
+
+test:
+ clients:
+ default:
+ database: slack_sup_test
+ hosts:
+ - 127.0.0.1:27017
+ options:
+ raise_not_found_error: false
+ use_utc: true
+
+production:
+ clients:
+ default:
+ uri: <%= ENV['MONGO_URL'] || ENV['MONGOHQ_URI'] || ENV['MONGOLAB_URI'] %>
+ options:
+ raise_not_found_error: false
+ use_utc: true
diff --git a/config/newrelic.yml b/config/newrelic.yml
new file mode 100644
index 0000000..364789b
--- /dev/null
+++ b/config/newrelic.yml
@@ -0,0 +1,217 @@
+# Here are the settings that are common to all environments
+common: &default_settings
+ # ============================== LICENSE KEY ===============================
+
+ # You must specify the license key associated with your New Relic
+ # account. This key binds your Agent's data to your account in the
+ # New Relic service.
+ license_key: '<%= ENV["NEW_RELIC_LICENSE_KEY"] %>'
+
+ # Application Name Set this to be the name of your application as
+ # you'd like it show up in New Relic. The service will then auto-map
+ # instances of your application into an "application" on your
+ # dashboard page. If you want to map this instance into multiple
+ # apps, like "AJAX Requests" and "All UI" then specify a semicolon
+ # separated list of up to three distinct names, or a yaml list.
+ app_name: <%= ENV["NEW_RELIC_APP_NAME"] || 'SlackSup' %>
+
+ # When "true", the agent collects performance data about your
+ # application and reports this data to the New Relic service at
+ # newrelic.com. This global switch is normally overridden for each
+ # environment below. (formerly called 'enabled')
+ monitor_mode: true
+
+ # Developer mode should be off in every environment but
+ # development as it has very high overhead in memory.
+ developer_mode: false
+
+ # The newrelic agent generates its own log file to keep its logging
+ # information separate from that of your application. Specify its
+ # log level here.
+ log_level: info
+
+ # Optionally set the path to the log file This is expanded from the
+ # root directory (may be relative or absolute, e.g. 'log/' or
+ # '/var/log/') The agent will attempt to create this directory if it
+ # does not exist.
+ # log_file_path: 'log'
+
+ # Optionally set the name of the log file, defaults to 'newrelic_agent.log'
+ # log_file_name: 'newrelic_agent.log'
+
+ # The newrelic agent communicates with the service via http by
+ # default. If you want to communicate via https to increase
+ # security, then turn on SSL by setting this value to true. Note,
+ # this will result in increased CPU overhead to perform the
+ # encryption involved in SSL communication, but this work is done
+ # asynchronously to the threads that process your application code,
+ # so it should not impact response times.
+ ssl: false
+
+ # EXPERIMENTAL: enable verification of the SSL certificate sent by
+ # the server. This setting has no effect unless SSL is enabled
+ # above. This may block your application. Only enable it if the data
+ # you send us needs end-to-end verified certificates.
+ #
+ # This means we cannot cache the DNS lookup, so each request to the
+ # service will perform a lookup. It also means that we cannot
+ # use a non-blocking lookup, so in a worst case, if you have DNS
+ # problems, your app may block indefinitely.
+ # verify_certificate: true
+
+ # Set your application's Apdex threshold value with the 'apdex_t'
+ # setting, in seconds. The apdex_t value determines the buckets used
+ # to compute your overall Apdex score.
+ # Requests that take less than apdex_t seconds to process will be
+ # classified as Satisfying transactions; more than apdex_t seconds
+ # as Tolerating transactions; and more than four times the apdex_t
+ # value as Frustrating transactions.
+ # For more about the Apdex standard, see
+ # http://newrelic.com/docs/general/apdex
+
+ apdex_t: 0.5
+
+ #============================== Browser Monitoring ===============================
+ # New Relic Real User Monitoring gives you insight into the performance real users are
+ # experiencing with your website. This is accomplished by measuring the time it takes for
+ # your users' browsers to download and render your web pages by injecting a small amount
+ # of JavaScript code into the header and footer of each page.
+ browser_monitoring:
+ # By default the agent automatically injects the monitoring JavaScript
+ # into web pages. Set this attribute to false to turn off this behavior.
+ auto_instrument: true
+
+ # Proxy settings for connecting to the service.
+ #
+ # If a proxy is used, the host setting is required. Other settings
+ # are optional. Default port is 8080.
+ #
+ # proxy_host: hostname
+ # proxy_port: 8080
+ # proxy_user:
+ # proxy_pass:
+
+
+ # Tells transaction tracer and error collector (when enabled)
+ # whether or not to capture HTTP params. When true, frameworks can
+ # exclude HTTP parameters from being captured.
+ # Rails: the RoR filter_parameter_logging excludes parameters
+ # Java: create a config setting called "ignored_params" and set it to
+ # a comma separated list of HTTP parameter names.
+ # ex: ignored_params: credit_card, ssn, password
+ capture_params: true
+
+
+ # Transaction tracer captures deep information about slow
+ # transactions and sends this to the service once a
+ # minute. Included in the transaction is the exact call sequence of
+ # the transactions including any SQL statements issued.
+ transaction_tracer:
+
+ # Transaction tracer is enabled by default. Set this to false to
+ # turn it off. This feature is only available at the Professional
+ # and above product levels.
+ enabled: true
+
+ # Threshold in seconds for when to collect a transaction
+ # trace. When the response time of a controller action exceeds
+ # this threshold, a transaction trace will be recorded and sent to
+ # the service. Valid values are any float value, or (default)
+ # "apdex_f", which will use the threshold for an dissatisfying
+ # Apdex controller action - four times the Apdex T value.
+ transaction_threshold: apdex_f
+
+ # When transaction tracer is on, SQL statements can optionally be
+ # recorded. The recorder has three modes, "off" which sends no
+ # SQL, "raw" which sends the SQL statement in its original form,
+ # and "obfuscated", which strips out numeric and string literals
+ record_sql: obfuscated
+
+ # Threshold in seconds for when to collect stack trace for a SQL
+ # call. In other words, when SQL statements exceed this threshold,
+ # then capture and send the current stack trace. This is
+ # helpful for pinpointing where long SQL calls originate from
+ stack_trace_threshold: 0.500
+
+ # Determines whether the agent will capture query plans for slow
+ # SQL queries. Only supported in mysql and postgres. Should be
+ # set to false when using other adapters.
+ # explain_enabled: true
+
+ # Threshold for query execution time below which query plans will not
+ # not be captured. Relevant only when `explain_enabled` is true.
+ # explain_threshold: 0.5
+
+ # Error collector captures information about uncaught exceptions and
+ # sends them to the service for viewing
+ error_collector:
+
+ # Error collector is enabled by default. Set this to false to turn
+ # it off. This feature is only available at the Professional and above
+ # product levels
+ enabled: true
+
+ # Rails Only - tells error collector whether or not to capture a
+ # source snippet around the place of the error when errors are View
+ # related.
+ capture_source: true
+
+ # To stop specific errors from reporting to New Relic, set this property
+ # to comma separated values. Default is to ignore routing errors
+ # which are how 404's get triggered.
+ #
+ ignore_errors: ActionController::RoutingError
+
+ # (Advanced) Uncomment this to ensure the cpu and memory samplers
+ # won't run. Useful when you are using the agent to monitor an
+ # external resource
+ # disable_samplers: true
+
+ # If you aren't interested in visibility in these areas, you can
+ # disable the instrumentation to reduce overhead.
+ #
+ # disable_view_instrumentation: true
+ # disable_activerecord_instrumentation: true
+ # disable_memcache_instrumentation: true
+ # disable_dj: true
+
+ # If you're interested in capturing memcache keys as though they
+ # were SQL uncomment this flag. Note that this does increase
+ # overhead slightly on every memcached call, and can have security
+ # implications if your memcached keys are sensitive
+ # capture_memcache_keys: true
+
+ # Certain types of instrumentation such as GC stats will not work if
+ # you are running multi-threaded. Please let us know.
+ # multi_threaded = false
+
+# Application Environments
+# ------------------------------------------
+
+development:
+ <<: *default_settings
+ # Turn off communication to New Relic service in development mode (also
+ # 'enabled').
+ # NOTE: for initial evaluation purposes, you may want to temporarily
+ # turn the agent on in development mode.
+ monitor_mode: false
+
+ # Rails Only - when running in Developer Mode, the New Relic Agent will
+ # present performance information on the last 100 transactions you have
+ # executed since starting the mongrel.
+ # NOTE: There is substantial overhead when running in developer mode.
+ # Do not use for production or load testing.
+ developer_mode: true
+
+ # Enable textmate links
+ # textmate: true
+
+test:
+ <<: *default_settings
+ # It almost never makes sense to turn on the agent when running
+ # unit, functional or integration tests or the like.
+ monitor_mode: false
+
+production:
+ <<: *default_settings
+ monitor_mode: true
diff --git a/public/favicon.ico b/public/favicon.ico
new file mode 100644
index 0000000..a22f4cb
Binary files /dev/null and b/public/favicon.ico differ
diff --git a/public/help.html b/public/help.html
new file mode 100644
index 0000000..fc3628a
--- /dev/null
+++ b/public/help.html
@@ -0,0 +1,15 @@
+
+
diff --git a/public/partials/_head.html.erb b/public/partials/_head.html.erb
new file mode 100644
index 0000000..e2adbad
--- /dev/null
+++ b/public/partials/_head.html.erb
@@ -0,0 +1,3 @@
+
+
+
diff --git a/public/privacy.html b/public/privacy.html
new file mode 100644
index 0000000..30df272
--- /dev/null
+++ b/public/privacy.html
@@ -0,0 +1,62 @@
+
+
+ Sup for Slack: Privacy Policy
+
+
+
+
+
+
tl;dr
+
+ Sup for Slack does not want to know who you are and tries to collect just enough data to enable our services.
+
+
1 - Definition and Nature of Personal Data
+
+ During your use of the services that can be accessed on the Website http://api-explorer.playplay.io (hereinafter referred to as the "Website"), including our Slack bots (hereinafter referred to as the "Bots"), we do not require you to provide us with any personal data, however we may collect data that indirectly allows us to indentify you. Therefore, the term "personal data" means any data that enables a person to be identified, which corresponds in particular to your family name, first name, photograph, postal address, email address, telephone numbers, date of birth, data relating to your transactions on the Website, detail of your orders and subscriptions, bank card number, messages, as well as any other information about you that you choose to provide us with.
+
+
2 - Types of Data We Collect
+
+ We do not collect personal information from users, but we do collect data that may indirectly identify you.
+
+
2.1 - Information Collected About Your Team from Slack
+
+ We collect the team's Slack ID, Team Name and Domain upon registration. Please see the the team data model for details.
+
+
2.2 - Information Collected About You from Slack
+
+ We do not collect any information about you from Slack.
+
+
2.3 - Information You Provide to Us
+
+ We may collect personal information from you, such as your first and last name, e-mail or Twitter handle if you provide us feedback or contact us. We will collect your name and e-mail address, as well as any other content included in the e-mail, in order to send you a reply.
+
+
2.4 - Information Collected from Slack Messages
+
+ We require you to communicate with Bots through Instant Messaging (Slack). This requires special care on our side, and a more restrictive privacy measures: We do not collect or keep information from incoming conversations, and we do not process messages transmitted, except for messages related to the explicit usage of the service. We do not monitor team channels.
+
+
2.5 - Information Collected via Technology
+
+ Logs. As is true of most websites, we gather certain information automatically and store it in logs. This information includes IP addresses, browser type, Internet service provider ("ISP"), referring/exit pages, operating system, date/time stamp, and clickstream data. We use this information to analyze trends, administer the Site, track users’ movements around the Site, gather demographic information about our user base as a whole, and better tailor our Services to our users’ needs. For example, some of the information may be collected so that when you visit the Site or the Services again, it will recognize you and the information could then be used to serve advertisements and other information appropriate to your interests. Except as noted in this Privacy Policy, we do not link this automatically-collected data to personal information. Cookies. Like many online services, we use cookies to collect information. "Cookies" are small pieces of information that a website sends to your computer’s hard drive while you are viewing the website. We may use both session Cookies (which expire once you close your web browser) and persistent Cookies (which stay on your computer until you delete them) to provide you with a more personal and interactive experience on our Service. This type of information is collected to make the Service more useful to you and to tailor the experience with us to meet your special interests and needs. Traffic analytics.
+
+ We use a number of third party service provides, such as Google Analytics, to help analyze how users use the Service ("Analytics Companies"). These Analytics Companies uses Cookies to collect information such as how often users visit the Service, what features they use on our Services, and what other sites they used prior to coming to the Site. We use the information we get from these Analytics Companies only to improve our Site and Services. These Analytics Companies collect only the IP address assigned to you on the date you visit the Service, rather than your name or other personally identifying information. We do not combine the information generated through the use of our Analytics Companies with your personal information. [NOTE: Please confirm] Although these Analytics Companies may plant a persistent Cookie on your web browser or mobile device to identify you as a unique user the next time you visit the Service, the Cookie cannot be used by anyone but the Analytics Company that placed the applicable Cookie. This Policy does not apply to and we are not responsible for the Cookies used by these Analytics Companies.
+
+
3 - Information Available Publicly
+
+ We do not make any information about you or your team available publicly.
+
+
4 - Transfer or Sale of Personal Data
+
+ We shall not sell, transfer or lease out your personal data to third parties.
+
+
5 - Safety
+
+ We reserve the right, at our sole discretion, to modify this Privacy policy or any portion thereof. Any changes will be effective from the time of publication of the new Privacy policy. Your use of the Website after the changes have been implemented implicitly expresses your acknowledgement and acceptance of the new Privacy policy. Otherwise, and if the new Privacy policy does not suit you, you must no longer use the Services.
+
+
6 - Modifications
+
+ We reserve the right, at our sole discretion, to modify this Privacy policy or any portion thereof. Any changes will be effective from the time of publication of the new Privacy policy. Your use of the Website after the changes have been implemented implicitly expresses your acknowledgement and acceptance of the new Privacy policy. Otherwise, and if the new Privacy policy does not suit you, you must no longer use the Services.
+
+ If you have any questions or concerns or complaints about our Privacy Policy or our data collection or processing practices, or if you want to report any security violations to us, please message @dblockdotorg on Twitter or e-mail dblock[at]dblock[dot]org.
+
+
+
diff --git a/public/scripts/jquery-1.7.1.min.js b/public/scripts/jquery-1.7.1.min.js
new file mode 100644
index 0000000..198b3ff
--- /dev/null
+++ b/public/scripts/jquery-1.7.1.min.js
@@ -0,0 +1,4 @@
+/*! jQuery v1.7.1 jquery.com | jquery.org/license */
+(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cv(a){if(!ck[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){cl||(cl=c.createElement("iframe"),cl.frameBorder=cl.width=cl.height=0),b.appendChild(cl);if(!cm||!cl.createElement)cm=(cl.contentWindow||cl.contentDocument).document,cm.write((c.compatMode==="CSS1Compat"?"":"")+""),cm.close();d=cm.createElement(a),cm.body.appendChild(d),e=f.css(d,"display"),b.removeChild(cl)}ck[a]=e}return ck[a]}function cu(a,b){var c={};f.each(cq.concat.apply([],cq.slice(0,b)),function(){c[this]=a});return c}function ct(){cr=b}function cs(){setTimeout(ct,0);return cr=f.now()}function cj(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ci(){try{return new a.XMLHttpRequest}catch(b){}}function cc(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){if(c!=="border")for(;g=0===c})}function S(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function K(){return!0}function J(){return!1}function n(a,b,c){var d=b+"defer",e=b+"queue",g=b+"mark",h=f._data(a,d);h&&(c==="queue"||!f._data(a,e))&&(c==="mark"||!f._data(a,g))&&setTimeout(function(){!f._data(a,e)&&!f._data(a,g)&&(f.removeData(a,d,!0),h.fire())},0)}function m(a){for(var b in a){if(b==="data"&&f.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function l(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(k,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNumeric(d)?parseFloat(d):j.test(d)?f.parseJSON(d):d}catch(g){}f.data(a,c,d)}else d=b}return d}function h(a){var b=g[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=/-([a-z]|[0-9])/ig,w=/^-ms-/,x=function(a,b){return(b+"").toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=m.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.7.1",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.add(a);return this},eq:function(a){a=+a;return a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;A.fireWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").off("ready")}},bindReady:function(){if(!A){A=e.Callbacks("once memory");if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||D.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw new Error(a)},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,"ms-").replace(v,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?i.call(arguments,0):b,j.notifyWith(k,e)}}function l(a){return function(c){b[a]=arguments.length>1?i.call(arguments,0):c,--g||j.resolveWith(j,b)}}var b=i.call(arguments,0),c=0,d=b.length,e=Array(d),g=d,h=d,j=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred(),k=j.promise();if(d>1){for(;c
a",d=q.getElementsByTagName("*"),e=q.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=q.getElementsByTagName("input")[0],b={leadingWhitespace:q.firstChild.nodeType===3,tbody:!q.getElementsByTagName("tbody").length,htmlSerialize:!!q.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:q.className!=="t",enctype:!!c.createElement("form").enctype,html5Clone:c.createElement("nav").cloneNode(!0).outerHTML!=="<:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,b.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,b.optDisabled=!h.disabled;try{delete q.test}catch(s){b.deleteExpando=!1}!q.addEventListener&&q.attachEvent&&q.fireEvent&&(q.attachEvent("onclick",function(){b.noCloneEvent=!1}),q.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),b.radioValue=i.value==="t",i.setAttribute("checked","checked"),q.appendChild(i),k=c.createDocumentFragment(),k.appendChild(q.lastChild),b.checkClone=k.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=i.checked,k.removeChild(i),k.appendChild(q),q.innerHTML="",a.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",q.style.width="2px",q.appendChild(j),b.reliableMarginRight=(parseInt((a.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0);if(q.attachEvent)for(o in{submit:1,change:1,focusin:1})n="on"+o,p=n in q,p||(q.setAttribute(n,"return;"),p=typeof q[n]=="function"),b[o+"Bubbles"]=p;k.removeChild(q),k=g=h=j=q=i=null,f(function(){var a,d,e,g,h,i,j,k,m,n,o,r=c.getElementsByTagName("body")[0];!r||(j=1,k="position:absolute;top:0;left:0;width:1px;height:1px;margin:0;",m="visibility:hidden;border:0;",n="style='"+k+"border:5px solid #000;padding:0;'",o="