Skip to content

eKristensen/beer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status codecov Minimum PHP Version License: MIT Coding Standards StyleCI Scrutinizer Code Quality FOSSA Status Known Vulnerabilities Maintainability Coverage Status

Beer and other stuff accounting - Kitchen O, P. O. Pedersen Kollegiet

System used to keep track of how drunk we get.

Enviroment requirements

Ubuntu Server 20.04 LTS or Fedora 32+ is recommended, but any server capable of running the following will work:

  • Web-server Eg. nginx (see sample config below) or apache
  • PHP 8.1 or later
  • MySQL or MariaDB server

It is recommended to setup lets encrypt on your webserver. Please look at Certbot

Install instructions

This is a laravel project. Some steps from https://laravel.com/docs/5.8/installation do still apply here. Webserver must have PHP 7.4 or newer and point to the public folder.

On the webserver install dependencies with this command:

composer install --no-dev

After installation copy the .env.example file and configure access to the mysql database you've setup:

cp .env.example .env

To use the application you must set a application key, do that with:

php artisan key:generate

When in the project root.

Javascript

As pr May 13, 2020 this github repo no longer contains the compiled javascript code. Please compile on your own with npm. Run to get JavaScript working:

npm install
npm run prod

Another easy way to update is with

make deploy-update

Create admin user

In the root of the project enter PHP artisan tinker:

php artisan tinker

In here, create the admin user with the following commands:

$user = new User();
$user->name = "Your name";
$user->email = "[email protected]";
$user->password = Hash::make('your-super-secure-password');
$user->save();

Exit the shell with

exit();

Security risks

If you use this system on your own then please not that there is no limitation to who can place a order. Anybody who can access the website can buy anything on behalf of anyone. The webserver should be protected so that the purchase site not is public. If you get a leak, it is possible to remove imposters, since the IP for each purchase is noted.

You're welcome to fix this. Please see Contributing.

Code formatter

There is no single way to do it. But PSR-2 is the target.

Combine php cs fixer and php cs: https://github.com/Symplify/EasyCodingStandard

One way to do it:

php-cs-fixer-v2 fix --rules=@PSR2 .

Another way:

https://github.com/php-fig-rectified/psr2r-sniffer

https://github.com/squizlabs/PHP_CodeSniffer/

Install that code sniffer with: composer global require "squizlabs/php_codesniffer=*"

Analyze the code with: phpcs --standard=PSR2 --ignore=/vendor/,/bootstrap/,/storage/framework/views*,.blade.php,.js,*.css .

Try to fix stuff with: phpcbf --standard=PSR2 --ignore=/vendor/,/bootstrap/,/storage/framework/views*,.blade.php,.js,*.css .

PHP Linter

https://github.com/overtrue/phplint

Javascript testing

Travis is also testing javascript with vue unit tests

License

FOSSA Status

Cron job

For automatic updates you could use the beer-update.sh script in this repo with this crontab to update every day at 5am:

0 5 * * * sh /home/popadmin/homepage-update.sh >/dev/null 2>&1

Please not any issues will be disrecarded. Keep an eye on the upstream code. The intention is only to have working code on the master branch, then this won't be any issue.

Nginx sample configuration (Ubuntu)

Baisc config with nginx, https redirect and the server files in /var/www/beer

server {
    listen      80;
    server_name example.com;
    location / {
        return 301 https://$host$request_uri;
    }
}

server {
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

    root /var/www/beer/public;

    index index.php index.html index.htm;

    server_name example.com;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.4-fpm.sock;
    }
}

Add this to protect the server from outsider if running locally:

    allow   192.168.1.0/24;
    deny    all;

Nginx sample configuration (Fedora)

Setup of php-fpm is slightly different for Fedora. Use the following as inspiration.

First /etc/nginx/nginx.conf

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 4096;
    server_tokens off;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    ##
    # Virtual Host Configs
    ##

    include /etc/nginx/conf.d/*.conf;
    include /etc/nginx/sites-enabled/*;

}

Next the beer site:

server {
    listen      80;
    server_name beer.8r.dk;
    location / {
        return 301 https://$host$request_uri;
    }
}

server {
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/beer.8r.dk/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/beer.8r.dk/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

    allow   192.168.1.0/24;
    deny    all;

    root /var/www/beer/public;

    index index.php index.html index.htm index.nginx-debian.html;

    server_name beer.8r.dk;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.(php|phar)(/.*)?$ {
        fastcgi_split_path_info ^(.+\.(?:php|phar))(/.*)$;

        fastcgi_intercept_errors on;
        fastcgi_index  index.php;
        include        fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param  PATH_INFO $fastcgi_path_info;
        fastcgi_pass   unix:/run/php-fpm/www.sock;
    }
}

Client setup

Example with an Raspberry Pi with Rasbian minimal desktop.

change this file /home/pi/.config/lxsession/LXDE-pi/autostart

@lxpanel --profile LXDE-pi
@pcmanfm --desktop --profile LXDE-pi
@xscreensaver -no-splash
@point-rpi
@xset s noblank
@chromium-browser --app=https://beer.8r.dk/rooms --start-fullscreen

Website: https://www.raspberrypi.org/forums/viewtopic.php?t=132637

Credits

Converted from Bootstrap to Bulma with help from https://github.com/laravel-frontend-presets/bulma

About

Beer accounting for Kitchen O

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published