The project has the following dependencies:
- Python 3 / pip
- virtualenv
- Node.js / npm
-
Install Homebrew then Python 3:
brew install python3
-
Install pip, if necessary:
sudo easy_install pip3
-
Install virtualenv:
sudo pip3 install virtualenv
-
Install NodeJS (and npm)
-
Install the Linux subsystem for Windows, and then the Ubuntu distribution (docs)
-
Launch the newly-installed
bash.exe
to enter the Linux terminal (all commands will be run here) -
Install pip (Python 3 is installed by default as
python3
):sudo apt-get install python3-pip
-
Install virtualenv:
sudo pip3 install virtualenv
-
Install NodeJS:
sudo apt-get update curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - sudo apt-get install nodejs
-
Within the project directory, setup virtualenv:
virtualenv -p python3 venv
-
Install site requirements:
. venv/bin/activate pip3 install -r requirements.txt npm install
-
Follow configuration instructions below, then initialize the database:
. venv/bin/activate ./cli.py db upgrade
For development servers:
-
Create
/config/development/config.py
and copy all "Environment-specific" variables from/config/config.py
into it -
Customize config variables for local development environment
-
Execute the following:
npm start
-
Load the specified URL in browser
For production servers:
- Create
/config/production/config.py
and copy all "Environment-specific" variables from/config/config.py
into it - Customize config variables for production environment
- Enable
mod_wsgi
and point it toward/app.wsgi
- Setup rules to serve all immediate children of
/app/static
and all recursive children of/app/static/css
,/app/static/fonts
,/app/static/images
, and/app/static/js
statically
Ashes.live is written in Python using the Flask framework, with the deck builder and card browser implemented in VueJS. Data is available via SQL Alchemy with a mySQL database backend, and database schema is controlled via Alembic migrations.
/_assets
: card data files and related scripts (these are used to generate the data that populates the site, but are not directly accessed by the site logic)/app
: Flask application folder. You will be working with these files if you modify or add any Python logic./app/static/src
: VueJS app (and global scripts). Any modifications to the deck builder/card browser must be made here, and then compiled withnpm run build
(compiled Javascript lives in/app/static/js
)./app/static/less
: LESS stylesheet folder. Any modifications to the styles must be compiled withnpm run build
(compiled CSS lives in/app/static/css
)./migrations
: Alembic migration logic. Card JSON is stored in/migrations/data
and migration version files are in/migrations/versions
The deck builder uses Vuex for managing state. Basically, none of the source files for the deck builder access data directly. Instead, they all call through this.$store
to view or commit changes to the global state. The store object is defined in /app/static/src/app/store.js
. Actual logic for filtering, sorting, and fetching card data is handled by /app/static/src/app/card_manager.js
. Currently, all card data is fetched as soon as the deck builder is loaded, and stored client-side. Due to the relatively small number of cards in Ashes, this proved more performant on most devices than loading card data asynchronously.
Whenever you create a new Python view or API file, you will need to import it and register the route blueprint in /manager.py
.
Editing Python models necessitates an Alembic migration to modify the database. Typically, you will do the following:
- Modify (or create) the Flask model. If creating a new file, make sure to import it in
/cli.py
(otherwise Alembic will not notice it). - After entering the virtual environment, run
./cli.py db migrate -m "Short description"
- Locate the resulting file in
/migrations/versions
. You will need to strip out a bunch of the extra indices that Alembic is trying to re-create (I have not had a chance to track down why it is doing this), and double check that your defined model properties are included correctly. - Run
./cli.py db upgrade
to apply your migration
If you need to inspect the history, ./cli.py db history -r-10:
will give you the 10 latest migrations, and ./cli.py db current
will output the ID of the current migration.
Use 4 spaces for indenting Python, and tabs for indenting everything else. No semicolons in Javascript, please. Otherwise, try to match the existing style used across the site.
-
Create card data files in
_assets/card-data/
following naming patternID-expansion.txt
(e.g.014-king-of-titans.txt
). Card data formatting is documented in_assets/generate-card-json.js
. -
Process card data files on command line:
cd _assets/ ./generate-card-json.js card-data/FOLDER_NAME
-
Verify card dice requirements for any cards with costs in their effects (these tend to parse poorly).
-
Create a new migration and copy the hash
-
Move exported card JSON into
migrations/data/
named likeHASH_expansion_name.json
-
Copy and paste migration logic from most recent expansion migration, modifying as necessary
-
Add expansion ID and name to
config/config.py
-
Add expansion ID to
app/static/src/global.js
-
Add new Phoenixborn to
app/static/css.esdynamo/styles.less
in two locations (search formixin-phoenixborn-slice
) -
Add card images to
app/static/images/cards/
npm start
ornpm run start
: run development servernpm run venv
: enter virtual environmentnpm run upgrade
: upgrade Python and Node dependencies to latest specified versionsnpm run build
: parse Javascript (via webpack) and LESS filesnpm run build-production
: build production-ready JS and CSS files (may requireexport NODE_ENV='production'
first)npm run lint
: lint Javascript files