Skip to content

Setup Instructions

rnaphtal edited this page Nov 18, 2013 · 3 revisions

Installation Requirements

1. Git

Get it here. On your terminal/cmd, verify that you have Git installed by typing $ git

2. Python

Get it here. On your terminal/cmd, verify that you have the Python CLI installed by typing $ python

3. Django

Get it here. Ignore the sections about 'Apache and mod_wsgi' and 'Get your database running' for now. On your terminal/cmd, verify that you have Django installed by typing $ django-admin.py.

4. Heroku toolbelt

Get it here. On your terminal/cmd, verify that you have Heroku installed by typing $ heroku .


Git Common Tasks

Updating your local copy of the repo

When someone else makes changes, you need to update the repo before you push your own changes. Run $ git pull.

Adding a file

When you edit a file, you have to 'stage' these changes. Files that are untracked by Git or have not been 'staged' will not be committed.

  • To add all files: $ git add . Note that you must be on a top-level directory (you can't add any /../ files.
  • To add a specific file: $ git add <filename>

Commiting your changes

$ git commit -m "Type a meaningful message here

Push your changes

You just commited your changes to your local repo. To get everyone else to see them, run $ git push .

Merge conflicts

These are annoting, and should happen infrequently if we're careful. If git tells you to fix merge conflicts, you need to go into the files and manually resolve the conflict by deleting the outdated lines. More info here.


Heroku Setup

Heroku is magical. There's a small amount of initial setup to get everything running. Our app will run here.

Setup your SSH key

Follow the instructions here. This is a way for you to authenticate to Heroku. This one is kinda tricky, articles on stackoverflow.com help a lot. You then have to register your key on heroku using heroku keys:add (before pushing).

Login

Enter $ heroku login . You will be asked for your email / password. (I will email these to you).

Set up git remote branch

To deploy the repo to heroku, set up a Heroku remote branch

$ heroku git:remote -a teambarbara

Deploy to heroku

You make some changes. You want to see them on our website. After you commit and push locally, run:

$ git push heroku master .


Django

Project Structure

Here is a summary of important files

teambarbara/  
          
  	manage.py    # Used to run django comamnds   
            static/    # DON'T ADD STATIC FILES HERE  
            templates/    # Add HTML files here   
          videoconference/ #our app 	
  	videoconference/  `                     
                                    urls.py    # Route new URLs here   
  			static/    # Add static files here  
  					js/    # add .js files  
  					css/   # add .css files  
  					img/   # add images   

All HTML files live in templates/ Javascript/CSS/ img files should be added to the static folder in videoconference

URLs:

www.teambarbara.herokuapp.com/            # main page

manage.py

Most Django commands are run with manage.py. This file is inside the main directory. As this is a python file, you need to enter $ python manage.py <command name>.

Running the Django server

You need to run the Django server to preview any of your changes. Run it once, and it automatically updates after any changes.

$ python manage.py runserver

To see the website locally, go to http://127.0.0.1:8000/. If you get an error, you're not running the server.

Adding a new static file

If you need to add a new CSS/JS file, please add it to the respective folder in teambarbara/videoconference/static. There is a folder that is deceivingly named static/ in the main root. Don't add any files here.

When you add a new CSS/JS/image file, you need to run $ python manage.py collectstatic, and enter yes.

Linking a static file inside an HTML head

After you correctly add a static file, you can link it to your HTML file. Say you create a static file called foo.js. To include this file in an HTML doc, add this line:

<script type="text/javascript" src="{{ STATIC_URL }}js/foo.js"></script>

Adding a new URL

To create a new URL, add a line to urls.py. A URL consists of a regex and the template (HTML file) to load.