diff --git a/html/create_certificate.sh b/html/create_certificate.sh new file mode 100644 index 00000000..1b124b99 --- /dev/null +++ b/html/create_certificate.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +# Secure with Lets Encrypt +sudo apt install certbot python3-certbot-apache +sudo ufw allow 'WWW Full' +sudo ufw delete allow 'WWW' +sudo ufw status +certbot --apache -d paint-database.org +ls /etc/letsencrypt/live/ +echo "You can test the website by navigating to https://paint-database.org" diff --git a/html/install.sh b/html/install.sh new file mode 100755 index 00000000..6a7d873a --- /dev/null +++ b/html/install.sh @@ -0,0 +1,91 @@ +#!/bin/bash +PAINT_ROOT=/home/paint/PAINT +ENV_PATH=/home/paint/venv +AVAILABLE_PATH=/etc/apache2/sites-available +ENABLED_PATH=/etc/apache2/sites-enabled + +echo "Assuming that you are logged in as a user with sudo rights" + +# Initial Server Setup with Debian 11. +echo "Setting Up a Basic Firewall" +sudo apt update +sudo apt install ufw +sudo ufw allow OpenSSH +sudo ufw enable +sudo ufw status + +# Installing Apache +sudo apt update +sudo apt install apache2 +sudo ufw app list +echo "Your output will be a list of the application profiles" +sudo ufw allow 'WWW' +sudo ufw status +echo "The output will provide a list of allowed HTTP traffic" +echo "Make sure the service is active by running the command for the systemd init system" +sudo systemctl status apache2 +hostname -I +sudo apt install curl +curl -4 icanhazip.com +IP_ADDRESS=$(hostname -I | awk '{print $1}') +echo "Enter http://$IP_ADDRESS in the browser" +sudo mkdir -p /var/www/paint_domain +sudo chown -R $USER:$USER /var/www/paint_domain +sudo chmod -R 755 /var/www/paint_domain + +# Install git. +sudo apt-get update +sudo apt-get -y install apache2 git python3-venv + +# Enable apache proxy. +sudo a2enmod proxy +sudo a2enmod proxy_http +sudo a2enmod alias +sudo a2enmod cache + +# Check if repository exists, if not clone, if it exists pull. +if [ ! -d "$PAINT_ROOT" ]; then + git clone https://github.com/ARTIST-Association/PAINT.git $PAINT_ROOT +else + cd "${PAINT_ROOT}" || exit 1 + git pull +fi + +# Navigate to repository and create virtual environment if it doesn't exist yet. +cd "${PAINT_ROOT}" || exit 1 +if [ ! -d "$ENV_PATH" ]; then + python3 -m venv $ENV_PATH +fi + +# Navigate to html directory. +cd ${PAINT_ROOT}/html || exit 1 + +# Copy configuration files to correct folder. +sudo cp paint_domain.conf $AVAILABLE_PATH/paint_domain.conf +sudo cp paint_domain-le-ssl.conf $AVAILABLE_PATH/paint_domain-le-ssl.conf + +# Create symlinks in enabled folder. +sudo ln -sf $AVAILABLE_PATH/paint_domain.conf $ENABLED_PATH/paint_domain.conf +sudo ln -sf $AVAILABLE_PATH/paint_domain-le-ssl.conf $ENABLED_PATH/paint_domain-le-ssl.conf + +# Navigate back to repository root. +cd "${PAINT_ROOT}" || exit 1 + +sudo a2ensite paint_domain.conf +sudo a2dissite 000-default.conf +sudo apache2ctl configtest +echo "You should recieve: Syntax OK" +sudo systemctl restart apache2 + +# Activate virtual environment and upgrade pip. +source $ENV_PATH/bin/activate +pip install --upgrade pip + +# Install dependencies. +pip install --upgrade . + +# Mount to the LSDF +echo "Mount to the LSDF" +sudo sshfs -o umask=0,uid=0,gid=0,allow_other scc-paint-0001@os-login.lsdf.kit.edu:/lsdf/kit/scc/projects/paint /mnt/lsdf + +echo "Installation and setup complete." diff --git a/html/paint_domain-le-ssl.conf b/html/paint_domain-le-ssl.conf new file mode 100644 index 00000000..ef6a98a7 --- /dev/null +++ b/html/paint_domain-le-ssl.conf @@ -0,0 +1,30 @@ + + + ServerAdmin markus.goetz@kit.edu + ServerName paint-database.org + DocumentRoot "/var/www/html/" + ProxyPassMatch ^/favicon.ico ! + Alias /icons/ "/usr/share/apache2/icons/" + + Options Indexes MultiViews + AllowOverride None + Require all granted + Allow from all + + ProxyPass /WRI1030197 ! + Alias /WRI1030197 "/mnt/lsdf/WRI1030197/" + + Options Indexes FollowSymLinks + Require all granted + AddDefaultCharset UTF-8 + IndexOptions FancyIndexing IconsAreLinks + + ProxyPass / http://127.0.0.1:8000/ + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + ServerAlias paint-database.org + Include /etc/letsencrypt/options-ssl-apache.conf + SSLCertificateFile /etc/letsencrypt/live/paint-database.org/fullchain.pem + SSLCertificateKeyFile /etc/letsencrypt/live/paint-database.org/privkey.pem + + diff --git a/html/paint_domain.conf b/html/paint_domain.conf new file mode 100644 index 00000000..ca92a361 --- /dev/null +++ b/html/paint_domain.conf @@ -0,0 +1,30 @@ + + ServerAdmin markus.goetz@kit.edu + ServerName paint-database.org + ServerAlias paint-database.org + DocumentRoot "/var/www/html/" + ProxyPassMatch ^/favicon.ico ! + Alias /icons/ "/usr/share/apache2/icons/" + + Options Indexes MultiViews + AllowOverride None + Require all granted + Allow from all + + ProxyPass /WRI1030197 ! + Alias /WRI1030197 "/mnt/lsdf/WRI1030197/" + + Options Indexes FollowSymLinks + Require all granted + AddDefaultCharset UTF-8 + IndexOptions FancyIndexing IconsAreLinks + + ProxyPass / http://127.0.0.1:8000/ + ErrorLog ${APACHE_LOG_DIR}/error.log + CustomLog ${APACHE_LOG_DIR}/access.log combined + RewriteEngine on + RewriteCond %{SERVER_NAME} =paint.datamanager.kit.edu [OR] + RewriteCond %{SERVER_NAME} =www.paint-database.org [OR] + RewriteCond %{SERVER_NAME} =paint-database.org + RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] + diff --git a/html/run.sh b/html/run.sh new file mode 100755 index 00000000..fb0c5d78 --- /dev/null +++ b/html/run.sh @@ -0,0 +1,18 @@ +#!/bin/bash +PAINT_ROOT=/home/paint/PAINT +ENV_PATH=/home/paint/venv + +# Activate virtual environment. +source $ENV_PATH/bin/activate + +# Navigate to html directory. +cd ${PAINT_ROOT}/html || exit 1 + +# Kill flask application. +kill $(ps aux | grep '[p]ython wsgi.py' | awk '{print $2}') + +# Start flask application. +python wsgi.py & + +# Restart apache. +sudo systemctl restart apache2 diff --git a/html/static/css/paint.css b/html/static/css/paint.css index 33538d4e..a76bb899 100644 --- a/html/static/css/paint.css +++ b/html/static/css/paint.css @@ -19,6 +19,34 @@ font-weight: 400; } +@media (min-width: 1300px){ + .navbar-expand-custom { + flex-direction: row; + flex-wrap: nowrap; + justify-content: flex-start; + } + .navbar-expand-custom .navbar-nav { + flex-direction: row; + } + .navbar-expand-custom .dropdown-menu { + position: absolute; + } + .navbar-expand-custom .nav-link { + padding-right: .5rem; + padding-left: .5rem; + } + .navbar-expand-custom > .container { + flex-wrap: nowrap; + } + .navbar-expand-custom .navbar-collapse { + display: flex!important; + flex-basis: auto; + } + .navbar-expand-custom .navbar-toggler { + display: none; + } +} + :root { --bs-primary: #002864; --bs-primary-rgb: 0, 40, 100; diff --git a/html/templates/base.html b/html/templates/base.html index 9b3bfb84..d9960397 100644 --- a/html/templates/base.html +++ b/html/templates/base.html @@ -1,8 +1,8 @@ + PAINT – FAIR Concentrating Solar Power Plant Database - @@ -14,80 +14,81 @@ -
@@ -104,9 +105,15 @@ {% endif %} {% if active == "legal" %} - Legal information + Legal information {% else %} - Legal information + Legal information + {% endif %} + + {% if active == "contact" %} + Contact + {% else %} + Contact {% endif %} @@ -114,6 +121,32 @@
+ + diff --git a/html/wsgi.py b/html/wsgi.py index d35d4f68..95a630de 100644 --- a/html/wsgi.py +++ b/html/wsgi.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from flask import Flask, render_template +from waitress import serve app = Flask(__name__) @@ -97,4 +98,4 @@ def resources() -> str: if __name__ == "__main__": - app.run() + serve(app, host="127.0.0.1", port=8000) diff --git a/pyproject.toml b/pyproject.toml index 53e3c7f8..299763e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,6 +30,7 @@ dependencies = [ "Flask", "pystac", "opencv-python", + "waitress", "pyproj" ]