Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tomwardio committed Jan 30, 2024
0 parents commit af5dee4
Show file tree
Hide file tree
Showing 119 changed files with 16,627 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# In all environments, the following files are loaded if they exist,
# the latter taking precedence over the former:
#
# * .env contains default values for the environment variables needed by the app
# * .env.local uncommitted file with local overrides
# * .env.$APP_ENV committed environment-specific defaults
# * .env.$APP_ENV.local uncommitted environment-specific overrides
#
# Real environment variables win over .env files.
#
# DO NOT DEFINE PRODUCTION SECRETS IN THIS FILE NOR IN ANY OTHER COMMITTED FILES.
# https://symfony.com/doc/current/configuration/secrets.html
#
# Run "composer dump-env prod" to compile .env files for production use (requires symfony/flex >=1.2).
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration

###> symfony/framework-bundle ###
APP_ENV=dev
APP_SECRET=19f98234bf7fgd3716a81f6c4de28622
###< symfony/framework-bundle ###

###> doctrine/doctrine-bundle ###
# Format described at https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url
DATABASE_URL='mysql://digitalbeerwall:my_password@localhost:3306/digitalbeerwall'
###< doctrine/doctrine-bundle ###

###> symfony/messenger ###
MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
###< symfony/messenger ###

###> symfony/mailer ###
MAILER_DSN=null://null
###< symfony/mailer ###

###> google/recaptcha ###
# To use Google Recaptcha, you must register a site on Recaptcha's admin panel:
# https://www.google.com/recaptcha/admin
GOOGLE_RECAPTCHA_ENABLED=false
GOOGLE_RECAPTCHA_SITE_KEY='my_site_key'
GOOGLE_RECAPTCHA_SECRET='my_secret'
###< google/recaptcha ###

AWS_S3_ENABLED=false
AWS_S3_BUCKET='my_bucket'
AWS_S3_REGION='eu-west-1'
AWS_S3_ACCESS_KEY=''
AWS_S3_ACCESS_SECRET=''

# Token for mapbox API calls.
MAPBOX_TOKEN=''
6 changes: 6 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# define your env variables for the test env here
KERNEL_CLASS='App\Kernel'
APP_SECRET='$ecretf0rt3st'
SYMFONY_DEPRECATIONS_HELPER=999999
PANTHER_APP_ENV=panther
PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
26 changes: 26 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

###> symfony/framework-bundle ###
/.env.local
/.env.local.php
/.env.*.local
/config/secrets/prod/prod.decrypt.private.php
/public/bundles/
/public/uploads/**
/var/
/vendor/
###< symfony/framework-bundle ###

###> phpunit/phpunit ###
/phpunit.xml
.phpunit.result.cache
###< phpunit/phpunit ###

###> symfony/phpunit-bridge ###
.phpunit.result.cache
/phpunit.xml
###< symfony/phpunit-bridge ###

###> symfony/asset-mapper ###
/public/assets/
/assets/vendor
###< symfony/asset-mapper ###
95 changes: 95 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Digital Beer Wall

A [Symfony 7](http://www.symfony.com) based website for bottled beer. Originally created in 2015 using Symfony 2, this hobby site has been updated to work with the newest versions of various packages, and given a (very slight) makeover to include light/dark themes with bootstrap 5.

Below are instructions on how to setup the site on a new machine for development.

# Installation

## Requirements

* [Symfony CLI](https://symfony.com/download)
* [PHP 8.2](http://php.net) or newer.
* [MariaDB](https://mariadb.org/) (or MySQL) for the site's database
* [Composer](https://getcomposer.org/download/) to install PHP packages.

## Setup Database

First let's setup the database required to run the site and a user to access it.

```
$ sudo mysql -e "CREATE DATABASE digitalbeerwall;"
$ sudo mysql -e "CREATE USER 'digitalbeerwall'@'localhost' IDENTIFIED BY 'my_password';"
$ sudo mysql -e "GRANT ALL PRIVILEGES ON digitalbeerwall.* TO 'digitalbeerwall'@'localhost';"
```

These commands will setup a new database called `digitalbeerwall`, and a user called `digitalbeerwall` with password `my_password`, and is only accessible locally.

## Setup the website

Next, clone the digitalbeerwall repository and run composer to install the requisite packages.

```
$ git clone https://github.com/tomwardio/digitalbeerwall
$ cd digitalbeerwall
$ composer install
$ symfony check:requirements
```

The final command will check that we meet all the requirements necessary to run the site.

## Configure the site

With the site and database setup, now we need to configure the site to connect to this database. Copy the `.env` file to `.env.local` and open in your favorite text editor.

The first entry we need to modify is the `DATABASE_URL`. If you setup the database as described above, you don't need to do anything, otherwise modify the constituent parts to match your setup.

```
DATABASE_URL='mysql://digitalbeerwall:my_password@localhost:3306/digitalbeerwall'
```

Next, we need to create the necessary tables to run the site. From the site root, run:

```
$ symfony console doctrine:schema:create
```

Finally, run the following to start running the site on http://127.0.0.1:8000

```
$ symfony server:start
```

## Email configuration (optional)

In order to send emails for user account activation, you'll need to setup a mailer. See the [mailer docs](https://symfony.com/doc/current/mailer.html) for more details. I've used [AWS SES](https://aws.amazon.com/ses/) without too much issue.

## AWS S3 configuration (optional)

To store beer images on AWS rather than locally, set the following in your `.env.local` config file:

```
AWS_S3_ENABLED=true
AWS_S3_BUCKET='my_bucket'
AWS_S3_REGION='eu-west-1'
AWS_S3_ACCESS_KEY=''
AWS_S3_ACCESS_SECRET=''
```

## Mapbox configuration (optional)

To setup the mapbox world tiles, set the following in your `.env.local` file:

```
MAPBOX_TOKEN='<token>'
```

## reCaptcha (optional)

To prevent bots from attempting to create lots of accounts, you can optionally enable reCAPTCHA. To do this, set the following in your `.env.local` file:

```
GOOGLE_RECAPTCHA_ENABLED=true
GOOGLE_RECAPTCHA_SITE_KEY='my_site_key'
GOOGLE_RECAPTCHA_SECRET='my_secret'
```
Binary file added assets/android-chrome-192x192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/android-chrome-512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions assets/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import './bootstrap.js';
/*
* Welcome to your app's main JavaScript file!
*
* This file will be included onto the page via the importmap() Twig function,
* which should already be in your base.html.twig.
*/
import './styles/app.css'

