Skip to content

Commit b3d2995

Browse files
committed
updated README, installation procedure is maybe workable now
1 parent 440a8e1 commit b3d2995

File tree

2 files changed

+39
-117
lines changed

2 files changed

+39
-117
lines changed

README.md

Lines changed: 38 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -1,168 +1,89 @@
1-
# NOT YET READY FOR PRIMETIME
1+
### Introduction
22

3-
I still need to test and streamline the installation procedure for interested developers.
3+
This 'ggtracker' repository is the web server for ggtracker, plus the
4+
HTML/CSS/Javascript that makes the pretty pages pretty.
45

5-
So keep it quiet for now, thanks :)
6+
It does *not* do replay parsing, and delegates queries about players
7+
and matches to the ESDB API, both of which are in other repos:
8+
9+
* ESDB <-- the ruby API server, planning to make this public but it's not ready yet
10+
* https://github.com/dsjoerg/ggpyjobs <-- the replay-parsing python server
11+
* https://github.com/dsjoerg/gg <-- little gem for accessing ESDB
612

713

814
### Requirements
915

1016
* Ruby 1.9+ (get RVM: https://rvm.io/)
11-
* Bundler 1.2.0+ (gem install bundler --pre) [not a hard requirement currently, but will be at some point (see Bundlers 1.2 features)]
17+
* Bundler 1.2.0+ (gem install bundler --pre)
1218
* Redis
1319
* node.js, npm (see http://shapeshed.com/setting-up-nodejs-and-npm-on-mac-osx/)
1420
* juggernaut (npm install -g juggernaut, see https://github.com/maccman/juggernaut)
1521
* MySQL
1622

1723
On Mac OSX, I recommend using homebrew as package manager: http://mxcl.github.com/homebrew/
1824

19-
### Basic installation and updating
2025

21-
The first steps that should be done when checking out a fresh copy:
26+
### Basic installation and updating
2227

2328
* Run Bundler (`bundle`)
2429
* Copy and adjust database configuration (`cp config/database.yml.example config/database.yml`)
30+
* Copy secrets configuration (`cp config/secrets.yml.example config/secrets.yml`)
31+
* Copy s3 configuration (`cp config/s3.yml.example config/s3.yml`)
2532
* Create the database ggtracker needs (`mysql -u root` and then `create database ggtracker_development;` and then `quit`)
2633
* Run migrations (`bundle exec rake db:migrate`)
2734

28-
Whenever you pull in changes to Gemfile* or db/migrations, you should run Bundler or migrations, then check integrity by running specs.
29-
30-
Make sure to keep your bundle updated (especially the gg gem, which will receive updates often): `bundle update gg`
31-
32-
### Keeping npm/node updated
33-
34-
Note: node includes npm, which should be sufficient. If you installed npm before node, you may have to `brew link -f node`
35-
36-
Remember to keep node and npm updated. It's a little convoluted, due to their love for shellscript installers, but should be painless:
37-
38-
update/install npm: `curl https://npmjs.org/install.sh | sh`
39-
update/install node: `brew install node`
40-
41-
There are massive differences at times between minor revisions for both of these. Versions for development as of 9/16: npm 1.0.106, node 0.8.8
42-
4335
### Starting
4436

45-
To boot up the rails application, use `rails s` for Webrick or `foreman start web` to start Unicorn via Foreman.
46-
47-
If you need the full stack (Juggernaut for websockets/push, Resque for background jobs) use `foreman start` or `foreman start [component]` - see Procfile for components of the full stack.
37+
`foreman start web`
4838

49-
#### Running on multiple systems
39+
And then go to http://localhost:3000/ in your browser.
5040

51-
If you're running ggtracker and esdb on different systems (or just a system different than the one used to access ggtracker web), you need to set the ESDB host manually (it defaults to localhost:9292 in development) by setting the ESDB_HOST environment variable:
41+
Note: the first time you request a page, it will be slow while it compiles CSS, JS etc.
5242

53-
`ESDB_HOST=192.168.2.102:9292 foreman start web`
43+
It'll work, but there will be no matches, no players. To make it more interesting, point your ggtracker at the production ESDB server like so:
5444

55-
### Database Dumps
45+
`ESDB_HOST=api.ggtracker.com ESDB_MATCHBLOBS_BUCKET=gg2-matchblobs-prod foreman start web`
5646

57-
Once necessary, there will be dumps at https://github.com/ggtracker/ggtracker/downloads
47+
And then go to http://localhost:3000/matches in your browser. If you see recent matches, it's working!
5848

59-
Make sure you run migrations on these, especially if you pick an older one.
6049

61-
### Testing
62-
63-
#### Javascript (via Testacular, with Jasmine)
64-
65-
Install testacular: `npm install -g testacular`
50+
### Keeping npm/node updated
6651

67-
Note: Depending on your system configuration, the executable might not be in your PATH by default.
52+
update/install npm: `curl https://npmjs.org/install.sh | sh`
53+
update/install node: `brew install node`
6854

69-
Start testacular: `/usr/local/share/npm/bin/testacular start`
55+
Note: node includes npm, which should be sufficient. If you installed npm before node, you may have to `brew link -f node`
7056

71-
This will launch a chrome window (you need chrome installed, of course) and automatically monitor specs for changes.
7257

73-
Run all tests: `/usr/local/share/npm/bin/testacular run`
58+
### Testing
7459

7560
#### Ruby (rspec)
7661

77-
Make sure you have your test database set up in config/database.yml and created, then prepare it via `rake db:test:prepare` (run this after applying new migrations, it applies the schema to your test database)
62+
The first time you run tests, set up the test database with:
63+
* `mysql -u root`
64+
** `create database ggtracker_test;`
65+
** `quit`
66+
* `rake db:test:prepare`
7867

79-
Execute all specs: `bundle exec rspec`
68+
To run tests: `bundle exec rspec`
8069

81-
To create specs, you can use the rspec: generators (e.g. `rails g rspec:controller <name>`)
8270

8371
#### Test Coverage (ruby, simplecov)
8472

85-
To see our test coverage, simply run all specs and open coverage/index.html in a browser!
73+
After running rspec, open coverage/index.html in a browser.
8674

87-
## Caching
8875

89-
Varnish is used via the varnish_frontend recipe (which adds a NAT route to work with HAProxy)
9076

91-
A quick rundown of how and why this works:
92-
93-
Rails sets HTTP caching headers (Cache-Control) in application_controller#setup_http_caching - these are picked up by varnish and determine whether it should cache the response or not.
94-
95-
Rails also sets a cookie named "cctrl" via Warden callbacks in config/initializers/warden.rb which when set will make Varnish pass through all requests to Rails, effectively disabling all caching for logged in users.
96-
97-
To ensure that the browser checks with us, we let Varnish modify Cache-Control (setting it to no-cache) to disable caching.
98-
99-
All varnish configuration is in the recipe, at cookbooks/varnish_frontend/templates/default/app.vcl.erb
100-
101-
## Deployment
102-
### How to avoid depedency injection issues
103-
104-
If you're seeing javascript errors like `Uncaught Error: Unknown provider: e from gg` in production, make sure all angular code has proper dependency injection set up. When minifying/obfuscating the javascript code, method names and arguments are being renamed. To avoid problems with this, you should use `factory` (and it's friends `controller`, etc.) wherever you need to inject dependencies.
105-
106-
e.g. instead of this:
107-
108-
SomeController = function(dependency) {}
109-
110-
Do this:
111-
112-
gg.controller('SomeController', ['dependency', function(dependency){}]);
113-
114-
For more information, read: http://docs.angularjs.org/guide/di
115-
116-
### Notes on debugging dependency injection:
117-
118-
As said, one of the most prominent pointers are "xProvider" missing errors and these will only appear once we've minified/uglified the code, so it's hard to track them down.
119-
120-
* Run ggtracker in production, precompile all assets
121-
* Always restart the appserver, and re-precompile the assets before you do
122-
* Start with retracing any recent changes, then remove/comment them out entirely until the problem goes away
123-
* Then start re-introducing code until it re-appears
124-
125-
May be an obvious procedure, but even I forget restarting the appserver from time to time, or precompilation after a step, or even attempt to debug it by trying to read the minified code.. just don't. It's nasty.
126-
127-
Also, as I've outlined above, these are likely DI issues and as such you can also just grep for a controller that slipped by without proper definition:
128-
129-
$ find app/assets/javascripts/|xargs grep "controller: f"
130-
(TODO: figure out an elaborate grep regex that also greps for directive/factory definitions that aren't an array and.. add a pre-commit hook that dies a horrible death?)
131-
132-
## Styling Rules
133-
134-
I'll keep a very concise list of things to do and not to do in the CSS structure that is established here, just for the record.
135-
136-
* Do not listen to random blogs on the internet. Almost nothing has a "best practice" in how you structure stylesheets, it's always app specific.
137-
* Do not separate position and color, or anything really. This is something people in 2000 thought would be cool. It is not and has never been. One block per selector.
138-
* Do not try to group stuff, keep things in the order and structure that the intended usage dictates. li inside ul blocks, etc.
139-
* Use [SCSS](http://sass-lang.com/). It's like looking into the future. Nesting rules is a thing of beauty. Do NOT use Sass (or HAML for that matter)! I would rather kill myself than convert another SASS stylesheet hell into proper (S)CSS.
140-
* Use [Compass](http://compass-style.org/). Do not user browser specific rules - if one exists, it's likely the Compass framework has a helper for it.
141-
* Do not apply (location) specific styles to generic components when it can be helped. If that button needs to be blue on one page and green on the other, give the button style a way to do that. At the very least, give it .button-green and .button-blue classes that you then apply instead of giving #pageN .button the color green.
142-
* If it belongs inside a widget (directive, controller, etc.), it puts the styles in its own file or else it gets the hose again.
143-
144-
Plus more implicit rules that are so engrained in my muscle memory that I can't think of them right now.
145-
146-
### About Bootstrap Usage
147-
148-
I've opted to not use all-out bootstrap because it makes customizations a mess, much more complex than necessary and will include even more unused code. However, bootstrap is very good CSS and javascript. As such, it makes cherrypicking the features you want very easy.
149-
150-
Here's some notes for the future:
77+
#### Javascript (via Testacular, with Jasmine)
15178

152-
* Whenever there is time, it may be worthwhile to write a quick rake task that pulls in, updates and automatically translate or just outright uses bootstraps LESS. Until then, simply taking the LESS code and translating ".<include>" calls into "@include <include>" and @variables into $variables is also just a 5-minute-job.
153-
* All of bootstraps CSS/JS is in either javascripts/bootstrap or stylesheets/ui, named exactly like it is in bootstrap.
154-
* Modifications to bootstrap are done after bootstrap is included, outside of the bootstrap files. They are always left genuine (apart from translation into SCSS.)
79+
NOTE: *The following is obsolete as of 20140815. If & when more than one person is actively developing GGTracker Javascript code, I'll revive it.*
15580

156-
### HTML5!
81+
Install testacular: `npm install -g testacular`
15782

158-
* Don't use <section> to arbitrarily replace <div> - sections are meant to be a section of content, says Captain Obvious.
159-
* There really only is one <header>, it has the navigation, period. Same goes for <footer>
83+
Note: Depending on your system configuration, the executable might not be in your PATH by default.
16084

161-
Here's a small read on the subject: http://html5doctor.com/avoiding-common-html5-mistakes/
85+
Start testacular: `/usr/local/share/npm/bin/testacular start`
16286

163-
Bottom line: most of the new tags in HTML aren't meant to be styling aids. They have a CLEAR semantic meaning. We should not abuse them. You can never go wrong with a <div> when in doubt. It's better to have no semantic structure than to have it wrong.
164-
165-
Some class naming aids in "my style":
87+
This will launch a chrome window (you need chrome installed, of course) and automatically monitor specs for changes.
16688

167-
* header and footer are the header and footer of the page. Only one exists. Don't ever give anything a class name "header" - use "top", "bottom" and "middle" to denote their structural position if necessary. You might see me calling something "head" from time to time, which then is because ..it's actually a heading, such as the global "head" sitting in .content - it's huge, unique and unmistakably a heading element. I don't call it head because it's on top.
168-
* Don't use id for anything that isn't unique. No id shall ever be used twice on a page. When in doubt: class, not id.
89+
Run all tests: `/usr/local/share/npm/bin/testacular run`

config/application.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ def secret(key)
8181

8282
# S3 configuration from config/s3.yml
8383
config.s3 = YAML.load(ERB.new(File.read("#{Rails.root}/config/s3.yml")).result)[Rails.env]
84+
config.s3['matchblobs']['bucket'] = ENV['ESDB_MATCHBLOBS_BUCKET'] if ENV['ESDB_MATCHBLOBS_BUCKET']
8485

8586
config.generators do |g|
8687
# We disable all automatic spec generation because it's annoying behavior

0 commit comments

Comments
 (0)