Go Web Application for UVIC SENG 299 by Morgan, Mycheal, Ben, and Brandon
Created Summer 2016, forked and modified further by Morgan, 2019
A live demo of this app should be available at http://gogame.morganzolob.info/
If you just want to run this project, a docker-compose file has been provided to get you up and running quickly and easily. First clone this repo with the submodule:
git clone --recurse-submodules https://github.com/mogzol/Go-Game-WebApp.git
Next you will want to make a copy of app.env.dist
as app.env
and modify the variables inside it to suit your needs.
Now just make sure you have Docker installed on your machine, and then run docker-compose up app
from the root of the repo. It will take a little bit to download all the node modules, but eventually you should see a message that says 'Listening on port 10050'. Just navigate to localhost:10050 and you should see the site.
JetBrains IntelliJ (or WebStorm) is recommended for development. You can sign up for a student license for free: https://www.jetbrains.com/student/
SourceTree is a nice GUI for Git if you don't want to use the command line: https://www.sourcetreeapp.com/
Note that we use Nunjucks as our templating engine, which has a syntax similar to Twig (and Jinja), so if your editor supports Twig, make sure you set it to treat njk
files as twig
files. In JetBrains IDEs, this can be set in File > Settings > Editor > File Types and then find Twig in the list and add *.njk
to the registered patterns. If your editor does not support twig (or Jinja), then just treat njk
files as html
files.
To begin setting up your dev environment, clone the repo to your machine: https://github.com/mogzol/Go-Game-WebApp.git
Now run npm install
from the project directory, which will download and install all the dependencies specified in package.json
Next just make sure you have mongod
running, and then start the server with node server.js
(Node 6.2.2 or later is recommended).
The AI server is no longer up, but the AI repo has been included as a submodule in this repo (the goai folder). You can run your own instance of the ai, just be sure to set the GO_AI_HOST
and GO_AI_PORT
environmental variables before starting the main app, so that it knows where to connect to the AI.
The server.js
file is where the server is set up, and all the modules and routes are set up.
The actual logic for the pages is handled by the controllers in the controllers
folder. Controllers are auto-loaded, so after adding a new controller js file, it should just work without having to do anything in server.js
(other than setting up the routes).
The pages themselves are located in the views
folder. As mentioned earlier, these are Nunjuck templates. All of our pages should extend the base.html.njk
file.
Nunjuck templates are basically just HTML with some extra features, you can read about how to write them here: https://mozilla.github.io/nunjucks/templating.html.
Any static content (such as javascript/css libraries) is located in the public
folder.
When committing make sure you don't commit any files that are not strictly part of this project, such as editor specific files (the JetBrains editor's .idea
folder has already been added to the gitignore). Also make sure not to commit the node_modules
folder (again, it has already been added to the gitignore, so it would be pretty hard to do this by accident).
When writing commit messages, please follow the guidelines set here: http://chris.beams.io/posts/git-commit/
Really, please read that, it's worth it.
Indent with tabs not spaces. Class and function declarations should have curly braces on a new line, unless they are being declared inline:
function exampleFunc(arg1, arg2)
{
// function code
}
thingWithCallback(arg, function() {
// inline function code
});
All other blocks should have curly braces on the same line. Blocks with a single line of code in them do not need curly braces, but they should include a line break after the statement and condition:
if (condition) {
// some code
// some more code
}
while (condition)
// single line of code
Finally, make sure to add a blank line at the end of every file, or else Git diffs will include an annoying 'no blank line' message.
Here are the links to the pages for all the dependencies we are currently using, use them if you are unsure on how to use something.
auto-loader: https://github.com/jwerle/node-auto-loader
bcrypt: https://github.com/dcodeIO/bcrypt.js
body-parser: https://github.com/expressjs/body-parser
connect-flash: https://github.com/jaredhanson/connect-flash
csurf: https://github.com/expressjs/csurf
express: http://expressjs.com/en/4x/api.html
express-session: https://github.com/expressjs/session
express-ws: https://github.com/HenningM/express-ws
mongojs: https://github.com/mafintosh/mongojs
nunjucks: http://mozilla.github.io/nunjucks/