If you want to run KQ Scene Scoring on your computer, or do development on it, follow the instructions in this section. Instructions for installing it on Heroku are provided later on.
Clone the repo and set up gems and the initial database:
$ git clone https://github.com/acidhelm/kq_scene_scoring_server.git
$ cd kq_scene_scoring_server
$ bundle install --path vendor/bundle
$ bin/rails db:schema:load
If you don't want to set up a GitHub account, you can also download the source code and unzip it.
There is one configuration key that you need to set, but you'll only have
to do this once. In the kq_scene_scoring_server
directory, run:
$ ruby -e 'require "securerandom"; puts "ATTR_ENCRYPTED_KEY=#{SecureRandom.hex 16}"' > .env
That creates an encryption key that only works on your computer. You should not copy that key to any other computer; generate a new key if you start using KQ Scene Scoring on another computer.
Then run the Rails server:
$ bin/rails server
KQ Scene Scoring accounts are used to hold the list of tournaments that you are scoring and your Challonge API key. You can find your API key in your account settings.
There is no UI for creating accounts, but you can make an account in the Rails console. Run the console:
$ bin/rails console
Then run this command to make an account:
> User.create user_name: "A user name",
api_key: "Your API key",
password: "A password"
The user name and password that you set here are used to log in to KQ Scene Scoring. They do not have to be the same as your Challonge user name and password.
KQ Scene Scoring is ready to deploy to a Heroku app, so that tournament scores can be viewed by anyone. These instructions assume that you have created accounts on Heroku and GitHub. KQ Scene Scoring doesn't require any paid components, so you can use a free Heroku account.
To use command-line tools, you must install the Heroku CLI app. After you clone the repo, run:
$ heroku create <heroku app name>
For example, run this command:
$ heroku create my-kq-scene-scoring
to create my-kq-scene-scoring.herokuapp.com. heroku create
also
creates a git remote with the default name of "heroku". Then, push
the app to that remote:
$ git push heroku master
You'll see a bunch of output as the app is compiled and installed. Next,
create the environment variable ATTR_ENCRYPTED_KEY
. Instead of creating an
.env
file, you add the variable to your Heroku app's configuration:
$ key=`ruby -e 'require "securerandom"; puts SecureRandom.hex(16)'`
$ heroku config:set ATTR_ENCRYPTED_KEY=$key
Next, set up the database:
$ heroku run rails db:migrate
Run the Rails console:
$ heroku console
and create a KQ Scene Scoring account as described earlier. You can then access KQ Scene Scoring at https://your-app-name.herokuapp.com.
On GitHub, fork the KQ Scene Scoring repo to make a copy of it in your GitHub account. On your Heroku dashboard, click New→Create new app, and give it a name. Click that app in the dashboard, then click Deploy. In the Deployment method section, click GitHub, then Connect to GitHub. That will show a popup window from GitHub asking you to allow Heroku to access your GitHub account. Click the Authorize button.
The Connect to GitHub page will now show your GitHub account and a search field. Enter the name of your forked repo and click Search. Click Connect next to your repo in the search results.
The page will have a new Manual deploy section at the bottom. Click Deploy branch to deploy the master branch to your Heroku app. Once the deployment is done, the page will say "Your app was successfully deployed." \o/
Click Settings, then in the top-right corner, click More→Run console. Type "bash", then click Run. Run the Ruby command to generate an encryption key as described earlier, and copy the key. Close the console.
Click Reveal config vars and create an ATTR_ENCRYPTED_KEY variable. Use the encryption key that you just created as the value for that variable. Create SLACK_TOKEN too if you want to send Slack notifications.
Click More→Run console again, and enter "rails db:migrate". When that finishes, click Run another command at the bottom of the window, and enter "console". Create a KQ Scene Scoring account as described earlier. You can then access KQ Scene Scoring at https://your-app-name.herokuapp.com.