New website suggestion. Testing only.
b0b8f30580
Bulma is simple and free full-CSS framework. Unlike Bootstrap, it fits within a single small CSS file. It is also well integrated in Django. https://bulma.io/ |
||
---|---|---|
khaganat | ||
logs | ||
navbar | ||
neluser | ||
pages | ||
.gitignore | ||
LICENSE.txt | ||
manage.py | ||
Pipfile | ||
README.md | ||
utils.py |
Khaganat's web site
Requirements
- Python 3.6 or newer
- pipenv
- git
- gettext
Quick deployment
git clone https://git.khaganat.net/Tycho/khaganat-web.git khaganat-web
cd khaganat-web
vim .env
PIPENV_VENV_IN_PROJECT=1 pipenv --three update
pipenv run ./manage.py migrate
pipenv run ./manage.py collectstatic
pipenv run ./manage.py compilemessages
pipenv run ./manage.py createsuperuser
Then configure your server as you like. One way to deploy is to use Nginx and uWSGI:
You can get the virtualenv's path using pipenv --venv
.
Do not forget to check the deployment checklist.
Environment variables
You can set the following variables in the .env
file:
KHAGANAT_SECRET_KEY
(required): Django's secret key, keep it secret (tip: generate one usingopenssl rand -base64 42
).KHAGANAT_DEBUG
: Debug mode, default is false.KHAGANAT_HOSTNAMES
: Allowed hostnames, coma separated.KHAGANAT_LANGUAGE_CODE
: Language code, default isfr
.KHAGANAT_TIME_ZONE
: Time zone, default isEurope/Paris
.KHAGANAT_STATIC_URL
: URL for static files, default is/static/
.KHAGANAT_STATIC_ROOT
: Absolute path to the directory where static files should be collected.KHAGANAT_LOGS_MIN_DAYS
: Numbers of days before logs are hidden, default is 7.KHAGANAT_LOGS_MAX_DAYS
: Number of days before logs are published, default is 0.KHAGANAT_LOGIN_REDIRECT_URL
: URL to redirect after user login. Will be reversed, default isindex
.KHAGANAT_REGISTER_REQUIRE_VALIDATION
: require email validation upon registration, default is true.KHAGANAT_EMAIL_HOST
: The host to use for sending email, default islocalhost
.KHAGANAT_EMAIL_PORT
: Port to use for the SMTP server, default is25
.KHAGANAT_EMAIL_HOST_USER
: Username to use for the SMTP server, default is empty (no authentication).KHAGANAT_EMAIL_HOST_PASSWORD
: Password to use for the SMTP server, default is empty.KHAGANAT_EMAIL_USE_STARTTLS
: Whether to use STARTTLS to connect to the SMTP server, default isFalse
.KHAGANAT_EMAIL_USE_TLS
: Whether to use a TLS connection to the SMTP server, default isFalse
.KHAGANAT_EMAIL_SUBJECT_PREFIX
: Subject-line prefix for email, default is empty.KHAGANAT_DEFAULT_FROM_EMAIL
: Default email address to use, default isno-reply@localhost
.KHAGANAT_FORCE_HTTPS
: If True, enable the use ofKHAGANAT_HTTPS_HEADER_NAME
andKHAGANAT_HTTPS_HEADER_VALUE
to set theSECURE_PROXY_SSL_HEADER
configuration option. Default isFalse
.KHAGANAT_HTTPS_HEADER_NAME
: Header name forSECURE_PROXY_SSL_HEADER
, default isHTTP_X_FORWARDED_PROTO
.KHAGANAT_HTTPS_HEADER_VALUE
: Header value forSECURE_PROXY_SSL_HEADER
, default ishttps
.KHAGANAT_NSFW_TAGS
: Coma-separated list of words that triggers the content warning in logs, default is\#nsfw
.KHAGANAT_NSFW_NAME
: Name of the cookie holding the NSFW allowance, default isnsfw_allowed
.
Quick update
cd khaganat-web
git pull
pipenv --three update
pipenv run ./manage.py migrate
pipenv run ./manage.py collectstatic
pipenv run ./manage.py compilemessages
Then restart the WSGI server.
Nginx + uWSGI on ArchLinux
Install nginx-mainline
, uwsgi
and uwsgi-plugin-python
.
# mkdir -p /srv/http/khaganat/static
# cd /srv/http/khaganat
# git clone https://git.khaganat.net/Tycho/khaganat-web.git app
# cd app
# PIPENV_VENV_IN_PROJECT=1 pipenv --three update
Create /etc/uwsgi/khaganat.ini
with the appropriate environment variables:
[uwsgi]
chdir = /srv/http/khaganat/app
home = /srv/http/khaganat/app/.venv
module = khaganat.wsgi:application
plugins = python
socket = /srv/http/khaganat/uwsgi.sock
uid = http
gid = http
threads = 2
vacuum = True
env = KHAGANAT_SECRET_KEY="generate a new one"
env = KHAGANAT_DEBUG=False
env = KHAGANAT_STATIC_ROOT=/srv/http/khaganat/static
env = KHAGANAT_HOSTNAMES=khaganat.local
Create /etc/systemd/system/multi-user.target.wants/uwsgi@khaganat.service
:
[Unit]
Description=uWSGI service unit
After=syslog.target
[Service]
ExecStart=/usr/bin/uwsgi --ini /etc/uwsgi/%I.ini
ExecReload=/bin/kill -HUP $MAINPID
ExecStop=/bin/kill -INT $MAINPID
Restart=always
Type=notify
StandardError=syslog
NotifyAccess=all
KillSignal=SIGQUIT
[Install]
WantedBy=multi-user.target
Configure nginx :
server {
listen 80;
listen [::]:80;
server_name "khaganat.local";
include custom/headers.conf;
location /static {
root /srv/http/khaganat/;
}
location / {
uwsgi_pass unix:///srv/http/khaganat/uwsgi.sock;
include uwsgi_params;
}
}
Finish the installation:
# cd /srv/http/khaganat/app
# pipenv run ./manage.py migrate
# pipenv run ./manage.py collectstatic
# pipenv run ./manage.py compilemessages
# pipenv run ./manage.py createsuperuser
# chown -R http:http /srv/http/khaganat/
# systemctl enable uwsgi@khaganat.service
# systemctl start uwsgi@khaganat.service
# systemctl enable nginx.service
# systemctl start nginx.service