Giter Club home page Giter Club logo

measuring_polyphony_django's Introduction

Measuring Polyphony: Django Project

About

This website is created to display the research of Professor Karen Desmond at Brandeis University. It is built using Django with Python 3.6.

How to Install (initial)

  1. Run the initial setup guide: https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-16-04

  2. Install Python 3.6 on your machine

    1. To install on ubuntu: https://askubuntu.com/questions/865554/how-do-i-install-python-3-6-using-apt-get
  3. Create a virtual environment for verovio.

    1. python3.6 -m pip install virtualenv
    2. mkvirtualenv polyphony
    3. source polyphony/bin/activate
    4. Note: You should always do that source command when using python on the server
  4. Install SWIG

    1. For ubuntu: sudo apt-get install swig
  5. Install the developer tools for Python

    1. sudo apt-get install python3-dev
  6. Install Verovio: https://github.com/rism-ch/verovio/wiki/Building-instructions#building-the-python-toolkit

  7. Git pull this repository, and CD into the folder it was downloaded to

  8. (In the virtual environment you sourced in step 2) - pip install -r requirements.txt

  9. Create the secrets.py folder, and populate it with these four variables:

    1. SECRET_KEY -> A string which is your secret key
    2. DATABASE_PASSWORD -> The password for the 'polyphony' user in the database (you'll add this later)
    3. font_path => "{path verovio was installed}/data"
    4. debug -> True or False (depending on if the website is live or not)
  10. Go through this tutorial to set up the actual web server: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04

    1. Note that this is the guide to making a new app - there isn't one on hosting an already made app. Keep this in mind
    2. In postgres: Create a database called polyphony, and a user called polyphony, and grant that user all privileges on the database
  11. To import data from the CSV file, you can do python importer.py

How to modify files on the website

  1. Push the files to git.
  2. Pull them onto the server
  3. Activate the virtual environment. On the current box you would do source ~/envs/polyphonyenv/bin/activate
  4. If you changed any of the static files: python manage.py collectstatic (Say yes if it asks for permission)
  5. If you changed any of the files in models.py
    1. python manage.py makemigrations
    2. python manage.py migrate
  6. Run sudo systemctl restart gunicorn

Important files

  • importer.py -> The program I wrote to transfer the files from the CSV to the database
  • requirements.txt -> List of all the python libraries needed for this app to run
  • secrets.py -> All of the "secret" variables that should not be checked into the git repository.
  • measuring_polyphony/settings.py -> Where the settings for the project are.
  • media/... -> All the files uploaded to the database
  • mei_files/... -> All the initial mei files given for the project. They dont serve any purpose in the app, but they're good to keep in that format.
  • static/... -> All of the collected static files. Don't edit these ones, always edit the ones in viewer/static/... and then run python manage.py collectstatic
  • templates/... -> All of the templates that are rendered - edit these to edit the HTML files for the website. They are rendered using the Django templating language (like HTML but with some logic for loops and stuff). The way the templates are rendered is you have these template files, which refer to variables and such, and those are provided by the functions/classes in viewer/views.py
    • templates/base.html is the "base" template - it contains all of the stuff that is in all of the other files as well (e.g. navbar and footer).
  • viewer/... -> All of the files for the main app.
    • static/... -> All of the CSS, javascript, etc for the website template we're using: https://templated.co/introspect - edit these files and then run the python manage.py collectstatic command
    • admin.py -> The code that controls the admin interface
    • logic.py -> All of the functions relating to verovio
    • models.py -> All of the database models. If you want to change the SQL, this is where you do it (and then run the makemigrations/migrate commands)
    • urls.py -> All of the URLS for the project. They're determined using regex. When a user types a URL, django uses this file to decide which view to run.
    • views.py -> The files that render web pages.

If you want to edit:

  • HTML: files in templates/...
  • CSS: files in viewer/static/introspect/assets/css
  • Add a new page: Write the template, put it in the templates folder, add a function in viewer/views.py that renders the template with a context, and then write the URL in viewer/urls.py

This tutorial might be helpful: https://docs.djangoproject.com/en/1.11/intro/tutorial01/

measuring_polyphony_django's People

Contributors

misingnoglic avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.