import 'bootstrap';
import 'bootstrap/dist/css/bootstrap.min.css';
import 'bootstrap-icons/font/bootstrap-icons.min.css';
Binary file added assets/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions assets/bootstrap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { startStimulusApp } from '@symfony/stimulus-bundle';

const app = startStimulusApp();
// register any custom, 3rd party controllers here
// app.register('some_controller_name', SomeImportedController);
12 changes: 12 additions & 0 deletions assets/browserconfig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig>
<msapplication>
<tile>
<square70x70logo src="/mstile-70x70.png"/>
<square150x150logo src="/mstile-150x150.png"/>
<square310x310logo src="/mstile-310x310.png"/>
<wide310x150logo src="/mstile-310x150.png"/>
<TileColor>#da532c</TileColor>
</tile>
</msapplication>
</browserconfig>
15 changes: 15 additions & 0 deletions assets/controllers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"controllers": {
"@symfony/ux-turbo": {
"turbo-core": {
"enabled": true,
"fetch": "eager"
},
"mercure-turbo-stream": {
"enabled": false,
"fetch": "eager"
}
}
},
"entrypoints": []
}
32 changes: 32 additions & 0 deletions assets/controllers/freewall_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { Controller } from '@hotwired/stimulus';

import 'freewall';
import Spinner from 'spin';
import imagesLoaded from 'imagesloaded';

export default class extends Controller {
connect() {
var wall = new freewall("#freewall");
var spinTarget = document.getElementById("spinner");
var spinner = new Spinner().spin(spinTarget);

imagesLoaded(document.querySelector('#freewall'), function (instance) {
wall.reset({
selector: '.brick',
animate: true,
cellW: 220,
cellH: 'auto',
onResize: function () {
wall.fitWidth();
}
});

spinner.stop();
document.getElementById("freewall").removeAttribute("hidden");
if (document.getElementById("pages")) {
document.getElementById("pages").removeAttribute("hidden");
}
wall.fitWidth();
});
}
}
41 changes: 41 additions & 0 deletions assets/controllers/image_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Controller } from '@hotwired/stimulus';

import loadImage from 'blueimp-load-image';

/* stimulusFetch: 'lazy' */
export default class extends Controller {
connect() {
if (document.getElementById('form_imgdata').value) {
var beer_image = document.getElementById('beer_img');
beer_image.setAttribute('src', document.getElementById('form_imgdata').value);
}

document.getElementById('form_image').onchange = function (e) {

var file = e.target && e.target.files && e.target.files[0];
var options = {
maxWidth: 720,
canvas: true
};
if (!file)
return;

loadImage.parseMetaData(file, function (data) {
if (data.exif) {
if (data.exif.get('Orientation')) {
options.orientation = data.exif.get('Orientation');
}
}

// load the image
loadImage(file,
function (img) {
var image_data = img.toDataURL("image/jpeg");
document.getElementById('beer_img').setAttribute('src', image_data);
document.getElementById('form_imgdata').value = image_data;
},
options);
});
};
}
}
Loading

0 comments on commit af5dee4

Please sign in to comment.