public-trust
- What is this?
- Assumptions
- What's in here?
- Bootstrap the project
- Hide project secrets
- Save media assets
- Add a page to the site
- Run the project
- Run Python tests
- Run Javascript tests
- Compile static assets
- Test the rendered app
- Deploy to S3
What is this?
The Public Trust is a Daily Californian audio project exploring what it means to be a public university in an era of declining state funding.
This application is a stripped and modified version of NPR's application template.
Assumptions
The following things are assumed to be true in this documentation.
- You are running OSX.
- You are using Python 2.7.
- You have virtualenv installed and working.
What's in here?
The project contains the following folders and important files:
confs
-- Server configuration files for nginx and uwsgi. Edit the templates thenfab <ENV> servers.render_confs
, don't edit anything inconfs/rendered
directly.data
-- Data files, such as those used to generate HTML.fabfile
-- Fabric commands for automating setup, deployment, data processing, etc.etc
-- Miscellaneous scripts and metadata for project bootstrapping.jst
-- Javascript (Underscore.js) templates.less
-- LESS files, will be compiled to CSS and concatenated for deployment.templates
-- HTML (Jinja2) templates, to be compiled locally.tests
-- Python unit tests.www
-- Static and compiled assets to be deployed. (a.k.a. "the output")www/test
-- Javascript tests and supporting files.app.py
-- A Flask app for rendering the project locally.app_config.py
-- Global project configuration for scripts, deployment, etc.render_utils.py
-- Code supporting template rendering.requirements.txt
-- Python requirements.static.py
-- Static Flask views used in bothapp.py
andpublic_app.py
.
Bootstrap the project
Node.js is required for the static asset pipeline. If you don't already have it, get it like this:
brew install node
curl https://npmjs.org/install.sh | sh
Then bootstrap the project:
cd public-trust
source bin/activate
pip install -r requirements.txt
npm install
fab update
Hide project secrets
Project secrets should never be stored in app_config.py
or anywhere else in the repository. They will be leaked to the client if you do. Instead, always store passwords, keys, etc. in environment variables and document that they are needed here in the README.
Run the project
A flask app is used to run the project locally. It will automatically recompile templates and assets on demand.
fab app
Visit localhost:8000 in your browser.
Compile static assets
Compile LESS to CSS, compile javascript templates to Javascript and minify all assets:
fab render
(This is done automatically whenever you deploy to S3.)
Test the rendered app
If you want to test the app once you've rendered it out, just use the Python webserver:
cd www
python -m SimpleHTTPServer
Deploy to S3
fab staging master deploy