Git Product home page Git Product logo

galaxy-media-site's Introduction

Galaxy Media Site (GMS)

A simple content site for a Galaxy instance, built with Django.


For developer docs, please check out the wiki. Administration is also well-documented there.

Branches

The commit process is documented in the dev wiki.

dev - development branch deployed to https://dev-site.gvl.org.au

main - production branch deployed to https://site.usegalaxy.org.au

What it does

This web app is designed to host content related to a Galaxy instance. It is lightweight, easy to install and maintain, and provides interfaces for publishing:

  • A dynamic landing page for the Galaxy instance
  • Galaxy Lab landing pages
  • Landing page notices
  • Event posts
  • News articles (including automated tool updates)
  • Team members

The site also hosts support webforms and static pages like "about" content, terms of service etc. There is also a rudimentary facility for sending bulk mail and handling unsubscribe requests (this requires better integration with site, the currently file R/W is a bit hacky and error prone).

This content is all embedded in HTML templates. If you fork the repository, these templates can be updated with content relevant to your Galaxy instance, and new pages can be added too.

The GMS homepage (aka landing page) is designed to be displayed as your Galaxy instance "welcome" page. Just create a welcome.html file with an iframe that points to https://mygms.com/landing to get a landing page without the navbar.

The site is designed to be fully navigable from within your Galaxy instance, with the GMS Navbar being nested under the main Galaxy navbar:

site navigation

A note on iframe behaviour

When requested in an <iframe> from a Galaxy instance, GMS pages "know" that they are in an iframe and will render slightly differently than if the user was visting the GMS site directly. For developers, if there is content that you'd like to render differently you can use the global inIframe() JavaScript function on any page to check if you're currently in an iframe.

This repository

  • deploy/ for deployment of GMS with Ansible and shell script
  • scrape/ python scripts for scraping content from the old jekyll site codebase
  • webapp/ this is the Django app

Deployment

If you are setting this up for production, create a DNS record for your domain name before running the setup script - this should be an A record pointing to the IP address of the host machine. Subdomains are fine.

This app has been developed and tested on Ubuntu 20.04 LTS. Other operating systems may require manual installation. The application is installed on a Nginx-Gunicorn-Postgres stack and is not containerized. We recommend installation in a fresh virtual machine instance.

Deploy with Ansible

If you're familiar with ansible, this is the recommended method of deployment. See deploy/ansible/.

Deploy with shell

Install and deploy the application in your webserver terminal:

cd <my-projects-directory>
git clone https://github.com/usegalaxy-au/galaxy-media-site.git
cd galaxy-media-site
PROJECT_ROOT=$PWD

# Create a .env file here - see .env.sample
nano .env

# Follow prompts
./deploy/setup.sh

# Check operation with Django local serve
# Django will provide feedback on any issues detected
source deploy/.venv/bin/activate
python webapp/manage.py runserver

A note on performance

The app was tested with Locust against a web server with 1vCPU / 2GB RAM (see locustfile.py). It could handle 500 concurrent users with <1s response times before web performance started to degrade.

In 2021, peak traffic experienced by Galaxy Australia was below 1000 requests per hour, so it seems that a 1CPU machine can handle this service adequately, based on the Locust model.

Deploy the maintenance site

For any downtime, the maintenance site can be found here.

Point the DNS for your domain name to the host IP address. Then, on your Ubuntu web server:

sudo apt install nginx
git clone https://github.com/usegalaxy-au/galaxy-media-site.git
cd galaxy-media-site
sudo ln -s /srv/sites/gms-maintenance-site ./deploy/maintenance-site

# Edit with your domain as the server_name
nano ./deploy/maintenance-site/nginx.conf
sudo cp ./deploy/maintenance-site/nginx.conf /etc/nginx/sites-available
sudo ln -s /etc/nginx/sites-available/nginx.conf /etc/nginx/sites-enabled/nginx.conf
sudo service nginx restart

