Skip to content

wsgi application to be both a standalone gtfs editor or deployed to google app engine/other wsgi compliant hosting.

License

Notifications You must be signed in to change notification settings

ModernizacionMuniCBA/gtfseditor

 
 

Repository files navigation

Gtfseditor

A customizable editor for GTFS files which can be used both as a standalone app or deployed to a wsgi compliant hosting.

GTFSEditor

Demo

There might be a demo running at http://gtfseditor.herokuapp.com The admin interface is at http://gtfseditor.herokuapp.com/editor and the credentials are

username: [email protected] password: admin

Installation

Clone the project and cd into the new folder using

$ git clone https://github.com/avilaton/gtfseditor.git
$ cd gtfseditor

which will get you the latest version.

If you never use a virtual environment before, install it:

$ pip install virtualenvwrapper
$ export WORKON_HOME=~/Envs
$ mkdir -p $WORKON_HOME
$ source /usr/local/bin/virtualenvwrapper.sh

Create a new virtual environment (we named it gtfs but you can name it anything you like) and activate it using

$ mkvirtualenv gtfs

You should now see your command line prompt changed to something like

(gtfs)$

Install the projects dependencies using

pip install -r requirements.txt

Check for PostgrSQL instalation:

sudo apt-get install postgresql postgresql-contrib
sudo -i -u postgres

You can now run the server using

honcho start

and open your web browser at http://localhost:5000.

Management

A series of database management scripts are accesible from the command line using the manage.py script.

To initialize the database, use

$ ./manage.py db upgrade

In development mode this will create a file called data-dev.sqlite in the same directory with a DB looking like the one in production.

Configuration

The main configuration file for the server is located at config.py. Environment variables can be overriden by writing them inside a .env file at the root level.

Development

The project has two main parts,

  • a client application, located at app/
  • a API server + some building tools at server/

The client application uses

  • require.js to load javascript modules,
  • backbone.js to structure models and views,
  • openlayers.js to create and manage the map components,
  • bootstrap.js for styling, scaffolding and plugins,
  • handlebars.js as a templating engine.

The API server uses

  • flask.py for WSGI,
  • SQLAlchemy for database abstraction,
  • transitfeed.py for gtfs building and validation.

among other auxiliary packages.

Database

Development and local usage are best served by using SQLite as a db engine. It allows for rapid setup and portability.

Some hosted services do not support sqlite as a db engine (heroku), and postgres can be used.

Install postgresql and run

createdb -T template0 dbname

You are now ready to initialize an empty DB by using

FLASK_CONFIG=dev ./manage.py db upgrade

Importing a DB dump

To create a database dump use

pg_dump -Fc --no-acl --no-owner dbname > mydb.dump

To import a DB dump run

pg_restore -d dbname dump.tar

where dbname is the name of your database.

Deployment to EC2

Set up an ubuntu instance in Amazon EC2. On it, run

$ sudo apt-get update
$ sudo apt-get install python-pip libpq-dev python-dev nginx postgresql postgresql-contrib

Configuring nginx

Create a site file in /etc/nginx/sites-available/ by copying the example file nginx.site.example over and editing it appropriately. Once you are done, enable the site using

$ sudo ln -s \
/etc/nginx/sites-available/mydomain.com \
/etc/nginx/sites-enabled/mydomain.com

where mydomain.com is the name of the file you created.

Configuring Postgresql

Create a database user with the same name as your current username

$ sudo -u postgres createuser --superuser $USER

and change it's password using

$ sudo -u postgres psql
...
postgres=# \password $USER

This user will not need a password to connect to the DB.

Helping us with documentation

Install Sphinx and ReadTheDocs theme.

pip install Sphinx
pip install sphinx_rtd_theme

Write docs at app/static/docs/ and compile rst files whith make html

About

wsgi application to be both a standalone gtfs editor or deployed to google app engine/other wsgi compliant hosting.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 41.5%
  • Python 32.2%
  • HTML 23.4%
  • CSS 2.8%
  • Mako 0.1%