simple-calendar

Extremely simple calendar app

Stars
0
Committers
1

Calendar

Extremely simple calendar app

To use

Edit calendar

Edit the yaml calendar file. For example, to set the status for the 5 days beginning 2024-01-29...

2024-01-29:
- monday info
- ¯\_(ツ)_/¯
- tuesday
-
- friday

2024-02-15: doing this on this specific day

Rebuild site

With npm

npm run build

With docker

(for first-time use switch run build for install)

docker run --rm --workdir /_site -v $(pwd):/_site --entrypoint "npm" node:18.16.1-alpine3.18 run build

or

./build.sh

Set up on server

Install nvm and node

Install these in a location accessible to anyone, so that the www-data user can use them later.

# install nvm to /usr/alifeee/nvm
export XDG_CONFIG_HOME="/usr/alifeee"
# install nvm, see https://github.com/nvm-sh/nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
# install node
source ~/.bashrc
nvm install 20
nvm use 20

Now you can use node and npm as any user by running:

export NVM_DIR="/usr/alifeee/nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm

nvm use 20
npm run build

Test this by putting the above in a script and running (e.g.,) sudo -u www-data build.sh

Download files

mkdir -p /var/www/
git clone [email protected]:alifeee/simple-calendar.git /var/www/simple-calendar/
cd /var/www/simple-calendar/
npm install
npm run build
chown -R alifeee:www-data _site/

Edit nginx config

sudo nano /etc/nginx/nginx.conf
  server {
    server_name cal.alifeee.co.uk;
    location / {
      root /var/www/simple-calendar/_site;
      try_files $uri $uri/ =404;
      add_header Cache-Control no-cache;
      if_modified_since off;
      add_header Last-Modified "";
    }
    location = /edit {
      include fastcgi_params;
      fastcgi_param SCRIPT_FILENAME /var/www/simple-calendar/edit;
      fastcgi_pass unix:/var/run/fcgiwrap.socket;
      auth_basic "calendar edit";
      auth_basic_user_file /etc/nginx/.htpasswd;
    }
    listen 80;
    listen [::]:80;
  }
sudo certbot --nginx
sudo systemctl restart nginx.service

Set up Python for CGI edit script

python3 -m venv env
./env/bin/pip install -r requirements.txt
chown alifeee:www-data _data/alfie.yaml

to test edit script:

echo 'name=alfie&2024-09-01=what' | sudo -u www-data ./edit
Related Projects