Site administration

Visit /admin/login and log in with a staff user account. If you don't have one, you can create one with the Django CLI.

N.B. superuser creation is included in the Ansible playbook

cd $PROJECT_ROOT
source deploy/.venv/bin/activate

# Follow prompts
python webapp/manage.py createsuperuser

Check out the Wiki to learn about site administration through the web admin.


Migrating between servers

Application state is stored in the PostgreSQL database, with images in the webapp/webapp/media directory. If required, you can migrate the application between servers. This assumes some experience with postgres and the psql shell.

N.B. if the database username has changed, you will have to dump the database with the --no-owner flag and create privileges for the new owner manually in a psql shell.

The following steps demonstrate migrating application state to a new machine:

  1. Grab a db dump on the old machine:
sudo -u postgres pg_dump <DBNAME> > gms.sql
  1. Install GMS on the new webserver with ansible or over the CLI (N.B your superuser will be overwritten in the following steps)

For Ansible deployment

Update webservers.yml with:

# Don't forget to remove this afterwards to resume migrations in the future!
skip_database_migration: true
  1. Drop and recreate the new database

For script/CLI deployment

sudo -u postgres psql -c "DROP DATABASE <DBNAME>"
sudo -u postgres psql -c "CREATE DATABASE <DBNAME>"
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE <DBNAME> TO <user>"

For Ansible deployment You already handled this in step 2, well done!

  1. Load the db dump

sudo -u postgres psql -d <DBNAME> < gms.sql

  1. Check out the new site, the content should be there.

  2. Images/media must be migrated separately. tar the webapp/webapp/media directory and send to the new server:

# N.B. you will ssh access to the new webserver with sudo privileges

REMOTE_ADDRESS=mynewsite.com
REMOTE_PROJECT_ROOT=/path/to/the/new/galaxy-media-site
cd $PROJECT_ROOT
tar cf - webapp/webapp/media \
    | ssh $REMOTE_ADDRESS \ "(
        cd ${REMOTE_PROJECT_ROOT}/webapp/webapp;
        cat > media.tar;
        tar -xf media.tar && rm media.tar;
        sudo chown -R www-data:www-data media)"

Your images should now be display on the new site.

  1. If you are using a Jenkins task for automated news posts, you will need to update the Jenkins config if the hostname has changed. The API key should be unchanged.

galaxy-media-site's People

Contributors

annasyme avatar cat-bro avatar garethprice-aus avatar minh-biocommons avatar neoformit avatar patcapon39 avatar supernord avatar

Watchers

 avatar  avatar

galaxy-media-site's Issues

Markdown preview styling

Admin markdown preview is being styled by Django admin CSS. Mostly this is ok, but list element styling needs to be overwritten:

image

Package `/scrape` for reuse?

Other galaxies might like to use this to import old Jekyll site content into this app - depends on whether others show interest in forking/reusing this

Tool updates listed separately

It would make more sense for the automated tool update news items to be listed in a separate place, and maybe show less items with more info e.g. tool names.

Navbar styling inside iframe

Could be more intuitive - suggest pale/transparent navbar background with dark grey text so that users are aware it's different from the main Galaxy navbar.

Turn off auto dark theme

Django applies a dark theme to the admin based on the user's desktop theme settings. It doesn't work well with the custom admin styling so better to disable it.

Update event not working

  • Added a new tag (works)
  • Updated two events with new tag and a supporter
  • Saves "ok" but the entry has not actually been updated, as though the changes weren't committed

Notice items

  • Manual entry from legacy codebase
  • Ensure markdown parsing is consistent with news/events
  • Template

Blurbs are not parsed effectively

The parser needs to be a bit smarter - split by double-lines and html characters (<) could be sufficient, with a char count check as items are re-assembled.

Event address rendering

It's a JSON dict, so of course it renders in random order.
Would be better to just create a foreignkey field to let people re-use addresses.

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.